diff --git a/includes/conditions.class.php b/includes/conditions.class.php index d3c10e99..f28634b4 100644 --- a/includes/conditions.class.php +++ b/includes/conditions.class.php @@ -122,33 +122,33 @@ class Conditions private const IDX_SRC_ID = 2; private const IDX_SRC_FN = 3; - private static $source = array( // [Group, Entry, Id] - self::SRC_NONE => [null, null, null, null], - self::SRC_CREATURE_LOOT_TEMPLATE => [Type::NPC, Type::ITEM, null, 'lootIdToNpc'], - self::SRC_DISENCHANT_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, 'disenchantIdToItem'], - self::SRC_FISHING_LOOT_TEMPLATE => [Type::ZONE, Type::ITEM, null, null], - self::SRC_GAMEOBJECT_LOOT_TEMPLATE => [Type::OBJECT, Type::ITEM, null, 'lootIdToGObject'], - self::SRC_ITEM_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, null], - self::SRC_MAIL_LOOT_TEMPLATE => [Type::QUEST, Type::ITEM, null, 'RewardTemplateToQuest'], - self::SRC_MILLING_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, null], - self::SRC_PICKPOCKETING_LOOT_TEMPLATE => [Type::NPC, Type::ITEM, null, 'PickpocketLootToNpc'], - self::SRC_PROSPECTING_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, null], - self::SRC_REFERENCE_LOOT_TEMPLATE => [null, Type::ITEM, null, null], - self::SRC_SKINNING_LOOT_TEMPLATE => [Type::NPC, Type::ITEM, null, 'SkinLootToNpc'], - self::SRC_SPELL_LOOT_TEMPLATE => [Type::SPELL, Type::ITEM, null, null], - self::SRC_SPELL_IMPLICIT_TARGET => [true, Type::SPELL, null, null], - self::SRC_GOSSIP_MENU => [true, true, null, null], - self::SRC_GOSSIP_MENU_OPTION => [true, true, null, null], - self::SRC_CREATURE_TEMPLATE_VEHICLE => [null, Type::NPC, null, null], - self::SRC_SPELL => [null, Type::SPELL, null, null], - self::SRC_SPELL_CLICK_EVENT => [Type::NPC, Type::SPELL, null, null], - self::SRC_QUEST_AVAILABLE => [null, Type::QUEST, null, null], - self::SRC_QUEST_SHOW_MARK => [null, Type::QUEST, null, null], - self::SRC_VEHICLE_SPELL => [Type::NPC, Type::SPELL, null, null], - self::SRC_SMART_EVENT => [true, true, true, null], - self::SRC_NPC_VENDOR => [Type::NPC, Type::ITEM, null, null], - self::SRC_SPELL_PROC => [null, Type::SPELL, null, null], - self::SRC_AREATRIGGER_CLIENT => [null, true, null, null] + private static $source = array( // [Group, Entry, Id, typeResolverFN] + self::SRC_NONE => [null, null, null, null], + self::SRC_CREATURE_LOOT_TEMPLATE => [Type::NPC, Type::ITEM, null, 'lootIdToNpc'], + self::SRC_DISENCHANT_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, 'disenchantIdToItem'], + self::SRC_FISHING_LOOT_TEMPLATE => [Type::ZONE, Type::ITEM, null, null], + self::SRC_GAMEOBJECT_LOOT_TEMPLATE => [Type::OBJECT, Type::ITEM, null, 'lootIdToGObject'], + self::SRC_ITEM_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, null], + self::SRC_MAIL_LOOT_TEMPLATE => [Type::QUEST, Type::ITEM, null, 'RewardTemplateToQuest'], + self::SRC_MILLING_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, null], + self::SRC_PICKPOCKETING_LOOT_TEMPLATE => [Type::NPC, Type::ITEM, null, 'PickpocketLootToNpc'], + self::SRC_PROSPECTING_LOOT_TEMPLATE => [Type::ITEM, Type::ITEM, null, null], + self::SRC_REFERENCE_LOOT_TEMPLATE => [null, Type::ITEM, null, null], + self::SRC_SKINNING_LOOT_TEMPLATE => [Type::NPC, Type::ITEM, null, 'SkinLootToNpc'], + self::SRC_SPELL_LOOT_TEMPLATE => [Type::SPELL, Type::ITEM, null, null], + self::SRC_SPELL_IMPLICIT_TARGET => [true, Type::SPELL, null, null], + self::SRC_GOSSIP_MENU => [true, true, null, null], + self::SRC_GOSSIP_MENU_OPTION => [true, true, null, null], + self::SRC_CREATURE_TEMPLATE_VEHICLE => [null, Type::NPC, null, null], + self::SRC_SPELL => [null, Type::SPELL, null, null], + self::SRC_SPELL_CLICK_EVENT => [Type::NPC, Type::SPELL, null, null], + self::SRC_QUEST_AVAILABLE => [null, Type::QUEST, null, null], + self::SRC_QUEST_SHOW_MARK => [null, Type::QUEST, null, null], + self::SRC_VEHICLE_SPELL => [Type::NPC, Type::SPELL, null, null], + self::SRC_SMART_EVENT => [true, true, true, null], + self::SRC_NPC_VENDOR => [Type::NPC, Type::ITEM, null, null], + self::SRC_SPELL_PROC => [null, Type::SPELL, null, null], + self::SRC_AREATRIGGER_CLIENT => [null, Type::AREATRIGGER, null, null] ); private const IDX_CND_VAL1 = 0; @@ -219,55 +219,61 @@ class Conditions /* IN */ /******/ - public function getBySourceEntry(int $entry, int ...$srcType) : bool + public function getBySourceEntry(int $entry, int ...$srcType) : self { - $this->rows = DB::World()->select( + $this->rows = array_merge($this->rows, DB::World()->select( 'SELECT `SourceTypeOrReferenceId`, `SourceEntry`, `SourceGroup`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition` FROM conditions WHERE `SourceTypeOrReferenceId` IN (?a) AND `SourceEntry` = ?d ORDER BY `SourceTypeOrReferenceId`, `SourceEntry`, `SourceGroup`, `ElseGroup` ASC', $srcType, $entry - ); + )); - return $this->fromSource(); + return $this; } - public function getBySourceGroup(int $group, int ...$srcType) : bool + public function getBySourceGroup(int $group, int ...$srcType) : self { - $this->rows = DB::World()->select( + $this->rows = array_merge($this->rows, DB::World()->select( 'SELECT `SourceTypeOrReferenceId`, `SourceEntry`, `SourceGroup`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition` FROM conditions WHERE `SourceTypeOrReferenceId` IN (?a) AND `SourceGroup` = ?d ORDER BY `SourceTypeOrReferenceId`, `SourceEntry`, `SourceGroup`, `ElseGroup` ASC', $srcType, $group - ); + )); - return $this->fromSource(); + return $this; } - public function getByCondition(int $type, int $typeId/* , int ...$conditionIds */) : bool + public function getByCondition(int $type, int $typeId/* , int ...$conditionIds */) : self { $lookups = []; // can only be in val1 for now foreach (self::$conditions as $cId => [$cVal1, , , ]) if ($type === $cVal1 /* && (!$conditionIds || in_array($cId, $conditionIds)) */ ) - $lookups[] = sprintf("(c2.`ConditionTypeOrReference` = %d AND c2.`ConditionValue1` = %d)", $cId, $typeId); + { + if ($cId == self::CHR_CLASS || $cId == self::CHR_RACE) + $lookups[] = sprintf("(c2.`ConditionTypeOrReference` = %d AND (c2.`ConditionValue1` & %d) > 0)", $cId, 1 << ($typeId - 1)); + else + $lookups[] = sprintf("(c2.`ConditionTypeOrReference` = %d AND c2.`ConditionValue1` = %d)", $cId, $typeId); + } if (!$lookups) - return false; + return $this; - $this->rows = DB::World()->select(sprintf( + $this->rows = array_merge($this->rows, DB::World()->select(sprintf( 'SELECT c1.`SourceTypeOrReferenceId`, c1.`SourceEntry`, c1.`SourceGroup`, c1.`SourceId`, c1.`ElseGroup`, c1.`ConditionTypeOrReference`, c1.`ConditionTarget`, c1.`ConditionValue1`, c1.`ConditionValue2`, c1.`ConditionValue3`, c1.`NegativeCondition` FROM conditions c1 JOIN conditions c2 ON c1.SourceTypeOrReferenceId = c2.SourceTypeOrReferenceId AND c1.SourceEntry = c2.SourceEntry AND c1.SourceGroup = c2.SourceGroup AND c1.SourceId = c2.SourceId WHERE %s + GROUP BY `SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3` ORDER BY `SourceTypeOrReferenceId`, `SourceEntry`, `SourceGroup`, `ElseGroup` ASC', implode(' OR ', $lookups)) - ); + )); - return $this->fromSource(); + return $this; } public function addExternalCondition(int $srcType, string $groupKey, array $condition, bool $orGroup = false) : void @@ -337,25 +343,35 @@ class Conditions return [null, $tab]; } - public function toListviewColumn(array &$lvRows, ?array &$extraCols = [], int $srcEntry = 0) : bool + // $keyX params are string(ref to lv column) or int(fixed value) + public function toListviewColumn(array &$lvRows, ?array &$extraCols = [], $keyGroup = 'id', $keyEntry = 0, $keyId = 0) : bool { if (!$this->result) return false; $success = false; - foreach ($lvRows as $key => &$row) + foreach ($lvRows as &$row) { - $key = ($row['id'] ?? $key).':'.$srcEntry; // loot rows don't have an 'id' while being generated, but they have a usable $key - while (substr_count($key, ':') < 3) // pad with missing srcEntry, SrcId, cndTarget to group key - $key .= ':0'; + $srcKey = implode(':', array( + is_string($keyGroup) ? ($row[$keyGroup] ?? 0) : $keyGroup, + is_string($keyEntry) ? ($row[$keyEntry] ?? 0) : $keyEntry, + is_string($keyId) ? ($row[$keyId] ?? 0) : $keyId, + '' // cndTarget - 0 / 1 + )); foreach ($this->result as $cndData) { - if (empty($cndData[$key])) - continue; + if (isset($cndData[$srcKey.'0'])) + { + $row['condition'][self::SRC_NONE][$srcKey.'0'] = $cndData[$srcKey.'0']; + $success = true; + } - $row['condition'][self::SRC_NONE][$key] = $cndData[$key]; - $success = true; + if (isset($cndData[$srcKey.'1'])) + { + $row['condition'][self::SRC_NONE][$srcKey.'1'] = $cndData[$srcKey.'1']; + $success = true; + } } } @@ -413,7 +429,7 @@ class Conditions return true; } - private function fromSource() : bool + public function prepare() : bool { // itr over rows and prep data if (!$this->rows) @@ -496,7 +512,7 @@ class Conditions return $result; } - private function factionToSide($cId, &$cVal1, $cVal2, $cVal3) : bool + private function factionToSide($cndId, &$cVal1, $cVal2, $cVal3) : bool { if ($cVal1 == 469) $cVal1 = SIDE_ALLIANCE; @@ -508,7 +524,7 @@ class Conditions return true; } - private function mapToZone($cId, &$cVal1, &$cVal2, $cVal3) : bool + private function mapToZone($cndId, &$cVal1, &$cVal2, $cVal3) : bool { // use g_zone_categories id if ($cVal1 == 530) // outland @@ -533,16 +549,16 @@ class Conditions return true; } - private function maskToBits($cId, &$cVal1, $cVal2, $cVal3) : bool + private function maskToBits($cndId, &$cVal1, $cVal2, $cVal3) : bool { - if ($cId == self::CHR_CLASS) + if ($cndId == self::CHR_CLASS) { $cVal1 &= CLASS_MASK_ALL; foreach (Util::mask2bits($cVal1, 1) as $cId) $this->jsGlobals[Type::CHR_CLASS][$cId] = $cId; } - if ($cId == self::CHR_RACE) + if ($cndId == self::CHR_RACE) { $cVal1 &= RACE_MASK_ALL; foreach (Util::mask2bits($cVal1, 1) as $rId) @@ -552,7 +568,7 @@ class Conditions return true; } - private function typeidToId($cId, $cVal1, &$cVal2, &$cVal3) : bool + private function typeidToId($cndId, $cVal1, &$cVal2, &$cVal3) : bool { if ($cVal1 == self::TYPEID_UNIT) { diff --git a/includes/loot.class.php b/includes/loot.class.php index 9081798b..86e2d1de 100644 --- a/includes/loot.class.php +++ b/includes/loot.class.php @@ -246,8 +246,7 @@ class Loot continue; } - $cndKey = $lootId . ':' . (-1 * ($set['reference'] ?? -$set['content'])); - $loot[$cndKey] = $set; + $loot[] = $set; } foreach (array_keys($nGroupEquals) as $k) @@ -264,10 +263,10 @@ class Loot $groupChances[$k] = (100 - $sum) / ($nGroupEquals[$k] ?: 1); } - if ($cnd->getBySourceGroup($lootId, Conditions::lootTableToConditionSource($tableName))) + if ($cnd->getBySourceGroup($lootId, Conditions::lootTableToConditionSource($tableName))->prepare()) { self::storeJSGlobals($cnd->getJsGlobals()); - $cnd->toListviewColumn($loot, $this->extraCols); + $cnd->toListviewColumn($loot, $this->extraCols, $lootId, 'content'); } return [$loot, array_unique($rawItems)]; diff --git a/pages/achievement.php b/pages/achievement.php index bec23318..f41bc550 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -268,7 +268,7 @@ class AchievementPage extends GenericPage // tab: condition for $cnd = new Conditions(); - if ($cnd->getByCondition(Type::ACHIEVEMENT, $this->typeId)) + if ($cnd->getByCondition(Type::ACHIEVEMENT, $this->typeId)->prepare()) { $this->extendGlobalData($cnd->getJsGlobals()); $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); diff --git a/pages/areatrigger.php b/pages/areatrigger.php index a845a428..5230b35e 100644 --- a/pages/areatrigger.php +++ b/pages/areatrigger.php @@ -86,7 +86,7 @@ class AreaTriggerPage extends GenericPage // tab: conditions $cnd = new Conditions(); - $cnd->getBySourceEntry($this->typeId, Conditions::SRC_AREATRIGGER_CLIENT); + $cnd->getBySourceEntry($this->typeId, Conditions::SRC_AREATRIGGER_CLIENT)->prepare(); if ($tab = $cnd->toListviewTab()); { $this->extendGlobalData($cnd->getJsGlobals()); diff --git a/pages/class.php b/pages/class.php index 1006e057..a4e6bb6b 100644 --- a/pages/class.php +++ b/pages/class.php @@ -230,6 +230,14 @@ class ClassPage extends GenericPage $races = new CharRaceList(array(['classMask', $_mask, '&'])); if (!$races->error) $this->lvTabs[] = [CharRaceList::$brickFile, ['data' => array_values($races->getListviewData())]]; + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::CHR_CLASS, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } } diff --git a/pages/event.php b/pages/event.php index 00bf12f9..80a07d8b 100644 --- a/pages/event.php +++ b/pages/event.php @@ -267,7 +267,7 @@ class EventPage extends GenericPage // tab: condition for $cnd = new Conditions(); - if ($cnd->getByCondition(Type::WORLDEVENT, $this->typeId)) + if ($cnd->getByCondition(Type::WORLDEVENT, $this->typeId)->prepare()) { $this->extendGlobalData($cnd->getJsGlobals()); $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); diff --git a/pages/faction.php b/pages/faction.php index 8836ccf0..3cdb12b5 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -294,6 +294,14 @@ class FactionPage extends GenericPage 'visibleCols' => ['category'] )]; } + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::FACTION, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } } diff --git a/pages/item.php b/pages/item.php index de7c4848..3f48d54e 100644 --- a/pages/item.php +++ b/pages/item.php @@ -541,7 +541,7 @@ class ItemPage extends genericPage ); if ($extraCols) - $tabData['extraCols'] = array_unique($extraCols); + $tabData['extraCols'] = array_values(array_unique($extraCols)); if ($hiddenCols) $tabData['hiddenCols'] = array_unique($hiddenCols); @@ -784,6 +784,7 @@ class ItemPage extends genericPage $extraCols = ['$Listview.extraCols.stock', "\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; $cnd = new Conditions(); + $cnd->getBySourceEntry($this->typeId, Conditions::SRC_NPC_VENDOR)->prepare(); foreach ($sbData as $k => &$row) { $currency = []; @@ -805,7 +806,7 @@ class ItemPage extends genericPage $row['cost'] = [empty($vendors[$k][0][0]) ? 0 : $vendors[$k][0][0]]; if ($e = $vendors[$k][0]['event']) - $cnd->addExternalCondition(Conditions::SRC_NONE, $k, [Conditions::ACTIVE_EVENT, $e]); + $cnd->addExternalCondition(Conditions::SRC_NONE, $k.':'.$this->typeId, [Conditions::ACTIVE_EVENT, $e]); if ($currency || $tokens) // fill idx:3 if required $row['cost'][] = $currency; @@ -823,7 +824,7 @@ class ItemPage extends genericPage $row['stack'] = $x; } - if ($cnd->toListviewColumn($sbData, $extraCols)) + if ($cnd->toListviewColumn($sbData, $extraCols, 'id', $this->typeId)) $this->extendGlobalData($cnd->getJsGlobals()); $this->lvTabs[] = [CreatureList::$brickFile, array( @@ -1008,6 +1009,14 @@ class ItemPage extends genericPage } } + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::ITEM, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } + // // todo - tab: taught by // use var $createdBy to find source of this spell diff --git a/pages/npc.php b/pages/npc.php index 1b57073d..394f75dd 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -490,6 +490,11 @@ class NpcPage extends GenericPage } } + $cnd = new Conditions(); + $cnd->getBySourceGroup($this->typeId, Conditions::SRC_VEHICLE_SPELL)->prepare(); + if ($cnd->toListviewColumn($controled, $extraCols, $this->typeId, 'id')) + $this->extendGlobalData($cnd->getJsGlobals()); + if ($normal) $this->lvTabs[] = [SpellList::$brickFile, array( 'data' => array_values($normal), @@ -498,11 +503,17 @@ class NpcPage extends GenericPage )]; if ($controled) - $this->lvTabs[] = [SpellList::$brickFile, array( + { + $lvTab = array( 'data' => array_values($controled), 'name' => '$LANG.tab_controlledabilities', 'id' => 'controlled-abilities' - )]; + ); + if ($extraCols) + $lvTab['extraCols'] = $extraCols; + + $this->lvTabs[] = [SpellList::$brickFile, $lvTab]; + } } } @@ -645,10 +656,10 @@ class NpcPage extends GenericPage } $cnd = new Conditions(); - if ($cnd->getBySourceGroup($this->typeId, Conditions::SRC_NPC_VENDOR)) + if ($cnd->getBySourceGroup($this->typeId, Conditions::SRC_NPC_VENDOR)->prepare()) { $this->extendGlobalData($cnd->getJsGlobals()); - $cnd->toListviewColumn($lvData, $extraCols); + $cnd->toListviewColumn($lvData, $extraCols, $this->typeId, 'id'); } $this->lvTabs[] = [ItemList::$brickFile, array( @@ -877,10 +888,14 @@ class NpcPage extends GenericPage // tab: conditions $cnd = new Conditions(); - if ($cnd->getBySourceEntry($this->typeId, Conditions::SRC_CREATURE_TEMPLATE_VEHICLE)) + $cnd->getBySourceEntry($this->typeId, Conditions::SRC_CREATURE_TEMPLATE_VEHICLE) + ->getBySourceGroup($this->typeId, Conditions::SRC_SPELL_CLICK_EVENT) + ->getByCondition(Type::NPC, $this->typeId) + ->prepare(); + if ($tab = $cnd->toListviewTab()) { $this->extendGlobalData($cnd->getJsGlobals()); - $this->lvTabs[] = $cnd->toListviewTab(); + $this->lvTabs[] = $tab; } } diff --git a/pages/object.php b/pages/object.php index 93c90f78..cb2c2a2a 100644 --- a/pages/object.php +++ b/pages/object.php @@ -472,6 +472,14 @@ class ObjectPage extends GenericPage 'id' => 'same-model-as' )]; } + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::OBJECT, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } protected function generateTooltip() diff --git a/pages/quest.php b/pages/quest.php index 1376c0b2..fff446d6 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -1023,7 +1023,9 @@ class QuestPage extends GenericPage // tab: conditions $cnd = new Conditions(); - $cnd->getBySourceEntry($this->typeId, Conditions::SRC_QUEST_AVAILABLE, Conditions::SRC_QUEST_SHOW_MARK); + $cnd->getBySourceEntry($this->typeId, Conditions::SRC_QUEST_AVAILABLE, Conditions::SRC_QUEST_SHOW_MARK) + ->getByCondition(Type::QUEST, $this->typeId) + ->prepare(); if ($_ = $this->subject->getField('reqMinRepFaction')) $cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, $this->typeId, [Conditions::REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))]); diff --git a/pages/race.php b/pages/race.php index 76151547..a2e12498 100644 --- a/pages/race.php +++ b/pages/race.php @@ -201,6 +201,14 @@ class RacePage extends GenericPage )]; } } + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::CHR_RACE, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } } diff --git a/pages/skill.php b/pages/skill.php index 40d6f63d..2b53d74d 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -336,6 +336,14 @@ class SkillPage extends GenericPage if (!$races->error) $this->lvTabs[] = [CharRaceList::$brickFile, ['data' => array_values($races->getListviewData())]]; } + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::SKILL, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } } diff --git a/pages/spell.php b/pages/spell.php index c62f70b0..8f5a2294 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -1084,7 +1084,7 @@ class SpellPage extends GenericPage $this->extendGlobalData($tbTrainer->getJSGlobals()); $cnd = new Conditions(); - $skill = $this->subject->getField('skill'); + $skill = $this->subject->getField('skillLines'); foreach ($trainers as $tId => $train) { @@ -1240,18 +1240,13 @@ class SpellPage extends GenericPage // tab: conditions $cnd = new Conditions(); - if ($cnd->getBySourceEntry($this->typeId, Conditions::SRC_SPELL_LOOT_TEMPLATE, Conditions::SRC_SPELL_IMPLICIT_TARGET, Conditions::SRC_SPELL, Conditions::SRC_SPELL_CLICK_EVENT, Conditions::SRC_VEHICLE_SPELL, Conditions::SRC_SPELL_PROC)) + $cnd->getBySourceEntry($this->typeId, Conditions::SRC_SPELL_IMPLICIT_TARGET, Conditions::SRC_SPELL, Conditions::SRC_SPELL_CLICK_EVENT, Conditions::SRC_VEHICLE_SPELL, Conditions::SRC_SPELL_PROC) + ->getByCondition(Type::SPELL, $this->typeId) + ->prepare(); + if ($tab = $cnd->toListviewTab()) { $this->extendGlobalData($cnd->getJsGlobals()); - $this->lvTabs[] = $cnd->toListviewTab(); - } - - // tab: condition for - $cnd = new Conditions(); - if ($cnd->getByCondition(Type::SPELL, $this->typeId)) - { - $this->extendGlobalData($cnd->getJsGlobals()); - $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + $this->lvTabs[] = $tab; } } diff --git a/pages/title.php b/pages/title.php index ded6e026..d9381706 100644 --- a/pages/title.php +++ b/pages/title.php @@ -131,7 +131,30 @@ class TitlePage extends GenericPage } } - // tab: criteria of (to be added by TC) + // tab: criteria of + if ($crt = DB::World()->selectCol('SELECT `criteria_id` FROM achievement_criteria_data WHERE `type` = 23 AND `value1` = ?d', $this->typeId)) + { + $acvs = new AchievementList(array(['ac.id', $crt])); + if (!$acvs->error) + { + $this->extendGlobalData($acvs->getJSGlobals()); + + $this->lvTabs[] = [AchievementList::$brickFile, array( + 'data' => array_values($acvs->getListviewData()), + 'id' => 'criteria-of', + 'name' => '$LANG.tab_criteriaof', + 'visibleCols' => ['category'] + )]; + } + } + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::TITLE, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } } diff --git a/pages/zone.php b/pages/zone.php index 0c4772f6..208acf55 100644 --- a/pages/zone.php +++ b/pages/zone.php @@ -784,6 +784,14 @@ class ZonePage extends GenericPage $this->zoneMusic['intro'] = $_; } } + + // tab: condition-for + $cnd = new Conditions(); + if ($cnd->getByCondition(Type::ZONE, $this->typeId)->prepare()) + { + $this->extendGlobalData($cnd->getJsGlobals()); + $this->lvTabs[] = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for'); + } } private function addMoveLocationMenu($parentArea, $parentFloor)