Exemple #1
0
function glyphs()
{
    $success = true;
    $glyphList = DB::Aowow()->Select('SELECT i.id AS itemId,
                   i.*,
                   IF (g.typeFlags & 0x1, 2, 1) AS type,
                   i.subclass AS classs,
                   i.requiredLevel AS level,
                   s1.Id AS glyphSpell,
                   ic.iconString AS icon,
                   s1.skillLine1 AS skillId,
                   s2.Id AS glyphEffect,
                   s2.Id AS ARRAY_KEY
            FROM   ?_items i
            JOIN   ?_spell s1 ON s1.Id = i.spellid1
            JOIN   ?_glyphproperties g ON g.Id = s1.effect1MiscValue
            JOIN   ?_spell s2 ON s2.Id = g.spellId
            JOIN   ?_icons ic ON ic.Id = s1.iconIdAlt
            WHERE  i.classBak = 16');
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    $glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
    foreach (CLISetup::$localeIds as $lId) {
        set_time_limit(30);
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $glyphsOut = [];
        foreach ($glyphSpells->iterate() as $__) {
            $pop = $glyphList[$glyphSpells->id];
            if (!$pop['glyphEffect']) {
                continue;
            }
            if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) {
                continue;
            }
            $glyphsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'description' => $glyphSpells->parseText()[0], 'icon' => $pop['icon'], 'type' => $pop['type'], 'classs' => $pop['classs'], 'skill' => $pop['skillId'], 'level' => $pop['level']);
        }
        $toFile = "var g_glyphs = " . Util::toJSON($glyphsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/glyphs';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $success;
}
Exemple #2
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     $_mask = 1 << $this->typeId - 1;
     $tcClassId = [null, 8, 3, 1, 5, 4, 9, 6, 2, 7, null, 0];
     // see TalentCalc.js
     /***********/
     /* Infobox */
     /***********/
     // hero class
     if ($this->subject->getField('flags') & 0x40) {
         $infobox[] = '[tooltip=tooltip_heroclass]' . Lang::game('heroClass') . '[/tooltip]';
     }
     // resource
     if ($this->typeId == 11) {
         // special Druid case
         $infobox[] = Lang::game('resources') . Lang::main('colon') . '[tooltip name=powertype1]' . Lang::game('st', 0) . ', ' . Lang::game('st', 31) . ', ' . Lang::game('st', 2) . '[/tooltip][span class=tip tooltip=powertype1]' . Util::ucFirst(Lang::spell('powerTypes', 0)) . '[/span], ' . '[tooltip name=powertype2]' . Lang::game('st', 5) . ', ' . Lang::game('st', 8) . '[/tooltip][span class=tip tooltip=powertype2]' . Util::ucFirst(Lang::spell('powerTypes', 1)) . '[/span], ' . '[tooltip name=powertype8]' . Lang::game('st', 1) . '[/tooltip][span class=tip tooltip=powertype8]' . Util::ucFirst(Lang::spell('powerTypes', 3)) . '[/span]';
     } else {
         if ($this->typeId == 6) {
             // special DK case
             $infobox[] = Lang::game('resources') . Lang::main('colon') . '[span]' . Util::ucFirst(Lang::spell('powerTypes', 5)) . ', ' . Util::ucFirst(Lang::spell('powerTypes', $this->subject->getField('powerType'))) . '[/span]';
         } else {
             // regular case
             $infobox[] = Lang::game('resource') . Lang::main('colon') . '[span]' . Util::ucFirst(Lang::spell('powerTypes', $this->subject->getField('powerType'))) . '[/span]';
         }
     }
     // roles
     $roles = [];
     for ($i = 0; $i < 4; $i++) {
         if ($this->subject->getField('roles') & 1 << $i) {
             $roles[] = (count($roles) == 2 ? "\n" : '') . Lang::game('_roles', $i);
         }
     }
     if ($roles) {
         $infobox[] = (count($roles) > 1 ? Lang::game('roles') : Lang::game('role')) . Lang::main('colon') . implode(', ', $roles);
     }
     // specs
     $specList = [];
     $skills = new SkillList(array(['id', $this->subject->getField('skills')]));
     foreach ($skills->iterate() as $k => $__) {
         $specList[$k] = '[icon name=' . $skills->getField('iconString') . '][url=?spells=7.' . $this->typeId . '.' . $k . ']' . $skills->getField('name', true) . '[/url][/icon]';
     }
     if ($specList) {
         $infobox[] = Lang::game('specs') . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $specList) . '[/li][/ul]';
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     $this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
     $this->headIcons = ['class_' . strtolower($this->subject->getField('fileString'))];
     $this->redButtons = array(BUTTON_LINKS => ['color' => '', 'linkId' => ''], BUTTON_WOWHEAD => true, BUTTON_TALENT => ['href' => '?talent#' . Util::$tcEncoding[$tcClassId[$this->typeId] * 3], 'pet' => false], BUTTON_FORUM => false);
     /**************/
     /* Extra Tabs */
     /**************/
     // Tab: Spells (grouped)
     //     '$LANG.tab_armorproficiencies',
     //     '$LANG.tab_weaponskills',
     //     '$LANG.tab_glyphs',
     //     '$LANG.tab_abilities',
     //     '$LANG.tab_talents',
     $conditions = array(['s.typeCat', [-13, -11, -2, 7]], [['s.cuFlags', SPELL_CU_TRIGGERED | CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['OR', ['s.reqClassMask', $_mask, '&'], ['s.skillLine1', $this->subject->getField('skills')], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->subject->getField('skills')]]], ['OR', ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], ['s.rankNo', 0]]);
     $genSpells = new SpellList($conditions);
     if (!$genSpells->error) {
         $this->extendGlobalData($genSpells->getJSGlobals(GLOBALINFO_SELF));
         $this->lvTabs[] = array('file' => 'spell', 'data' => $genSpells->getListviewData(), 'params' => array('id' => 'spells', 'name' => '$LANG.tab_spells', 'visibleCols' => "\$['level', 'schools', 'type', 'classes']", 'hiddenCols' => "\$['reagents', 'skill']", 'sort' => "\$['-level', 'type', 'name']", 'computeDataFunc' => '$Listview.funcBox.initSpellFilter', 'onAfterCreate' => '$Listview.funcBox.addSpellIndicator'));
     }
     // Tab: Items (grouped)
     $conditions = array(['requiredClass', 0, '>'], ['requiredClass', $_mask, '&'], [['requiredClass', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'], ['itemset', 0], 0);
     $items = new ItemList($conditions);
     if (!$items->error) {
         $this->extendGlobalData($items->getJSGlobals());
         if (!$items->hasDiffFields(['requiredRace'])) {
             $hidden = "\$['side']";
         }
         $this->lvTabs[] = array('file' => 'item', 'data' => $items->getListviewData(), 'params' => array('id' => 'items', 'name' => '$LANG.tab_items', 'visibleCols' => "\$['dps', 'armor', 'slot']", 'hiddenCols' => isset($hidden) ? $hidden : null, 'computeDataFunc' => '$Listview.funcBox.initSubclassFilter', 'onAfterCreate' => '$Listview.funcBox.addSubclassIndicator', 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=152;crs=' . $this->typeId . ';crv=0'), '_truncated' => 1));
     }
     // Tab: Quests
     $conditions = array(['reqClassMask', $_mask, '&'], [['reqClassMask', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!']);
     $quests = new QuestList($conditions);
     if (!$quests->error) {
         $this->extendGlobalData($quests->getJSGlobals());
         $this->lvTabs[] = array('file' => 'quest', 'data' => $quests->getListviewData(), 'params' => ['sort' => "\$['reqlevel', 'name']"]);
     }
     // Tab: Itemsets
     $sets = new ItemsetList(array(['classMask', $_mask, '&']));
     if (!$sets->error) {
         $this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF));
         $this->lvTabs[] = array('file' => 'itemset', 'data' => $sets->getListviewData(), 'params' => array('note' => sprintf(Util::$filterResultString, '?itemsets&filter=cl=' . $this->typeId), 'hiddenCols' => "\$['classes']", 'sort' => "\$['-level', 'name']"));
     }
     // Tab: Trainer
     $conditions = array(['npcflag', 0x30, '&'], ['trainerType', 0], ['trainerClass', $this->typeId]);
     $trainer = new CreatureList($conditions);
     if (!$trainer->error) {
         $this->lvTabs[] = array('file' => 'creature', 'data' => $trainer->getListviewData(), 'params' => array('id' => 'trainers', 'name' => '$LANG.tab_trainers'));
     }
     // Tab: Races
     $races = new CharRaceList(array(['classMask', $_mask, '&']));
     if (!$races->error) {
         $this->lvTabs[] = array('file' => 'race', 'data' => $races->getListviewData(), 'params' => []);
     }
 }
Exemple #3
0
 public function getBonuses()
 {
     $spells = [];
     for ($i = 1; $i < 9; $i++) {
         $spl = $this->getField('spell' . $i);
         $qty = $this->getField('bonus' . $i);
         // cant use spell as index, would change order
         if ($spl && $qty) {
             $spells[] = ['id' => $spl, 'bonus' => $qty];
         }
     }
     // sort by required pieces ASC
     usort($spells, function ($a, $b) {
         if ($a['bonus'] == $b['bonus']) {
             return 0;
         }
         return $a['bonus'] > $b['bonus'] ? 1 : -1;
     });
     $setSpells = new SpellList(array(['s.id', array_column($spells, 'id')]));
     foreach ($setSpells->iterate() as $spellId => $__) {
         foreach ($spells as &$s) {
             if ($spellId != $s['id']) {
                 continue;
             }
             $s['desc'] = $setSpells->parseText('description', $this->getField('reqLevel') ?: MAX_LEVEL)[0];
         }
     }
     return $spells;
 }
Exemple #4
0
 public function writeStatsTable()
 {
     $enchantments = [];
     // buffer Ids for lookup id => src; src>0: socketBonus; src<0: gemEnchant
     foreach ($this->iterate() as $__) {
         $this->itemMods[$this->id] = [];
         // also occurs as seperate field (gets summed in calculation but not in tooltip)
         if ($_ = $this->getField('block')) {
             $this->itemMods[$this->id][ITEM_MOD_BLOCK_VALUE] = $_;
         }
         // convert itemMods to stats
         for ($h = 1; $h <= 10; $h++) {
             $mod = $this->curTpl['statType' . $h];
             $val = $this->curTpl['statValue' . $h];
             if (!$mod || !$val) {
                 continue;
             }
             Util::arraySumByKey($this->itemMods[$this->id], [$mod => $val]);
         }
         // convert spells to stats
         $equipSpells = [];
         for ($h = 1; $h <= 5; $h++) {
             if ($this->curTpl['spellId' . $h] <= 0) {
                 continue;
             }
             // armor & weapons only onEquip && consumables only onUse
             if (!(in_array($this->curTpl['class'], [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) && $this->curTpl['spellTrigger' . $h] == 1) && !($this->curTpl['class'] == ITEM_CLASS_CONSUMABLE && $this->curTpl['spellTrigger' . $h] == 0)) {
                 continue;
             }
             $equipSpells[] = $this->curTpl['spellId' . $h];
         }
         if ($equipSpells) {
             $eqpSplList = new SpellList(array(['s.id', $equipSpells]));
             foreach ($eqpSplList->getStatGain() as $stats) {
                 Util::arraySumByKey($this->itemMods[$this->id], $stats);
             }
         }
         // prepare: convert enchantments to stats
         if (!empty($this->json[$this->id]['socketbonus'])) {
             $enchantments[$this->json[$this->id]['socketbonus']][] = $this->id;
         }
         if ($geId = $this->curTpl['gemEnchantmentId']) {
             $enchantments[$geId][] = -$this->id;
         }
     }
     // execute: convert enchantments to stats
     // and merge enchantments back
     foreach ($enchantments as $eId => $items) {
         if (empty($this->enchParsed[$eId])) {
             continue;
         }
         foreach ($items as $item) {
             if ($item > 0) {
                 // apply socketBonus
                 $this->json[$item]['socketbonusstat'] = $this->enchParsed[$eId];
             } else {
                 /* if ($item < 0) */
                 // apply gemEnchantment
                 Util::arraySumByKey($this->json[-$item], $this->enchParsed[$eId]);
             }
         }
     }
     // collect data and write to DB
     foreach ($this->iterate() as $__) {
         $updateFields = ['type' => TYPE_ITEM, 'typeId' => $this->id];
         foreach (@$this->json[$this->id] as $k => $v) {
             if (!in_array($k, $this->statCols) || !$v || $k == 'id') {
                 continue;
             }
             $updateFields[$k] = number_format($v, 2, '.', '');
         }
         if (isset($this->itemMods[$this->id])) {
             foreach ($this->itemMods[$this->id] as $k => $v) {
                 if (!$v) {
                     continue;
                 }
                 if ($str = Util::$itemMods[$k]) {
                     $updateFields[$str] = number_format($v, 2, '.', '');
                 }
             }
         }
         DB::Aowow()->query('REPLACE INTO ?_item_stats (?#) VALUES (?a)', array_keys($updateFields), array_values($updateFields));
     }
 }
Exemple #5
0
 private function createEffects(&$infobox, &$redButtons)
 {
     // proc data .. maybe use more information..?
     $procData = DB::World()->selectRow('SELECT IF(ppmRate > 0, -ppmRate, customChance) AS chance, cooldown FROM spell_proc_event WHERE entry = ?d', $this->typeId);
     if (!isset($procData['cooldown'])) {
         $procData['cooldown'] = 0;
     }
     $effects = [];
     $spellIdx = array_unique(array_merge($this->subject->canTriggerSpell(), $this->subject->canTeachSpell()));
     $itemIdx = $this->subject->canCreateItem();
     // Iterate through all effects:
     for ($i = 1; $i < 4; $i++) {
         if ($this->subject->getField('effect' . $i . 'Id') <= 0) {
             continue;
         }
         $effId = (int) $this->subject->getField('effect' . $i . 'Id');
         $effMV = (int) $this->subject->getField('effect' . $i . 'MiscValue');
         $effBP = (int) $this->subject->getField('effect' . $i . 'BasePoints');
         $effDS = (int) $this->subject->getField('effect' . $i . 'DieSides');
         $effRPPL = $this->subject->getField('effect' . $i . 'RealPointsPerLevel');
         $effAura = (int) $this->subject->getField('effect' . $i . 'AuraId');
         $foo =& $effects[];
         // Icons:
         // .. from item
         if (in_array($i, $itemIdx)) {
             $_ = $this->subject->getField('effect' . $i . 'CreateItemId');
             foreach ($this->subject->relItems->iterate() as $itemId => $__) {
                 if ($itemId != $_) {
                     continue;
                 }
                 $foo['icon'] = array('id' => $this->subject->relItems->id, 'name' => $this->subject->relItems->getField('name', true), 'quality' => $this->subject->relItems->getField('quality'), 'count' => $effDS + $effBP, 'icon' => $this->subject->relItems->getField('iconString'));
                 break;
             }
             if ($effDS > 1) {
                 $foo['icon']['count'] = "'" . ($effBP + 1) . '-' . $foo['icon']['count'] . "'";
             }
         } else {
             if (in_array($i, $spellIdx) || $effId == 133) {
                 $_ = $this->subject->getField('effect' . $i . 'TriggerSpell');
                 if (!$_) {
                     $_ = $this->subject->getField('effect' . $i . 'MiscValue');
                 }
                 $trig = new SpellList(array(['s.id', (int) $_]));
                 $foo['icon'] = array('id' => $_, 'name' => $trig->error ? Util::ucFirst(Lang::game('spell')) . ' #' . $_ : $trig->getField('name', true), 'count' => 0);
                 $this->extendGlobalData($trig->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             }
         }
         // Effect Name
         $foo['name'] = (User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'EffectId: ' . $effId, Util::$spellEffectStrings[$effId]) : Util::$spellEffectStrings[$effId]) . Lang::main('colon');
         if ($this->subject->getField('effect' . $i . 'RadiusMax') > 0) {
             $foo['radius'] = $this->subject->getField('effect' . $i . 'RadiusMax');
         }
         if (!in_array($i, $itemIdx) && !in_array($i, $spellIdx) && !in_array($effAura, [225, 227])) {
             $foo['value'] = ($effDS && $effDS != 1 ? $effBP + 1 . Lang::game('valueDelim') : null) . ($effBP + $effDS);
         }
         if ($effRPPL != 0) {
             $foo['value'] = (isset($foo['value']) ? $foo['value'] : '0') . sprintf(Lang::spell('costPerLevel'), $effRPPL);
         }
         if ($this->subject->getField('effect' . $i . 'Periode') > 0) {
             $foo['interval'] = Util::formatTime($this->subject->getField('effect' . $i . 'Periode'));
         }
         if ($_ = $this->subject->getField('effect' . $i . 'Mechanic')) {
             $foo['mechanic'] = Lang::game('me', $_);
         }
         if (!empty($procData['chance'])) {
             $foo['procData'] = array($procData['chance'], $procData['cooldown'] ? Util::formatTime($procData['cooldown'] * 1000, true) : null);
         } else {
             if (in_array($i, $this->subject->canTriggerSpell()) && $this->subject->getField('procChance')) {
                 $foo['procData'] = array($this->subject->getField('procChance'), $procData['cooldown'] ? Util::formatTime($procData['cooldown'] * 1000, true) : null);
             }
         }
         // parse masks and indizes
         switch ($effId) {
             case 8:
                 // Power Drain
             // Power Drain
             case 30:
                 // Energize
             // Energize
             case 137:
                 // Energize Pct
                 $_ = Lang::spell('powerTypes', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 if ($effMV == POWER_RAGE || $effMV == POWER_RUNIC_POWER) {
                     $foo['value'] = ($effDS && $effDS != 1 ? ($effBP + 1) / 10 . Lang::game('valueDelim') : null) . ($effBP + $effDS) / 10;
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 16:
                 // QuestComplete
                 if ($_ = QuestList::getName($effMV)) {
                     $foo['name'] .= '(<a href="?quest=' . $effMV . '">' . $_ . '</a>)';
                 } else {
                     $foo['name'] .= Util::ucFirst(Lang::game('quest')) . ' #' . $effMV;
                 }
                 break;
             case 28:
                 // Summon
             // Summon
             case 90:
                 // Kill Credit
             // Kill Credit
             case 134:
                 // Kill Credit2
                 $_ = Lang::game('npc') . ' #' . $effMV;
                 if ($summon = $this->subject->getModelInfo($this->typeId, $i)) {
                     $_ = $summon['typeId'] ? ' (<a href="?npc=' . $summon['typeId'] . '">' . $summon['displayName'] . '</a>)' : ' (#0)';
                     $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $summon['displayId']];
                 }
                 $foo['name'] .= $_;
                 break;
             case 33:
                 // Open Lock
                 $_ = $effMV ? Lang::spell('lockType', $effMV) : $effMV;
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 53:
                 // Enchant Item Perm
             // Enchant Item Perm
             case 54:
                 // Enchant Item Temp
             // Enchant Item Temp
             case 92:
                 // Enchant Held Item
             // Enchant Held Item
             case 156:
                 // Enchant Item Prismatic
                 if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $effMV)) {
                     $foo['name'] .= ' (<a href="?enchantment=' . $effMV . '" class="q2">' . Util::localizedString($_, 'name') . '</a>)';
                 } else {
                     $foo['name'] .= ' #' . $effMV;
                 }
                 break;
             case 38:
                 // Dispel [miscValue => Types]
             // Dispel [miscValue => Types]
             case 126:
                 // Steal Aura
                 $_ = Lang::game('dt', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 39:
                 // Learn Language
                 $_ = Lang::game('languages', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 50:
                 // Trans Door
             // Trans Door
             case 76:
                 // Summon Object (Wild)
                 // case 86:                                 // Activate Object
             // Summon Object (Wild)
             // case 86:                                 // Activate Object
             case 104:
                 // Summon Object (slot 1)
             // Summon Object (slot 1)
             case 105:
                 // Summon Object (slot 2)
             // Summon Object (slot 2)
             case 106:
                 // Summon Object (slot 3)
             // Summon Object (slot 3)
             case 107:
                 // Summon Object (slot 4)
                 $_ = Util::ucFirst(Lang::game('object')) . ' #' . $effMV;
                 if ($summon = $this->subject->getModelInfo($this->typeId, $i)) {
                     $_ = $summon['typeId'] ? ' (<a href="?object=' . $summon['typeId'] . '">' . $summon['displayName'] . '</a>)' : ' (#0)';
                     $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_OBJECT, 'displayId' => $summon['displayId']];
                 }
                 $foo['name'] .= $_;
                 break;
             case 74:
                 // Apply Glyph
                 if ($_ = DB::Aowow()->selectCell('SELECT spellId FROM ?_glyphproperties WHERE id = ?d', $effMV)) {
                     if ($n = SpellList::getName($_)) {
                         $foo['name'] .= '(<a href="?spell=' . $_ . '">' . $n . '</a>)';
                     } else {
                         $foo['name'] .= Util::ucFirst(Lang::game('spell')) . ' #' . $effMV;
                     }
                 } else {
                     $foo['name'] .= ' #' . $effMV;
                 }
                 break;
             case 95:
                 // Skinning
                 switch ($effMV) {
                     case 0:
                         $_ = Lang::game('ct', 1) . ', ' . Lang::game('ct', 2);
                         break;
                         // Beast, Dragonkin
                     // Beast, Dragonkin
                     case 1:
                     case 2:
                         $_ = Lang::game('ct', 4);
                         break;
                         // Elemental (nature based, earth based)
                     // Elemental (nature based, earth based)
                     case 3:
                         $_ = Lang::game('ct', 9);
                         break;
                         // Mechanic
                     // Mechanic
                     default:
                         $_ = '';
                 }
                 if (User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     $_ = $effMV;
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 108:
                 // Dispel Mechanic
                 $_ = Lang::game('me', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 118:
                 // Require Skill
                 if ($_ = SkillList::getName($effMV)) {
                     $foo['name'] .= '(<a href="?skill=' . $effMV . '">' . $_ . '</a>)';
                 } else {
                     $foo['name'] .= Util::ucFirst(Lang::game('skill')) . ' #' . $effMV;
                 }
                 break;
             case 146:
                 // Activate Rune
                 $_ = Lang::spell('powerRunes', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 123:
                 // Send Taxi - effMV is taxiPathId. We only use paths for flightmasters for now, so spell-triggered paths are not in the table
             // Send Taxi - effMV is taxiPathId. We only use paths for flightmasters for now, so spell-triggered paths are not in the table
             default:
                 if (($effMV || $effId == 97) && $effId != 155) {
                     $foo['name'] .= ' (' . $effMV . ')';
                 }
                 // Aura
             // Aura
             case 6:
                 // Simple
             // Simple
             case 27:
                 // AA Persistent
             // AA Persistent
             case 35:
                 // AA Party
             // AA Party
             case 65:
                 // AA Raid
             // AA Raid
             case 119:
                 // AA Pet
             // AA Pet
             case 128:
                 // AA Friend
             // AA Friend
             case 129:
                 // AA Enemy
             // AA Enemy
             case 143:
                 if ($effAura > 0 && isset(Util::$spellAuraStrings[$effAura])) {
                     $foo['name'] .= User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'AuraId: ' . $effAura, Util::$spellAuraStrings[$effAura]) : Util::$spellAuraStrings[$effAura];
                     $bar = $effMV;
                     switch ($effAura) {
                         case 17:
                             // Mod Stealth Detection
                             if ($_ = Lang::spell('stealthType', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 19:
                             // Mod Invisibility Detection
                             if ($_ = Lang::spell('invisibilityType', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 24:
                             // Periodic Energize
                         // Periodic Energize
                         case 21:
                             // Obsolete Mod Power
                         // Obsolete Mod Power
                         case 35:
                             // Mod Increase Power
                         // Mod Increase Power
                         case 85:
                             // Mod Power Regeneration
                         // Mod Power Regeneration
                         case 110:
                             // Mod Power Regeneration Pct
                             if ($_ = Lang::spell('powerTypes', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 29:
                             // Mod Stat
                         // Mod Stat
                         case 80:
                             // Mod Stat %
                         // Mod Stat %
                         case 137:
                             // Mod Total Stat %
                         // Mod Total Stat %
                         case 175:
                             // Mod Spell Healing Of Stat Percent
                         // Mod Spell Healing Of Stat Percent
                         case 212:
                             // Mod Ranged Attack Power Of Stat Percent
                         // Mod Ranged Attack Power Of Stat Percent
                         case 219:
                             // Mod Mana Regeneration from Stat
                         // Mod Mana Regeneration from Stat
                         case 268:
                             // Mod Attack Power Of Stat Percent
                             $mask = $effMV == -1 ? 0x1f : 1 << $effMV;
                             $_ = [];
                             for ($j = 0; $j < 5; $j++) {
                                 if ($mask & 1 << $j) {
                                     $_[] = Lang::game('stats', $j);
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                             }
                             $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             break;
                         case 36:
                             // Shapeshift
                             if ($st = $this->subject->getModelInfo($this->typeId, $i)) {
                                 $redButtons[BUTTON_VIEW3D] = array('type' => TYPE_NPC, 'displayId' => $st['displayId']);
                                 if ($st['creatureType'] > 0) {
                                     $infobox[] = Lang::game('type') . Lang::main('colon') . Lang::game('ct', $st['creatureType']);
                                 }
                                 if ($_ = $st['displayName']) {
                                     $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                                 }
                             }
                             break;
                         case 37:
                             // Effect immunity
                             if (isset(Util::$spellEffectStrings[$effMV])) {
                                 $_ = Util::$spellEffectStrings[$effMV];
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 38:
                             // Aura immunity
                             if (isset(Util::$spellAuraStrings[$effMV])) {
                                 $_ = Util::$spellAuraStrings[$effMV];
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 41:
                             // Dispel Immunity
                         // Dispel Immunity
                         case 178:
                             // Mod Debuff Resistance
                         // Mod Debuff Resistance
                         case 245:
                             // Mod Aura Duration By Dispel
                             if ($_ = Lang::game('dt', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 44:
                             // Track Creature
                             if ($_ = Lang::game('ct', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 45:
                             // Track Resource
                             if ($_ = Lang::spell('lockType', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 75:
                             // Language
                             if ($_ = Lang::game('languages', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 77:
                             // Mechanic Immunity
                         // Mechanic Immunity
                         case 117:
                             // Mod Mechanic Resistance
                         // Mod Mechanic Resistance
                         case 232:
                             // Mod Mechanic Duration
                         // Mod Mechanic Duration
                         case 234:
                             // Mod Mechanic Duration (no stack)
                         // Mod Mechanic Duration (no stack)
                         case 255:
                             // Mod Mechanic Damage Taken Pct
                         // Mod Mechanic Damage Taken Pct
                         case 276:
                             // Mod Mechanic Damage Done Percent
                             if ($_ = Lang::game('me', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 147:
                             // Mechanic Immunity Mask
                             $_ = [];
                             foreach (Lang::game('me') as $k => $str) {
                                 if ($effMV & 1 << $k - 1) {
                                     $_[] = $str;
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 10:
                             // Mod Threat
                         // Mod Threat
                         case 13:
                             // Mod Damage Done
                         // Mod Damage Done
                         case 14:
                             // Mod Damage Taken
                         // Mod Damage Taken
                         case 22:
                             // Mod Resistance
                         // Mod Resistance
                         case 39:
                             // School Immunity
                         // School Immunity
                         case 40:
                             // Damage Immunity
                         // Damage Immunity
                         case 50:
                             // Mod Critical Healing Amount
                         // Mod Critical Healing Amount
                         case 57:
                             // Mod Spell Crit Chance
                         // Mod Spell Crit Chance
                         case 69:
                             // School Absorb
                         // School Absorb
                         case 71:
                             // Mod Spell Crit Chance School
                         // Mod Spell Crit Chance School
                         case 72:
                             // Mod Power Cost School Percent
                         // Mod Power Cost School Percent
                         case 73:
                             // Mod Power Cost School Flat
                         // Mod Power Cost School Flat
                         case 74:
                             // Reflect Spell School
                         // Reflect Spell School
                         case 79:
                             // Mod Damage Done Pct
                         // Mod Damage Done Pct
                         case 81:
                             // Split Damage Pct
                         // Split Damage Pct
                         case 83:
                             // Mod Base Resistance
                         // Mod Base Resistance
                         case 87:
                             // Mod Damage Taken Pct
                         // Mod Damage Taken Pct
                         case 97:
                             // Mana Shield
                         // Mana Shield
                         case 101:
                             // Mod Resistance Pct
                         // Mod Resistance Pct
                         case 115:
                             // Mod Healing Taken
                         // Mod Healing Taken
                         case 118:
                             // Mod Healing Taken Pct
                         // Mod Healing Taken Pct
                         case 123:
                             // Mod Target Resistance
                         // Mod Target Resistance
                         case 135:
                             // Mod Healing Done
                         // Mod Healing Done
                         case 136:
                             // Mod Healing Done Pct
                         // Mod Healing Done Pct
                         case 142:
                             // Mod Base Resistance Pct
                         // Mod Base Resistance Pct
                         case 143:
                             // Mod Resistance Exclusive
                         // Mod Resistance Exclusive
                         case 149:
                             // Reduce Pushback
                         // Reduce Pushback
                         case 163:
                             // Mod Crit Damage Bonus
                         // Mod Crit Damage Bonus
                         case 174:
                             // Mod Spell Damage Of Stat Percent
                         // Mod Spell Damage Of Stat Percent
                         case 182:
                             // Mod Resistance Of Stat Percent
                         // Mod Resistance Of Stat Percent
                         case 186:
                             // Mod Attacker Spell Hit Chance
                         // Mod Attacker Spell Hit Chance
                         case 194:
                             // Mod Target Absorb School
                         // Mod Target Absorb School
                         case 195:
                             // Mod Target Ability Absorb School
                         // Mod Target Ability Absorb School
                         case 199:
                             // Mod Increases Spell Percent to Hit
                         // Mod Increases Spell Percent to Hit
                         case 229:
                             // Mod AoE Damage Avoidance
                         // Mod AoE Damage Avoidance
                         case 271:
                             // Mod Damage Percent Taken Form Caster
                         // Mod Damage Percent Taken Form Caster
                         case 310:
                             // Mod Creature AoE Damage Avoidance
                             if ($_ = Lang::getMagicSchools($effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 30:
                             // Mod Skill
                         // Mod Skill
                         case 98:
                             // Mod Skill Value
                             if ($_ = SkillList::getName($effMV)) {
                                 $bar = ' (<a href="?skill=' . $effMV . '">' . SkillList::getName($effMV) . '</a>)';
                             } else {
                                 $bar = Lang::main('colon') . Util::ucFirst(Lang::game('skill')) . ' #' . $effMV;
                             }
                             break;
                         case 107:
                             // Flat Modifier
                         // Flat Modifier
                         case 108:
                             // Pct Modifier
                             if ($_ = Lang::spell('spellModOp', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 189:
                             // Mod Rating
                         // Mod Rating
                         case 220:
                             // Combat Rating From Stat
                             $_ = [];
                             foreach (Lang::spell('combatRating') as $k => $str) {
                                 if (1 << $k & $effMV) {
                                     $_[] = $str;
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 168:
                             // Mod Damage Done Versus
                         // Mod Damage Done Versus
                         case 59:
                             // Mod Damage Done Versus Creature
                         // Mod Damage Done Versus Creature
                         case 102:
                             // Mod Melee Attack Power Versus
                         // Mod Melee Attack Power Versus
                         case 131:
                             // Mod Ranged Attack Power Versus
                         // Mod Ranged Attack Power Versus
                         case 180:
                             // Mod Spell Damage Versus
                             $_ = [];
                             foreach (Lang::game('ct') as $k => $str) {
                                 if ($effMV & 1 << $k - 1) {
                                     $_[] = $str;
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 249:
                             // Convert Rune
                             $x = $this->subject->getField('effect' . $i . 'MiscValueB');
                             if ($_ = Lang::spell('powerRunes', $x)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $x, $_) : $_;
                             }
                             break;
                         case 78:
                             // Mounted
                         // Mounted
                         case 56:
                             // Transform
                             if ($transform = $this->subject->getModelInfo($this->typeId, $i)) {
                                 $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $transform['displayId']];
                                 $bar = $transform['typeId'] ? ' (<a href="?npc=' . $transform['typeId'] . '">' . $transform['displayName'] . '</a>)' : ' (#0)';
                             } else {
                                 $bar = Lang::main('colon') . Lang::game('npc') . ' #' . $effMV;
                             }
                             break;
                         case 139:
                             // Force Reaction
                             $foo['value'] = sprintf(Util::$dfnString, $foo['value'], Lang::game('rep', $foo['value']));
                             // DO NOT BREAK
                         // DO NOT BREAK
                         case 190:
                             // Mod Faction Reputation Gain
                             $bar = ' (<a href="?faction=' . $effMV . '">' . FactionList::getName($effMV) . '</a>)';
                             break;
                             // also breaks for 139
                     }
                     $foo['name'] .= strstr($bar, 'href') || strstr($bar, '#') ? $bar : ($bar ? ' (' . $bar . ')' : null);
                     if (in_array($effAura, [174, 220, 182])) {
                         $foo['name'] .= ' [' . sprintf(Util::$dfnString, Lang::game('stats', $this->subject->getField('effect' . $i . 'MiscValueB')), $this->subject->getField('effect' . $i . 'MiscValueB')) . ']';
                     } else {
                         if ($this->subject->getField('effect' . $i . 'MiscValueB') > 0) {
                             $foo['name'] .= ' [' . $this->subject->getField('effect' . $i . 'MiscValueB') . ']';
                         }
                     }
                 } else {
                     if ($effAura > 0) {
                         $foo['name'] .= Lang::main('colon') . 'Unknown Aura (' . $effAura . ')';
                     }
                 }
                 break;
         }
         // cases where we dont want 'Value' to be displayed
         if (in_array($effAura, [11, 12, 36, 77]) || in_array($effId, []) || empty($foo['value'])) {
             unset($foo['value']);
         }
     }
     unset($foo);
     // clear reference
     return $effects;
 }
Exemple #6
0
 private function createRewards()
 {
     $rewards = [];
     // moneyReward / maxLevelCompensation
     $comp = $this->subject->getField('rewardMoneyMaxLevel');
     $questMoney = $this->subject->getField('rewardOrReqMoney');
     if ($questMoney > 0) {
         $rewards['money'] = Util::formatMoney($questMoney);
         if ($comp > 0) {
             $rewards['money'] .= '&nbsp;' . sprintf(Lang::quest('expConvert'), Util::formatMoney($questMoney + $comp), MAX_LEVEL);
         }
     } else {
         if ($questMoney <= 0 && $questMoney + $comp > 0) {
             $rewards['money'] = sprintf(Lang::quest('expConvert2'), Util::formatMoney($questMoney + $comp), MAX_LEVEL);
         }
     }
     // itemChoices
     if (!empty($this->subject->choices[$this->typeId][TYPE_ITEM])) {
         $c = $this->subject->choices[$this->typeId][TYPE_ITEM];
         $choiceItems = new ItemList(array(['id', array_keys($c)]));
         if (!$choiceItems->error) {
             $this->extendGlobalData($choiceItems->getJSGlobals());
             foreach ($choiceItems->Iterate() as $id => $__) {
                 $rewards['choice'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $choiceItems->getField('name', true), 'quality' => $choiceItems->getField('quality'), 'qty' => $c[$id], 'globalStr' => 'g_items');
             }
         }
     }
     // itemRewards
     if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM])) {
         $ri = $this->subject->rewards[$this->typeId][TYPE_ITEM];
         $rewItems = new ItemList(array(['id', array_keys($ri)]));
         if (!$rewItems->error) {
             $this->extendGlobalData($rewItems->getJSGlobals());
             foreach ($rewItems->Iterate() as $id => $__) {
                 $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $rewItems->getField('name', true), 'quality' => $rewItems->getField('quality'), 'qty' => $ri[$id], 'globalStr' => 'g_items');
             }
         }
     }
     if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY])) {
         $rc = $this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY];
         $rewCurr = new CurrencyList(array(['id', array_keys($rc)]));
         if (!$rewCurr->error) {
             $this->extendGlobalData($rewCurr->getJSGlobals());
             foreach ($rewCurr->Iterate() as $id => $__) {
                 $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_CURRENCY], 'id' => $id, 'name' => $rewCurr->getField('name', true), 'quality' => 1, 'qty' => $rc[$id] * ($_side == 2 ? -1 : 1), 'globalStr' => 'g_gatheredcurrencies');
             }
         }
     }
     // spellRewards
     $displ = $this->subject->getField('rewardSpell');
     $cast = $this->subject->getField('rewardSpellCast');
     if (!$cast && $displ) {
         $cast = $displ;
         $displ = 0;
     }
     if ($cast || $displ) {
         $rewSpells = new SpellList(array(['id', [$displ, $cast]]));
         $this->extendGlobalData($rewSpells->getJSGlobals());
         if (User::isInGroup(U_GROUP_EMPLOYEE)) {
             $extra = null;
             if ($_ = $rewSpells->getEntry($displ)) {
                 $extra = sprintf(Lang::quest('spellDisplayed'), $displ, Util::localizedString($_, 'name'));
             }
             if ($_ = $rewSpells->getEntry($cast)) {
                 $rewards['spells']['extra'] = $extra;
                 $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells');
             }
         } else {
             $teach = [];
             foreach ($rewSpells->iterate() as $id => $__) {
                 if ($_ = $rewSpells->canTeachSpell()) {
                     foreach ($_ as $idx) {
                         $teach[$rewSpells->getField('effect' . $idx . 'TriggerSpell')] = $id;
                     }
                 }
             }
             if ($_ = $rewSpells->getEntry($displ)) {
                 $rewards['spells']['extra'] = null;
                 $rewards['spells'][$teach ? 'learn' : 'cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $displ, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells');
             } else {
                 if (($_ = $rewSpells->getEntry($cast)) && !$teach) {
                     $rewards['spells']['extra'] = null;
                     $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells');
                 } else {
                     $taught = new SpellList(array(['id', array_keys($teach)]));
                     if (!$taught->error) {
                         $this->extendGlobalData($taught->getJSGlobals());
                         $rewards['spells']['extra'] = null;
                         foreach ($taught->iterate() as $id => $__) {
                             $rewards['spells']['learn'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $id, 'name' => $taught->getField('name', true), 'globalStr' => 'g_spells');
                         }
                     }
                 }
             }
         }
     }
     return $rewards;
 }
Exemple #7
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // points
     if ($_ = $this->subject->getField('points')) {
         $infobox[] = Lang::achievement('points') . Lang::main('colon') . '[achievementpoints=' . $_ . ']';
     }
     // location
     // todo (low)
     // faction
     switch ($this->subject->getField('faction')) {
         case 1:
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-alliance]' . Lang::game('si', SIDE_ALLIANCE) . '[/span]';
             break;
         case 2:
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-horde]' . Lang::game('si', SIDE_HORDE) . '[/span]';
             break;
         default:
             // case 3
             $infobox[] = Lang::main('side') . Lang::main('colon') . Lang::game('si', SIDE_BOTH);
     }
     // realm first available?
     if ($this->subject->getField('flags') & 0x100 && DB::isConnectable(DB_AUTH)) {
         $avlb = [];
         foreach (DB::Auth()->selectCol('SELECT id AS ARRAY_KEY, name FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_VERSION) as $rId => $name) {
             if (!DB::isConnectable(DB_CHARACTERS . $rId)) {
                 continue;
             }
             if (!DB::Characters($rId)->selectCell('SELECT 1 FROM character_achievement WHERE achievement = ?d LIMIT 1', $this->typeId)) {
                 $avlb[] = $name;
             }
         }
         if ($avlb) {
             $infobox[] = Lang::achievement('rfAvailable') . implode(', ', $avlb);
         }
     }
     /**********/
     /* Series */
     /**********/
     $series = [];
     if ($c = $this->subject->getField('chainId')) {
         $chainAcv = new AchievementList(array(['chainId', $c]));
         foreach ($chainAcv->iterate() as $aId => $__) {
             $pos = $chainAcv->getField('chainPos');
             if (!isset($series[$pos])) {
                 $series[$pos] = [];
             }
             $series[$pos][] = array('side' => $chainAcv->getField('faction'), 'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT], 'typeId' => $aId, 'name' => $chainAcv->getField('name', true));
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->mail = $this->createMail($reqBook);
     $this->headIcons = [$this->subject->getField('iconString')];
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->series = $series ? [[$series, null]] : null;
     $this->description = $this->subject->getField('description', true);
     $this->redButtons = array(BUTTON_LINKS => ['color' => 'ffffff00', 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT] . ':' . $this->typeId . ':&quot;..UnitGUID(&quot;player&quot;)..&quot;:0:0:0:0:0:0:0:0'], BUTTON_WOWHEAD => !($this->subject->getField('cuFlags') & CUSTOM_SERVERSIDE));
     $this->criteria = array('reqQty' => $this->subject->getField('reqCriteriaCount'), 'icons' => [], 'data' => []);
     if ($reqBook) {
         $this->addCss(['path' => 'Book.css']);
     }
     // create rewards
     if ($foo = $this->subject->getField('rewards')) {
         array_walk($foo, function (&$item) {
             $item = $item[0] != TYPE_ITEM ? null : $item[1];
         });
         $bar = new ItemList(array(['i.id', $foo]));
         foreach ($bar->iterate() as $id => $__) {
             $this->rewards['item'][] = array('name' => $bar->getField('name', true), 'quality' => $bar->getField('quality'), 'typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'globalStr' => 'g_items');
         }
     }
     if ($foo = $this->subject->getField('rewards')) {
         array_walk($foo, function (&$item) {
             $item = $item[0] != TYPE_TITLE ? null : $item[1];
         });
         $bar = new TitleList(array(['id', $foo]));
         foreach ($bar->iterate() as $__) {
             $this->rewards['title'][] = sprintf(Lang::achievement('titleReward'), $bar->id, trim(str_replace('%s', '', $bar->getField('male', true))));
         }
     }
     $this->rewards['text'] = $this->subject->getField('reward', true);
     // factionchange-equivalent
     if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_achievement WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) {
         $altAcv = new AchievementList(array(['id', abs($pendant)]));
         if (!$altAcv->error) {
             $this->transfer = sprintf(Lang::achievement('_transfer'), $altAcv->id, 1, $altAcv->getField('iconString'), $altAcv->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2));
         }
     }
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: see also
     $conditions = array(['name_loc' . User::$localeId, $this->subject->getField('name', true)], ['id', $this->typeId, '!']);
     $saList = new AchievementList($conditions);
     $this->lvTabs[] = array('file' => 'achievement', 'data' => $saList->getListviewData(), 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso', 'visibleCols' => "\$['category']"));
     $this->extendGlobalData($saList->getJSGlobals());
     // tab: criteria of
     $refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d', ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, $this->typeId);
     if (!empty($refs)) {
         $coList = new AchievementList(array(['id', $refs]));
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $coList->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof', 'visibleCols' => "\$['category']"));
         $this->extendGlobalData($coList->getJSGlobals());
     }
     /*****************/
     /* Criteria List */
     /*****************/
     $iconId = 1;
     $rightCol = [];
     foreach ($this->subject->getCriteria() as $i => $crt) {
         // hide hidden criteria for regular users (really do..?)
         // if (($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN) && User::$perms > 0)
         // continue;
         // alternative display option
         $displayMoney = $crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER;
         $crtName = Util::localizedString($crt, 'name');
         $tmp = array('id' => $crt['id'], 'name' => $crtName, 'type' => $crt['type']);
         $obj = (int) $crt['value1'];
         $qty = (int) $crt['value2'];
         switch ($crt['type']) {
             // link to npc
             case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
             case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
                 $tmp['link'] = array('href' => '?npc=' . $obj, 'text' => $crtName);
                 $tmp['extraText'] = Lang::achievement('slain');
                 break;
                 // link to area (by map)
             // link to area (by map)
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
             case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
             case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP:
                 if ($zoneId = DB::Aowow()->selectCell('SELECT id FROM ?_zones WHERE mapId = ? LIMIT 1', $obj)) {
                     $tmp['link'] = array('href' => '?zone=' . $zoneId, 'text' => $crtName);
                 } else {
                     $tmp['extraText'] = $crtName;
                 }
                 break;
                 // link to area
             // link to area
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
             case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
                 $tmp['link'] = array('href' => '?zone=' . $obj, 'text' => $crtName);
                 break;
                 // link to skills
             // link to skills
             case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
                 $tmp['link'] = array('href' => '?skill=' . $obj, 'text' => $crtName);
                 break;
                 // link to class
             // link to class
             case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
                 $tmp['link'] = array('href' => '?class=' . $obj, 'text' => $crtName);
                 break;
                 // link to race
             // link to race
             case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
                 $tmp['link'] = array('href' => '?race=' . $obj, 'text' => $crtName);
                 break;
                 // link to title - todo (low): crosslink
             // link to title - todo (low): crosslink
             case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
                 $tmp['extraText'] = Util::ucFirst(Lang::game('title')) . Lang::main('colon') . $crtName;
                 break;
                 // link to achivement (/w icon)
             // link to achivement (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
                 $tmp['link'] = array('href' => '?achievement=' . $obj, 'text' => $crtName);
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_achievements', 'id' => $obj);
                 $this->extendGlobalIds(TYPE_ACHIEVEMENT, $obj);
                 break;
                 // link to quest
             // link to quest
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
                 // $crtName = ;
                 $tmp['link'] = array('href' => '?quest=' . $obj, 'text' => $crtName ?: QuestList::getName($obj));
                 break;
                 // link to spell (/w icon)
             // link to spell (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
                 $tmp['link'] = array('href' => '?spell=' . $obj, 'text' => $crtName ?: SpellList::getName($obj));
                 $this->extendGlobalIds(TYPE_SPELL, $obj);
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_spells', 'id' => $obj);
                 break;
                 // link to item (/w icon)
             // link to item (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
                 $crtItm = new ItemList(array(['i.id', $obj]));
                 $tmp['link'] = array('href' => '?item=' . $obj, 'text' => $crtName ?: $crtItm->getField('name', true), 'quality' => $crtItm->getField('quality'), 'count' => $qty);
                 $this->extendGlobalData($crtItm->getJSGlobals());
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_items', 'id' => $obj, 'count' => $qty);
                 break;
                 // link to faction (/w target reputation)
             // link to faction (/w target reputation)
             case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
                 $tmp['link'] = array('href' => '?faction=' . $obj, 'text' => $crtName ?: FactionList::getName($obj));
                 $tmp['extraText'] = ' (' . Lang::getReputationLevelForPoints($qty) . ')';
                 break;
                 // link to GObject
             // link to GObject
             case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
             case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
                 $tmp['link'] = array('href' => '?object=' . $obj, 'text' => $crtName);
                 break;
             default:
                 // Add a gold coin icon if required
                 $tmp['extraText'] = $displayMoney ? Util::formatMoney($qty) : $crtName;
                 break;
         }
         // If the right column
         if ($i % 2) {
             $this->criteria['data'][] = $tmp;
         } else {
             $rightCol[] = $tmp;
         }
     }
     // If you found the second column - merge data from it to the end of the main body
     if ($rightCol) {
         $this->criteria['data'] = array_merge($this->criteria['data'], $rightCol);
     }
 }
Exemple #8
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // reqLevel
     if ($_ = $this->subject->getField('requiredLevel')) {
         $infobox[] = sprintf(Lang::game('reqLevel'), $_);
     }
     // reqskill
     if ($_ = $this->subject->getField('skillLine')) {
         $this->extendGlobalIds(TYPE_SKILL, $_);
         $foo = sprintf(Lang::game('requires'), '&nbsp;[skill=' . $_ . ']');
         if ($_ = $this->subject->getField('skillLevel')) {
             $foo .= ' (' . $_ . ')';
         }
         $infobox[] = $foo;
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->effects = [];
     // 3 effects
     for ($i = 1; $i < 4; $i++) {
         $_ty = $this->subject->getField('type' . $i);
         $_qty = $this->subject->getField('amount' . $i);
         $_obj = $this->subject->getField('object' . $i);
         switch ($_ty) {
             case 1:
             case 3:
             case 7:
                 $sArr = $this->subject->getField('spells')[$i];
                 $spl = $this->subject->getRelSpell($sArr[0]);
                 $this->effects[$i]['name'] = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Type: ' . $_ty, Lang::item('trigger', $sArr[1])) : Lang::item('trigger', $sArr[1]);
                 $this->effects[$i]['proc'] = $sArr[3];
                 $this->effects[$i]['value'] = $_qty ?: null;
                 $this->effects[$i]['icon'] = array('name' => !$spl ? Util::ucFirst(Lang::game('spell')) . ' #' . $sArr[0] : Util::localizedString($spl, 'name'), 'id' => $sArr[0], 'count' => $sArr[2]);
                 break;
             case 5:
                 if ($_obj < 2) {
                     // [mana, health] are on [0, 1] respectively and are expected on [1, 2] ..
                     $_obj++;
                 }
                 // 0 is weaponDmg .. ehh .. i messed up somewhere
                 $this->effects[$i]['tip'] = [$_obj, Util::$itemMods[$_obj]];
                 // DO NOT BREAK!
             // DO NOT BREAK!
             case 2:
             case 6:
             case 8:
             case 4:
                 $this->effects[$i]['name'] = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Type: ' . $_ty, Lang::enchantment('types', $_ty)) : Lang::enchantment('types', $_ty);
                 $this->effects[$i]['value'] = $_qty;
                 if ($_ty == 4) {
                     $this->effects[$i]['name'] .= Lang::main('colon') . '(' . (User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Object: ' . $_obj, Lang::getMagicSchools(1 << $_obj)) : Lang::getMagicSchools(1 << $_obj)) . ')';
                 }
         }
     }
     // activation conditions
     if ($_ = $this->subject->getField('conditionId')) {
         $x = '';
         if ($gemCnd = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantmentcondition WHERE id = ?d', $_)) {
             for ($i = 1; $i < 6; $i++) {
                 if (!$gemCnd['color' . $i]) {
                     continue;
                 }
                 $fiColors = function ($idx) {
                     $foo = '';
                     switch ($idx) {
                         case 2:
                             $foo = '0:3:5';
                             break;
                             // red
                         // red
                         case 3:
                             $foo = '2:4:5';
                             break;
                             // yellow
                         // yellow
                         case 4:
                             $foo = '1:3:4';
                             break;
                             // blue
                     }
                     return $foo;
                 };
                 $bLink = $gemCnd['color' . $i] ? '<a href="?items=3&filter=ty=' . $fiColors($gemCnd['color' . $i]) . '">' . Lang::item('gemColors', $gemCnd['color' . $i] - 1) . '</a>' : '';
                 $cLink = $gemCnd['cmpColor' . $i] ? '<a href="?items=3&filter=ty=' . $fiColors($gemCnd['cmpColor' . $i]) . '">' . Lang::item('gemColors', $gemCnd['cmpColor' . $i] - 1) . '</a>' : '';
                 switch ($gemCnd['comparator' . $i]) {
                     case 2:
                         // requires less <color> than (<value> || <comparecolor>) gems
                     // requires less <color> than (<value> || <comparecolor>) gems
                     case 5:
                         // requires at least <color> than (<value> || <comparecolor>) gems
                         $sp = (int) $gemCnd['value' . $i] > 1;
                         $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', $gemCnd['comparator' . $i], $sp), $gemCnd['value' . $i], $bLink) . '</span><br />';
                         break;
                     case 3:
                         // requires more <color> than (<value> || <comparecolor>) gems
                         $link = '<a href="?items=3&filter=ty=' . $fiColors($gemCnd['cmpColor' . $i]) . '">' . Lang::item('gemColors', $gemCnd['cmpColor' . $i] - 1) . '</a>';
                         $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', 3), $bLink, $cLink) . '</span><br />';
                         break;
                 }
             }
         }
         $this->activateCondition = $x;
     }
     /**************/
     /* Extra Tabs */
     /**************/
     // used by gem
     $gemList = new ItemList(array(['gemEnchantmentId', $this->typeId]));
     if (!$gemList->error) {
         $this->lvTabs[] = ['item', array('data' => array_values($gemList->getListviewData()), 'name' => '$LANG.tab_usedby + \' \' + LANG.gems', 'id' => 'used-by-gem')];
         $this->extendGlobalData($gemList->getJsGlobals());
     }
     // used by socket bonus
     $socketsList = new ItemList(array(['socketBonus', $this->typeId]));
     if (!$socketsList->error) {
         $this->lvTabs[] = ['item', array('data' => array_values($socketsList->getListviewData()), 'name' => '$LANG.tab_usedby + \' \' + \'' . Lang::item('socketBonus') . '\'', 'id' => 'used-by-socketbonus')];
         $this->extendGlobalData($socketsList->getJsGlobals());
     }
     // used by spell
     // used by useItem
     $cnd = array('OR', ['AND', ['effect1Id', [53, 54, 156, 92]], ['effect1MiscValue', $this->typeId]], ['AND', ['effect2Id', [53, 54, 156, 92]], ['effect2MiscValue', $this->typeId]], ['AND', ['effect3Id', [53, 54, 156, 92]], ['effect3MiscValue', $this->typeId]]);
     $spellList = new SpellList($cnd);
     if (!$spellList->error) {
         $spellData = $spellList->getListviewData();
         $this->extendGlobalData($spellList->getJsGlobals());
         $spellIds = $spellList->getFoundIDs();
         $conditions = array('OR', ['AND', ['spellTrigger1', [0, 5]], ['spellId1', $spellIds]], ['AND', ['spellTrigger2', [0, 5]], ['spellId2', $spellIds]], ['AND', ['spellTrigger3', [0, 5]], ['spellId3', $spellIds]], ['AND', ['spellTrigger4', [0, 5]], ['spellId4', $spellIds]], ['AND', ['spellTrigger5', [0, 5]], ['spellId5', $spellIds]]);
         $ubItems = new ItemList($conditions);
         if (!$ubItems->error) {
             $this->lvTabs[] = ['item', array('data' => array_values($ubItems->getListviewData()), 'name' => '$LANG.tab_usedby + \' \' + LANG.types[3][0]', 'id' => 'used-by-item')];
             $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF));
         }
         // remove found spells if they are used by an item
         if (!$ubItems->error) {
             foreach ($spellList->iterate() as $sId => $__) {
                 // if Perm. Enchantment has a createItem its a Scroll of Enchantment (display both)
                 for ($i = 1; $i < 4; $i++) {
                     if ($spellList->getField('effect' . $i . 'Id') == 53 && $spellList->getField('effect' . $i . 'CreateItemId')) {
                         continue 2;
                     }
                 }
                 foreach ($ubItems->iterate() as $__) {
                     for ($i = 1; $i < 6; $i++) {
                         if ($ubItems->getField('spellId' . $i) == $sId) {
                             unset($spellData[$sId]);
                             break 2;
                         }
                     }
                 }
             }
         }
         $this->lvTabs[] = ['spell', array('data' => array_values($spellData), 'name' => '$LANG.tab_usedby + \' \' + LANG.types[6][0]', 'id' => 'used-by-spell')];
     }
     // used by randomAttrItem
     $ire = DB::Aowow()->select('SELECT *, ABS(id) AS ARRAY_KEY FROM ?_itemrandomenchant WHERE enchantId1 = ?d OR enchantId2 = ?d OR enchantId3 = ?d OR enchantId4 = ?d OR enchantId5 = ?d', $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId);
     if ($ire) {
         if ($iet = DB::World()->select('SELECT entry AS ARRAY_KEY, ench, chance FROM item_enchantment_template WHERE ench IN (?a)', array_keys($ire))) {
             $randIds = [];
             // transform back to signed format
             foreach ($iet as $tplId => $data) {
                 $randIds[$ire[$data['ench']]['id'] > 0 ? $tplId : -$tplId] = $ire[$data['ench']]['id'];
             }
             $randItems = new ItemList(array(CFG_SQL_LIMIT_NONE, ['randomEnchant', array_keys($randIds)]));
             if (!$randItems->error) {
                 $data = $randItems->getListviewData();
                 foreach ($randItems->iterate() as $iId => $__) {
                     $re = $randItems->getField('randomEnchant');
                     $data[$iId]['percent'] = $iet[abs($re)]['chance'];
                     $data[$iId]['count'] = 1;
                     // expected by js or the pct-col becomes unsortable
                     $data[$iId]['rel'] = 'rand=' . $ire[$iet[abs($re)]['ench']]['id'];
                     $data[$iId]['name'] .= ' ' . Util::localizedString($ire[$iet[abs($re)]['ench']], 'name');
                 }
                 $this->lvTabs[] = ['item', array('data' => array_values($data), 'id' => 'used-by-rand', 'name' => '$LANG.tab_usedby + \' \' + \'' . Lang::item('_rndEnchants') . '\'', 'extraCols' => ['$Listview.extraCols.percent'])];
                 $this->extendGlobalData($randItems->getJSGlobals(GLOBALINFO_SELF));
             }
         }
     }
 }
Exemple #9
0
 public function getByItem($entry, $maxResults = CFG_SQL_LIMIT_DEFAULT, $lootTableList = [])
 {
     $this->entry = intVal($entry);
     if (!$this->entry) {
         return false;
     }
     //  [fileName, tabData, tabName, tabId, extraCols, hiddenCols, visibleCols]
     $tabsFinal = array(['item', [], '$LANG.tab_containedin', 'contained-in-item', [], [], []], ['item', [], '$LANG.tab_disenchantedfrom', 'disenchanted-from', [], [], []], ['item', [], '$LANG.tab_prospectedfrom', 'prospected-from', [], [], []], ['item', [], '$LANG.tab_milledfrom', 'milled-from', [], [], []], ['creature', [], '$LANG.tab_droppedby', 'dropped-by', [], [], []], ['creature', [], '$LANG.tab_pickpocketedfrom', 'pickpocketed-from', [], [], []], ['creature', [], '$LANG.tab_skinnedfrom', 'skinned-from', [], [], []], ['creature', [], '$LANG.tab_minedfromnpc', 'mined-from-npc', [], [], []], ['creature', [], '$LANG.tab_salvagedfrom', 'salvaged-from', [], [], []], ['creature', [], '$LANG.tab_gatheredfromnpc', 'gathered-from-npc', [], [], []], ['quest', [], '$LANG.tab_rewardfrom', 'reward-from-quest', [], [], []], ['zone', [], '$LANG.tab_fishedin', 'fished-in-zone', [], [], []], ['object', [], '$LANG.tab_containedin', 'contained-in-object', [], [], []], ['object', [], '$LANG.tab_minedfrom', 'mined-from-object', [], [], []], ['object', [], '$LANG.tab_gatheredfrom', 'gathered-from-object', [], [], []], ['object', [], '$LANG.tab_fishedin', 'fished-in-object', [], [], []], ['spell', [], '$LANG.tab_createdby', 'created-by', [], [], []], ['achievement', [], '$LANG.tab_rewardfrom', 'reward-from-achievement', [], [], []]);
     $refResults = [];
     $chanceMods = [];
     $query = 'SELECT
                         lt1.entry AS ARRAY_KEY,
                         IF(lt1.reference = 0, lt1.item, lt1.reference) AS item,
                         lt1.chance,
                         SUM(IF(lt2.chance = 0, 1, 0)) AS nZeroItems,
                         SUM(lt2.chance) AS sumChance,
                         IF(lt1.groupid > 0, 1, 0) AS isGrouped,
                         IF(lt1.reference = 0, lt1.mincount, 1) AS min,
                         IF(lt1.reference = 0, lt1.maxcount, 1) AS max,
                         IF(lt1.reference > 0, lt1.maxcount, 1) AS multiplier
                     FROM
                         ?# lt1
                     LEFT JOIN
                         ?# lt2 ON lt1.entry = lt2.entry AND lt1.groupid = lt2.groupid
                     WHERE
                         %s
                     GROUP BY lt2.entry, lt2.groupid';
     $calcChance = function ($refs, $parents = []) use(&$chanceMods) {
         $retData = [];
         $retKeys = [];
         foreach ($refs as $rId => $ref) {
             // check for possible database inconsistencies
             if (!$ref['chance'] && !$ref['isGrouped']) {
                 Util::addNote(U_GROUP_EMPLOYEE, 'Loot by Item: ungrouped Item/Ref ' . $ref['item'] . ' has 0% chance assigned!');
             }
             if ($ref['isGrouped'] && $ref['sumChance'] > 100) {
                 Util::addNote(U_GROUP_EMPLOYEE, 'Loot by Item: group with Item/Ref ' . $ref['item'] . ' has ' . number_format($ref['sumChance'], 2) . '% total chance! Some items cannot drop!');
             }
             if ($ref['isGrouped'] && $ref['sumChance'] >= 100 && !$ref['chance']) {
                 Util::addNote(U_GROUP_EMPLOYEE, 'Loot by Item: Item/Ref ' . $ref['item'] . ' with adaptive chance cannot drop. Group already at 100%!');
             }
             $chance = abs($ref['chance'] ?: (100 - $ref['sumChance']) / $ref['nZeroItems']) / 100;
             // apply inherited chanceMods
             if (isset($chanceMods[$ref['item']])) {
                 $chance *= $chanceMods[$ref['item']][0];
                 $chance = 1 - pow(1 - $chance, $chanceMods[$ref['item']][1]);
             }
             // save chance for parent-ref
             $chanceMods[$rId] = [$chance, $ref['multiplier']];
             // refTemplate doesn't point to a new ref -> we are done
             if (!in_array($rId, $parents)) {
                 $data = array('percent' => $chance, 'stack' => [$ref['min'], $ref['max']], 'count' => 1);
                 if ($_ = self::createStack($ref)) {
                     $data['pctstack'] = $_;
                 }
                 // sort highest chances first
                 $i = 0;
                 for (; $i < count($retData); $i++) {
                     if ($retData[$i]['percent'] < $data['percent']) {
                         break;
                     }
                 }
                 array_splice($retData, $i, 0, [$data]);
                 array_splice($retKeys, $i, 0, [$rId]);
             }
         }
         return array_combine($retKeys, $retData);
     };
     /*
         get references containing the item
     */
     $newRefs = DB::World()->select(sprintf($query, 'lt1.item = ?d AND lt1.reference = 0'), LOOT_REFERENCE, LOOT_REFERENCE, $this->entry);
     while ($newRefs) {
         $curRefs = $newRefs;
         $newRefs = DB::World()->select(sprintf($query, 'lt1.reference IN (?a)'), LOOT_REFERENCE, LOOT_REFERENCE, array_keys($curRefs));
         $refResults += $calcChance($curRefs, array_column($newRefs, 'item'));
     }
     /*
         search the real loot-templates for the itemId and gathered refds
     */
     for ($i = 1; $i < count($this->lootTemplates); $i++) {
         if ($lootTableList && !in_array($this->lootTemplates[$i], $lootTableList)) {
             continue;
         }
         $result = $calcChance(DB::World()->select(sprintf($query, '{lt1.reference IN (?a) OR }(lt1.reference = 0 AND lt1.item = ?d)'), $this->lootTemplates[$i], $this->lootTemplates[$i], $refResults ? array_keys($refResults) : DBSIMPLE_SKIP, $this->entry));
         // do not skip here if $result is empty. Additional loot for spells and quest is added separately
         // format for actual use
         foreach ($result as $k => $v) {
             unset($result[$k]);
             $v['percent'] = round($v['percent'] * 100, 3);
             $result[abs($k)] = $v;
         }
         // cap fetched entries to the sql-limit to guarantee, that the highest chance items get selected first
         // screws with GO-loot and skinnig-loot as these templates are shared for several tabs (fish, herb, ore) (herb, ore, leather)
         $ids = array_slice(array_keys($result), 0, $maxResults);
         switch ($this->lootTemplates[$i]) {
             case LOOT_CREATURE:
                 $field = 'lootId';
                 $tabId = 4;
                 break;
             case LOOT_PICKPOCKET:
                 $field = 'pickpocketLootId';
                 $tabId = 5;
                 break;
             case LOOT_SKINNING:
                 $field = 'skinLootId';
                 $tabId = -6;
                 break;
                 // assigned later
             // assigned later
             case LOOT_PROSPECTING:
                 $field = 'id';
                 $tabId = 2;
                 break;
             case LOOT_MILLING:
                 $field = 'id';
                 $tabId = 3;
                 break;
             case LOOT_ITEM:
                 $field = 'id';
                 $tabId = 0;
                 break;
             case LOOT_DISENCHANT:
                 $field = 'disenchantId';
                 $tabId = 1;
                 break;
             case LOOT_FISHING:
                 $field = 'id';
                 $tabId = 11;
                 break;
                 // subAreas are currently ignored
             // subAreas are currently ignored
             case LOOT_GAMEOBJECT:
                 if (!$ids) {
                     continue 2;
                 }
                 $srcObj = new GameObjectList(array(['lootId', $ids]));
                 if ($srcObj->error) {
                     continue 2;
                 }
                 $srcData = $srcObj->getListviewData();
                 foreach ($srcObj->iterate() as $__id => $curTpl) {
                     switch ($curTpl['typeCat']) {
                         case 25:
                             $tabId = 15;
                             break;
                             // fishing node
                         // fishing node
                         case -3:
                             $tabId = 14;
                             break;
                             // herb
                         // herb
                         case -4:
                             $tabId = 13;
                             break;
                             // vein
                         // vein
                         default:
                             $tabId = 12;
                             break;
                             // general chest loot
                     }
                     $tabsFinal[$tabId][1][] = array_merge($srcData[$srcObj->id], $result[$srcObj->getField('lootId')]);
                     $tabsFinal[$tabId][4][] = 'Listview.extraCols.percent';
                     if ($tabId != 15) {
                         $tabsFinal[$tabId][6][] = 'skill';
                     }
                 }
                 continue 2;
             case LOOT_MAIL:
                 // quest part
                 $conditions = array(['rewardChoiceItemId1', $this->entry], ['rewardChoiceItemId2', $this->entry], ['rewardChoiceItemId3', $this->entry], ['rewardChoiceItemId4', $this->entry], ['rewardChoiceItemId5', $this->entry], ['rewardChoiceItemId6', $this->entry], ['rewardItemId1', $this->entry], ['rewardItemId2', $this->entry], ['rewardItemId3', $this->entry], ['rewardItemId4', $this->entry], 'OR');
                 if ($ids) {
                     $conditions[] = ['rewardMailTemplateId', $ids];
                 }
                 $srcObj = new QuestList($conditions);
                 if (!$srcObj->error) {
                     self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
                     $srcData = $srcObj->getListviewData();
                     foreach ($srcObj->iterate() as $_) {
                         $tabsFinal[10][1][] = array_merge($srcData[$srcObj->id], empty($result[$srcObj->id]) ? ['percent' => -1] : $result[$srcObj->id]);
                     }
                 }
                 // achievement part
                 $conditions = array(['itemExtra', $this->entry]);
                 if ($ar = DB::World()->selectCol('SELECT entry FROM achievement_reward WHERE item = ?d{ OR mailTemplate IN (?a)}', $this->entry, $ids ?: DBSIMPLE_SKIP)) {
                     array_push($conditions, ['id', $ar], 'OR');
                 }
                 $srcObj = new AchievementList($conditions);
                 if (!$srcObj->error) {
                     self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
                     $srcData = $srcObj->getListviewData();
                     foreach ($srcObj->iterate() as $_) {
                         $tabsFinal[17][1][] = array_merge($srcData[$srcObj->id], empty($result[$srcObj->id]) ? ['percent' => -1] : $result[$srcObj->id]);
                     }
                     $tabsFinal[17][5][] = 'rewards';
                     $tabsFinal[17][6][] = 'category';
                 }
                 continue 2;
             case LOOT_SPELL:
                 $conditions = array('OR', ['AND', ['effect1CreateItemId', $this->entry], ['OR', ['effect1Id', SpellList::$effects['itemCreate']], ['effect1AuraId', SpellList::$auras['itemCreate']]]], ['AND', ['effect2CreateItemId', $this->entry], ['OR', ['effect2Id', SpellList::$effects['itemCreate']], ['effect2AuraId', SpellList::$auras['itemCreate']]]], ['AND', ['effect3CreateItemId', $this->entry], ['OR', ['effect3Id', SpellList::$effects['itemCreate']], ['effect3AuraId', SpellList::$auras['itemCreate']]]]);
                 if ($ids) {
                     $conditions[] = ['id', $ids];
                 }
                 $srcObj = new SpellList($conditions);
                 if (!$srcObj->error) {
                     self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
                     $srcData = $srcObj->getListviewData();
                     if (!empty($result)) {
                         $tabsFinal[16][4][] = 'Listview.extraCols.percent';
                     }
                     if ($srcObj->hasSetFields(['reagent1'])) {
                         $tabsFinal[16][6][] = 'reagents';
                     }
                     foreach ($srcObj->iterate() as $_) {
                         $tabsFinal[16][1][] = array_merge($srcData[$srcObj->id], empty($result[$srcObj->id]) ? ['percent' => -1] : $result[$srcObj->id]);
                     }
                 }
                 continue 2;
         }
         if (!$ids) {
             continue;
         }
         switch ($tabsFinal[abs($tabId)][0]) {
             case 'creature':
                 // new CreatureList
             // new CreatureList
             case 'item':
                 // new ItemList
             // new ItemList
             case 'zone':
                 // new ZoneList
                 $oName = ucFirst($tabsFinal[abs($tabId)][0]) . 'List';
                 $srcObj = new $oName(array([$field, $ids]));
                 if (!$srcObj->error) {
                     $srcData = $srcObj->getListviewData();
                     self::storeJSGlobals($srcObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
                     foreach ($srcObj->iterate() as $curTpl) {
                         if ($tabId < 0 && $curTpl['typeFlags'] & NPC_TYPEFLAG_HERBLOOT) {
                             $tabId = 9;
                         } else {
                             if ($tabId < 0 && $curTpl['typeFlags'] & NPC_TYPEFLAG_ENGINEERLOOT) {
                                 $tabId = 8;
                             } else {
                                 if ($tabId < 0 && $curTpl['typeFlags'] & NPC_TYPEFLAG_MININGLOOT) {
                                     $tabId = 7;
                                 } else {
                                     if ($tabId < 0) {
                                         $tabId = abs($tabId);
                                     }
                                 }
                             }
                         }
                         // general case (skinning)
                         $tabsFinal[$tabId][1][] = array_merge($srcData[$srcObj->id], $result[$srcObj->getField($field)]);
                         $tabsFinal[$tabId][4][] = 'Listview.extraCols.percent';
                     }
                 }
                 break;
         }
     }
     $this->results = $tabsFinal;
     return true;
 }
Exemple #10
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // level range
     $infobox[] = Lang::game('level') . Lang::main('colon') . $this->subject->getField('minLevel') . ' - ' . $this->subject->getField('maxLevel');
     // exotic
     if ($this->subject->getField('exotic')) {
         $infobox[] = '[url=?spell=53270]' . Lang::pet('exotic') . '[/url]';
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     $this->headIcons = [$this->subject->getField('iconString')];
     $this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true, BUTTON_TALENT => ['href' => '?petcalc#' . Util::$tcEncoding[(int) ($this->typeId / 10)] . Util::$tcEncoding[2 * ($this->typeId % 10) + ($this->subject->getField('exotic') ? 1 : 0)], 'pet' => true]);
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: tameable & gallery
     $condition = array(['ct.type', 1], ['ct.typeFlags', 0x1, '&'], ['ct.family', $this->typeId], ['OR', ['ft.A', 1, '<'], ['ft.H', 1, '<']]);
     $tng = new CreatureList($condition);
     $this->lvTabs[] = array('file' => 'creature', 'data' => $tng->getListviewData(NPCINFO_TAMEABLE), 'params' => array('name' => '$LANG.tab_tameable', 'hiddenCols' => "\$['type']", 'visibleCols' => "\$['skin']", 'note' => sprintf(Util::$filterResultString, '?npcs=1&filter=fa=38'), 'id' => 'tameable'));
     $this->lvTabs[] = array('file' => 'model', 'data' => $tng->getListviewData(NPCINFO_MODEL), 'params' => []);
     // tab: diet
     $list = [];
     $mask = $this->subject->getField('foodMask');
     for ($i = 1; $i < 7; $i++) {
         if ($mask & 1 << $i - 1) {
             $list[] = $i;
         }
     }
     $food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list], CFG_SQL_LIMIT_NONE));
     $this->extendGlobalData($food->getJSGlobals());
     $this->lvTabs[] = array('file' => 'item', 'data' => $food->getListviewData(), 'params' => array('name' => '$LANG.diet', 'hiddenCols' => "\$['source', 'slot', 'side']", 'sort' => "\$['level']", 'id' => 'diet'));
     // tab: spells
     $mask = 0x0;
     foreach (Util::$skillLineMask[-1] as $idx => $pair) {
         if ($pair[0] == $this->typeId) {
             $mask = 1 << $idx;
             break;
         }
     }
     $conditions = [['s.typeCat', -3], ['OR', ['skillLine1', $this->subject->getField('skillLineId')], ['AND', ['skillLine1', 0, '>'], ['skillLine2OrMask', $this->subject->getField('skillLineId')]], ['AND', ['skillLine1', -1], ['skillLine2OrMask', $mask, '&']]]];
     $spells = new SpellList($conditions);
     $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF));
     $this->lvTabs[] = array('file' => 'spell', 'data' => $spells->getListviewData(), 'params' => array('name' => '$LANG.tab_abilities', 'visibleCols' => "\$['schools', 'level']", 'id' => 'abilities'));
     // tab: talents
     $conditions = array(['s.typeCat', -7], ['OR', ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], ['s.rankNo', 0]]);
     switch ($this->subject->getField('type')) {
         case 0:
             $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE0, '&'];
             break;
         case 1:
             $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE1, '&'];
             break;
         case 2:
             $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE2, '&'];
             break;
     }
     $talents = new SpellList($conditions);
     $this->extendGlobalData($talents->getJSGlobals(GLOBALINFO_SELF));
     $this->lvTabs[] = array('file' => 'spell', 'data' => $talents->getListviewData(), 'params' => array('visibleCols' => "\$['tier', 'level']", 'name' => '$LANG.tab_talents', 'id' => 'talents', 'sort' => "\$['tier', 'name']", '_petTalents' => 1));
 }
Exemple #11
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();
 }
Exemple #12
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // City
     if ($this->subject->getField('flags') & 0x8 && !$this->subject->getField('parentArea')) {
         $infobox[] = Lang::zone('city');
     }
     // Auto repop
     if ($this->subject->getField('flags') & 0x1000 && !$this->subject->getField('parentArea')) {
         $infobox[] = Lang::zone('autoRez');
     }
     // Level
     if ($_ = $this->subject->getField('levelMin')) {
         if ($_ < $this->subject->getField('levelMax')) {
             $_ .= ' - ' . $this->subject->getField('levelMax');
         }
         $infobox[] = Lang::game('level') . Lang::main('colon') . $_;
     }
     // required Level
     if ($_ = $this->subject->getField('levelReq')) {
         if ($__ = $this->subject->getField('levelReqLFG')) {
             $buff = sprintf(Lang::zone('reqLevels'), $_, $__);
         } else {
             $buff = Lang::main('_reqLevel') . Lang::main('colon') . $_;
         }
         $infobox[] = $buff;
     }
     // Territory
     $_ = $this->subject->getField('faction');
     $__ = '%s';
     if ($_ == 0) {
         $__ = '[span class=icon-alliance]%s[/span]';
     } else {
         if ($_ == 1) {
             $__ = '[span class=icon-horde]%s[/span]';
         } else {
             if ($_ == 4) {
                 $__ = '[span class=icon-ffa]%s[/span]';
             }
         }
     }
     $infobox[] = Lang::zone('territory') . Lang::main('colon') . sprintf($__, Lang::zone('territories', $_));
     // Instance Type
     $infobox[] = Lang::zone('instanceType') . Lang::main('colon') . '[span class=icon-instance' . $this->subject->getField('type') . ']' . Lang::zone('instanceTypes', $this->subject->getField('type')) . '[/span]';
     // Heroic mode
     if ($_ = $this->subject->getField('levelHeroic')) {
         $infobox[] = '[icon preset=heroic]' . sprintf(Lang::zone('hcAvailable'), $_) . '[/icon]';
     }
     // number of players
     if ($_ = $this->subject->getField('maxPlayer')) {
         $infobox[] = Lang::zone('numPlayers') . Lang::main('colon') . ($_ == -2 ? '10/25' : $_);
     }
     // Attunement Quest/Achievements & Keys
     if ($attmnt = $this->subject->getField('attunes')) {
         foreach ($attmnt as $type => $ids) {
             $this->extendGlobalIds($type, array_map('abs', $ids));
             foreach ($ids as $id) {
                 if ($type == TYPE_ITEM) {
                     $infobox[] = Lang::zone('key', (int) ($id < 0)) . Lang::main('colon') . '[item=' . abs($id) . ']';
                 } else {
                     $infobox[] = Lang::zone('attunement', (int) ($id < 0)) . Lang::main('colon') . '[' . Util::$typeStrings[$type] . '=' . abs($id) . ']';
                 }
             }
         }
     }
     // Instances
     if ($_ = DB::Aowow()->selectCol('SELECT id FROM ?_zones WHERE parentAreaId = ?d AND (flags & ?d) = 0', $this->typeId, CUSTOM_EXCLUDE_FOR_LISTVIEW)) {
         $this->extendGlobalIds(TYPE_ZONE, $_);
         $infobox[] = Lang::maps('Instances') . Lang::main('colon') . "\n[zone=" . implode("], \n[zone=", $_) . ']';
     }
     // location (if instance)
     if ($pa = $this->subject->getField('parentAreaId')) {
         $paO = new ZoneList(array(['id', $pa]));
         if (!$paO->error) {
             $pins = str_pad($this->subject->getField('parentX') * 10, 3, '0', STR_PAD_LEFT) . str_pad($this->subject->getField('parentY') * 10, 3, '0', STR_PAD_LEFT);
             $infobox[] = Lang::zone('location') . Lang::main('colon') . '[lightbox=map zone=' . $pa . ' pins=' . $pins . ']' . $paO->getField('name', true) . '[/lightbox]';
         }
     }
     /*  has to be defined in an article, i think
     
         // faction(s) / Reputation Hub / Raid Faction
         // [li]Raid faction: [faction=1156][/li] || [li]Factions: [faction=1156]/[faction=1156][/li]
     
         // final boss
         // [li]Final boss: [icon preset=boss][npc=37226][/icon][/li]
     */
     /****************/
     /* Main Content */
     /****************/
     $addToMap = function ($what, $entry) use(&$som) {
         // entry always contains: type, id, name, level, coords[]
         if (!isset($som[$what][$entry['name']])) {
             // not found yet
             $som[$what][$entry['name']][] = $entry;
         } else {
             // check for identical floors
             foreach ($som[$what][$entry['name']] as &$byFloor) {
                 if ($byFloor['level'] != $entry['level']) {
                     continue;
                 }
                 // found existing floor, ammending coords
                 $byFloor['coords'][] = $entry['coords'][0];
                 break;
             }
             // floor not used yet, create it
             $som[$what][$entry['name']][] = $entry;
         }
     };
     if ($_ = $this->subject->getField('parentArea')) {
         $this->extraText = sprintf(Lang::zone('zonePartOf'), $_);
         $this->extendGlobalIds(TYPE_ZONE, $_);
     }
     // we cannot fetch spawns via lists. lists are grouped by entry
     $oSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_OBJECT);
     $cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_NPC);
     $conditions = [CFG_SQL_LIMIT_NONE, ['s.areaId', $this->typeId]];
     if (!User::isInGroup(U_GROUP_STAFF)) {
         $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
     }
     $objectSpawns = new GameObjectList($conditions);
     $creatureSpawns = new CreatureList($conditions);
     $questsLV = $rewardsLV = [];
     // see if we can actually display a map
     $hasMap = file_exists('static/images/wow/maps/' . Util::$localeStrings[User::$localeId] . '/normal/' . $this->typeId . '.jpg');
     if (!$hasMap) {
         // try multilayered
         $hasMap = file_exists('static/images/wow/maps/' . Util::$localeStrings[User::$localeId] . '/normal/' . $this->typeId . '-1.jpg');
     }
     if (!$hasMap) {
         // try english fallback
         $hasMap = file_exists('static/images/wow/maps/enus/normal/' . $this->typeId . '.jpg');
     }
     if (!$hasMap) {
         // try english fallback, multilayered
         $hasMap = file_exists('static/images/wow/maps/enus/normal/' . $this->typeId . '-1.jpg');
     }
     if ($hasMap) {
         $som = [];
         foreach ($oSpawns as $spawn) {
             $tpl = $objectSpawns->getEntry($spawn['typeId']);
             if (!$tpl) {
                 continue;
             }
             $n = Util::localizedString($tpl, 'name');
             $what = '';
             switch ($tpl['typeCat']) {
                 case -3:
                     $what = 'herb';
                     break;
                 case -4:
                     $what = 'vein';
                     break;
                 case 9:
                     $what = 'book';
                     break;
                 case -6:
                     if ($tpl['spellFocusId'] == 1) {
                         $what = 'anvil';
                     } else {
                         if ($tpl['spellFocusId'] == 3) {
                             $what = 'forge';
                         }
                     }
                     break;
             }
             if ($what) {
                 $addToMap($what, array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_OBJECT, 'id' => $tpl['id']));
             }
             if ($tpl['startsQuests']) {
                 $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', TYPE_OBJECT], ['qse.typeId', $tpl['id']]));
                 if ($started->error) {
                     continue;
                 }
                 // store data for misc tabs
                 foreach ($started->getListviewData() as $id => $data) {
                     if (!empty($started->rewards[$id][TYPE_ITEM])) {
                         $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][TYPE_ITEM]));
                     }
                     if (!empty($started->choices[$id][TYPE_ITEM])) {
                         $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][TYPE_ITEM]));
                     }
                     $questsLV[$id] = $data;
                 }
                 $this->extendGlobalData($started->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS));
                 if ($tpl['A'] != -1 & ($_ = $started->getSOMData(SIDE_ALLIANCE))) {
                     $addToMap('alliancequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_OBJECT, 'id' => $tpl['id'], 'side' => ($tpl['A'] < 0 ? 0 : 0x1) | ($tpl['H'] < 0 ? 0 : 0x2), 'quests' => array_values($_)));
                 }
                 if ($tpl['H'] != -1 & ($_ = $started->getSOMData(SIDE_HORDE))) {
                     $addToMap('hordequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_OBJECT, 'id' => $tpl['id'], 'side' => ($tpl['A'] < 0 ? 0 : 0x1) | ($tpl['H'] < 0 ? 0 : 0x2), 'quests' => array_values($_)));
                 }
             }
         }
         $flightNodes = [];
         foreach ($cSpawns as $spawn) {
             $tpl = $creatureSpawns->getEntry($spawn['typeId']);
             if (!$tpl) {
                 continue;
             }
             $n = Util::localizedString($tpl, 'name');
             $sn = Util::localizedString($tpl, 'subname');
             $what = '';
             if ($tpl['npcflag'] & NPC_FLAG_REPAIRER) {
                 $what = 'repair';
             } else {
                 if ($tpl['npcflag'] & NPC_FLAG_AUCTIONEER) {
                     $what = 'auctioneer';
                 } else {
                     if ($tpl['npcflag'] & NPC_FLAG_BANKER) {
                         $what = 'banker';
                     } else {
                         if ($tpl['npcflag'] & NPC_FLAG_BATTLEMASTER) {
                             $what = 'battlemaster';
                         } else {
                             if ($tpl['npcflag'] & NPC_FLAG_INNKEEPER) {
                                 $what = 'innkeeper';
                             } else {
                                 if ($tpl['npcflag'] & NPC_FLAG_TRAINER) {
                                     $what = 'trainer';
                                 } else {
                                     if ($tpl['npcflag'] & NPC_FLAG_VENDOR) {
                                         $what = 'vendor';
                                     } else {
                                         if ($tpl['npcflag'] & NPC_FLAG_FLIGHT_MASTER) {
                                             $flightNodes[$tpl['id']] = [$spawn['posX'], $spawn['posY']];
                                             $what = 'flightmaster';
                                         } else {
                                             if ($tpl['npcflag'] & NPC_FLAG_STABLE_MASTER) {
                                                 $what = 'stablemaster';
                                             } else {
                                                 if ($tpl['npcflag'] & NPC_FLAG_GUILD_MASTER) {
                                                     $what = 'guildmaster';
                                                 } else {
                                                     if ($tpl['npcflag'] & (NPC_FLAG_SPIRIT_HEALER | NPC_FLAG_SPIRIT_GUIDE)) {
                                                         $what = 'spirithealer';
                                                     } else {
                                                         if ($creatureSpawns->isBoss()) {
                                                             $what = 'boss';
                                                         } else {
                                                             if ($tpl['rank'] == 2 || $tpl['rank'] == 4) {
                                                                 $what = 'rare';
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if ($what) {
                 $addToMap($what, array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'] ?: 1, 'reactalliance' => $tpl['A'] ?: 1, 'description' => $sn));
             }
             if ($tpl['startsQuests']) {
                 $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', TYPE_NPC], ['qse.typeId', $tpl['id']]));
                 if ($started->error) {
                     continue;
                 }
                 // store data for misc tabs
                 foreach ($started->getListviewData() as $id => $data) {
                     if (!empty($started->rewards[$id][TYPE_ITEM])) {
                         $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][TYPE_ITEM]));
                     }
                     if (!empty($started->choices[$id][TYPE_ITEM])) {
                         $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][TYPE_ITEM]));
                     }
                     $questsLV[$id] = $data;
                 }
                 if ($tpl['A'] != -1 & ($_ = $started->getSOMData(SIDE_ALLIANCE))) {
                     $addToMap('alliancequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'], 'reactalliance' => $tpl['A'], 'side' => ($tpl['A'] < 0 ? 0 : SIDE_ALLIANCE) | ($tpl['H'] < 0 ? 0 : SIDE_HORDE), 'quests' => array_values($_)));
                 }
                 if ($tpl['H'] != -1 & ($_ = $started->getSOMData(SIDE_HORDE))) {
                     $addToMap('hordequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'], 'reactalliance' => $tpl['A'], 'side' => ($tpl['A'] < 0 ? 0 : SIDE_ALLIANCE) | ($tpl['H'] < 0 ? 0 : SIDE_HORDE), 'quests' => array_values($_)));
                 }
             }
         }
         // remove unwanted indizes
         foreach ($som as $what => &$dataz) {
             if (empty($som[$what])) {
                 continue;
             }
             foreach ($dataz as &$data) {
                 $data = array_values($data);
             }
             if (!in_array($what, ['vein', 'herb', 'rare'])) {
                 $foo = [];
                 foreach ($dataz as $d) {
                     foreach ($d as $_) {
                         $foo[] = $_;
                     }
                 }
                 $dataz = $foo;
             }
         }
         // append paths between nodes
         if ($flightNodes) {
             // neutral nodes come last as the line is colored by the node it's attached to
             usort($som['flightmaster'], function ($a, $b) {
                 $n1 = $a['reactalliance'] == $a['reacthorde'];
                 $n2 = $b['reactalliance'] == $b['reacthorde'];
                 if ($n1 && !$n2) {
                     return 1;
                 }
                 if (!$n1 && $n2) {
                     return -1;
                 }
                 return 0;
             });
             $paths = DB::Aowow()->select('SELECT n1.typeId AS "0", n2.typeId AS "1" FROM ?_taxipath p JOIN ?_taxinodes n1 ON n1.id = p.startNodeId JOIN ?_taxinodes n2 ON n2.id = p.endNodeId WHERE n1.typeId IN (?a) AND n2.typeId IN (?a)', array_keys($flightNodes), array_keys($flightNodes));
             foreach ($paths as $k => $path) {
                 foreach ($som['flightmaster'] as &$fm) {
                     if ($fm['id'] != $path[0] && $fm['id'] != $path[1]) {
                         continue;
                     }
                     if ($fm['id'] == $path[0]) {
                         $fm['paths'][] = $flightNodes[$path[1]];
                     }
                     if ($fm['id'] == $path[1]) {
                         $fm['paths'][] = $flightNodes[$path[0]];
                     }
                     unset($paths[$k]);
                     break;
                 }
             }
         }
         // preselect bosses for raids/dungeons
         if (in_array($this->subject->getField('type'), [2, 3, 4, 5, 7, 8])) {
             $som['instance'] = true;
         }
         $this->map = array('data' => ['parent' => 'mapper-generic', 'zone' => $this->typeId], 'som' => $som);
     } else {
         $this->map = false;
     }
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true);
     /*
        - associated with holiday?
     */
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: NPCs
     if ($cSpawns && !$creatureSpawns->error) {
         $lvData = array('file' => 'creature', 'data' => $creatureSpawns->getListviewData(), 'params' => ['note' => sprintf(Util::$filterResultString, '?npcs&filter=cr=6;crs=' . $this->typeId . ';crv=0')]);
         if ($creatureSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
             $lvData['params']['_truncated'] = 1;
         }
         $this->extendGlobalData($creatureSpawns->getJSGlobals(GLOBALINFO_SELF));
         $this->lvTabs[] = $lvData;
     }
     // tab: Objects
     if ($oSpawns && !$objectSpawns->error) {
         $lvData = array('file' => 'object', 'data' => $objectSpawns->getListviewData(), 'params' => ['note' => sprintf(Util::$filterResultString, '?objects&filter=cr=1;crs=' . $this->typeId . ';crv=0')]);
         if ($objectSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
             $lvData['params']['_truncated'] = 1;
         }
         $this->extendGlobalData($objectSpawns->getJSGlobals(GLOBALINFO_SELF));
         $this->lvTabs[] = $lvData;
     }
     // tab: Quests [data collected by SOM-routine]
     if ($questsLV) {
         $this->lvTabs[] = array('file' => 'quest', 'data' => $questsLV, 'params' => ['note' => '$$WH.sprintf(LANG.lvnote_zonequests, ' . $this->subject->getField('mapId') . ', ' . $this->typeId . ', \'' . Util::jsEscape($this->subject->getField('name', true)) . '\', ' . $this->typeId . ')']);
     }
     // tab: item-quest starter
     // select every quest starter, that is a drop
     $questStartItem = DB::Aowow()->select('
         SELECT qse.typeId AS ARRAY_KEY, moreType, moreTypeId, moreZoneId
         FROM   ?_quests_startend qse JOIN ?_source src ON src.type = qse.type AND src.typeId = qse.typeId
         WHERE  src.src2 IS NOT NULL AND qse.type = ?d AND (moreZoneId = ?d OR (moreType = ?d AND moreTypeId IN (?a)) OR (moreType = ?d AND moreTypeId IN (?a)))', TYPE_ITEM, $this->typeId, TYPE_NPC, array_unique(array_column($cSpawns, 'typeId')) ?: [0], TYPE_OBJECT, array_unique(array_column($oSpawns, 'typeId')) ?: [0]);
     if ($questStartItem) {
         $qsiList = new ItemList(array(['id', array_keys($questStartItem)]));
         if (!$qsiList->error) {
             $this->lvTabs[] = array('file' => 'item', 'data' => $qsiList->getListviewData(), 'params' => ['name' => '$LANG.tab_startsquest', 'id' => 'starts-quest']);
             $this->extendGlobalData($qsiList->getJSGlobals(GLOBALINFO_SELF));
         }
     }
     // tab: Quest Rewards [ids collected by SOM-routine]
     if ($rewardsLV) {
         $rewards = new ItemList(array(['id', array_unique($rewardsLV)]));
         if (!$rewards->error) {
             $this->lvTabs[] = array('file' => 'item', 'data' => $rewards->getListviewData(), 'params' => ['name' => '$LANG.tab_questrewards', 'id' => 'quest-rewards', 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=126;crs=' . $this->typeId . ';crv=0')]);
             $this->extendGlobalData($rewards->getJSGlobals(GLOBALINFO_SELF));
         }
     }
     // tab: achievements
     // tab: fished in zone
     $fish = new Loot();
     if ($fish->getByContainer(LOOT_FISHING, $this->typeId)) {
         $this->extendGlobalData($fish->jsGlobals);
         $xCols = array_merge(['Listview.extraCols.percent'], $fish->extraCols);
         foreach ($fish->iterate() as $lv) {
             if (!$lv['quest']) {
                 continue;
             }
             $xCols = array_merge($xCols, ['Listview.extraCols.condition']);
             $reqQuest[$lv['id']] = 0;
             $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
         }
         $this->lvTabs[] = array('file' => 'item', 'data' => $fish->getResult(), 'params' => ['name' => '$LANG.tab_fishing', 'id' => 'fishing', 'extraCols' => $xCols ? "\$[" . implode(', ', array_unique($xCols)) . "]" : null, 'hiddenCols' => "\$['side']"]);
     }
     // tab: spells
     if ($saData = DB::World()->select('SELECT * FROM spell_area WHERE area = ?d', $this->typeId)) {
         $spells = new SpellList(array(['id', array_column($saData, 'spell')]));
         if (!$spells->error) {
             $lvSpells = $spells->getListviewData();
             $this->extendGlobalData($spells->getJSGlobals());
             $extra = false;
             foreach ($saData as $a) {
                 if (empty($lvSpells[$a['spell']])) {
                     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]];
                 }
                 if ($condition) {
                     $extra = true;
                     $lvSpells[$a['spell']] = array_merge($lvSpells[$a['spell']], ['condition' => $condition]);
                 }
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $lvSpells, 'params' => array('extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, 'hiddenCols' => "\$['skill']"));
         }
     }
     // tab: subzones
     $subZones = new ZoneList(array(['parentArea', $this->typeId]));
     if (!$subZones->error) {
         $this->lvTabs[] = array('file' => 'zone', 'data' => $subZones->getListviewData(), 'params' => ['name' => '$LANG.tab_zones', 'id' => 'subzones', 'hiddenCols' => "\$['territory', 'instancetype']"]);
         $this->extendGlobalData($subZones->getJSGlobals(GLOBALINFO_SELF));
     }
 }
Exemple #13
0
 protected function generateContent()
 {
     $infobox = [];
     $_mask = 1 << $this->typeId - 1;
     $mountVendors = array(null, [384, 33307], [3362, 33553], [1261, 33310], [4730, 33653], [4731, 33555], [3685, 33556], [7955, 33650], [7952, 33554], null, [16264, 33557], [17584, 33657]);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // side
     if ($_ = $this->subject->getField('side')) {
         $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-' . ($_ == 2 ? 'horde' : 'alliance') . ']' . Lang::game('si', $_) . '[/span]';
     }
     // faction
     if ($_ = $this->subject->getField('factionId')) {
         $fac = new FactionList(array(['f.id', $_]));
         $this->extendGlobalData($fac->getJSGlobals());
         $infobox[] = Util::ucFirst(Lang::game('faction')) . Lang::main('colon') . '[faction=' . $fac->id . ']';
     }
     // leader
     if ($_ = $this->subject->getField('leader')) {
         $this->extendGlobalIds(TYPE_NPC, $_);
         $infobox[] = Lang::race('racialLeader') . Lang::main('colon') . '[npc=' . $_ . ']';
     }
     // start area
     if ($_ = $this->subject->getField('startAreaId')) {
         $this->extendGlobalIds(TYPE_ZONE, $_);
         $infobox[] = Lang::race('startZone') . Lang::main('colon') . '[zone=' . $_ . ']';
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     $this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
     $this->headIcons = array('race_' . strtolower($this->subject->getField('fileString')) . '_male', 'race_' . strtolower($this->subject->getField('fileString')) . '_female');
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true);
     /**************/
     /* Extra Tabs */
     /**************/
     // Classes
     $classes = new CharClassList(array(['racemask', $_mask, '&']));
     if (!$classes->error) {
         $this->extendGlobalData($classes->getJSGlobals());
         $this->lvTabs[] = ['class', ['data' => array_values($classes->getListviewData())]];
     }
     // Tongues
     $conditions = array(['typeCat', -11], ['reqRaceMask', $_mask, '&']);
     $tongues = new SpellList($conditions);
     if (!$tongues->error) {
         $this->extendGlobalData($tongues->getJSGlobals());
         $this->lvTabs[] = ['spell', array('data' => array_values($tongues->getListviewData()), 'id' => 'languages', 'name' => '$LANG.tab_languages', 'hiddenCols' => ['reagents'])];
     }
     // Racials
     $conditions = array(['typeCat', -4], ['reqRaceMask', $_mask, '&']);
     $racials = new SpellList($conditions);
     if (!$racials->error) {
         $this->extendGlobalData($racials->getJSGlobals());
         $this->lvTabs[] = ['spell', array('data' => array_values($racials->getListviewData()), 'id' => 'racial-traits', 'name' => '$LANG.tab_racialtraits', 'hiddenCols' => ['reagents'])];
     }
     // Quests
     $conditions = array(['reqRaceMask', $_mask, '&'], [['reqRaceMask', RACE_MASK_HORDE, '&'], RACE_MASK_HORDE, '!'], [['reqRaceMask', RACE_MASK_ALLIANCE, '&'], RACE_MASK_ALLIANCE, '!']);
     $quests = new QuestList($conditions);
     if (!$quests->error) {
         $this->extendGlobalData($quests->getJSGlobals());
         $this->lvTabs[] = ['quest', ['data' => array_values($quests->getListviewData())]];
     }
     // Mounts
     // ok, this sucks, but i rather hardcode the trainer, than fetch items by namepart
     $items = isset($mountVendors[$this->typeId]) ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE entry IN (?a)', $mountVendors[$this->typeId]) : 0;
     $conditions = array(['i.id', $items], ['i.class', ITEM_CLASS_MISC], ['i.subClass', 5]);
     $mounts = new ItemList($conditions);
     if (!$mounts->error) {
         $this->extendGlobalData($mounts->getJSGlobals());
         $this->lvTabs[] = ['item', array('data' => array_values($mounts->getListviewData()), 'id' => 'mounts', 'name' => '$LANG.tab_mounts', 'hiddenCols' => ['slot', 'type'])];
     }
 }
Exemple #14
0
 protected function handleLoad()
 {
     /*  params
                 id: profileId
                 items: string       [itemIds.join(':')]
                 unnamed: unixtime   [only to force the browser to reload instead of cache]
             return
                 lots...
         */
     // titles, achievements, characterData, talents (, pets)
     // and some onLoad-hook to .. load it registerProfile($data)
     // everything else goes through data.php .. strangely enough
     if (!$this->_get['id']) {
         return;
     }
     $char = new ProfileList(array(['id', $this->_get['id'][0]]));
     // or string or whatever
     $buff = '';
     if ($it = array_column($char->getField('inventory'), 0)) {
         $itemz = new ItemList(array(['id', $it, CFG_SQL_LIMIT_NONE]));
         $data = $itemz->getListviewData(ITEMINFO_JSON | ITEMINFO_SUBITEMS);
         // get and apply inventory
         foreach ($itemz->iterate() as $iId => $__) {
             $buff .= 'g_items.add(' . $iId . ', {name_' . User::$localeString . ":'" . Util::jsEscape($itemz->getField('name', true)) . "', quality:" . $itemz->getField('quality') . ", icon:'" . $itemz->getField('iconString') . "', jsonequip:" . Util::toJSON($data[$iId]) . "});\n";
         }
         $buff .= "\n";
     }
     if ($au = $char->getField('auras')) {
         $auraz = new SpellList(array(['id', $char->getField('auras')], CFG_SQL_LIMIT_NONE));
         $dataz = $auraz->getListviewData();
         $modz = $auraz->getProfilerMods();
         // get and apply aura-mods
         foreach ($dataz as $id => $data) {
             $mods = [];
             if (!empty($modz[$id])) {
                 foreach ($modz[$id] as $k => $v) {
                     if (is_array($v)) {
                         $mods[] = $v;
                     } else {
                         if ($str = @Util::$itemMods[$k]) {
                             $mods[$str] = $v;
                         }
                     }
                 }
             }
             $buff .= 'g_spells.add(' . $id . ", {id:" . $id . ", name:'" . Util::jsEscape(mb_substr($data['name'], 1)) . "', icon:'" . $data['icon'] . "', modifier:" . Util::toJSON($mods) . "});\n";
         }
         $buff .= "\n";
     }
     /* depending on progress-achievements
            // required by progress in JScript move to handleLoad()?
            Util::$pageTemplate->extendGlobalIds(TYPE_NPC, [29120, 31134, 29306, 29311, 23980, 27656, 26861, 26723, 28923, 15991]);
        */
     // load available titles
     Util::loadStaticFile('p-titles-' . $char->getField('gender'), $buff, true);
     // load available achievements
     if (!Util::loadStaticFile('p-achievements', $buff, true)) {
         $buff .= "\n\ng_achievement_catorder = [];";
         $buff .= "\n\ng_achievement_points = [0];";
     }
     // excludes; structure UNK type => [maskBit => [typeIds]] ?
     /*
         g_user.excludes = [type:[typeIds]]
         g_user.includes = [type:[typeIds]]
         g_user.excludegroups = groupMask        // requires g_user.settings != null
     
         maskBit are matched against fieldId from excludeGroups
         id: 1, label: LANG.dialog_notavail
         id: 2, label: LANG.dialog_tcg
         id: 4, label: LANG.dialog_collector
         id: 8, label: LANG.dialog_promo
         id: 16, label: LANG.dialog_nonus
         id: 96, label: LANG.dialog_faction
         id: 896, label: LANG.dialog_profession
         id: 1024, label: LANG.dialog_noexalted
     */
     // $buff .= "\n\ng_excludes = {};";
     // add profile to buffer
     $buff .= "\n\n\$WowheadProfiler.registerProfile(" . Util::toJSON($char->getEntry(2)) . ");";
     // can't use JSON_NUMERIC_CHECK or the talent-string becomes a float
     return $buff . "\n";
 }
Exemple #15
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 #16
0
function itemset()
{
    $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU];
    $setToHoliday = array(761 => 141, 762 => 372, 785 => 341, 812 => 181);
    // find events associated with holidayIds
    if ($pairs = DB::World()->selectCol('SELECT holiday AS ARRAY_KEY, eventEntry FROM game_event WHERE holiday IN (?a)', array_values($setToHoliday))) {
        foreach ($setToHoliday as &$hId) {
            $hId = !empty($pairs[$hId]) ? $pairs[$hId] : 0;
        }
    }
    // tags where refId == virtualId
    // in pve sets are not recycled beyond the contentGroup
    $tagsById = array(1 => [181, 182, 183, 184, 185, 186, 187, 188, 189], 2 => [511, 512, 513, 514, 515, 516, 517, 518, 519], 3 => [201, 202, 203, 204, 205, 206, 207, 208, 209], 4 => [210, 211, 212, 213, 214, 215, 216, 217, 218], 5 => [521, 523, 524, 525, 526, 527, 528, 529, 530], 6 => [522, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 697, 718], 7 => [281, 282, 301, 341, 342, 343, 344, 345, 346, 347, 348, 361, 362, 381, 382, 401], 8 => [383, 384, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 402, 717, 698], 9 => [494, 495, 498, 500, 502, 504, 506, 508, 510], 10 => [493, 496, 497, 499, 501, 503, 505, 507, 509], 11 => [477, 480, 474, 475, 476, 478, 479, 481, 482], 12 => [621, 624, 625, 626, 631, 632, 633, 638, 639, 640, 645, 648, 651, 654, 655, 663, 664], 13 => [622, 627, 628, 629, 634, 635, 636, 641, 642, 643, 646, 649, 652, 656, 657, 665, 666], 14 => [620, 623, 630, 637, 644, 647, 650, 653, 658, 659, 660, 661, 662], 15 => [467, 468, 469, 470, 471, 472, 473, 483, 484, 485, 486, 487, 488, 908], 16 => [587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 688, 689, 691, 692, 693, 694, 695, 696], 18 => [668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684], 21 => [738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752], 23 => [795, 805, 804, 803, 802, 801, 800, 799, 798, 797, 796, 794, 793, 792, 791, 790, 789, 788, 787], 25 => [838, 837, 836, 835, 834, 833, 832, 831, 830, 829, 828, 827, 826, 825, 824, 823, 822, 821, 820], 27 => [880, 879, 878, 877, 876, 875, 874, 873, 872, 871, 870, 869, 868, 867, 866, 865, 864, 863, 862, 861, 860, 859, 858, 857, 856, 855, 854, 853, 852, 851, 850, 849, 848, 847, 846, 845, 844, 843], 29 => [901, 900, 899, 898, 897, 896, 895, 894, 893, 892, 891, 890, 889, 888, 887, 886, 885, 884, 883]);
    // well .. f**k
    $tagsByNamePart = array(17 => ['gladiator'], 19 => ['merciless'], 20 => ['vengeful'], 22 => ['brutal'], 24 => ['deadly', 'hateful', 'savage'], 26 => ['furious'], 28 => ['relentless'], 30 => ['wrathful']);
    DB::Aowow()->query('TRUNCATE TABLE ?_itemset');
    $vIdx = 0;
    $virtualId = 0;
    $sets = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM dbc_itemset');
    foreach ($sets as $setId => $setData) {
        $spells = $items = $mods = $descText = $name = $gains = [];
        $max = $reqLvl = $min = $quality = $heroic = $nPieces = [];
        $classMask = $type = 0;
        $hasRing = false;
        $holiday = isset($setToHoliday[$setId]) ? $setToHoliday[$setId] : 0;
        $canReuse = !$holiday;
        // can't reuse holiday-sets
        $slotList = [];
        $pieces = DB::World()->select('SELECT *, IF(InventoryType = 15, 26, IF(InventoryType = 5, 20, InventoryType)) AS slot, entry AS ARRAY_KEY FROM item_template WHERE itemset = ?d AND (class <> 4 OR subclass NOT IN (1, 2, 3, 4) OR armor > 0 OR Quality = 1) ORDER BY itemLevel, subclass, slot ASC', $setId);
        /****************************************/
        /* determine type and reuse from pieces */
        /****************************************/
        // make the first vId always same as setId
        $firstPiece = reset($pieces);
        $tmp = [$firstPiece['Quality'] . $firstPiece['ItemLevel'] => $setId];
        // walk through all items associated with the set
        foreach ($pieces as $itemId => $piece) {
            $classMask |= $piece['AllowableClass'] & CLASS_MASK_ALL;
            $key = $piece['Quality'] . str_pad($piece['ItemLevel'], 3, 0, STR_PAD_LEFT);
            if (!isset($tmp[$key])) {
                $tmp[$key] = --$vIdx;
            }
            $vId = $tmp[$key];
            // check only actual armor in rare quality or higher (or inherits holiday)
            if ($piece['class'] != ITEM_CLASS_ARMOR || $piece['subclass'] == 0) {
                $canReuse = false;
            }
            /* gather relevant stats for use */
            if (!isset($quality[$vId]) || $piece['Quality'] > $quality[$vId]) {
                $quality[$vId] = $piece['Quality'];
            }
            if ($piece['Flags'] & ITEM_FLAG_HEROIC) {
                $heroic[$vId] = true;
            }
            if (!isset($reqLvl[$vId]) || $piece['RequiredLevel'] > $reqLvl[$vId]) {
                $reqLvl[$vId] = $piece['RequiredLevel'];
            }
            if (!isset($min[$vId]) || $piece['ItemLevel'] < $min[$vId]) {
                $min[$vId] = $piece['ItemLevel'];
            }
            if (!isset($max[$vId]) || $piece['ItemLevel'] > $max[$vId]) {
                $max[$vId] = $piece['ItemLevel'];
            }
            if (!isset($items[$vId][$piece['slot']]) || !$canReuse) {
                if (!isset($nPieces[$vId])) {
                    $nPieces[$vId] = 1;
                } else {
                    $nPieces[$vId]++;
                }
            }
            if (isset($items[$vId][$piece['slot']])) {
                // not reusable -> insert anyway on unique keys
                if (!$canReuse) {
                    $items[$vId][$piece['slot'] . $itemId] = $itemId;
                } else {
                    CLISetup::log("set: " . $setId . " ilvl: " . $piece['ItemLevel'] . " - conflict between item: " . $items[$vId][$piece['slot']] . " and item: " . $itemId . " choosing lower itemId", CLISetup::LOG_WARN);
                    if ($items[$vId][$piece['slot']] > $itemId) {
                        $items[$vId][$piece['slot']] = $itemId;
                    }
                }
            } else {
                $items[$vId][$piece['slot']] = $itemId;
            }
            /* check for type */
            // skip cloaks, they mess with armor classes
            if ($piece['slot'] == 16) {
                continue;
            }
            // skip event-sets
            if ($piece['Quality'] == 1) {
                continue;
            }
            if ($piece['class'] == 2 && $piece['subclass'] == 0) {
                $type = 8;
            } else {
                if ($piece['class'] == 2 && $piece['subclass'] == 4) {
                    $type = 9;
                } else {
                    if ($piece['class'] == 2 && $piece['subclass'] == 7) {
                        $type = 10;
                    } else {
                        if ($piece['class'] == 2 && $piece['subclass'] == 13) {
                            $type = 7;
                        } else {
                            if ($piece['class'] == 2 && $piece['subclass'] == 15) {
                                $type = 5;
                            }
                        }
                    }
                }
            }
            // Dagger
            if (!$type) {
                if ($piece['class'] == 4 && $piece['slot'] == 12) {
                    $type = 11;
                } else {
                    if ($piece['class'] == 4 && $piece['slot'] == 2) {
                        $type = 12;
                    } else {
                        if ($piece['class'] == 4 && $piece['subclass'] != 0) {
                            $type = $piece['subclass'];
                        }
                    }
                }
                // 'armor' set
                if ($piece['class'] == 4 && $piece['slot'] == 11) {
                    $hasRing = true;
                }
                // contains ring
            }
        }
        if ($hasRing && !$type) {
            $type = 6;
        }
        // pure ring-set
        $isMultiSet = false;
        $oldSlotMask = 0x0;
        foreach ($items as $subset) {
            $curSlotMask = 0x0;
            foreach ($subset as $slot => $item) {
                $curSlotMask |= 1 << $slot;
            }
            if ($oldSlotMask && $oldSlotMask == $curSlotMask) {
                $isMultiSet = true;
                break;
            }
            $oldSlotMask = $curSlotMask;
        }
        if (!$isMultiSet || !$canReuse || $setId == 555) {
            $temp = [];
            foreach ($items as $subset) {
                foreach ($subset as $slot => $item) {
                    if (isset($temp[$slot]) && $temp[$slot] < $item) {
                        CLISetup::log("set: " . $setId . " - conflict between item: " . $item . " and item: " . $temp[$slot] . " choosing lower itemId", CLISetup::LOG_WARN);
                    } else {
                        if ($slot == 13 || ($slot = 11)) {
                            // special case
                            $temp[] = $item;
                        } else {
                            $temp[$slot] = $item;
                        }
                    }
                }
            }
            $items = [$temp];
            $heroic = [reset($heroic)];
            $nPieces = [count($temp)];
            $quality = [reset($quality)];
            $reqLvl = [reset($reqLvl)];
            $max = $max ? [max($max)] : [0];
            $min = $min ? [min($min)] : [0];
        }
        foreach ($items as &$subsets) {
            $subsets = array_pad($subsets, 10, 0);
        }
        /********************/
        /* calc statbonuses */
        /********************/
        for ($i = 1; $i < 9; $i++) {
            if ($setData['spellId' . $i] > 0 && $setData['itemCount' . $i] > 0) {
                $spells[] = [$setData['spellId' . $i], $setData['itemCount' . $i]];
            }
        }
        $bonusSpells = new SpellList(array(['s.id', array_column($spells, 0)]));
        $mods = $bonusSpells->getStatGain();
        $spells = array_pad($spells, 8, [0, 0]);
        for ($i = 1; $i < 9; $i++) {
            if ($setData['itemCount' . $i] > 0 && !empty($mods[$setData['spellId' . $i]])) {
                $gains[$setData['itemCount' . $i]] = $mods[$setData['spellId' . $i]];
            }
        }
        /**************************/
        /* get name & description */
        /**************************/
        foreach ($locales as $loc) {
            User::useLocale($loc);
            $name[$loc] = Util::localizedString($setData, 'name');
            foreach ($bonusSpells->iterate() as $__) {
                if (!isset($descText[$loc])) {
                    $descText[$loc] = '';
                }
                $descText[$loc] .= $bonusSpells->parseText()[0] . "\n";
            }
            // strip rating blocks - e.g. <!--rtg19-->14&nbsp;<small>(<!--rtg%19-->0.30%&nbsp;@&nbsp;L<!--lvl-->80)</small>
            $descText[$loc] = preg_replace('/<!--rtg\\d+-->(\\d+)&nbsp.*?<\\/small>/i', '\\1', $descText[$loc]);
        }
        /****************************/
        /* finalaize data and write */
        /****************************/
        foreach ($items as $vId => $vSet) {
            $note = 0;
            foreach ($tagsById as $tag => $sets) {
                if (!in_array($setId, $sets)) {
                    continue;
                }
                $note = $tag;
            }
            if (!$note && $min > 120 && $classMask && $classMask != CLASS_MASK_ALL) {
                foreach ($tagsByNamePart as $tag => $strings) {
                    foreach ($strings as $str) {
                        if (isset($pieces[reset($vSet)]) && stripos($pieces[reset($vSet)]['name'], $str) === 0) {
                            $note = $tag;
                            break 2;
                        }
                    }
                }
            }
            $row = [];
            $row[] = $vId < 0 ? --$virtualId : $setId;
            $row[] = $setId;
            // refSetId
            $row[] = 0;
            // cuFlags
            $row = array_merge($row, $name, $vSet);
            foreach (array_column($spells, 0) as $spellId) {
                $row[] = $spellId;
            }
            foreach (array_column($spells, 1) as $nItems) {
                $row[] = $nItems;
            }
            $row = array_merge($row, $descText);
            $row[] = serialize($gains);
            $row[] = $nPieces[$vId];
            $row[] = $min[$vId];
            $row[] = $max[$vId];
            $row[] = $reqLvl[$vId];
            $row[] = $classMask == CLASS_MASK_ALL ? 0 : $classMask;
            $row[] = !empty($heroic[$vId]) ? 1 : 0;
            $row[] = $quality[$vId];
            $row[] = $type;
            $row[] = $note;
            // contentGroup
            $row[] = $holiday;
            $row[] = $setData['reqSkillId'];
            $row[] = $setData['reqSkillLevel'];
            DB::Aowow()->query('REPLACE INTO ?_itemset VALUES (?a)', array_values($row));
        }
    }
    // hide empty sets
    DB::Aowow()->query('UPDATE ?_itemset SET cuFlags = cuFlags | ?d WHERE item1 = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
    return true;
}
Exemple #17
0
function enchants()
{
    // from g_item_slots: 13:"One-Hand", 26:"Ranged", 17:"Two-Hand",
    $slotPointer = [13, 17, 26, 26, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
    $castItems = [];
    $successs = true;
    $enchantSpells = new SpellList([['effect1Id', 53], ['name_loc0', 'QA%', '!'], CFG_SQL_LIMIT_NONE]);
    // enchantItemPermanent && !qualityAssurance
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    $enchIds = [];
    foreach ($enchantSpells->iterate() as $__) {
        $enchIds[] = $enchantSpells->getField('effect1MiscValue');
    }
    $enchMisc = [];
    $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
    foreach (CLISetup::$localeIds as $lId) {
        set_time_limit(120);
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $enchantsOut = [];
        foreach ($enchantSpells->iterate() as $__) {
            // slots have to be recalculated
            $slot = 0;
            if ($enchantSpells->getField('equippedItemClass') == 4) {
                if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask')) {
                    $slot = $invType >> 1;
                } else {
                    /* if (equippedItemSubClassMask == 64) */
                    // shields have it their own way <_<
                    $slot = 1 << 14 - 1;
                }
            } else {
                if ($enchantSpells->getField('equippedItemClass') == 2) {
                    foreach ($slotPointer as $i => $sp) {
                        if (!$sp) {
                            continue;
                        }
                        if (1 << $i & $enchantSpells->getField('equippedItemSubClassMask')) {
                            if ($sp == 13) {
                                // also mainHand & offHand *siiigh*
                                $slot |= 1 << 21 - 1 | 1 << 22 - 1;
                            }
                            $slot |= 1 << $sp - 1;
                        }
                    }
                }
            }
            $eId = $enchantSpells->getField('effect1MiscValue');
            // defaults
            $ench = array('name' => [], 'quality' => -1, 'icon' => strToLower($enchantSpells->getField('iconString')), 'source' => [], 'skill' => -1, 'slots' => [], 'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'), 'jsonequip' => @$enchJSON[$eId] ?: [], 'temp' => 0, 'classes' => 0);
            if (isset($enchMisc[$eId]['reqskill'])) {
                $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskill'];
            }
            if (isset($enchMisc[$eId]['reqskillrank'])) {
                $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskillrank'];
            }
            if (isset($enchMisc[$eId]['requiredLevel'])) {
                $ench['jsonequip']['requiredLevel'] = $enchMisc[$eId]['requiredLevel'];
            }
            // check if the spell has an entry in skill_line_ability -> Source:Profession
            if ($skills = $enchantSpells->getField('skillLines')) {
                $ench['name'][] = $enchantSpells->getField('name', true);
                $ench['source'][] = $enchantSpells->id;
                $ench['skill'] = $skills[0];
                $ench['slots'][] = $slot;
            }
            // check if this spell can be cast via item -> Source:Item
            if (!isset($castItems[$enchantSpells->id])) {
                $castItems[$enchantSpells->id] = new ItemList([['spellId1', $enchantSpells->id], ['name_loc0', 'Scroll of Enchant%', '!']]);
            }
            // do not reuse enchantment scrolls
            $cI =& $castItems[$enchantSpells->id];
            // this construct is a bit .. unwieldy
            foreach ($cI->iterate() as $__) {
                $ench['name'][] = $cI->getField('name', true);
                $ench['source'][] = -$cI->id;
                $ench['icon'] = strTolower($cI->getField('iconString'));
                $ench['slots'][] = $slot;
                if ($cI->getField('quality') > $ench['quality']) {
                    $ench['quality'] = $cI->getField('quality');
                }
                if ($cI->getField('requiredClass') > 0) {
                    $ench['classes'] = $cI->getField('requiredClass');
                    $ench['jsonequip']['classes'] = $cI->getField('requiredClass');
                }
                if (!isset($ench['jsonequip']['reqlevel'])) {
                    if ($cI->getField('requiredLevel') > 0) {
                        $ench['jsonequip']['reqlevel'] = $cI->getField('requiredLevel');
                    }
                }
            }
            // enchant spell not in use
            if (empty($ench['source'])) {
                continue;
            }
            // everything gathered
            if (isset($enchantsOut[$eId])) {
                foreach ($enchantsOut[$eId] as $k => $v) {
                    if (is_array($v)) {
                        while ($pop = array_pop($ench[$k])) {
                            $enchantsOut[$eId][$k][] = $pop;
                        }
                    } else {
                        if ($k == 'quality') {
                            if ($enchantsOut[$eId]['source'][0] > 0 && $ench['source'][0] < 0) {
                                $enchantsOut[$eId][$k] = -1;
                            } else {
                                if ($enchantsOut[$eId]['source'][0] < 0 && $ench['source'][0] > 0) {
                                    $enchantsOut[$eId][$k] = -1;
                                } else {
                                    $enchantsOut[$eId][$k] = $ench[$k];
                                }
                            }
                        } else {
                            if ($enchantsOut[$eId][$k] <= 0) {
                                $enchantsOut[$eId][$k] = $ench[$k];
                            }
                        }
                    }
                }
            } else {
                // nothing yet, create new
                $enchantsOut[$eId] = $ench;
            }
        }
        // walk over each entry and strip single-item arrays
        foreach ($enchantsOut as &$ench) {
            foreach ($ench as $k => $v) {
                if (is_array($v) && count($v) == 1 && $k != 'jsonequip') {
                    $ench[$k] = $v[0];
                }
            }
        }
        $toFile = "var g_enchants = " . Util::toJSON($enchantsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/enchants';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $successs;
}
Exemple #18
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // Event (ignore events, where the object only gets removed)
     if ($_ = DB::World()->selectCol('SELECT DISTINCT IF(ge.holiday, ge.holiday, -ge.eventEntry) FROM game_event ge, game_event_gameobject geg, gameobject g WHERE ge.eventEntry = geg.eventEntry AND g.guid = geg.guid AND g.id = ?d', $this->typeId)) {
         $this->extendGlobalIds(TYPE_WORLDEVENT, $_);
         $ev = [];
         foreach ($_ as $i => $e) {
             $ev[] = ($i % 2 ? '[br]' : ' ') . '[event=' . $e . ']';
         }
         $infobox[] = Util::ucFirst(Lang::game('eventShort')) . Lang::main('colon') . implode(',', $ev);
     }
     // Reaction
     $_ = function ($r) {
         if ($r == 1) {
             return 2;
         }
         if ($r == -1) {
             return 10;
         }
         return;
     };
     $infobox[] = Lang::npc('react') . Lang::main('colon') . '[color=q' . $_($this->subject->getField('A')) . ']A[/color] [color=q' . $_($this->subject->getField('H')) . ']H[/color]';
     // reqSkill
     switch ($this->subject->getField('typeCat')) {
         case -3:
             // Herbalism
             $infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 2) . ' (' . $this->subject->getField('reqSkill') . ')');
             break;
         case -4:
             // Mining
             $infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 3) . ' (' . $this->subject->getField('reqSkill') . ')');
             break;
         case -5:
             // Lockpicking
             $infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 1) . ' (' . $this->subject->getField('reqSkill') . ')');
             break;
         default:
             $locks = Lang::getLocks($this->subject->getField('lockId'));
             $l = '';
             foreach ($locks as $idx => $_) {
                 if ($idx < 0) {
                     continue;
                 }
                 $this->extendGlobalIds(TYPE_ITEM, $idx);
                 $l = Lang::gameObject('key') . Lang::main('colon') . '[item=' . $idx . ']';
             }
             // if no propper item is found use a skill
             if ($locks) {
                 $infobox[] = $l ? $l : array_pop($locks);
             }
     }
     // linked trap
     if ($_ = $this->subject->getField('linkedTrap')) {
         $this->extendGlobalIds(TYPE_OBJECT, $_);
         $infobox[] = Lang::gameObject('trap') . Lang::main('colon') . '[object=' . $_ . ']';
     }
     // trap for
     $trigger = new GameObjectList(array(['linkedTrap', $this->typeId]));
     if (!$trigger->error) {
         $this->extendGlobalData($trigger->getJSGlobals());
         $infobox[] = Lang::gameObject('triggeredBy') . Lang::main('colon') . '[object=' . $trigger->id . ']';
     }
     // SpellFocus
     if ($_ = $this->subject->getField('spellFocusId')) {
         if ($sfo = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE id = ?d', $_)) {
             $infobox[] = '[tooltip name=focus]' . Lang::gameObject('focusDesc') . '[/tooltip][span class=tip tooltip=focus]' . Lang::gameObject('focus') . Lang::main('colon') . Util::localizedString($sfo, 'name') . '[/span]';
         }
     }
     // lootinfo: [min, max, restock]
     if (($_ = $this->subject->getField('lootStack')) && $_[0]) {
         $buff = Lang::item('charges') . Lang::main('colon') . $_[0];
         if ($_[0] < $_[1]) {
             $buff .= Lang::game('valueDelim') . $_[1];
         }
         // since Veins don't have charges anymore, the timer is questionable
         $infobox[] = $_[2] > 1 ? '[tooltip name=restock]' . sprintf(Lang::gameObject('restock'), Util::formatTime($_[2] * 1000)) . '[/tooltip][span class=tip tooltip=restock]' . $buff . '[/span]' : $buff;
     }
     // meeting stone [minLevel, maxLevel, zone]
     if ($this->subject->getField('type') == OBJECT_MEETINGSTONE) {
         if ($_ = $this->subject->getField('mStone')) {
             $this->extendGlobalIds(TYPE_ZONE, $_[2]);
             $m = Lang::game('meetingStone') . Lang::main('colon') . '[zone=' . $_[2] . ']';
             $l = $_[0];
             if ($_[0] > 1 && $_[1] > $_[0]) {
                 $l .= Lang::game('valueDelim') . min($_[1], MAX_LEVEL);
             }
             $infobox[] = $l ? '[tooltip name=meetingstone]' . sprintf(Lang::game('reqLevel'), $l) . '[/tooltip][span class=tip tooltip=meetingstone]' . $m . '[/span]' : $m;
         }
     }
     // capture area [minPlayer, maxPlayer, minTime, maxTime, radius]
     if ($this->subject->getField('type') == OBJECT_CAPTURE_POINT) {
         if ($_ = $this->subject->getField('capture')) {
             $buff = Lang::gameObject('capturePoint');
             if ($_[2] > 1 || $_[0]) {
                 $buff .= Lang::main('colon') . '[ul]';
             }
             if ($_[2] > 1) {
                 $buff .= '[li]' . Lang::game('duration') . Lang::main('colon') . ($_[3] > $_[2] ? Util::FormatTime($_[3] * 1000, true) . ' - ' : null) . Util::FormatTime($_[2] * 1000, true) . '[/li]';
             }
             if ($_[1]) {
                 $buff .= '[li]' . Lang::main('players') . Lang::main('colon') . $_[0] . ($_[1] > $_[0] ? ' - ' . $_[1] : null) . '[/li]';
             }
             if ($_[4]) {
                 $buff .= '[li]' . sprintf(Lang::spell('range'), $_[4]) . '[/li]';
             }
             if ($_[2] > 1 || $_[0]) {
                 $buff .= '[/ul]';
             }
         }
         $infobox[] = $buff;
     }
     // AI
     if (User::isInGroup(U_GROUP_EMPLOYEE)) {
         if ($_ = $this->subject->getField('ScriptName')) {
             $infobox[] = 'Script' . Lang::main('colon') . $_;
         } else {
             if ($_ = $this->subject->getField('AIName')) {
                 $infobox[] = 'AI' . Lang::main('colon') . $_;
             }
         }
     }
     /****************/
     /* Main Content */
     /****************/
     // pageText
     $pageText = [];
     if ($next = $this->subject->getField('pageTextId')) {
         while ($next) {
             $row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next);
             $next = $row['next_page'];
             $pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
         }
     }
     // add conditional js & css
     if ($pageText) {
         $this->addCSS(['path' => 'Book.css']);
         $this->addJS('Book.js');
     }
     // get spawns and path
     $map = null;
     if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL)) {
         $map = ['data' => ['parent' => 'mapper-generic'], 'mapperData' => &$spawns];
         foreach ($spawns as $areaId => &$areaData) {
             $map['extra'][$areaId] = ZoneList::getName($areaId);
         }
     }
     // consider pooled spawns
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->pageText = $pageText;
     $this->map = $map;
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true, BUTTON_VIEW3D => ['displayId' => $this->subject->getField('displayId'), 'type' => TYPE_OBJECT, 'typeId' => $this->typeId]);
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: summoned by
     $conditions = array('OR', ['AND', ['effect1Id', [50, 76, 104, 105, 106, 107]], ['effect1MiscValue', $this->typeId]], ['AND', ['effect2Id', [50, 76, 104, 105, 106, 107]], ['effect2MiscValue', $this->typeId]], ['AND', ['effect3Id', [50, 76, 104, 105, 106, 107]], ['effect3MiscValue', $this->typeId]]);
     $summons = new SpellList($conditions);
     if (!$summons->error) {
         $this->extendGlobalData($summons->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         $this->lvTabs[] = array('file' => 'spell', 'data' => $summons->getListviewData(), 'params' => array('id' => 'summoned-by', 'name' => '$LANG.tab_summonedby'));
     }
     // tab: related spells
     if ($_ = $this->subject->getField('spells')) {
         $relSpells = new SpellList(array(['id', $_]));
         if (!$relSpells->error) {
             $this->extendGlobalData($relSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $data = $relSpells->getListviewData();
             foreach ($data as $relId => $d) {
                 $data[$relId]['trigger'] = array_search($relId, $_);
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spells', 'name' => '$LANG.tab_spells', 'hiddenCols' => "\$['skill']", 'extraCols' => "\$[Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')]"));
         }
     }
     // tab: criteria of
     $acvs = new AchievementList(array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT]], ['ac.value1', $this->typeId]));
     if (!$acvs->error) {
         $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $acvs->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof'));
     }
     // tab: starts quest
     // tab: ends quest
     $startEnd = new QuestList(array(['qse.type', TYPE_OBJECT], ['qse.typeId', $this->typeId]));
     if (!$startEnd->error) {
         $this->extendGlobalData($startEnd->getJSGlobals());
         $lvData = $startEnd->getListviewData();
         $_ = [[], []];
         foreach ($startEnd->iterate() as $id => $__) {
             $m = $startEnd->getField('method');
             if ($m & 0x1) {
                 $_[0][] = $lvData[$id];
             }
             if ($m & 0x2) {
                 $_[1][] = $lvData[$id];
             }
         }
         if ($_[0]) {
             $this->lvTabs[] = array('file' => 'quest', 'data' => $_[0], 'params' => array('name' => '$LANG.tab_starts', 'id' => 'starts'));
         }
         if ($_[1]) {
             $this->lvTabs[] = array('file' => 'quest', 'data' => $_[1], 'params' => array('name' => '$LANG.tab_ends', 'id' => 'ends'));
         }
     }
     // tab: related quests
     if ($_ = $this->subject->getField('reqQuest')) {
         $relQuest = new QuestList(array(['id', $_]));
         if (!$relQuest->error) {
             $this->extendGlobalData($relQuest->getJSGlobals());
             $this->lvTabs[] = array('file' => 'quest', 'data' => $relQuest->getListviewData(), 'params' => array('name' => '$LANG.tab_quests', 'id' => 'quests'));
         }
     }
     // tab: contains
     $reqQuest = [];
     if ($_ = $this->subject->getField('lootId')) {
         $goLoot = new Loot();
         if ($goLoot->getByContainer(LOOT_GAMEOBJECT, $_)) {
             $extraCols = $goLoot->extraCols;
             $hiddenCols = ['source', 'side', 'slot', 'reqlevel'];
             $this->extendGlobalData($goLoot->jsGlobals);
             foreach ($goLoot->iterate() as &$lv) {
                 if (!empty($hiddenCols)) {
                     foreach ($hiddenCols as $k => $str) {
                         if (!empty($lv[$str])) {
                             unset($hiddenCols[$k]);
                         }
                     }
                 }
                 if (!$lv['quest']) {
                     continue;
                 }
                 $extraCols[] = 'Listview.extraCols.condition';
                 $reqQuest[$lv['id']] = 0;
                 $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
             }
             $extraCols[] = 'Listview.extraCols.percent';
             $this->lvTabs[] = array('file' => 'item', 'data' => $goLoot->getResult(), 'params' => array('name' => '$LANG.tab_contains', 'id' => 'contains', 'extraCols' => "\$[" . implode(', ', array_unique($extraCols)) . "]", 'hiddenCols' => $hiddenCols ? '$' . Util::toJSON(array_values($hiddenCols)) : null));
         }
     }
     if ($reqIds = array_keys($reqQuest)) {
         $conditions = array('OR', ['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds], ['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds], ['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds], ['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]);
         $reqQuests = new QuestList($conditions);
         $this->extendGlobalData($reqQuests->getJSGlobals());
         foreach ($reqQuests->iterate() as $qId => $__) {
             if (empty($reqQuests->requires[$qId][TYPE_ITEM])) {
                 continue;
             }
             foreach ($reqIds as $rId) {
                 if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) {
                     $reqQuest[$rId] = $reqQuests->id;
                 }
             }
         }
     }
     // tab: Same model as .. whats the f*****g point..?
     $sameModel = new GameObjectList(array(['displayId', $this->subject->getField('displayId')], ['id', $this->typeId, '!']));
     if (!$sameModel->error) {
         $this->extendGlobalData($sameModel->getJSGlobals());
         $this->lvTabs[] = array('file' => 'object', 'data' => $sameModel->getListviewData(), 'params' => array('name' => '$LANG.tab_samemodelas', 'id' => 'same-model-as'));
     }
 }
