diff --git a/pages/item.php b/pages/item.php index 372eb48b..14dd5ea4 100644 --- a/pages/item.php +++ b/pages/item.php @@ -908,11 +908,22 @@ class ItemPage extends genericPage } // tab: Shared cooldown - $cdCats = []; + $cdCats = []; + $useSpells = []; for ($i = 1; $i < 6; $i++) + { + // as defined on item if ($this->subject->getField('spellId'.$i) > 0 && $this->subject->getField('spellCategory'.$i) > 0) $cdCats[] = $this->subject->getField('spellCategory'.$i); + // as defined in spell + if ($this->subject->getField('spellId'.$i) > 0) + $useSpells[] = $this->subject->getField('spellId'.$i); + } + if ($useSpells) + if ($_ = DB::Aowow()->selectCol('SELECT category FROM ?_spell WHERE id IN (?a) AND recoveryCategory > 0', $useSpells)) + $cdCats += $_; + if ($cdCats) { $conditions = array( @@ -926,6 +937,11 @@ class ItemPage extends genericPage ['spellCategory5', $cdCats], ] ); + + if ($spellsByCat = DB::Aowow()->selectCol('SELECT id FROM ?_spell WHERE category IN (?a)', $cdCats)) + for ($i = 1; $i < 6; $i++) + $conditions[1][] = ['spellId'.$i, $spellsByCat]; + $cdItems = new ItemList($conditions); if (!$cdItems->error) { @@ -939,7 +955,6 @@ class ItemPage extends genericPage } } - // tab: sounds $soundIds = []; if ($_class == ITEM_CLASS_WEAPON) diff --git a/pages/spell.php b/pages/spell.php index 3fe2a541..c7c368ce 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -512,6 +512,32 @@ class SpellPage extends GenericPage $this->extendGlobalData($saSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } + // tab: shared cooldown + if ($this->subject->getField('recoveryCategory')) + { + $conditions = array( + ['id', $this->typeId, '!'], + ['category', $this->subject->getField('category')], + ['recoveryCategory', 0, '>'], + ); + + // limit shared cooldowns to same player class for regulat users + if (!User::isInGroup(U_GROUP_STAFF) && $this->subject->getField('spellFamilyId')) + $conditions[] = ['spellFamilyId', $this->subject->getField('spellFamilyId')]; + + $cdSpells = new SpellList($conditions); + if (!$cdSpells->error) + { + $this->lvTabs[] = ['spell', array( + 'data' => array_values($cdSpells->getListviewData()), + 'name' => '$LANG.tab_sharedcooldown', + 'id' => 'shared-cooldown' + )]; + + $this->extendGlobalData($cdSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); + } + } + // tab: used by - spell if ($so = DB::Aowow()->selectCell('SELECT id FROM ?_spelloverride WHERE spellId1 = ?d OR spellId2 = ?d OR spellId3 = ?d OR spellId4 = ?d OR spellId5 = ?d', $this->subject->id, $this->subject->id, $this->subject->id, $this->subject->id, $this->subject->id)) {