Exemple #1
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     $_cat = $this->subject->getField('typeCat');
     $redButtons = array(BUTTON_LINKS => ['color' => 'ff71d5ff', 'linkId' => Util::$typeStrings[TYPE_SPELL] . ':' . $this->typeId], BUTTON_VIEW3D => false, BUTTON_WOWHEAD => true);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // level
     if (!in_array($_cat, [-5, -6])) {
         if ($_ = $this->subject->getField('talentLevel')) {
             $infobox[] = in_array($_cat, [-2, 7, -13]) ? sprintf(Lang::game('reqLevel'), $_) : Lang::game('level') . Lang::main('colon') . $_;
         } else {
             if ($_ = $this->subject->getField('spellLevel')) {
                 $infobox[] = in_array($_cat, [-2, 7, -13]) ? sprintf(Lang::game('reqLevel'), $_) : Lang::game('level') . Lang::main('colon') . $_;
             }
         }
     }
     // races
     if ($_ = Lang::getRaceString($this->subject->getField('reqRaceMask'), $__, $jsg, $n, false)) {
         if ($_ != Lang::game('ra', 0)) {
             $this->extendGlobalIds(TYPE_RACE, $jsg);
             $t = $n == 1 ? Lang::game('race') : Lang::game('races');
             $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $_;
         }
     }
     // classes
     if ($_ = Lang::getClassString($this->subject->getField('reqClassMask'), $jsg, $n, false)) {
         $this->extendGlobalIds(TYPE_CLASS, $jsg);
         $t = $n == 1 ? Lang::game('class') : Lang::game('classes');
         $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $_;
     }
     // spell focus
     if ($_ = $this->subject->getField('spellFocusObject')) {
         $bar = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE id = ?d', $_);
         $focus = new GameObjectList(array(['spellFocusId', $_], 1));
         $infobox[] = Lang::game('requires2') . ' ' . ($focus->error ? Util::localizedString($bar, 'name') : '[url=?object=' . $focus->id . ']' . Util::localizedString($bar, 'name') . '[/url]');
     }
     // primary & secondary trades
     if (in_array($_cat, [9, 11])) {
         // skill
         if ($_ = $this->subject->getField('skillLines')[0]) {
             $rSkill = new SkillList(array(['id', $_]));
             if (!$rSkill->error) {
                 $this->extendGlobalData($rSkill->getJSGlobals());
                 $bar = sprintf(Lang::game('requires'), ' [skill=' . $rSkill->id . ']');
                 if ($_ = $this->subject->getField('learnedAt')) {
                     $bar .= ' (' . $_ . ')';
                 }
                 $infobox[] = $bar;
             }
         }
         // specialization
         if ($_ = $this->subject->getField('reqSpellId')) {
             $rSpell = new SpellList(array(['id', $_]));
             if (!$rSpell->error) {
                 $this->extendGlobalData($rSpell->getJSGlobals());
                 $infobox[] = Lang::game('requires2') . ' [spell=' . $rSpell->id . '][/li]';
             }
         }
         // difficulty
         if ($_ = $this->subject->getColorsForCurrent()) {
             $bar = [];
             for ($i = 0; $i < 4; $i++) {
                 if ($_[$i]) {
                     $bar[] = '[color=r' . ($i + 1) . ']' . $_[$i] . '[/color]';
                 }
             }
             $infobox[] = Lang::game('difficulty') . Lang::main('colon') . implode(' ', $bar);
         }
     }
     // accquisition..   10: starter spell; 7: discovery
     if (isset($this->subject->sources[$this->subject->id][10])) {
         $infobox[] = Lang::spell('starter');
     } else {
         if (isset($this->subject->sources[$this->subject->id][7])) {
             $infobox[] = Lang::spell('discovered');
         }
     }
     // training cost
     if ($cost = $this->subject->getField('trainingCost')) {
         $infobox[] = Lang::spell('trainingCost') . Lang::main('colon') . '[money=' . $cost . '][/li]';
     }
     // used in mode
     foreach ($this->difficulties as $n => $id) {
         if ($id == $this->typeId) {
             // "Mode" seems to be multilingual acceptable
             $infobox[] = 'Mode' . Lang::main('colon') . Lang::game('modes', $n);
         }
     }
     $effects = $this->createEffects($infobox, $redButtons);
     // spell script
     if (User::isInGroup(U_GROUP_STAFF)) {
         if ($_ = DB::World()->selectCell('SELECT ScriptName FROM spell_script_names WHERE ABS(spell_id) = ?d', $this->firstRank)) {
             $infobox[] = 'Script' . Lang::main('colon') . $_;
         }
     }
     $infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : '';
     // append glyph symbol if available
     $glyphId = 0;
     for ($i = 1; $i < 4; $i++) {
         if ($this->subject->getField('effect' . $i . 'Id') == 74) {
             $glyphId = $this->subject->getField('effect' . $i . 'MiscValue');
         }
     }
     if ($_ = DB::Aowow()->selectCell('SELECT si.iconString FROM ?_glyphproperties gp JOIN ?_icons si ON gp.iconId = si.id WHERE gp.spellId = ?d { OR gp.id = ?d }', $this->typeId, $glyphId ?: DBSIMPLE_SKIP)) {
         if (file_exists('static/images/wow/Interface/Spellbook/' . $_ . '.png')) {
             $infobox .= '[img src=' . STATIC_URL . '/images/wow/Interface/Spellbook/' . $_ . '.png border=0 float=center margin=15]';
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->reagents = $this->createReagentList();
     $this->scaling = $this->createScalingData();
     $this->items = $this->createRequiredItems();
     $this->tools = $this->createTools();
     $this->effects = $effects;
     $this->infobox = $infobox;
     $this->powerCost = $this->subject->createPowerCostForCurrent();
     $this->castTime = $this->subject->createCastTimeForCurrent(false, false);
     $this->name = $this->subject->getField('name', true);
     $this->headIcons = [$this->subject->getField('iconString'), $this->subject->getField('stackAmount')];
     $this->level = $this->subject->getField('spellLevel');
     $this->rangeName = $this->subject->getField('rangeText', true);
     $this->range = $this->subject->getField('rangeMaxHostile');
     $this->gcd = Util::formatTime($this->subject->getField('startRecoveryTime'));
     $this->gcdCat = null;
     // todo (low): nyi; find out how this works [n/a; normal; ..]
     $this->school = [Util::asHex($this->subject->getField('schoolMask')), Lang::getMagicSchools($this->subject->getField('schoolMask'))];
     $this->dispel = $this->subject->getField('dispelType') ? Lang::game('dt', $this->subject->getField('dispelType')) : null;
     $this->mechanic = $this->subject->getField('mechanic') ? Lang::game('me', $this->subject->getField('mechanic')) : null;
     $this->unavailable = $this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE;
     $this->redButtons = $redButtons;
     // minRange exists..  prepend
     if ($_ = $this->subject->getField('rangeMinHostile')) {
         $this->range = $_ . ' - ' . $this->range;
     }
     if ($this->subject->getField('attributes2') & 0x80000) {
         $this->stances = Lang::getStances($this->subject->getField('stanceMask'));
     }
     if (($_ = $this->subject->getField('recoveryTime')) && $_ > 0) {
         $this->cooldown = Util::formatTime($_);
     }
     if (($_ = $this->subject->getField('duration')) && $_ > 0) {
         $this->duration = Util::formatTime($_);
     }
     // factionchange-equivalent
     if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_spells WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) {
         $altSpell = new SpellList(array(['id', abs($pendant)]));
         if (!$altSpell->error) {
             $this->transfer = sprintf(Lang::spell('_transfer'), $altSpell->id, 1, $altSpell->getField('iconString'), $altSpell->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2));
         }
     }
     /**************/
     /* Extra Tabs */
     /**************/
     $j = [null, 'A', 'B', 'C'];
     // tab: abilities [of shapeshift form]
     for ($i = 1; $i < 4; $i++) {
         if ($this->subject->getField('effect' . $i . 'AuraId') != 36) {
             continue;
         }
         $formSpells = DB::Aowow()->selectRow('SELECT spellId1, spellId2, spellId3, spellId4, spellId5, spellId6, spellId7, spellId8 FROM ?_shapeshiftforms WHERE id = ?d', $this->subject->getField('effect' . $i . 'MiscValue'));
         if (!$formSpells) {
             continue;
         }
         $abilities = new SpellList(array(['id', $formSpells]));
         if (!$abilities->error) {
             if (!$abilities->hasSetFields(['skillLines'])) {
                 $abH = "\$['skill']";
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $abilities->getListviewData(), 'params' => array('id' => 'controlledabilities', 'name' => '$LANG.tab_controlledabilities', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($abH) ? $abH : null));
             $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF));
         }
     }
     // tab: modifies $this
     $sub = ['OR'];
     $conditions = [['s.typeCat', [0, -9, -8], '!'], ['s.spellFamilyId', $this->subject->getField('spellFamilyId')], &$sub];
     for ($i = 1; $i < 4; $i++) {
         // Flat Mods (107), Pct Mods (108), No Reagent Use (256) .. include dummy..? (4)
         if (!in_array($this->subject->getField('effect' . $i . 'AuraId'), [107, 108, 256, 286])) {
             continue;
         }
         $m1 = $this->subject->getField('effect1SpellClassMask' . $j[$i]);
         $m2 = $this->subject->getField('effect2SpellClassMask' . $j[$i]);
         $m3 = $this->subject->getField('effect3SpellClassMask' . $j[$i]);
         if (!$m1 && !$m2 && !$m3) {
             continue;
         }
         $sub[] = ['s.spellFamilyFlags1', $m1, '&'];
         $sub[] = ['s.spellFamilyFlags2', $m2, '&'];
         $sub[] = ['s.spellFamilyFlags3', $m3, '&'];
     }
     if (count($sub) > 1) {
         $modSpells = new SpellList($conditions);
         if (!$modSpells->error) {
             if (!$modSpells->hasSetFields(['skillLines'])) {
                 $msH = "\$['skill']";
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $modSpells->getListviewData(), 'params' => array('id' => 'modifies', 'name' => '$LANG.tab_modifies', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($msH) ? $msH : null));
             $this->extendGlobalData($modSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
     // tab: modified by $this
     $sub = ['OR'];
     $conditions = [['s.spellFamilyId', $this->subject->getField('spellFamilyId')], &$sub];
     for ($i = 1; $i < 4; $i++) {
         $m1 = $this->subject->getField('spellFamilyFlags1');
         $m2 = $this->subject->getField('spellFamilyFlags2');
         $m3 = $this->subject->getField('spellFamilyFlags3');
         if (!$m1 && !$m2 && !$m3) {
             continue;
         }
         $sub[] = array('AND', ['s.effect' . $i . 'AuraId', [107, 108, 256, 286]], ['OR', ['s.effect1SpellClassMask' . $j[$i], $m1, '&'], ['s.effect2SpellClassMask' . $j[$i], $m2, '&'], ['s.effect3SpellClassMask' . $j[$i], $m3, '&']]);
     }
     if (count($sub) > 1) {
         $modsSpell = new SpellList($conditions);
         if (!$modsSpell->error) {
             if (!$modsSpell->hasSetFields(['skillLines'])) {
                 $mbH = "\$['skill']";
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $modsSpell->getListviewData(), 'params' => array('id' => 'modified-by', 'name' => '$LANG.tab_modifiedby', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($mbH) ? $mbH : null));
             $this->extendGlobalData($modsSpell->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
     // tab: see also
     $conditions = array(['s.schoolMask', $this->subject->getField('schoolMask')], ['s.effect1Id', $this->subject->getField('effect1Id')], ['s.effect2Id', $this->subject->getField('effect2Id')], ['s.effect3Id', $this->subject->getField('effect3Id')], ['s.id', $this->subject->id, '!'], ['s.name_loc' . User::$localeId, $this->subject->getField('name', true)]);
     $saSpells = new SpellList($conditions);
     if (!$saSpells->error) {
         $data = $saSpells->getListviewData();
         if ($this->difficulties) {
             $saE = '$[Listview.extraCols.mode]';
             foreach ($data as $id => &$d) {
                 $d['modes'] = ['mode' => 0];
                 if ($this->difficulties[0] == $id) {
                     if (!$this->difficulties[2] && !$this->difficulties[3]) {
                         $d['modes']['mode'] |= 0x2;
                     } else {
                         $d['modes']['mode'] |= 0x8;
                     }
                 }
                 if ($this->difficulties[1] == $id) {
                     if (!$this->difficulties[2] && !$this->difficulties[3]) {
                         $d['modes']['mode'] |= 0x1;
                     } else {
                         $d['modes']['mode'] |= 0x10;
                     }
                 }
                 if ($this->difficulties[2] == $id) {
                     // b0100000
                     $d['modes']['mode'] |= 0x20;
                 }
                 if ($this->difficulties[3] == $id) {
                     // b1000000
                     $d['modes']['mode'] |= 0x40;
                 }
             }
         }
         if (!$saSpells->hasSetFields(['skillLines'])) {
             $saH = "\$['skill']";
         }
         $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso', 'visibleCols' => "\$['level']", 'extraCols' => isset($saE) ? $saE : null, 'hiddenCols' => isset($saH) ? $saH : null));
         $this->extendGlobalData($saSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: used by - itemset
     $conditions = array('OR', ['spell1', $this->subject->id], ['spell2', $this->subject->id], ['spell3', $this->subject->id], ['spell4', $this->subject->id], ['spell5', $this->subject->id], ['spell6', $this->subject->id], ['spell7', $this->subject->id], ['spell8', $this->subject->id]);
     $ubSets = new ItemsetList($conditions);
     if (!$ubSets->error) {
         $this->lvTabs[] = array('file' => 'itemset', 'data' => $ubSets->getListviewData(), 'params' => array('id' => 'used-by-itemset', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubSets->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: used by - item
     $conditions = array('OR', ['AND', ['spellTrigger1', 6, '!'], ['spellId1', $this->subject->id]], ['AND', ['spellTrigger2', 6, '!'], ['spellId2', $this->subject->id]], ['AND', ['spellTrigger3', 6, '!'], ['spellId3', $this->subject->id]], ['AND', ['spellTrigger4', 6, '!'], ['spellId4', $this->subject->id]], ['AND', ['spellTrigger5', 6, '!'], ['spellId5', $this->subject->id]]);
     $ubItems = new ItemList($conditions);
     if (!$ubItems->error) {
         $this->lvTabs[] = array('file' => 'item', 'data' => $ubItems->getListviewData(), 'params' => array('id' => 'used-by-item', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: used by - object
     $conditions = array('OR', ['onUseSpell', $this->subject->id], ['onSuccessSpell', $this->subject->id], ['auraSpell', $this->subject->id], ['triggeredSpell', $this->subject->id]);
     $ubObjects = new GameObjectList($conditions);
     if (!$ubObjects->error) {
         $this->lvTabs[] = array('file' => 'object', 'data' => $ubObjects->getListviewData(), 'params' => array('id' => 'used-by-object', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubObjects->getJSGlobals());
     }
     // tab: criteria of
     $conditions = array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL]], ['ac.value1', $this->typeId]);
     $coAchievemnts = new AchievementList($conditions);
     if (!$coAchievemnts->error) {
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $coAchievemnts->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof'));
         $this->extendGlobalData($coAchievemnts->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: contains
     // spell_loot_template & skill_extra_item_template
     $extraItem = DB::World()->selectRow('SELECT * FROM skill_extra_item_template WHERE spellid = ?d', $this->subject->id);
     $spellLoot = new Loot();
     if ($spellLoot->getByContainer(LOOT_SPELL, $this->subject->id) || $extraItem) {
         $this->extendGlobalData($spellLoot->jsGlobals);
         $lv = $spellLoot->getResult();
         $extraCols = $spellLoot->extraCols;
         $extraCols[] = 'Listview.extraCols.percent';
         if ($extraItem && $this->subject->canCreateItem()) {
             $foo = $this->subject->relItems->getListviewData();
             for ($i = 1; $i < 4; $i++) {
                 if (($bar = $this->subject->getField('effect' . $i . 'CreateItemId')) && isset($foo[$bar])) {
                     $lv[$bar] = $foo[$bar];
                     $lv[$bar]['percent'] = $extraItem['additionalCreateChance'];
                     $lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]];
                     $this->extendGlobalIds(TYPE_SPELL, $extraItem['requiredSpecialization']);
                     $extraCols[] = 'Listview.extraCols.condition';
                     if ($max = $extraItem['additionalMaxNum']) {
                         $lv[$bar]['mincount'] = 1;
                         $lv[$bar]['maxcount'] = $max;
                     }
                     break;
                     // skill_extra_item_template can only contain 1 item
                 }
             }
         }
         $this->lvTabs[] = array('file' => 'item', 'data' => $lv, 'params' => array('name' => '$LANG.tab_contains', 'id' => 'contains', 'hiddenCols' => "\$['side', 'slot', 'source', 'reqlevel']", 'extraCols' => '$[' . implode(', ', $extraCols) . ']'));
     }
     // tab: exclusive with
     if ($this->firstRank) {
         $linkedSpells = DB::World()->selectCol('SELECT      IF(sg2.spell_id < 0, sg2.id, sg2.spell_id) AS ARRAY_KEY, IF(sg2.spell_id < 0, sg2.spell_id, sr.stack_rule)
             FROM        spell_group sg1
             JOIN        spell_group sg2
                 ON      (sg1.id = sg2.id OR sg1.id = -sg2.spell_id) AND sg1.spell_id != sg2.spell_id
             LEFT JOIN   spell_group_stack_rules sr
                 ON      sg1.id = sr.group_id
             WHERE       sg1.spell_id = ?d', $this->firstRank);
         if ($linkedSpells) {
             $extraSpells = [];
             foreach ($linkedSpells as $k => $v) {
                 if ($v > 0) {
                     continue;
                 }
                 $extraSpells += DB::World()->selectCol('SELECT      sg2.spell_id AS ARRAY_KEY, sr.stack_rule
                     FROM        spell_group sg1
                     JOIN        spell_group sg2
                         ON      sg2.id = -sg1.spell_id AND sg2.spell_id != ?d
                     LEFT JOIN   spell_group_stack_rules sr
                         ON      sg1.id = sr.group_id
                     WHERE       sg1.id = ?d', $this->firstRank, $k);
                 unset($linkedSpells[$k]);
             }
             $groups = $linkedSpells + $extraSpells;
             $stacks = new SpellList(array(['s.id', array_keys($groups)]));
             if (!$stacks->error) {
                 $data = $stacks->getListviewData();
                 foreach ($data as $k => $d) {
                     $data[$k]['stackRule'] = $groups[$k];
                 }
                 if (!$stacks->hasSetFields(['skillLines'])) {
                     $sH = "\$['skill']";
                 }
                 $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spell-group-stack', 'name' => 'Stack Group', 'visibleCols' => "\$['stackRules']", 'hiddenCols' => isset($sH) ? $sH : null));
                 $this->extendGlobalData($stacks->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             }
         }
     }
     // tab: linked with
     $rows = DB::World()->select('
         SELECT  spell_trigger AS `trigger`,
                 spell_effect AS effect,
                 type,
                 IF(ABS(spell_effect) = ?d, ABS(spell_trigger), ABS(spell_effect)) AS related
         FROM    spell_linked_spell
         WHERE   ABS(spell_effect) = ?d OR ABS(spell_trigger) = ?d', $this->typeId, $this->typeId, $this->typeId);
     $related = [];
     foreach ($rows as $row) {
         $related[] = $row['related'];
     }
     if ($related) {
         $linked = new SpellList(array(['s.id', $related]));
     }
     if (isset($linked) && !$linked->error) {
         $lv = $linked->getListviewData();
         $data = [];
         foreach ($rows as $r) {
             foreach ($lv as $dk => $d) {
                 if ($r['related'] != $dk) {
                     continue;
                 }
                 $lv[$dk]['linked'] = [$r['trigger'], $r['effect'], $r['type']];
                 $data[] = $lv[$dk];
                 break;
             }
         }
         $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spell-link', 'name' => 'Linked with', 'hiddenCols' => "\$['skill', 'name']", 'visibleCols' => "\$['linkedTrigger', 'linkedEffect']"));
         $this->extendGlobalData($linked->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: triggered by
     $conditions = array('OR', ['AND', ['OR', ['effect1Id', SpellList::$effects['trigger']], ['effect1AuraId', SpellList::$auras['trigger']]], ['effect1TriggerSpell', $this->subject->id]], ['AND', ['OR', ['effect2Id', SpellList::$effects['trigger']], ['effect2AuraId', SpellList::$auras['trigger']]], ['effect2TriggerSpell', $this->subject->id]], ['AND', ['OR', ['effect3Id', SpellList::$effects['trigger']], ['effect3AuraId', SpellList::$auras['trigger']]], ['effect3TriggerSpell', $this->subject->id]]);
     $trigger = new SpellList($conditions);
     if (!$trigger->error) {
         $this->lvTabs[] = array('file' => 'spell', 'data' => $trigger->getListviewData(), 'params' => array('id' => 'triggered-by', 'name' => '$LANG.tab_triggeredby'));
         $this->extendGlobalData($trigger->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: used by - creature
     // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86
     $conditions = array('OR', ['spell1', $this->typeId], ['spell2', $this->typeId], ['spell3', $this->typeId], ['spell4', $this->typeId], ['spell5', $this->typeId], ['spell6', $this->typeId], ['spell7', $this->typeId], ['spell8', $this->typeId]);
     if ($_ = DB::World()->selectCol('SELECT entryOrGUID FROM smart_scripts WHERE entryorguid > 0 AND source_type = 0 AND action_type IN (11, 75, 85, 86) AND action_param1 = ?d', $this->typeId)) {
         $conditions[] = ['id', $_];
     }
     $ubCreature = new CreatureList($conditions);
     if (!$ubCreature->error) {
         $this->lvTabs[] = array('file' => 'creature', 'data' => $ubCreature->getListviewData(), 'params' => array('id' => 'used-by-npc', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubCreature->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: zone
     if ($areas = DB::World()->select('SELECT * FROM spell_area WHERE spell = ?d', $this->typeId)) {
         $zones = new ZoneList(array(['id', array_column($areas, 'area')]));
         if (!$zones->error) {
             $lvZones = $zones->getListviewData();
             $this->extendGlobalData($zones->getJSGlobals());
             $lv = [];
             $parents = [];
             $extra = false;
             foreach ($areas as $a) {
                 if (empty($lvZones[$a['area']])) {
                     continue;
                 }
                 $condition = [];
                 if ($a['aura_spell']) {
                     $this->extendGlobalIds(TYPE_SPELL, abs($a['aura_spell']));
                     $condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]];
                 }
                 if ($a['quest_start']) {
                     $this->extendGlobalIds(TYPE_QUEST, $a['quest_start']);
                     $group = [];
                     for ($i = 0; $i < 7; $i++) {
                         if (!($a['quest_start_status'] & 1 << $i)) {
                             continue;
                         }
                         if ($i == 0) {
                             $group[] = [CND_QUEST_NONE, $a['quest_start']];
                         } else {
                             if ($i == 1) {
                                 $group[] = [CND_QUEST_COMPLETE, $a['quest_start']];
                             } else {
                                 if ($i == 3) {
                                     $group[] = [CND_QUESTTAKEN, $a['quest_start']];
                                 } else {
                                     if ($i == 6) {
                                         $group[] = [CND_QUESTREWARDED, $a['quest_start']];
                                     }
                                 }
                             }
                         }
                     }
                     if ($group) {
                         $condition[0][$this->typeId][] = $group;
                     }
                 }
                 if ($a['quest_end'] && $a['quest_end'] != $a['quest_start']) {
                     $this->extendGlobalIds(TYPE_QUEST, $a['quest_end']);
                     $group = [];
                     for ($i = 0; $i < 7; $i++) {
                         if (!($a['quest_end_status'] & 1 << $i)) {
                             continue;
                         }
                         if ($i == 0) {
                             $group[] = [-CND_QUEST_NONE, $a['quest_end']];
                         } else {
                             if ($i == 1) {
                                 $group[] = [-CND_QUEST_COMPLETE, $a['quest_end']];
                             } else {
                                 if ($i == 3) {
                                     $group[] = [-CND_QUESTTAKEN, $a['quest_end']];
                                 } else {
                                     if ($i == 6) {
                                         $group[] = [-CND_QUESTREWARDED, $a['quest_end']];
                                     }
                                 }
                             }
                         }
                     }
                     if ($group) {
                         $condition[0][$this->typeId][] = $group;
                     }
                 }
                 if ($a['racemask']) {
                     $foo = [];
                     for ($i = 0; $i < 11; $i++) {
                         if ($a['racemask'] & 1 << $i) {
                             $foo[] = $i + 1;
                         }
                     }
                     $this->extendGlobalIds(TYPE_RACE, $foo);
                     $condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]];
                 }
                 if ($a['gender'] != 2) {
                     // 2: both
                     $condition[0][$this->typeId][] = [[CND_GENDER, $a['gender'] + 1]];
                 }
                 $row = $lvZones[$a['area']];
                 if ($condition) {
                     $extra = true;
                     $row = array_merge($row, ['condition' => $condition]);
                 }
                 // merge subzones, into one row, if: conditions match && parentZone is shared
                 if ($p = $zones->getEntry($a['area'])['parentArea']) {
                     $parents[] = $p;
                     $row['parentArea'] = $p;
                     $row['subzones'] = [$a['area']];
                 } else {
                     $row['parentArea'] = 0;
                 }
                 $set = false;
                 foreach ($lv as &$v) {
                     if ($v['parentArea'] != $row['parentArea'] && $v['id'] != $row['parentArea']) {
                         continue;
                     }
                     if (empty($v['condition']) xor empty($row['condition'])) {
                         continue;
                     }
                     if (!empty($row['condition']) && !empty($v['condition']) && $v['condition'] != $row['condition']) {
                         continue;
                     }
                     if (!$row['parentArea'] && $v['id'] != $row['parentArea']) {
                         continue;
                     }
                     $set = true;
                     $v['subzones'][] = $row['id'];
                     break;
                 }
                 // add self as potential subzone; IF we are a parentZone without added children, we get filtered in JScript
                 if (!$set) {
                     $row['subzones'] = [$row['id']];
                     $lv[] = $row;
                 }
             }
             // overwrite lvData with parent-lvData (condition and subzones are kept)
             if ($parents) {
                 $parents = (new ZoneList(array(['id', $parents])))->getListviewData();
                 foreach ($lv as &$_) {
                     if (isset($parents[$_['parentArea']])) {
                         $_ = array_merge($_, $parents[$_['parentArea']]);
                     }
                 }
             }
             $this->lvTabs[] = array('file' => 'zone', 'data' => $lv, 'params' => array('extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, 'hiddenCols' => $extra ? "\$['instancetype']" : null));
         }
     }
     // tab: teaches
     if ($ids = Util::getTaughtSpells($this->subject)) {
         $teaches = new SpellList(array(['id', $ids]));
         if (!$teaches->error) {
             $this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $vis = ['level', 'schools'];
             $hid = [];
             if (!$teaches->hasSetFields(['skillLines'])) {
                 $hid[] = 'skill';
             }
             foreach ($teaches->iterate() as $__) {
                 if (!$teaches->canCreateItem()) {
                     continue;
                 }
                 $vis[] = 'reagents';
                 break;
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $teaches->getListviewData(), 'params' => array('id' => 'teaches-spell', 'name' => '$LANG.tab_teaches', 'visibleCols' => '$' . Util::toJSON($vis), 'hiddenCols' => $hid ? '$' . Util::toJSON($hid) : null));
         }
     }
     // tab: taught by npc (source:6 => trainer)
     if (!empty($this->subject->sources[$this->typeId][6])) {
         $src = $this->subject->sources[$this->typeId][6];
         $list = [];
         if (count($src) == 1 && $src[0] == 1) {
             $tt = null;
             // Professions
             if (in_array($_cat, [9, 11]) && isset(Util::$trainerTemplates[TYPE_SKILL][$this->subject->getField('skillLines')[0]])) {
                 $tt = Util::$trainerTemplates[TYPE_SKILL][$this->subject->getField('skillLines')[0]];
             } else {
                 if ($_cat == 7 && $this->subject->getField('reqClassMask')) {
                     $clId = log($this->subject->getField('reqClassMask'), 2) + 1;
                     if (intVal($clId) == $clId) {
                         // only one class was set, so float == int
                         if (isset(Util::$trainerTemplates[TYPE_CLASS][$clId])) {
                             $tt = Util::$trainerTemplates[TYPE_CLASS][$clId];
                         }
                     }
                 }
             }
             if ($tt) {
                 $list = DB::World()->selectCol('SELECT DISTINCT ID FROM npc_trainer WHERE SpellID IN (?a) AND ID < 200000', $tt);
             } else {
                 $mask = 0;
                 foreach (Util::$skillLineMask[-3] as $idx => $pair) {
                     if ($pair[1] == $this->typeId) {
                         $mask |= 1 << $idx;
                     }
                 }
                 $list = DB::World()->selectCol('
                     SELECT    IF(t1.ID > 200000, t2.ID, t1.ID)
                     FROM      npc_trainer t1
                     LEFT JOIN npc_trainer t2 ON t2.SpellID = -t1.ID
                     WHERE     t1.SpellID = ?d', $this->typeId);
             }
         } else {
             if ($src) {
                 $list = array_values($src);
             }
         }
         if ($list) {
             $tbTrainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&']));
             if (!$tbTrainer->error) {
                 $this->extendGlobalData($tbTrainer->getJSGlobals());
                 $this->lvTabs[] = array('file' => 'creature', 'data' => $tbTrainer->getListviewData(), 'params' => array('id' => 'taught-by-npc', 'name' => '$LANG.tab_taughtby'));
             }
         }
     }
     // tab: taught by spell
     $conditions = array('OR', ['AND', ['effect1Id', SpellList::$effects['teach']], ['effect1TriggerSpell', $this->subject->id]], ['AND', ['effect2Id', SpellList::$effects['teach']], ['effect2TriggerSpell', $this->subject->id]], ['AND', ['effect3Id', SpellList::$effects['teach']], ['effect3TriggerSpell', $this->subject->id]]);
     $tbSpell = new SpellList($conditions);
     $tbsData = [];
     if (!$tbSpell->error) {
         $tbsData = $tbSpell->getListviewData();
         $this->lvTabs[] = array('file' => 'spell', 'data' => $tbsData, 'params' => array('id' => 'taught-by-spell', 'name' => '$LANG.tab_taughtby'));
         $this->extendGlobalData($tbSpell->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: taught by quest
     $conditions = ['OR', ['sourceSpellId', $this->typeId], ['rewardSpell', $this->typeId]];
     if ($tbsData) {
         $conditions[] = ['rewardSpell', array_keys($tbsData)];
         if (User::isInGroup(U_GROUP_EMPLOYEE)) {
             $conditions[] = ['rewardSpellCast', array_keys($tbsData)];
         }
     }
     if (User::isInGroup(U_GROUP_EMPLOYEE)) {
         $conditions[] = ['rewardSpellCast', $this->typeId];
     }
     $tbQuest = new QuestList($conditions);
     if (!$tbQuest->error) {
         $this->lvTabs[] = array('file' => 'quest', 'data' => $tbQuest->getListviewData(), 'params' => array('id' => 'reward-from-quest', 'name' => '$LANG.tab_rewardfrom'));
         $this->extendGlobalData($tbQuest->getJSGlobals());
     }
     // tab: taught by item (i'd like to precheck $this->subject->sources, but there is no source:item only complicated crap like "drop" and "vendor")
     $conditions = array('OR', ['AND', ['spellTrigger1', 6], ['spellId1', $this->subject->id]], ['AND', ['spellTrigger2', 6], ['spellId2', $this->subject->id]], ['AND', ['spellTrigger3', 6], ['spellId3', $this->subject->id]], ['AND', ['spellTrigger4', 6], ['spellId4', $this->subject->id]], ['AND', ['spellTrigger5', 6], ['spellId5', $this->subject->id]]);
     $tbItem = new ItemList($conditions);
     if (!$tbItem->error) {
         $this->lvTabs[] = array('file' => 'item', 'data' => $tbItem->getListviewData(), 'params' => array('id' => 'taught-by-item', 'name' => '$LANG.tab_taughtby'));
         $this->extendGlobalData($tbItem->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: enchantments
     $conditions = array('OR', ['AND', ['type1', [1, 3, 7]], ['object1', $this->typeId]], ['AND', ['type2', [1, 3, 7]], ['object2', $this->typeId]], ['AND', ['type3', [1, 3, 7]], ['object3', $this->typeId]]);
     $enchList = new EnchantmentList($conditions);
     if (!$enchList->error) {
         $this->lvTabs[] = array('file' => 'enchantment', 'data' => $enchList->getListviewData(), 'params' => []);
         $this->extendGlobalData($enchList->getJSGlobals());
     }
     // find associated NPC, Item and merge results
     // taughtbypets (unused..?)
     // taughtbyquest (usually the spell casted as quest reward teaches something; exclude those seplls from taughtBySpell)
     // taughtbytrainers
     // taughtbyitem
     // tab: conditions
     $sc = Util::getServerConditions([CND_SRC_SPELL_LOOT_TEMPLATE, CND_SRC_SPELL_IMPLICIT_TARGET, CND_SRC_SPELL, CND_SRC_SPELL_CLICK_EVENT, CND_SRC_VEHICLE_SPELL, CND_SRC_SPELL_PROC], null, $this->typeId);
     if (!empty($sc[0])) {
         $this->extendGlobalData($sc[1]);
         $tab = "<script type=\"text/javascript\">\n" . "var markup = ConditionList.createTab(" . Util::toJSON($sc[0]) . ");\n" . "Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" . "</script>";
         $this->lvTabs[] = array('file' => null, 'data' => $tab, 'params' => array('id' => 'conditions', 'name' => '$LANG.requires'));
     }
 }
Exemple #2
0
function profiler()
{
    $success = true;
    $scripts = [];
    /**********/
    /* Quests */
    /**********/
    $scripts[] = function () {
        $success = true;
        $condition = [CFG_SQL_LIMIT_NONE, 'AND', [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW], 0], [['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_REPEATABLE | QUEST_FLAG_AUTO_REWARDED, '&'], 0], [['specialFlags', QUEST_FLAG_SPECIAL_REPEATABLE | QUEST_FLAG_SPECIAL_DUNGEON_FINDER | QUEST_FLAG_SPECIAL_MONTHLY, '&'], 0]];
        $questz = new QuestList($condition);
        $_ = [];
        $currencies = array_column($questz->rewards, TYPE_CURRENCY);
        foreach ($currencies as $curr) {
            foreach ($curr as $cId => $qty) {
                $_[] = $cId;
            }
        }
        $relCurr = new CurrencyList(array(['id', $_]));
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(20);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_gatheredcurrencies;\n";
            foreach ($relCurr->getListviewData() as $id => $data) {
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            $buff .= "\n\nvar _ = g_quests;\n";
            foreach ($questz->getListviewData() as $id => $data) {
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            $buff .= "\ng_quest_catorder = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n";
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-quests', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /****************/
    /* Achievements */
    /****************/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], [['flags', 1, '&'], 0]);
        $achievez = new AchievementList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $sumPoints = 0;
            $buff = "var _ = g_achievements;\n";
            foreach ($achievez->getListviewData(ACHIEVEMENTINFO_PROFILE) as $id => $data) {
                $sumPoints += $data['points'];
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            // categories to sort by
            $buff .= "\ng_achievement_catorder = [92, 14863, 97, 169, 170, 171, 172, 14802, 14804, 14803, 14801, 95, 161, 156, 165, 14806, 14921, 96, 201, 160, 14923, 14808, 14805, 14778, 14865, 14777, 14779, 155, 14862, 14861, 14864, 14866, 158, 162, 14780, 168, 14881, 187, 14901, 163, 14922, 159, 14941, 14961, 14962, 14981, 15003, 15002, 15001, 15041, 15042, 81]";
            // sum points
            $buff .= "\ng_achievement_points = [" . $sumPoints . "];\n";
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-achievements', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /**********/
    /* Titles */
    /**********/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]);
        $titlez = new TitleList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            foreach ([0, 1] as $g) {
                $buff = "var _ = g_titles;\n";
                foreach ($titlez->getListviewData() as $id => $data) {
                    $data['name'] = Util::localizedString($titlez->getEntry($id), $g ? 'female' : 'male');
                    unset($data['namefemale']);
                    $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
                }
                if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-titles-' . $g, $buff)) {
                    $success = false;
                }
            }
        }
        return $success;
    };
    /**********/
    /* Mounts */
    /**********/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -5]);
        $mountz = new SpellList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_spells;\n";
            foreach ($mountz->getListviewData(ITEMINFO_MODEL) as $id => $data) {
                $data['quality'] = $data['name'][0];
                $data['name'] = mb_substr($data['name'], 1);
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-mounts', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /**************/
    /* Companions */
    /**************/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -6]);
        $companionz = new SpellList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_spells;\n";
            foreach ($companionz->getListviewData(ITEMINFO_MODEL) as $id => $data) {
                $data['quality'] = $data['name'][0];
                $data['name'] = mb_substr($data['name'], 1);
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-companions', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /************/
    /* Factions */
    /************/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]);
        $factionz = new FactionList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_factions;\n";
            foreach ($factionz->getListviewData() as $id => $data) {
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            $buff .= "\ng_faction_order = [0, 469, 891, 1037, 1118, 67, 1052, 892, 936, 1117, 169, 980, 1097];\n";
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-factions', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /***********/
    /* Recipes */
    /***********/
    $scripts[] = function () {
        // special case: secondary skills are always requested, so put them in one single file (185, 129, 356); it also contains g_skill_order
        $skills = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, [185, 129, 356]];
        $success = true;
        $baseCnd = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], ['effect2Id', [118, 60], '!'], ['OR', ['typeCat', 9], ['typeCat', 11]]);
        foreach ($skills as $s) {
            $file = is_array($s) ? 'sec' : (string) $s;
            $cnd = array_merge($baseCnd, [['skillLine1', $s]]);
            $recipez = new SpellList($cnd);
            $created = '';
            foreach ($recipez->iterate() as $__) {
                foreach ($recipez->canCreateItem() as $idx) {
                    $id = $recipez->getField('effect' . $idx . 'CreateItemId');
                    $created .= "g_items.add(" . $id . ", {'icon':'" . $recipez->relItems->getEntry($id)['iconString'] . "'});\n";
                }
            }
            foreach (CLISetup::$localeIds as $l) {
                set_time_limit(10);
                User::useLocale($l);
                Lang::load(Util::$localeStrings[$l]);
                $buff = '';
                foreach ($recipez->getListviewData() as $id => $data) {
                    $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
                }
                if (!$buff) {
                    // this behaviour is intended, do not create an error
                    CLISetup::log('profiler - file datasets/' . User::$localeString . '/p-recipes-' . $file . ' has no content => skipping', CLISetup::LOG_WARN);
                    continue;
                }
                $buff = $created . "\nvar _ = g_spells;\n" . $buff;
                if (is_array($s)) {
                    $buff .= "\ng_skill_order = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, 185, 129, 356];\n";
                }
                if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-recipes-' . $file, $buff)) {
                    $success = false;
                }
            }
        }
        return $success;
    };
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    // run scripts
    foreach ($scripts as $func) {
        if (!$func()) {
            $success = false;
        }
    }
    return $success;
}
Exemple #3
0
 protected function generateContent()
 {
     /****************/
     /* Main Content */
     /****************/
     $this->headIcons = [$this->subject->getField('iconString')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true);
     if ($_ = $this->subject->getField('description', true)) {
         $this->extraText = $_;
     }
     /**************/
     /* Extra Tabs */
     /**************/
     if (in_array($this->cat, [-5, 9, 11])) {
         // tab: recipes [spells] (crafted)
         $condition = array(['OR', ['s.reagent1', 0, '>'], ['s.reagent2', 0, '>'], ['s.reagent3', 0, '>'], ['s.reagent4', 0, '>'], ['s.reagent5', 0, '>'], ['s.reagent6', 0, '>'], ['s.reagent7', 0, '>'], ['s.reagent8', 0, '>']], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], CFG_SQL_LIMIT_NONE);
         $recipes = new SpellList($condition);
         // also relevant for 3
         if (!$recipes->error) {
             $this->extendGlobalData($recipes->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $this->lvTabs[] = array('file' => 'spell', 'data' => $recipes->getListviewData(), 'params' => array('id' => 'recipes', 'name' => '$LANG.tab_recipes', 'visibleCols' => "\$['reagents', 'source']", 'note' => sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . $this->typeId . '&filter=cr=20;crs=1;crv=0')));
         }
         // tab: recipe Items [items] (Books)
         $filterRecipe = [null, 165, 197, 202, 164, 185, 171, 129, 333, 356, 755, 773, 186, 182];
         $conditions = array(['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE], CFG_SQL_LIMIT_NONE);
         $recipeItems = new ItemList($conditions);
         if (!$recipeItems->error) {
             $this->extendGlobalData($recipeItems->getJSGlobals(GLOBALINFO_SELF));
             if ($_ = array_search($this->typeId, $filterRecipe)) {
                 $_ = sprintf(Util::$filterResultString, "?items=9." . $_);
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $recipeItems->getListviewData(), 'params' => array('id' => 'recipe-items', 'name' => '$LANG.tab_recipeitems', 'note' => $_));
         }
         // tab: crafted items [items]
         $filterItem = [null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, null, null, 356, 182, 773];
         $created = [];
         foreach ($recipes->iterate() as $__) {
             if ($idx = $recipes->canCreateItem()) {
                 foreach ($idx as $i) {
                     $created[] = $recipes->getField('effect' . $i . 'CreateItemId');
                 }
             }
         }
         if ($created) {
             $created = new ItemList(array(['i.id', $created], CFG_SQL_LIMIT_NONE));
             if (!$created->error) {
                 $this->extendGlobalData($created->getJSGlobals(GLOBALINFO_SELF));
                 if ($_ = array_search($this->typeId, $filterItem)) {
                     $_ = sprintf(Util::$filterResultString, "?items&filter=cr=86;crs=" . $_ . ";crv=0");
                 }
                 $this->lvTabs[] = array('file' => 'item', 'data' => $created->getListviewData(), 'params' => array('id' => 'crafted-items', 'name' => '$LANG.tab_crafteditems', 'note' => $_));
             }
         }
         // tab: required by [item]
         $conditions = array(['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE, '!'], CFG_SQL_LIMIT_NONE);
         $reqBy = new ItemList($conditions);
         if (!$reqBy->error) {
             $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF));
             if ($_ = array_search($this->typeId, $filterItem)) {
                 $_ = sprintf(Util::$filterResultString, "?items&filter=cr=99:168;crs=" . $_ . ":2;crv=0:0");
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $reqBy->getListviewData(), 'params' => array('id' => 'required-by', 'name' => '$LANG.tab_requiredby', 'note' => $_));
         }
         // tab: required by [itemset]
         $conditions = array(['skillId', $this->typeId], CFG_SQL_LIMIT_NONE);
         $reqBy = new ItemsetList($conditions);
         if (!$reqBy->error) {
             $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF));
             $this->lvTabs[] = array('file' => 'itemset', 'data' => $reqBy->getListviewData(), 'params' => array('id' => 'required-by-set', 'name' => '$LANG.tab_requiredby'));
         }
     }
     // tab: spells [spells] (exclude first tab)
     $reqClass = 0x0;
     $reqRace = 0x0;
     $condition = array(['AND', ['s.reagent1', 0], ['s.reagent2', 0], ['s.reagent3', 0], ['s.reagent4', 0], ['s.reagent5', 0], ['s.reagent6', 0], ['s.reagent7', 0], ['s.reagent8', 0]], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], CFG_SQL_LIMIT_NONE);
     foreach (Util::$skillLineMask as $line1 => $sets) {
         foreach ($sets as $idx => $set) {
             if ($set[1] == $this->typeId) {
                 $condition[1][] = array('AND', ['s.skillLine1', $line1], ['s.skillLine2OrMask', 1 << $idx, '&']);
                 break 2;
             }
         }
     }
     $spells = new SpellList($condition);
     if (!$spells->error) {
         foreach ($spells->iterate() as $__) {
             $reqClass |= $spells->getField('reqClassMask');
             $reqRace |= $spells->getField('reqRaceMask');
         }
         $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF));
         $lv = array('file' => 'spell', 'data' => $spells->getListviewData(), 'params' => ['visibleCols' => "\$['source']"]);
         switch ($this->cat) {
             case -4:
                 $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=-4');
                 break;
             case 7:
                 if ($this->typeId != 769) {
                     // Internal
                     $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . (log($reqClass, 2) + 1) . '.' . $this->typeId);
                 }
                 // doesn't matter what spell; reqClass should be identical for all Class Spells
                 break;
             case 9:
             case 11:
                 $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . $this->typeId);
                 break;
         }
         $this->lvTabs[] = $lv;
     }
     // tab: trainers [npcs]
     if (in_array($this->cat, [-5, 6, 7, 8, 9, 11])) {
         $list = [];
         if (!empty(Util::$trainerTemplates[TYPE_SKILL][$this->typeId])) {
             $list = DB::World()->selectCol('SELECT DISTINCT entry FROM npc_trainer WHERE spell IN (?a) AND entry < 200000', Util::$trainerTemplates[TYPE_SKILL][$this->typeId]);
         } else {
             $mask = 0;
             foreach (Util::$skillLineMask[-3] as $idx => $pair) {
                 if ($pair[1] == $this->typeId) {
                     $mask |= 1 << $idx;
                 }
             }
             $spellIds = DB::Aowow()->selectCol('SELECT id FROM ?_spell WHERE typeCat IN (-11, 9) AND (skillLine1 = ?d OR (skillLine1 > 0 AND skillLine2OrMask = ?d) {OR (skillLine1 = -3 AND skillLine2OrMask = ?d)})', $this->typeId, $this->typeId, $mask ?: DBSIMPLE_SKIP);
             $list = $spellIds ? DB::World()->selectCol('
                 SELECT    IF(t1.entry > 200000, t2.entry, t1.entry)
                 FROM      npc_trainer t1
                 LEFT JOIN npc_trainer t2 ON t2.spell = -t1.entry
                 WHERE     t1.spell IN (?a)', $spellIds) : [];
         }
         if ($list) {
             $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
             $trainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&']));
             if (!$trainer->error) {
                 $this->extendGlobalData($trainer->getJSGlobals());
                 $this->lvTabs[] = array('file' => 'creature', 'data' => $trainer->getListviewData(), 'params' => array('id' => 'trainer', 'name' => '$LANG.tab_trainers'));
             }
         }
     }
     // tab: quests [quests]
     if (in_array($this->cat, [9, 11])) {
         $sort = 0;
         switch ($this->typeId) {
             case 182:
                 $sort = 24;
                 break;
                 // Herbalism
             // Herbalism
             case 356:
                 $sort = 101;
                 break;
                 // Fishing
             // Fishing
             case 164:
                 $sort = 121;
                 break;
                 // Blacksmithing
             // Blacksmithing
             case 171:
                 $sort = 181;
                 break;
                 // Alchemy
             // Alchemy
             case 165:
                 $sort = 182;
                 break;
                 // Leatherworking
             // Leatherworking
             case 202:
                 $sort = 201;
                 break;
                 // Engineering
             // Engineering
             case 197:
                 $sort = 264;
                 break;
                 // Tailoring
             // Tailoring
             case 185:
                 $sort = 304;
                 break;
                 // Cooking
             // Cooking
             case 129:
                 $sort = 324;
                 break;
                 // First Aid
             // First Aid
             case 773:
                 $sort = 371;
                 break;
                 // Inscription
             // Inscription
             case 755:
                 $sort = 373;
                 break;
                 // Jewelcrafting
         }
         if ($sort) {
             $quests = new QuestList(array(['zoneOrSort', -$sort], CFG_SQL_LIMIT_NONE));
             if (!$quests->error) {
                 $this->extendGlobalData($quests->getJSGlobals());
                 $this->lvTabs[] = array('file' => 'quest', 'data' => $quests->getListviewData(), 'params' => []);
             }
         }
     }
     // tab: related classes (apply classes from [spells])
     $class = [];
     for ($i = 0; $i < 11; $i++) {
         if ($reqClass & 1 << $i) {
             $class[] = $i + 1;
         }
     }
     if ($class) {
         $classes = new CharClassList(array(['id', $class]));
         if (!$classes->error) {
             $this->lvTabs[] = array('file' => 'class', 'data' => $classes->getListviewData(), 'params' => []);
         }
     }
     // tab: related races (apply races from [spells])
     $race = [];
     for ($i = 0; $i < 12; $i++) {
         if ($reqRace & 1 << $i) {
             $race[] = $i + 1;
         }
     }
     if ($race) {
         $races = new CharRaceList(array(['id', $race]));
         if (!$races->error) {
             $this->lvTabs[] = array('file' => 'race', 'data' => $races->getListviewData(), 'params' => []);
         }
     }
 }
Exemple #4
0
 protected function generateXML($asError = false)
 {
     $root = new SimpleXML('<aowow />');
     if ($asError) {
         $root->addChild('error', 'Item not found!');
     } else {
         // item root
         $xml = $root->addChild('item');
         $xml->addAttribute('id', $this->subject->id);
         // name
         $xml->addChild('name')->addCData($this->subject->getField('name', true));
         // itemlevel
         $xml->addChild('level', $this->subject->getField('itemLevel'));
         // quality
         $xml->addChild('quality', Lang::item('quality', $this->subject->getField('quality')))->addAttribute('id', $this->subject->getField('quality'));
         // class
         $x = Lang::item('cat', $this->subject->getField('class'));
         $xml->addChild('class')->addCData(is_array($x) ? $x[0] : $x)->addAttribute('id', $this->subject->getField('class'));
         // subclass
         $x = $this->subject->getField('class') == 2 ? Lang::spell('weaponSubClass') : Lang::item('cat', $this->subject->getField('class'), 1);
         $xml->addChild('subclass')->addCData(is_array($x) ? is_array($x[$this->subject->getField('subClass')]) ? $x[$this->subject->getField('subClass')][0] : $x[$this->subject->getField('subClass')] : null)->addAttribute('id', $this->subject->getField('subClass'));
         // icon + displayId
         $xml->addChild('icon', $this->subject->getField('iconString'))->addAttribute('displayId', $this->subject->getField('displayId'));
         // inventorySlot
         $xml->addChild('inventorySlot', Lang::item('inventoryType', $this->subject->getField('slot')))->addAttribute('id', $this->subject->getField('slot'));
         // tooltip
         $xml->addChild('htmlTooltip')->addCData($this->subject->renderTooltip());
         $this->subject->extendJsonStats();
         // json
         $fields = ["classs", "displayid", "dps", "id", "level", "name", "reqlevel", "slot", "slotbak", "source", "sourcemore", "speed", "subclass"];
         $json = '';
         foreach ($fields as $f) {
             if (isset($this->subject->json[$this->subject->id][$f])) {
                 $_ = $this->subject->json[$this->subject->id][$f];
                 if ($f == 'name') {
                     $_ = 7 - $this->subject->getField('quality') . $_;
                 }
                 $json .= ',"' . $f . '":' . $_;
             }
         }
         $xml->addChild('json')->addCData(substr($json, 1));
         // jsonEquip missing: avgbuyout, cooldown, source, sourcemore
         $json = '';
         if ($_ = $this->subject->getField('sellPrice')) {
             // sellprice
             $json .= ',"sellprice":' . $_;
         }
         if ($_ = $this->subject->getField('requiredLevel')) {
             // reqlevel
             $json .= ',"reqlevel":' . $_;
         }
         if ($_ = $this->subject->getField('requiredSkill')) {
             // reqskill
             $json .= ',"reqskill":' . $_;
         }
         if ($_ = $this->subject->getField('requiredSkillRank')) {
             // reqskillrank
             $json .= ',"reqskillrank":' . $_;
         }
         foreach ($this->subject->itemMods[$this->subject->id] as $mod => $qty) {
             $json .= ',"' . $mod . '":' . $qty;
         }
         foreach ($_ = $this->subject->json[$this->subject->id] as $name => $qty) {
             if (in_array($name, Util::$itemFilter)) {
                 $json .= ',"' . $name . '":' . $qty;
             }
         }
         $xml->addChild('jsonEquip')->addCData(substr($json, 1));
         // jsonUse
         if ($onUse = $this->subject->getOnUseStats()) {
             $j = '';
             foreach ($onUse as $idx => $qty) {
                 $j .= ',"' . Util::$itemMods[$idx] . '":' . $qty;
             }
             $xml->addChild('jsonUse')->addCData(substr($j, 1));
         }
         // reagents
         $cnd = array('OR', ['AND', ['effect1CreateItemId', $this->subject->id], ['OR', ['effect1Id', SpellList::$effects['itemCreate']], ['effect1AuraId', SpellList::$auras['itemCreate']]]], ['AND', ['effect2CreateItemId', $this->subject->id], ['OR', ['effect2Id', SpellList::$effects['itemCreate']], ['effect2AuraId', SpellList::$auras['itemCreate']]]], ['AND', ['effect3CreateItemId', $this->subject->id], ['OR', ['effect3Id', SpellList::$effects['itemCreate']], ['effect3AuraId', SpellList::$auras['itemCreate']]]]);
         $spellSource = new SpellList($cnd);
         if (!$spellSource->error) {
             $cbNode = $xml->addChild('createdBy');
             foreach ($spellSource->iterate() as $sId => $__) {
                 foreach ($spellSource->canCreateItem() as $idx) {
                     if ($spellSource->getField('effect' . $idx . 'CreateItemId') != $this->subject->id) {
                         continue;
                     }
                     $splNode = $cbNode->addChild('spell');
                     $splNode->addAttribute('id', $sId);
                     $splNode->addAttribute('name', $spellSource->getField('name', true));
                     $splNode->addAttribute('icon', $this->subject->getField('iconString'));
                     $splNode->addAttribute('minCount', $spellSource->getField('effect' . $idx . 'BasePoints') + 1);
                     $splNode->addAttribute('maxCount', $spellSource->getField('effect' . $idx . 'BasePoints') + $spellSource->getField('effect' . $idx . 'DieSides'));
                     foreach ($spellSource->getReagentsForCurrent() as $rId => $qty) {
                         if ($reagent = $spellSource->relItems->getEntry($rId)) {
                             $rgtNode = $splNode->addChild('reagent');
                             $rgtNode->addAttribute('id', $rId);
                             $rgtNode->addAttribute('name', Util::localizedString($reagent, 'name'));
                             $rgtNode->addAttribute('quality', $reagent['quality']);
                             $rgtNode->addAttribute('icon', $reagent['iconString']);
                             $rgtNode->addAttribute('count', $qty[1]);
                         }
                     }
                     break;
                 }
             }
         }
         // link
         $xml->addChild('link', HOST_URL . '?item=' . $this->subject->id);
     }
     return $root->asXML();
 }