Exemple #19
0
 public static function parseItemEnchantment($ench, $raw = false, &$misc = null)
 {
     if (!$ench) {
         return [];
     }
     if (is_numeric($ench)) {
         $ench = [$ench];
     }
     if (!is_array($ench)) {
         return [];
     }
     $enchants = DB::Aowow()->select('SELECT *, Id AS ARRAY_KEY FROM ?_itemenchantment WHERE id IN (?a)', $ench);
     if (!$enchants) {
         return [];
     }
     $result = [];
     foreach ($enchants as $eId => $e) {
         $misc[$eId] = array('name' => self::localizedString($e, 'text'), 'text' => array('text_loc0' => $e['text_loc0'], 'text_loc2' => $e['text_loc2'], 'text_loc3' => $e['text_loc3'], 'text_loc6' => $e['text_loc6'], 'text_loc8' => $e['text_loc8']));
         if ($e['skillLine'] > 0) {
             $misc[$eId]['reqskill'] = $e['skillLine'];
         }
         if ($e['skillLevel'] > 0) {
             $misc[$eId]['reqskillrank'] = $e['skillLevel'];
         }
         if ($e['requiredLevel'] > 0) {
             $misc[$eId]['reqlevel'] = $e['requiredLevel'];
         }
         // parse stats
         $jsonStats = [];
         for ($h = 1; $h <= 3; $h++) {
             $obj = (int) $e['object' . $h];
             $val = (int) $e['amount' . $h];
             switch ($e['type' . $h]) {
                 case 2:
                     $obj = ITEM_MOD_WEAPON_DMG;
                     break;
                 case 3:
                 case 7:
                     $spl = new SpellList(array(['s.id', $obj]));
                     if (!$spl->error) {
                         Util::arraySumByKey($jsonStats, $spl->getStatGain()[$obj]);
                     }
                     $obj = null;
                     break;
                 case 4:
                     switch ($obj) {
                         case 0:
                             // Physical
                             $obj = ITEM_MOD_ARMOR;
                             break;
                         case 1:
                             // Holy
                             $obj = ITEM_MOD_HOLY_RESISTANCE;
                             break;
                         case 2:
                             // Fire
                             $obj = ITEM_MOD_FIRE_RESISTANCE;
                             break;
                         case 3:
                             // Nature
                             $obj = ITEM_MOD_NATURE_RESISTANCE;
                             break;
                         case 4:
                             // Frost
                             $obj = ITEM_MOD_FROST_RESISTANCE;
                             break;
                         case 5:
                             // Shadow
                             $obj = ITEM_MOD_SHADOW_RESISTANCE;
                             break;
                         case 6:
                             // Arcane
                             $obj = ITEM_MOD_ARCANE_RESISTANCE;
                             break;
                         default:
                             $obj = null;
                     }
                     break;
                 case 5:
                     break;
                 default:
                     // skip assignment below
                     $obj = null;
             }
             if ($obj) {
                 if (!isset($jsonStats[$obj])) {
                     $jsonStats[$obj] = 0;
                 }
                 $jsonStats[$obj] += $val;
             }
         }
         if ($raw) {
             $result[$eId] = $jsonStats;
         } else {
             $result[$eId] = [];
             foreach ($jsonStats as $k => $v) {
                 // check if we use these mods
                 if ($str = Util::$itemMods[$k]) {
                     $result[$eId][$str] = $v;
                 }
             }
         }
     }
     return $result;
 }
Exemple #20
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     $_itemId = $this->subject->getField('itemId');
     /***********/
     /* Infobox */
     /**********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     if ($this->typeId == 103) {
         // Arena Points
         $infobox[] = Lang::currency('cap') . Lang::main('colon') . '10\'000';
     } else {
         if ($this->typeId == 104) {
             // Honor
             $infobox[] = Lang::currency('cap') . Lang::main('colon') . '75\'000';
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->name = $this->subject->getField('name', true);
     $this->headIcons = $this->typeId == 104 ? ['inv_bannerpvp_02', 'inv_bannerpvp_01'] : [$this->subject->getField('iconString')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true);
     /**************/
     /* Extra Tabs */
     /**************/
     if ($this->typeId != 103 && $this->typeId != 104) {
         // tabs: this currency is contained in..
         $lootTabs = new Loot();
         if ($lootTabs->getByItem($_itemId)) {
             $this->extendGlobalData($lootTabs->jsGlobals);
             foreach ($lootTabs->iterate() as $tab) {
                 $this->lvTabs[] = array('file' => $tab[0], 'data' => $tab[1], 'params' => ['name' => $tab[2], 'id' => $tab[3], 'extraCols' => $tab[4] ? '$[' . implode(', ', array_unique($tab[4])) . ']' : null, 'hiddenCols' => $tab[5] ? '$[' . implode(', ', array_unique($tab[5])) . ']' : null, 'visibleCols' => $tab[6] ? '$' . Util::toJSON(array_unique($tab[6])) : null]);
             }
         }
         // tab: sold by
         $itemObj = new ItemList(array(['id', $_itemId]));
         if (!empty($itemObj->getExtendedCost()[$_itemId])) {
             $vendors = $itemObj->getExtendedCost()[$_itemId];
             $this->extendGlobalData($itemObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $soldBy = new CreatureList(array(['id', array_keys($vendors)]));
             if (!$soldBy->error) {
                 $sbData = $soldBy->getListviewData();
                 $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost'];
                 $holidays = [];
                 foreach ($sbData as $k => &$row) {
                     $items = [];
                     $tokens = [];
                     foreach ($vendors[$k] as $id => $qty) {
                         if (is_string($id)) {
                             continue;
                         }
                         if ($id > 0) {
                             $tokens[] = [$id, $qty];
                         } else {
                             if ($id < 0) {
                                 $items[] = [-$id, $qty];
                             }
                         }
                     }
                     if ($vendors[$k]['event']) {
                         if (count($extraCols) == 3) {
                             // not already pushed
                             $extraCols[] = 'Listview.extraCols.condition';
                         }
                         $this->extendGlobalIds(TYPE_WORLDEVENT, $vendors[$k]['event']);
                         $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $vendors[$k]['event']]];
                     }
                     $row['stock'] = $vendors[$k]['stock'];
                     $row['stack'] = $itemObj->getField('buyCount');
                     $row['cost'] = array($itemObj->getField('buyPrice'), $items ? $items : null, $tokens ? $tokens : null);
                 }
                 $this->lvTabs[] = array('file' => 'creature', 'data' => $sbData, 'params' => ['name' => '$LANG.tab_soldby', 'id' => 'sold-by-npc', 'extraCols' => '$[' . implode(', ', $extraCols) . ']', 'hiddenCols' => "\$['level', 'type']"]);
             }
         }
     }
     // tab: created by (spell) [for items its handled in Loot::getByContainer()]
     if ($this->typeId == 104) {
         $createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR'));
         if (!$createdBy->error) {
             $this->extendGlobalData($createdBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             if ($createdBy->hasSetFields(['reagent1'])) {
                 $visCols = ['reagents'];
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $createdBy->getListviewData(), 'params' => ['name' => '$LANG.tab_createdby', 'id' => 'created-by', 'visibleCols' => isset($visCols) ? '$' . Util::toJSON($visCols) : null]);
         }
     }
     // tab: currency for
     if ($this->typeId == 103) {
         $n = '?items&filter=cr=145;crs=1;crv=0';
         $w = 'reqArenaPoints > 0';
     } else {
         if ($this->typeId == 104) {
             $n = '?items&filter=cr=144;crs=1;crv=0';
             $w = 'reqHonorPoints > 0';
         } else {
             $n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs=' . $_itemId . ';crv=0' : null;
             $w = 'reqItemId1 = ' . $_itemId . ' OR reqItemId2 = ' . $_itemId . ' OR reqItemId3 = ' . $_itemId . ' OR reqItemId4 = ' . $_itemId . ' OR reqItemId5 = ' . $_itemId;
         }
     }
     $xCosts = DB::Aowow()->selectCol('SELECT id FROM ?_itemextendedcost WHERE ' . $w);
     $boughtBy = $xCosts ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE extendedCost IN (?a) UNION SELECT item FROM game_event_npc_vendor WHERE extendedCost IN (?a)', $xCosts, $xCosts) : [];
     if ($boughtBy) {
         $boughtBy = new ItemList(array(['id', $boughtBy]));
         if (!$boughtBy->error) {
             if ($boughtBy->getMatches() <= CFG_SQL_LIMIT_DEFAULT) {
                 $n = null;
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $this->typeId]), 'params' => ['name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', 'extraCols' => "\$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')]", 'note' => $n ? sprintf(Util::$filterResultString, $n) : null]);
             $this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
 }
Exemple #21
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     $_typeFlags = $this->subject->getField('typeFlags');
     $_altIds = [];
     $_altNPCs = null;
     $placeholder = null;
     $accessory = [];
     // difficulty entries of self
     if ($this->subject->getField('cuFlags') & NPC_CU_DIFFICULTY_DUMMY) {
         $placeholder = [$this->subject->getField('parentId'), $this->subject->getField('parent', true)];
     } else {
         for ($i = 1; $i < 4; $i++) {
             if ($_ = $this->subject->getField('difficultyEntry' . $i)) {
                 $_altIds[$_] = $i;
             }
         }
         if ($_altIds) {
             $_altNPCs = new CreatureList(array(['id', array_keys($_altIds)]));
         }
     }
     if ($_ = DB::World()->selectCol('SELECT DISTINCT entry FROM vehicle_template_accessory WHERE accessory_entry = ?d', $this->typeId)) {
         $vehicles = new CreatureList(array(['id', $_]));
         foreach ($vehicles->iterate() as $id => $__) {
             $accessory[] = [$id, $vehicles->getField('name', true)];
         }
     }
     // try to determine, if it's spawned in a dungeon or raid (shaky at best, if spawned by script)
     $mapType = 0;
     if ($maps = DB::Aowow()->selectCol('SELECT DISTINCT areaId from ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $this->typeId)) {
         if (count($maps) == 1) {
             switch (DB::Aowow()->selectCell('SELECT `type` FROM ?_zones WHERE id = ?d', $maps[0])) {
                 case 2:
                 case 5:
                     $mapType = 1;
                     break;
                 case 3:
                 case 7:
                 case 8:
                     $mapType = 2;
                     break;
             }
         }
     } else {
         if ($_altIds) {
             if (count($_altIds) > 1) {
                 // 3 or more version -> definitly raid (10/25 + hc)
                 $mapType = 2;
             } else {
                 // 2 versions; may be Heroic (use this), but may also be 10/25-raid
                 $mapType = 1;
             }
         }
     }
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // Event (ignore events, where the object only gets removed)
     if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.eventEntry FROM game_event ge, game_event_creature gec, creature c WHERE ge.eventEntry = gec.eventEntry AND c.guid = gec.guid AND c.id = ?d', $this->typeId)) {
         $this->extendGlobalIds(TYPE_WORLDEVENT, $_);
         $ev = [];
         foreach ($_ as $i => $e) {
             $ev[] = ($i % 2 ? '[br]' : ' ') . '[event=' . $e . ']';
         }
         $infobox[] = Util::ucFirst(Lang::game('eventShort')) . Lang::main('colon') . implode(',', $ev);
     }
     // Level
     if ($this->subject->getField('rank') != NPC_RANK_BOSS) {
         $level = $this->subject->getField('minLevel');
         $maxLvl = $this->subject->getField('maxLevel');
         if ($level < $maxLvl) {
             $level .= ' - ' . $maxLvl;
         }
     } else {
         // Boss Level
         $level = '??';
     }
     $infobox[] = Lang::game('level') . Lang::main('colon') . $level;
     // Classification
     if ($_ = $this->subject->getField('rank')) {
         $str = $_typeFlags & 0x4 ? '[span class=icon-boss]' . Lang::npc('rank', $_) . '[/span]' : Lang::npc('rank', $_);
         $infobox[] = Lang::npc('classification') . Lang::main('colon') . $str;
     }
     // Reaction
     $_ = function ($r) {
         if ($r == 1) {
             return 2;
         }
         if ($r == -1) {
             return 10;
         }
         return;
     };
     $infobox[] = Lang::npc('react') . Lang::main('colon') . '[color=q' . $_($this->subject->getField('A')) . ']A[/color] [color=q' . $_($this->subject->getField('H')) . ']H[/color]';
     // Faction
     $this->extendGlobalIds(TYPE_FACTION, $this->subject->getField('factionId'));
     $infobox[] = Util::ucFirst(Lang::game('faction')) . Lang::main('colon') . '[faction=' . $this->subject->getField('factionId') . ']';
     // Tameable
     if ($_typeFlags & 0x1) {
         if ($_ = $this->subject->getField('family')) {
             $infobox[] = sprintf(Lang::npc('tameable'), '[url=pet=' . $_ . ']' . Lang::game('fa', $_) . '[/url]');
         }
     }
     // Wealth
     if ($_ = intVal(($this->subject->getField('minGold') + $this->subject->getField('maxGold')) / 2)) {
         $infobox[] = Lang::npc('worth') . Lang::main('colon') . '[tooltip=tooltip_avgmoneydropped][money=' . $_ . '][/tooltip]';
     }
     // is Vehicle
     if ($this->subject->getField('vehicleId')) {
         $infobox[] = Lang::npc('vehicle');
     }
     // AI
     if (User::isInGroup(U_GROUP_EMPLOYEE)) {
         if ($_ = $this->subject->getField('scriptName')) {
             $infobox[] = 'Script' . Lang::main('colon') . $_;
         } else {
             if ($_ = $this->subject->getField('aiName')) {
                 $infobox[] = 'AI' . Lang::main('colon') . $_;
             }
         }
     }
     if (User::isInGroup(U_GROUP_STAFF)) {
         // Mechanic immune
         if ($immuneMask = $this->subject->getField('mechanicImmuneMask')) {
             $buff = [];
             for ($i = 0; $i < 31; $i++) {
                 if ($immuneMask & 1 << $i) {
                     $buff[] = (!fMod(count($buff), 3) ? "\n" : null) . '[url=?spells&filter=me=' . ($i + 1) . ']' . Lang::game('me', $i + 1) . '[/url]';
                 }
             }
             $infobox[] = 'Not affected by mechanic' . Lang::main('colon') . implode(', ', $buff);
         }
         // extra flags
         if ($flagsExtra = $this->subject->getField('flagsExtra')) {
             $buff = [];
             if ($flagsExtra & 0x1) {
                 $buff[] = 'Binds attacker to instance on death';
             }
             if ($flagsExtra & 0x2) {
                 $buff[] = "[tooltip name=civilian]- does not aggro\n- death costs Honor[/tooltip][span class=tip tooltip=civilian]Civilian[/span]";
             }
             if ($flagsExtra & 0x4) {
                 $buff[] = 'Cannot parry';
             }
             if ($flagsExtra & 0x8) {
                 $buff[] = 'Has no parry haste';
             }
             if ($flagsExtra & 0x10) {
                 $buff[] = 'Cannot block';
             }
             if ($flagsExtra & 0x20) {
                 $buff[] = 'Cannot deal Crushing Blows';
             }
             if ($flagsExtra & 0x40) {
                 $buff[] = 'Rewards no experience';
             }
             if ($flagsExtra & 0x80) {
                 $buff[] = 'Trigger-Creature';
             }
             if ($flagsExtra & 0x100) {
                 $buff[] = 'Immune to Taunt';
             }
             if ($flagsExtra & 0x8000) {
                 $buff[] = "[tooltip name=guard]- engages PvP-Attacker\n- ignores enemy stealth, invisibility and Feign Death[/tooltip][span class=tip tooltip=guard]Guard[/span]";
             }
             if ($flagsExtra & 0x20000) {
                 $buff[] = 'Cannot deal Critical Hits';
             }
             if ($flagsExtra & 0x40000) {
                 $buff[] = 'Attacker does not gain weapon skill';
             }
             if ($flagsExtra & 0x80000) {
                 $buff[] = 'Taunt has diminishing returns';
             }
             if ($flagsExtra & 0x100000) {
                 $buff[] = 'Is subject to diminishing returns';
             }
             if ($buff) {
                 $infobox[] = 'Extra Flags' . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $buff) . '[/li][/ul]';
             }
         }
     }
     // > Stats
     $stats = [];
     $modes = [];
     // get difficulty versions if set
     $hint = '[tooltip name=%3$s][table cellspacing=10][tr]%1s[/tr][/table][/tooltip][span class=tip tooltip=%3$s]%2s[/span]';
     $modeRow = '[tr][td]%s&nbsp;&nbsp;[/td][td]%s[/td][/tr]';
     // Health
     $health = $this->subject->getBaseStats('health');
     $stats['health'] = Util::ucFirst(Lang::spell('powerTypes', -2)) . Lang::main('colon') . ($health[0] < $health[1] ? Lang::nf($health[0]) . ' - ' . Lang::nf($health[1]) : Lang::nf($health[0]));
     // Mana (may be 0)
     $mana = $this->subject->getBaseStats('power');
     $stats['mana'] = $mana[0] ? Lang::spell('powerTypes', 0) . Lang::main('colon') . ($mana[0] < $mana[1] ? Lang::nf($mana[0]) . ' - ' . Lang::nf($mana[1]) : Lang::nf($mana[0])) : null;
     // Armor
     $armor = $this->subject->getBaseStats('armor');
     $stats['armor'] = Lang::npc('armor') . Lang::main('colon') . ($armor[0] < $armor[1] ? Lang::nf($armor[0]) . ' - ' . Lang::nf($armor[1]) : Lang::nf($armor[0]));
     // Melee Damage
     $melee = $this->subject->getBaseStats('melee');
     if ($_ = $this->subject->getField('dmgSchool')) {
         // magic damage
         $stats['melee'] = Lang::npc('melee') . Lang::main('colon') . Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]) . ' (' . Lang::game('sc', $_) . ')';
     } else {
         // phys. damage
         $stats['melee'] = Lang::npc('melee') . Lang::main('colon') . Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]);
     }
     // Ranged Damage
     $ranged = $this->subject->getBaseStats('ranged');
     $stats['ranged'] = Lang::npc('ranged') . Lang::main('colon') . Lang::nf($ranged[0]) . ' - ' . Lang::nf($ranged[1]);
     if (in_array($mapType, [1, 2])) {
         foreach ($_altIds as $id => $mode) {
             foreach ($_altNPCs->iterate() as $dId => $__) {
                 if ($dId != $id) {
                     continue;
                 }
                 $m = Lang::npc('modes', $mapType, $mode);
                 // Health
                 $health = $_altNPCs->getBaseStats('health');
                 $modes['health'][] = sprintf($modeRow, $m, $health[0] < $health[1] ? Lang::nf($health[0]) . ' - ' . Lang::nf($health[1]) : Lang::nf($health[0]));
                 // Mana (may be 0)
                 $mana = $_altNPCs->getBaseStats('power');
                 $modes['mana'][] = $mana[0] ? sprintf($modeRow, $m, $mana[0] < $mana[1] ? Lang::nf($mana[0]) . ' - ' . Lang::nf($mana[1]) : Lang::nf($mana[0])) : null;
                 // Armor
                 $armor = $_altNPCs->getBaseStats('armor');
                 $modes['armor'][] = sprintf($modeRow, $m, $armor[0] < $armor[1] ? Lang::nf($armor[0]) . ' - ' . Lang::nf($armor[1]) : Lang::nf($armor[0]));
                 // Melee Damage
                 $melee = $_altNPCs->getBaseStats('melee');
                 if ($_ = $_altNPCs->getField('dmgSchool')) {
                     // magic damage
                     $modes['melee'][] = sprintf($modeRow, $m, Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]) . ' (' . Lang::game('sc', $_) . ')');
                 } else {
                     // phys. damage
                     $modes['melee'][] = sprintf($modeRow, $m, Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]));
                 }
                 // Ranged Damage
                 $ranged = $_altNPCs->getBaseStats('ranged');
                 $modes['ranged'][] = sprintf($modeRow, $m, Lang::nf($ranged[0]) . ' - ' . Lang::nf($ranged[1]));
             }
         }
     }
     if ($modes) {
         foreach ($stats as $k => $v) {
             if ($v) {
                 $stats[$k] = sprintf($hint, implode('[/tr][tr]', $modes[$k]), $v, $k);
             }
         }
     }
     // < Stats
     if ($stats) {
         $infobox[] = Lang::npc('stats') . ($modes ? ' (' . Lang::npc('modes', $mapType, 0) . ')' : null) . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $stats) . '[/li][/ul]';
     }
     /****************/
     /* Main Content */
     /****************/
     // get spawns and path
     $map = null;
     if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL)) {
         $map = ['data' => ['parent' => 'mapper-generic'], 'mapperData' => &$spawns];
         foreach ($spawns as $areaId => &$areaData) {
             $map['extra'][$areaId] = ZoneList::getName($areaId);
         }
     }
     // consider pooled spawns
     $this->map = $map;
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     $this->placeholder = $placeholder;
     $this->accessory = $accessory;
     $this->quotes = $this->getQuotes();
     $this->reputation = $this->getOnKillRep($_altIds, $mapType);
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true, BUTTON_VIEW3D => ['type' => TYPE_NPC, 'typeId' => $this->typeId, 'displayId' => $this->subject->getRandomModelId()]);
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: SAI
     // hmm, how should this look like
     // tab: abilities / tab_controlledabilities (dep: VehicleId)
     // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86
     $smartSpells = DB::World()->selectCol('SELECT action_param1 FROM smart_scripts WHERE source_type = 0 AND action_type IN (11, 75, 85, 86) AND entryOrGUID = ?d', $this->typeId);
     $tplSpells = [];
     $conditions = ['OR'];
     for ($i = 1; $i < 9; $i++) {
         if ($_ = $this->subject->getField('spell' . $i)) {
             $tplSpells[] = $_;
         }
     }
     if ($tplSpells) {
         $conditions[] = ['id', $tplSpells];
     }
     if ($smartSpells) {
         $conditions[] = ['id', $smartSpells];
     }
     // Pet-Abilities
     if ($_typeFlags & 0x1 && ($_ = $this->subject->getField('family'))) {
         $skill = 0;
         $mask = 0x0;
         foreach (Util::$skillLineMask[-1] as $idx => $pair) {
             if ($pair[0] != $_) {
                 continue;
             }
             $skill = $pair[1];
             $mask = 1 << $idx;
             break;
         }
         $conditions[] = ['AND', ['s.typeCat', -3], ['OR', ['skillLine1', $skill], ['AND', ['skillLine1', 0, '>'], ['skillLine2OrMask', $skill]], ['AND', ['skillLine1', -1], ['skillLine2OrMask', $mask, '&']]]];
     }
     if (count($conditions) > 1) {
         $abilities = new SpellList($conditions);
         if (!$abilities->error) {
             $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $controled = $abilities->getListviewData();
             $normal = [];
             foreach ($controled as $id => $values) {
                 if (in_array($id, $smartSpells)) {
                     $normal[$id] = $values;
                     unset($controled[$id]);
                     continue;
                 }
                 // not quite right. All seats should be checked for allowed-to-cast-flag-something
                 if (!$this->subject->getField('vehicleId') && in_array($id, $tplSpells)) {
                     $normal[$id] = $values;
                     unset($controled[$id]);
                 }
             }
             if ($normal) {
                 $this->lvTabs[] = array('file' => 'spell', 'data' => $normal, 'params' => array('name' => '$LANG.tab_abilities', 'id' => 'abilities'));
             }
             if ($controled) {
                 $this->lvTabs[] = array('file' => 'spell', 'data' => $controled, 'params' => array('name' => '$LANG.tab_controlledabilities', 'id' => 'controlled-abilities'));
             }
         }
     }
     // tab: summoned by
     $conditions = array('OR', ['AND', ['effect1Id', 28], ['effect1MiscValue', $this->typeId]], ['AND', ['effect2Id', 28], ['effect2MiscValue', $this->typeId]], ['AND', ['effect3Id', 28], ['effect3MiscValue', $this->typeId]]);
     $summoned = new SpellList($conditions);
     if (!$summoned->error) {
         $this->extendGlobalData($summoned->getJSGlobals());
         $this->lvTabs[] = array('file' => 'spell', 'data' => $summoned->getListviewData(), 'params' => array('name' => '$LANG.tab_summonedby', 'id' => 'summoned-by'));
     }
     // tab: teaches
     if ($this->subject->getField('npcflag') & NPC_FLAG_TRAINER) {
         $teachQuery = '
             SELECT    IFNULL(t2.SpellID, t1.SpellID) AS ARRAY_KEY,
                       IFNULL(t2.MoneyCost, t1.MoneyCost) AS cost,
                       IFNULL(t2.ReqSkillLine, t1.ReqSkillLine) AS reqSkillId,
                       IFNULL(t2.ReqSkillRank, t1.ReqSkillRank) AS reqSkillValue,
                       IFNULL(t2.ReqLevel, t1.ReqLevel) AS reqLevel
             FROM      npc_trainer t1
             LEFT JOIN npc_trainer t2 ON t2.ID = IF(t1.SpellID < 0, -t1.SpellID, null)
             WHERE     t1.ID = ?d
         ';
         if ($tSpells = DB::World()->select($teachQuery, $this->typeId)) {
             $teaches = new SpellList(array(['id', array_keys($tSpells)]));
             if (!$teaches->error) {
                 $this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
                 $data = $teaches->getListviewData();
                 $extra = [];
                 foreach ($tSpells as $sId => $train) {
                     if (empty($data[$sId])) {
                         continue;
                     }
                     if ($_ = $train['reqSkillId']) {
                         $this->extendGlobalIds(TYPE_SKILL, $_);
                         if (!isset($extra[0])) {
                             $extra[0] = 'Listview.extraCols.condition';
                         }
                         $data[$sId]['condition'][0][$this->typeId][] = [[CND_SKILL, $_, $train['reqSkillValue']]];
                     }
                     if ($_ = $train['reqLevel']) {
                         if (!isset($extra[1])) {
                             $extra[1] = "Listview.funcBox.createSimpleCol('reqLevel', LANG.tooltip_reqlevel, '7%', 'reqLevel')";
                         }
                         $data[$sId]['reqLevel'] = $_;
                     }
                     if ($_ = $train['cost']) {
                         $data[$sId]['trainingcost'] = $_;
                     }
                 }
                 $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('name' => '$LANG.tab_teaches', 'id' => 'teaches', 'visibleCols' => "\$['trainingcost']", 'extraCols' => $extra ? '$[' . implode(', ', $extra) . ']' : null));
             }
         } else {
             trigger_error('NPC ' . $this->typeId . ' is flagged as trainer, but doesn\'t have any spells set', E_USER_WARNING);
         }
     }
     // tab: sells
     if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry = ?d UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id = ?d', $this->typeId, $this->typeId)) {
         $soldItems = new ItemList(array(['id', $sells]));
         if (!$soldItems->error) {
             $extraCols = ["Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost'];
             if ($soldItems->hasSetFields(['condition'])) {
                 $extraCols[] = 'Listview.extraCols.condition';
             }
             $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [TYPE_NPC => [$this->typeId]]);
             $sc = Util::getServerConditions(CND_SRC_NPC_VENDOR, $this->typeId);
             if (!empty($sc[0])) {
                 $this->extendGlobalData($sc[1]);
                 if (!array_search('Listview.extraCols.condition', $extraCols)) {
                     $extraCols[] = 'Listview.extraCols.condition';
                 }
                 foreach ($lvData as $id => &$row) {
                     foreach ($sc[0] as $srcType => $cndData) {
                         if (!empty($cndData[$id . ':' . $this->typeId])) {
                             $row['condition'][0][$id . ':' . $this->typeId] = $cndData[$id . ':' . $this->typeId];
                         }
                     }
                 }
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $lvData, 'params' => array('name' => '$LANG.tab_sells', 'id' => 'currency-for', 'extraCols' => '$[' . implode(', ', $extraCols) . ']'));
             $this->extendGlobalData($soldItems->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
     // tabs: this creature contains..
     $skinTab = ['tab_skinning', 'skinning'];
     if ($_typeFlags & NPC_TYPEFLAG_HERBLOOT) {
         $skinTab = ['tab_herbalism', 'herbalism'];
     } else {
         if ($_typeFlags & NPC_TYPEFLAG_MININGLOOT) {
             $skinTab = ['tab_mining', 'mining'];
         } else {
             if ($_typeFlags & NPC_TYPEFLAG_ENGINEERLOOT) {
                 $skinTab = ['tab_engineering', 'engineering'];
             }
         }
     }
     /*
             extraCols: [Listview.extraCols.count, Listview.extraCols.percent, Listview.extraCols.mode],
             _totalCount: 22531,
             computeDataFunc: Listview.funcBox.initLootTable,
             onAfterCreate: Listview.funcBox.addModeIndicator,
     
             modes:{"mode":1,"1":{"count":4408,"outof":16013},"4":{"count":4408,"outof":22531}}
     */
     $sourceFor = array([LOOT_CREATURE, $this->subject->getField('lootId'), '$LANG.tab_drops', 'drops', []], [LOOT_PICKPOCKET, $this->subject->getField('pickpocketLootId'), '$LANG.tab_pickpocketing', 'pickpocketing', ['side', 'slot', 'reqlevel']], [LOOT_SKINNING, $this->subject->getField('skinLootId'), '$LANG.' . $skinTab[0], $skinTab[1], ['side', 'slot', 'reqlevel']]);
     // temp: manually add loot for difficulty-versions
     $langref = array("-2" => '$LANG.tab_heroic', "-1" => '$LANG.tab_normal', 1 => '$$WH.sprintf(LANG.tab_normalX, 10)', 2 => '$$WH.sprintf(LANG.tab_normalX, 25)', 3 => '$$WH.sprintf(LANG.tab_heroicX, 10)', 4 => '$$WH.sprintf(LANG.tab_heroicX, 25)');
     if ($_altIds) {
         $sourceFor[0][2] = $mapType == 1 ? $langref[-1] : $langref[1];
         foreach ($_altNPCs->iterate() as $id => $__) {
             $mode = ($_altIds[$id] + 1) * ($mapType == 1 ? -1 : 1);
             if ($lootGO = DB::Aowow()->selectRow('SELECT o.id, o.lootId, o.name_loc0, o.name_loc2, o.name_loc3, o.name_loc6, o.name_loc8 FROM ?_loot_link l JOIN ?_objects o ON o.id = l.objectId WHERE l.npcId = ?d', $id)) {
                 array_splice($sourceFor, 1, 0, [[LOOT_GAMEOBJECT, $lootGO['lootId'], $langref[$mode], 'drops-object-' . abs($mode), [], 'note' => '$$WH.sprintf(LANG.lvnote_npcobjectsource, ' . $lootGO['id'] . ', \'' . Util::jsEscape(Util::localizedString($lootGO, 'name')) . '\')']]);
             }
             if ($lootId = $_altNPCs->getField('lootId')) {
                 array_splice($sourceFor, 1, 0, [[LOOT_CREATURE, $lootId, $langref[$mode], 'drops-' . abs($mode), []]]);
             }
         }
     }
     if ($lootGOs = DB::Aowow()->select('SELECT o.id, IF(npcId < 0, 1, 0) AS modeDummy, o.lootId, o.name_loc0, o.name_loc2, o.name_loc3, o.name_loc6, o.name_loc8 FROM ?_loot_link l JOIN ?_objects o ON o.id = l.objectId WHERE ABS(l.npcId) = ?d', $this->typeId)) {
         foreach ($lootGOs as $idx => $lgo) {
             array_splice($sourceFor, 1, 0, [[LOOT_GAMEOBJECT, $lgo['lootId'], $mapType ? $langref[($mapType == 1 ? -1 : 1) + ($lgo['modeDummy'] ? 1 : 0)] : '$LANG.tab_drops', 'drops-object-' . $idx, [], 'note' => '$$WH.sprintf(LANG.lvnote_npcobjectsource, ' . $lgo['id'] . ', \'' . Util::jsEscape(Util::localizedString($lgo, 'name')) . '\')']]);
         }
     }
     $reqQuest = [];
     foreach ($sourceFor as $sf) {
         $creatureLoot = new Loot();
         if ($creatureLoot->getByContainer($sf[0], $sf[1])) {
             $extraCols = $creatureLoot->extraCols;
             $extraCols[] = 'Listview.extraCols.percent';
             $this->extendGlobalData($creatureLoot->jsGlobals);
             foreach ($creatureLoot->iterate() as &$lv) {
                 if (!$lv['quest']) {
                     continue;
                 }
                 $extraCols[] = 'Listview.extraCols.condition';
                 $reqQuest[$lv['id']] = 0;
                 $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
             }
             $lootTab = array('file' => 'item', 'data' => $creatureLoot->getResult(), 'params' => array('name' => $sf[2], 'id' => $sf[3], 'extraCols' => "\$[" . implode(', ', array_unique($extraCols)) . "]", 'hiddenCols' => $sf[4] ? "\$" . Util::toJSON($sf[4]) : null, 'sort' => "\$['-percent', 'name']"));
             if (!empty($sf['note'])) {
                 $lootTab['params']['note'] = $sf['note'];
             }
             $this->lvTabs[] = $lootTab;
         }
     }
     if ($reqIds = array_keys($reqQuest)) {
         $conditions = array('OR', ['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds], ['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds], ['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds], ['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]);
         $reqQuests = new QuestList($conditions);
         $this->extendGlobalData($reqQuests->getJSGlobals());
         foreach ($reqQuests->iterate() as $qId => $__) {
             if (empty($reqQuests->requires[$qId][TYPE_ITEM])) {
                 continue;
             }
             foreach ($reqIds as $rId) {
                 if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) {
                     $reqQuest[$rId] = $reqQuests->id;
                 }
             }
         }
     }
     // tab: starts quest
     // tab: ends quest
     $startEnd = new QuestList(array(['qse.type', TYPE_NPC], ['qse.typeId', $this->typeId]));
     if (!$startEnd->error) {
         $this->extendGlobalData($startEnd->getJSGlobals());
         $lvData = $startEnd->getListviewData();
         $_ = [[], []];
         foreach ($startEnd->iterate() as $id => $__) {
             $m = $startEnd->getField('method');
             if ($m & 0x1) {
                 $_[0][] = $lvData[$id];
             }
             if ($m & 0x2) {
                 $_[1][] = $lvData[$id];
             }
         }
         if ($_[0]) {
             $this->lvTabs[] = array('file' => 'quest', 'data' => $_[0], 'params' => array('name' => '$LANG.tab_starts', 'id' => 'starts'));
         }
         if ($_[1]) {
             $this->lvTabs[] = array('file' => 'quest', 'data' => $_[1], 'params' => array('name' => '$LANG.tab_ends', 'id' => 'ends'));
         }
     }
     // tab: objective of quest
     $conditions = array('OR', ['AND', ['reqNpcOrGo1', $this->typeId], ['reqNpcOrGoCount1', 0, '>']], ['AND', ['reqNpcOrGo2', $this->typeId], ['reqNpcOrGoCount2', 0, '>']], ['AND', ['reqNpcOrGo3', $this->typeId], ['reqNpcOrGoCount3', 0, '>']], ['AND', ['reqNpcOrGo4', $this->typeId], ['reqNpcOrGoCount4', 0, '>']]);
     $objectiveOf = new QuestList($conditions);
     if (!$objectiveOf->error) {
         $this->extendGlobalData($objectiveOf->getJSGlobals());
         $this->lvTabs[] = array('file' => 'quest', 'data' => $objectiveOf->getListviewData(), 'params' => array('name' => '$LANG.tab_objectiveof', 'id' => 'objective-of'));
     }
     // tab: criteria of [ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE have no data set to check for]
     $conditions = array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE]], ['ac.value1', $this->typeId]);
     $crtOf = new AchievementList($conditions);
     if (!$crtOf->error) {
         $this->extendGlobalData($crtOf->getJSGlobals());
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $crtOf->getListviewData(), 'params' => array('name' => '$LANG.tab_criteriaof', 'id' => 'criteria-of'));
     }
     // tab: passengers
     if ($_ = DB::World()->selectCol('SELECT accessory_entry AS ARRAY_KEY, GROUP_CONCAT(seat_id) FROM vehicle_template_accessory WHERE entry = ?d GROUP BY accessory_entry', $this->typeId)) {
         $passengers = new CreatureList(array(['id', array_keys($_)]));
         if (!$passengers->error) {
             $data = $passengers->getListviewData();
             $xCols = null;
             if (User::isInGroup(U_GROUP_STAFF)) {
                 foreach ($data as $id => &$d) {
                     $d['seat'] = str_replace(',', ', ', $_[$id]);
                 }
                 $xCols = "\$[Listview.funcBox.createSimpleCol('seat', '" . Lang::npc('seat') . "', '10%', 'seat')]";
             }
             $this->extendGlobalData($passengers->getJSGlobals(GLOBALINFO_SELF));
             $this->lvTabs[] = array('file' => 'creature', 'data' => $data, 'params' => array('extraCols' => $xCols, 'name' => Lang::npc('accessory'), 'id' => 'accessory'));
         }
     }
 }
Exemple #22
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 #23
0
 protected function generateContent()
 {
     $conditions = [];
     $visibleCols = [];
     $hiddenCols = [];
     $tabData = ['data' => []];
     // the next lengthy ~250 lines determine $conditions and lvParams
     if ($this->category) {
         switch ($this->category[0]) {
             case -2:
                 // Character Talents
                 $this->filter['classPanel'] = true;
                 array_push($visibleCols, 'singleclass', 'level', 'schools', 'tier');
                 $conditions[] = ['s.typeCat', -2];
                 // i will NOT redefine those class2skillId ... reusing
                 if (isset($this->category[2])) {
                     $conditions[] = ['s.skillLine1', $this->category[2]];
                 } else {
                     if (isset($this->category[1])) {
                         $conditions[] = ['s.skillLine1', $this->validCats[-2][$this->category[1]]];
                     }
                 }
                 break;
             case -3:
                 // Pet Spells
                 array_push($visibleCols, 'level', 'schools');
                 $conditions[] = ['s.typeCat', -3];
                 if (isset($this->category[1])) {
                     $xCond = null;
                     for ($i = -2; $i < 0; $i++) {
                         foreach (Util::$skillLineMask[$i] as $idx => $pair) {
                             if ($pair[1] == $this->category[1]) {
                                 $xCond = ['AND', ['s.skillLine1', $i], ['s.skillLine2OrMask', 1 << $idx, '&']];
                                 break;
                             }
                         }
                     }
                     $conditions[] = ['OR', $xCond, ['s.skillLine1', $this->category[1]], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->category[1]]]];
                 } else {
                     $conditions[] = ['OR', ['s.skillLine1', [-1, -2]], ['s.skillLine1', $this->validCats[-3]], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->validCats[-3]]]];
                 }
                 break;
             case -4:
                 // Racials
                 array_push($visibleCols, 'classes');
                 $conditions[] = ['s.typeCat', -4];
                 break;
             case -8:
                 // NPC-Spells
             // NPC-Spells
             case -9:
                 // GM Spells
                 array_push($visibleCols, 'level');
             case -5:
                 // Mounts
             // Mounts
             case -6:
                 // Companions
                 $conditions[] = ['s.typeCat', $this->category[0]];
                 break;
             case -7:
                 // Pet Talents
                 array_push($visibleCols, 'level', 'tier');
                 $conditions[] = ['s.typeCat', -7];
                 if (isset($this->category[1])) {
                     switch ($this->category[1]) {
                         case 409:
                             // Tenacity
                             $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE1, '&'];
                             $url = '?pets=1';
                             break;
                         case 410:
                             // Cunning
                             $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE2, '&'];
                             $url = '?pets=2';
                             break;
                         case 411:
                             // Ferocity
                             $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE0, '&'];
                             $url = '?pets=0';
                             break;
                     }
                     $tabData['note'] = '$$WH.sprintf(LANG.lvnote_pettalents, "' . $url . '")';
                 }
                 $tabData['_petTalents'] = 1;
                 // not conviced, this is correct, but .. it works
                 break;
             case -11:
                 // Proficiencies ... the subIds are actually SkillLineCategories
                 if (!isset($this->category[1]) || $this->category[1] != 10) {
                     array_push($visibleCols, 'classes');
                 }
                 $conditions[] = ['s.typeCat', -11];
                 if (isset($this->category[1])) {
                     if ($this->category[1] == 6) {
                         // todo (med): we know Weapon(6) includes spell Shoot(3018), that has a mask; but really, ANY proficiency or petSkill should be in that mask so there is no need to differenciate
                         $conditions[] = ['OR', ['s.skillLine1', SpellList::$skillLines[$this->category[1]]], ['s.skillLine1', -3]];
                     } else {
                         $conditions[] = ['s.skillLine1', SpellList::$skillLines[$this->category[1]]];
                     }
                 }
                 break;
             case -13:
                 // Glyphs
                 $this->filter['classPanel'] = true;
                 $this->filter['glyphPanel'] = true;
                 array_push($visibleCols, 'singleclass', 'glyphtype');
                 $conditions[] = ['s.typeCat', -13];
                 if (isset($this->category[1])) {
                     $conditions[] = ['s.reqClassMask', 1 << $this->category[1] - 1, '&'];
                 }
                 break;
             case 7:
                 // Abilities
                 $this->filter['classPanel'] = true;
                 array_push($visibleCols, 'level', 'singleclass', 'schools');
                 $conditions[] = ['s.typeCat', [7, -2]];
                 $conditions[] = [['s.cuFlags', SPELL_CU_TRIGGERED | SPELL_CU_TALENT, '&'], 0];
                 // Runeforging listed multiple times, exclude from explicit skill-listing
                 // if (isset($this->category[1]) && $this->category[1] == 6 && isset($this->category[2]) && $this->category[2] != 776)
                 // $conditions[] = [['s.attributes0', 0x80, '&'], 0];
                 // else
                 // $conditions[] = [
                 // [['s.attributes0', 0x80, '&'], 0],      // ~SPELL_ATTR0_HIDDEN_CLIENTSIDE
                 // ['s.attributes0', 0x20, '&'],           // SPELL_ATTR0_TRADESPELL (DK: Runeforging)
                 // 'OR'
                 // ];
                 if (isset($this->category[2])) {
                     $conditions[] = ['OR', ['s.skillLine1', $this->category[2]], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->category[2]]]];
                 } else {
                     if (isset($this->category[1])) {
                         $conditions[] = ['OR', ['s.skillLine1', $this->validCats[7][$this->category[1]]], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->validCats[7][$this->category[1]]]]];
                     }
                 }
                 break;
             case 9:
                 // Secondary Skills
                 array_push($visibleCols, 'source');
                 $conditions[] = ['s.typeCat', 9];
                 if (isset($this->category[1])) {
                     $conditions[] = ['OR', ['s.skillLine1', $this->category[1]], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->category[1]]]];
                     if (!empty($this->shortFilter[$this->category[1]])) {
                         $sf = $this->shortFilter[$this->category[1]];
                         $txt = '';
                         if ($sf[0] && $sf[1]) {
                             $txt = sprintf(Lang::spell('relItems', 'crafted'), $sf[0]) . Lang::spell('relItems', 'link') . sprintf(Lang::spell('relItems', 'recipes'), $sf[1]);
                         } else {
                             if ($sf[0]) {
                                 $txt = sprintf(Lang::spell('relItems', 'crafted'), $sf[0]);
                             } else {
                                 if ($sf[1]) {
                                     $txt = sprintf(Lang::spell('relItems', 'recipes'), $sf[1]);
                                 }
                             }
                         }
                         $note = Lang::spell('cat', $this->category[0], $this->category[1]);
                         if (is_array($note)) {
                             $note = $note[0];
                         }
                         $tabData['note'] = sprintf(Lang::spell('relItems', 'base'), $txt, $note);
                         $tabData['sort'] = ['skill', 'name'];
                     }
                 }
                 break;
             case 11:
                 // Professions
                 array_push($visibleCols, 'source');
                 $conditions[] = ['s.typeCat', 11];
                 if (isset($this->category[2])) {
                     if ($this->category[2] == 9787) {
                         // general weaponsmithing
                         $conditions[] = ['s.reqSpellId', [9787, 17039, 17040, 17041]];
                     } else {
                         $conditions[] = ['s.reqSpellId', $this->category[2]];
                     }
                 } else {
                     if (isset($this->category[1])) {
                         $conditions[] = ['s.skillLine1', $this->category[1]];
                     }
                 }
                 if (isset($this->category[1])) {
                     $conditions[] = ['s.skillLine1', $this->category[1]];
                     if (!empty($this->shortFilter[$this->category[1]])) {
                         $sf = $this->shortFilter[$this->category[1]];
                         $txt = '';
                         if ($sf[0] && $sf[1]) {
                             $txt = sprintf(Lang::spell('relItems', 'crafted'), $sf[0]) . Lang::spell('relItems', 'link') . sprintf(Lang::spell('relItems', 'recipes'), $sf[1]);
                         } else {
                             if ($sf[0]) {
                                 $txt = sprintf(Lang::spell('relItems', 'crafted'), $sf[0]);
                             } else {
                                 if ($sf[1]) {
                                     $txt = sprintf(Lang::spell('relItems', 'recipes'), $sf[1]);
                                 }
                             }
                         }
                         $note = Lang::spell('cat', $this->category[0], $this->category[1]);
                         if (is_array($note)) {
                             $note = $note[0];
                         }
                         $tabData['note'] = sprintf(Lang::spell('relItems', 'base'), $txt, $note);
                         $tabData['sort'] = ['skill', 'name'];
                     }
                 }
                 break;
             case 0:
                 // misc. Spells & triggered player abilities
                 array_push($visibleCols, 'level');
                 $conditions[] = ['OR', ['s.typeCat', 0], ['AND', ['s.cuFlags', SPELL_CU_TRIGGERED, '&'], ['s.typeCat', [7, -2]]]];
                 break;
         }
     }
     if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
         $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
     }
     if ($_ = $this->filterObj->getConditions()) {
         $conditions[] = $_;
     }
     $spells = new SpellList($conditions);
     $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     $tabData['data'] = array_values($spells->getListviewData());
     // recreate form selection
     $this->filter = array_merge($this->filterObj->getForm('form'), $this->filter);
     $this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
     $this->filter['fi'] = $this->filterObj->getForm();
     if (!empty($this->filter['fi']['extraCols'])) {
         $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
     }
     // create note if search limit was exceeded; overwriting 'note' is intentional
     if ($spells->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
         $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), CFG_SQL_LIMIT_DEFAULT);
         $tabData['_truncated'] = 1;
     }
     if ($this->filterObj->error) {
         $tabData['_errors'] = 1;
     }
     // add source to cols if explicitly searching for it
     if ($_ = $this->filterObj->getForm('setCriteria', true)) {
         if (in_array(9, $_['cr']) && !in_array('source', $visibleCols)) {
             $visibleCols[] = 'source';
         }
     }
     $mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost', 'reqClassMask']);
     if ($mask & 0x1) {
         $visibleCols[] = 'reagents';
     }
     if (!($mask & 0x2) && $this->category && !in_array($this->category[0], [9, 11])) {
         $hiddenCols[] = 'skill';
     }
     if ($mask & 0x4) {
         $visibleCols[] = 'trainingcost';
     }
     if ($mask & 0x8 && !in_array('singleclass', $visibleCols)) {
         $visibleCols[] = 'singleclass';
     }
     if ($visibleCols) {
         $tabData['visibleCols'] = $visibleCols;
     }
     if ($hiddenCols) {
         $tabData['hiddenCols'] = $hiddenCols;
     }
     $this->lvTabs[] = ['spell', $tabData];
     // sort for dropdown-menus
     Lang::sort('game', 'ra');
     Lang::sort('game', 'cl');
     Lang::sort('game', 'sc');
     Lang::sort('game', 'me');
 }
Exemple #24
0
 public function getOnUseStats()
 {
     $onUseStats = [];
     // convert Spells
     $useSpells = [];
     for ($h = 1; $h <= 5; $h++) {
         if ($this->curTpl['spellId' . $h] <= 0) {
             continue;
         }
         if ($this->curTpl['class'] != ITEM_CLASS_CONSUMABLE || $this->curTpl['spellTrigger' . $h]) {
             continue;
         }
         $useSpells[] = $this->curTpl['spellId' . $h];
     }
     if ($useSpells) {
         $eqpSplList = new SpellList(array(['s.id', $useSpells]));
         foreach ($eqpSplList->getStatGain() as $stat) {
             Util::arraySumByKey($onUseStats, $stat);
         }
     }
     return $onUseStats;
 }
Exemple #25
0
 protected function generateContent()
 {
     $_ta = $this->subject->getField('contentGroup');
     $_ty = $this->subject->getField('type');
     $_cnt = count($this->subject->getField('pieces'));
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // unavailable (todo (low): set data)
     if ($this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE) {
         $infobox[] = Lang::main('unavailable');
     }
     // holiday
     if ($h = $this->subject->getField('holidayId')) {
         $infobox[] = Lang::game('eventShort') . Lang::main('colon') . '[event=' . $h . ']';
         $this->extendGlobalIds(TYPE_WORLDEVENT, $h);
     }
     // itemLevel
     if ($min = $this->subject->getField('minLevel')) {
         $foo = Lang::game('level') . Lang::main('colon') . $min;
         $max = $this->subject->getField('maxLevel');
         if ($min < $max) {
             $foo .= ' - ' . $max;
         }
         $infobox[] = $foo;
     }
     // class
     if ($cl = Lang::getClassString($this->subject->getField('classMask'), $jsg, $qty, false)) {
         $this->extendGlobalIds(TYPE_CLASS, $jsg);
         $t = $qty == 1 ? Lang::game('class') : Lang::game('classes');
         $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $cl;
     }
     // required level
     if ($lvl = $this->subject->getField('reqLevel')) {
         $infobox[] = sprintf(Lang::game('reqLevel'), $lvl);
     }
     // type
     if ($_ty) {
         $infobox[] = Lang::game('type') . Lang::main('colon') . Lang::itemset('types', $_ty);
     }
     // tag
     if ($_ta) {
         $infobox[] = Lang::itemset('_tag') . Lang::main('colon') . '[url=?itemsets&filter=ta=' . $_ta . ']' . Lang::itemset('notes', $_ta) . '[/url]';
     }
     /****************/
     /* Main Content */
     /****************/
     // pieces + Summary
     $pieces = [];
     $eqList = [];
     $compare = [];
     if (!$this->subject->pieceToSet) {
         $cnd = [0];
     } else {
         $cnd = ['i.id', array_keys($this->subject->pieceToSet)];
     }
     $iList = new ItemList(array($cnd));
     $data = $iList->getListviewData(ITEMINFO_SUBITEMS | ITEMINFO_JSON);
     foreach ($iList->iterate() as $itemId => $__) {
         if (empty($data[$itemId])) {
             continue;
         }
         $slot = $iList->getField('slot');
         $disp = $iList->getField('displayId');
         if ($slot && $disp) {
             $eqList[] = [$slot, $disp];
         }
         $compare[] = $itemId;
         $pieces[] = array('id' => $itemId, 'name' => $iList->getField('name', true), 'quality' => $iList->getField('quality'), 'icon' => $iList->getField('iconString'), 'json' => $data[$itemId]);
     }
     // spells
     $foo = [];
     $spells = [];
     for ($i = 1; $i < 9; $i++) {
         $spl = $this->subject->getField('spell' . $i);
         $qty = $this->subject->getField('bonus' . $i);
         if ($spl && $qty) {
             $foo[] = $spl;
             $spells[] = array('id' => $spl, 'bonus' => $qty, 'desc' => '');
         }
     }
     // sort by required pieces ASC
     usort($spells, function ($a, $b) {
         if ($a['bonus'] == $b['bonus']) {
             return 0;
         }
         return $a['bonus'] > $b['bonus'] ? 1 : -1;
     });
     $setSpells = new SpellList(array(['s.id', $foo]));
     foreach ($setSpells->iterate() as $spellId => $__) {
         foreach ($spells as &$s) {
             if ($spellId != $s['id']) {
                 continue;
             }
             $s['desc'] = $setSpells->parseText('description')[0];
         }
     }
     $skill = '';
     if ($_sk = $this->subject->getField('skillId')) {
         $spellLink = sprintf('<a href="?spells=11.%s">%s</a> (%s)', $_sk, Lang::spell('cat', 11, $_sk, 0), $this->subject->getField('skillLevel'));
         $skill = ' &ndash; <small><b>' . sprintf(Lang::game('requires'), $spellLink) . '</b></small>';
     }
     $this->bonusExt = $skill;
     $this->description = $_ta ? sprintf(Lang::itemset('_desc'), $this->name, Lang::itemset('notes', $_ta), $_cnt) : sprintf(Lang::itemset('_descTagless'), $this->name, $_cnt);
     $this->unavailable = $this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE;
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->pieces = $pieces;
     $this->spells = $spells;
     $this->expansion = 0;
     $this->redButtons = array(BUTTON_WOWHEAD => $this->typeId > 0, BUTTON_LINKS => ['color' => '', 'linkId' => ''], BUTTON_VIEW3D => ['type' => TYPE_ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList], BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt]);
     $this->compare = array('level' => $this->subject->getField('reqLevel'), 'items' => array_map(function ($v) {
         return [[$v]];
     }, $compare));
     /**************/
     /* Extra Tabs */
     /**************/
     // related sets (priority: 1: similar tag + class; 2: has event; 3: no tag + similar type, 4: similar type + profession)
     $rel = [];
     if ($_ta && count($this->path) == 3) {
         $rel[] = ['id', $this->typeId, '!'];
         $rel[] = ['classMask', 1 << end($this->path) - 1, '&'];
         $rel[] = ['contentGroup', (int) $_ta];
     } else {
         if ($this->subject->getField('holidayId')) {
             $rel[] = ['id', $this->typeId, '!'];
             $rel[] = ['holidayId', 0, '!'];
         } else {
             if ($this->subject->getField('skillId')) {
                 $rel[] = ['id', $this->typeId, '!'];
                 $rel[] = ['contentGroup', 0];
                 $rel[] = ['skillId', 0, '!'];
                 $rel[] = ['type', $_ty];
             } else {
                 if (!$_ta && $_ty) {
                     $rel[] = ['id', $this->typeId, '!'];
                     $rel[] = ['contentGroup', 0];
                     $rel[] = ['type', $_ty];
                     $rel[] = ['skillId', 0];
                 }
             }
         }
     }
     if ($rel) {
         $relSets = new ItemsetList($rel);
         if (!$relSets->error) {
             $lv = array('file' => 'itemset', 'data' => $relSets->getListviewData(), 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso'));
             if (!$relSets->hasDiffFields(['classMask'])) {
                 $lv['params']['hiddenCols'] = "\$['classes']";
             }
             $this->lvTabs[] = $lv;
             $this->extendGlobalData($relSets->getJSGlobals());
         }
     }
 }
Exemple #26
0
 private function _searchSpell($cndBase)
 {
     $result = [];
     $cnd = array_merge($cndBase, array(['OR', ['s.typeCat', [0, -9]], ['AND', ['s.cuFlags', SPELL_CU_TRIGGERED, '&'], ['s.typeCat', [7, -2]]]], $this->createLookup()));
     $misc = new SpellList($cnd);
     if ($data = $misc->getListviewData()) {
         if ($this->searchMask & SEARCH_TYPE_REGULAR) {
             $this->extendGlobalData($misc->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
         if ($this->searchMask & SEARCH_TYPE_OPEN) {
             foreach ($misc->iterate() as $__) {
                 $data[$misc->id]['param1'] = strToLower($misc->getField('iconString'));
             }
         }
         $result = array('type' => TYPE_SPELL, 'appendix' => ' (Spell)', 'matches' => $misc->getMatches(), 'file' => SpellList::$brickFile, 'data' => $data, 'params' => ['name' => '$LANG.tab_uncategorizedspells', 'visibleCols' => "\$['level']", 'hiddenCols' => "\$['skill']"]);
         if ($misc->getMatches() > $this->maxResults) {
             $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $misc->getMatches(), $this->maxResults);
             $result['params']['_truncated'] = 1;
         }
         if (isset($result['params']['note'])) {
             $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na=' . urlencode($this->search) . '\')';
         } else {
             $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na=' . urlencode($this->search) . '\')';
         }
     }
     return $result;
 }
Exemple #27
0
 public function renderTooltip()
 {
     $criteria = $this->getCriteria();
     $tmp = [];
     $rows = [];
     $i = 0;
     foreach ($criteria as $_row) {
         if ($i++ % 2) {
             $tmp[] = $_row;
         } else {
             $rows[] = $_row;
         }
     }
     if ($tmp) {
         $rows = array_merge($rows, $tmp);
     }
     $description = $this->getField('description', true);
     $name = $this->getField('name', true);
     $criteria = '';
     $i = 0;
     foreach ($rows as $crt) {
         $obj = (int) $crt['value1'];
         $qty = (int) $crt['value2'];
         // we could show them, but the tooltips are cluttered
         if ($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN && User::$perms <= 0) {
             continue;
         }
         $crtName = Util::localizedString($crt, 'name');
         switch ($crt['type']) {
             // link to title - todo (low): crosslink
             case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
                 $crtName = Util::ucFirst(Lang::game('title')) . Lang::main('colon') . $crtName;
                 break;
                 // link to quest
             // link to quest
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
                 if (!$crtName) {
                     $crtName = QuestList::getName($obj);
                 }
                 break;
                 // link to spell (/w icon)
             // link to spell (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
                 if (!$crtName) {
                     $crtName = SpellList::getName($obj);
                 }
                 break;
                 // link to item (/w icon)
             // link to item (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
                 if (!$crtName) {
                     $crtName = ItemList::getName($obj);
                 }
                 break;
                 // link to faction (/w target reputation)
             // link to faction (/w target reputation)
             case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
                 if (!$crtName) {
                     $crtName = FactionList::getName($obj);
                 }
                 break;
         }
         if ($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER) {
             $criteria .= '- ' . Util::jsEscape($crtName) . ' <span class="moneygold">' . number_format($crt['value2'] / 10000) . '</span><br />';
         } else {
             $criteria .= '- ' . Util::jsEscape($crtName) . '<br />';
         }
         if (++$i == round(count($rows) / 2)) {
             $criteria .= '</small></td><th class="q0" style="white-space: nowrap; text-align: left"><small>';
         }
     }
     $x = '<table><tr><td><b class="q">';
     $x .= Util::jsEscape($name);
     $x .= '</b></td></tr></table>';
     if ($description || $criteria) {
         $x .= '<table><tr><td>';
     }
     if ($description) {
         $x .= '<br />' . Util::jsEscape($description) . '<br />';
     }
     if ($criteria) {
         $x .= '<br /><span class="q">' . Lang::achievement('criteria') . ':</span>';
         $x .= '<table width="100%"><tr><td class="q0" style="white-space: nowrap"><small>' . $criteria . '</small></th></tr></table>';
     }
     if ($description || $criteria) {
         $x .= '</td></tr></table>';
     }
     return $x;
 }