diff --git a/pages/enchantment.php b/endpoints/enchantment/enchantment.php similarity index 53% rename from pages/enchantment.php rename to endpoints/enchantment/enchantment.php index 6cc09815..ab874512 100644 --- a/pages/enchantment.php +++ b/endpoints/enchantment/enchantment.php @@ -6,56 +6,63 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -// menuId 101: Enchantment g_initPath() -// tabId 0: Database g_initHeader() -class EnchantmentPage extends GenericPage +class EnchantmentBaseResponse extends TemplateResponse implements ICache { - use TrDetailPage; + use TrDetailPage, TrCache; - protected $effects = []; - protected $activation = []; + protected int $cacheType = CACHE_TYPE_PAGE; - protected $type = Type::ENCHANTMENT; - protected $typeId = 0; - protected $tpl = 'enchantment'; - protected $path = [0, 101]; - protected $tabId = 0; - protected $mode = CACHE_TYPE_PAGE; + protected string $template = 'enchantment'; + protected string $pageName = 'enchantment'; + protected ?int $activeTab = parent::TAB_DATABASE; + protected array $breadcrumb = [0, 101]; - public function __construct($pageCall, $id) + public int $type = Type::ENCHANTMENT; + public int $typeId = 0; + public array $effects = []; + public string $activation = ''; + + private EnchantmentList $subject; + + public function __construct(string $id) { - parent::__construct($pageCall, $id); + parent::__construct($id); - $this->typeId = intVal($id); + $this->typeId = intVal($id); + $this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE; + } + protected function generate() : void + { $this->subject = new EnchantmentList(array(['id', $this->typeId])); if ($this->subject->error) - $this->notFound(Lang::game('enchantment'), Lang::enchantment('notFound')); + $this->generateNotFound(Lang::game('enchantment'), Lang::enchantment('notFound')); $this->extendGlobalData($this->subject->getJSGlobals()); - $this->name = Util::ucFirst($this->subject->getField('name', true)); - } + $this->h1 = $this->subject->getField('name', true); - private function getDistinctType() - { - $type = 0; - for ($i = 1; $i < 4; $i++) - { - if ($_ = $this->subject->getField('type'.$i)) - { - if ($type) // already set - return 0; - else - $type = $_; - } - } + $this->gPageInfo += array( + 'type' => $this->type, + 'typeId' => $this->typeId, + 'name' => $this->h1 + ); + + /*************/ + /* Menu Path */ + /*************/ + + if ($_ = $this->getDistinctType()) + $this->breadcrumb[] = $_; + + + /**************/ + /* Page Title */ + /**************/ + + array_unshift($this->title, $this->h1, Util::ucFirst(Lang::game('enchantment'))); - return $type; - } - protected function generateContent() - { /***********/ /* Infobox */ /***********/ @@ -71,20 +78,21 @@ class EnchantmentPage extends GenericPage { $this->extendGlobalIds(Type::SKILL, $_); - $foo = sprintf(Lang::game('requires'), ' [skill='.$_.']'); + $foo = Lang::game('requires', [' [skill='.$_.']']); if ($_ = $this->subject->getField('skillLevel')) $foo .= ' ('.$_.')'; $infobox[] = $foo; } + if ($infobox) + $this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0'); + /****************/ /* Main Content */ /****************/ - - $this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null; $this->redButtons = array( BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], BUTTON_WOWHEAD => false @@ -97,6 +105,7 @@ class EnchantmentPage extends GenericPage $_ty = $this->subject->getField('type'.$i); $_qty = $this->subject->getField('amount'.$i); $_obj = $this->subject->getField('object'.$i); + $_tip = []; switch ($_ty) { @@ -105,114 +114,83 @@ class EnchantmentPage extends GenericPage case ENCHANTMENT_TYPE_USE_SPELL: [$spellId, $trigger, $charges, $procChance] = $this->subject->getField('spells')[$i]; $spl = $this->subject->getRelSpell($spellId); - $this->effects[$i]['name'] = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Type: '.$_ty, Lang::item('trigger', $trigger)) : Lang::item('trigger', $trigger); - $this->effects[$i]['proc'] = $procChance; - $this->effects[$i]['value'] = $_qty ?: null; - $this->effects[$i]['icon'] = array( - 'name' => !$spl ? Util::ucFirst(Lang::game('spell')).' #'.$spellId : Util::localizedString($spl, 'name'), - 'id' => $spellId, - 'count' => $charges + $this->effects[$i] = array( + 'name' => $this->fmtStaffTip(Lang::item('trigger', $trigger), 'Type: '.$_ty), + 'proc' => $procChance, + 'value' => $_qty ?: null, + 'tip' => [], + 'icon' => new IconElement( + Type::SPELL, + $spellId, + !$spl ? Util::ucFirst(Lang::game('spell')).' #'.$spellId : Util::localizedString($spl, 'name'), + $charges, + link: !!$spl + ) ); break; case ENCHANTMENT_TYPE_STAT: if ($idx = Stat::getIndexFrom(Stat::IDX_ITEM_MOD, $_obj)) if ($jsonStat = Stat::getJsonString($idx)) - $this->effects[$i]['tip'] = [$_obj, $jsonStat]; + $_tip = [User::isInGroup(U_GROUP_STAFF) ? $_obj : null, $jsonStat]; // DO NOT BREAK! case ENCHANTMENT_TYPE_DAMAGE: case ENCHANTMENT_TYPE_TOTEM: case ENCHANTMENT_TYPE_PRISMATIC_SOCKET: case ENCHANTMENT_TYPE_RESISTANCE: - $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)).')'; + $this->effects[$i] = array( + 'name' => $this->fmtStaffTip(Lang::enchantment('types', $_ty), 'Type: '.$_ty), + 'proc' => null, + 'value' => $_qty, + 'tip' => $_tip, + 'icon' => null + ); + if ($_ty == ENCHANTMENT_TYPE_RESISTANCE) + $this->effects[$i]['name'] .= Lang::main('colon').'('.$this->fmtStaffTip(Lang::getMagicSchools(1 << $_obj), 'Object: '.$_obj).')'; } } // activation conditions if ($_ = $this->subject->getField('conditionId')) - { - $x = ''; + $this->activation = Game::getEnchantmentCondition($_); - 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 - case 3: $foo = '2:4:5'; break; // yellow - case 4: $foo = '1:3:4'; break; // blue - } - - return $foo; - }; - - $bLink = $gemCnd['color'.$i] ? ''.Lang::item('gemColors', $gemCnd['color'.$i] - 1).'' : ''; - $cLink = $gemCnd['cmpColor'.$i] ? ''.Lang::item('gemColors', $gemCnd['cmpColor'.$i] - 1).'' : ''; - - switch ($gemCnd['comparator'.$i]) - { - case 2: // requires less than ( || ) gems - case 5: // requires at least than ( || ) gems - $sp = (int)$gemCnd['value'.$i] > 1; - $x .= ''.Lang::achievement('reqNumCrt').' '.Lang::item('gemConditions', $gemCnd['comparator'.$i], [$gemCnd['value'.$i], $bLink]).'
'; - break; - case 3: // requires more than ( || ) gems - $link = ''.Lang::item('gemColors', $gemCnd['cmpColor'.$i] - 1).''; - $x .= ''.Lang::achievement('reqNumCrt').' '.Lang::item('gemConditions', $gemCnd['comparator'.$i], [$bLink, $cLink]).'
'; - break; - } - } - } - - $this->activation = $x; - } /**************/ /* Extra Tabs */ /**************/ + $this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true); + // used by gem $gemList = new ItemList(array(['gemEnchantmentId', $this->typeId])); if (!$gemList->error) { - $this->lvTabs[] = [ItemList::$brickFile, array( - 'data' => array_values($gemList->getListviewData()), + $this->extendGlobalData($gemList->getJsGlobals()); + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $gemList->getListviewData(), 'name' => '$LANG.tab_usedby + \' \' + LANG.gems', 'id' => 'used-by-gem', - )]; - - $this->extendGlobalData($gemList->getJsGlobals()); + ), ItemList::$brickFile)); } // used by socket bonus $socketsList = new ItemList(array(['socketBonus', $this->typeId])); if (!$socketsList->error) { - $this->lvTabs[] = [ItemList::$brickFile, array( - 'data' => array_values($socketsList->getListviewData()), + $this->extendGlobalData($socketsList->getJsGlobals()); + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $socketsList->getListviewData(), 'name' => '$LANG.tab_socketbonus', 'id' => 'used-by-socketbonus', - )]; - - $this->extendGlobalData($socketsList->getJsGlobals()); + ), ItemList::$brickFile)); } // 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]], + ['AND', ['effect1Id', SpellList::EFFECTS_ENCHANTMENT], ['effect1MiscValue', $this->typeId]], + ['AND', ['effect2Id', SpellList::EFFECTS_ENCHANTMENT], ['effect2MiscValue', $this->typeId]], + ['AND', ['effect3Id', SpellList::EFFECTS_ENCHANTMENT], ['effect3MiscValue', $this->typeId]], ); $spellList = new SpellList($cnd); if (!$spellList->error) @@ -233,13 +211,12 @@ class EnchantmentPage extends GenericPage $ubItems = new ItemList($conditions); if (!$ubItems->error) { - $this->lvTabs[] = [ItemList::$brickFile, array( - 'data' => array_values($ubItems->getListviewData()), + $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF)); + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $ubItems->getListviewData(), 'name' => '$LANG.tab_usedby + \' \' + LANG.types[3][0]', 'id' => 'used-by-item', - )]; - - $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF)); + ), ItemList::$brickFile)); } // remove found spells if they are used by an item @@ -247,9 +224,9 @@ class EnchantmentPage extends GenericPage { foreach ($spellList->iterate() as $sId => $__) { - // if Perm. Enchantment has a createItem its a Scroll of Enchantment (display both) + // if Perm. Enchantment display both for ($i = 1; $i < 4; $i++) - if ($spellList->getField('effect'.$i.'Id') == 53 && $spellList->getField('effect'.$i.'CreateItemId')) + if ($spellList->getField('effect'.$i.'Id') == SPELL_EFFECT_ENCHANT_ITEM) continue 2; foreach ($ubItems->iterate() as $__) @@ -266,21 +243,22 @@ class EnchantmentPage extends GenericPage } } - $this->lvTabs[] = [SpellList::$brickFile, array( - 'data' => array_values($spellData), - 'name' => '$LANG.tab_usedby + \' \' + LANG.types[6][0]', - 'id' => 'used-by-spell', - )]; + if ($spellData) + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $spellData, + 'name' => '$LANG.tab_usedby + \' \' + LANG.types[6][0]', + 'id' => 'used-by-spell', + ), SpellList::$brickFile)); } // 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', + '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))) + 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) @@ -300,28 +278,35 @@ class EnchantmentPage extends GenericPage $data[$iId]['name'] .= ' '.Util::localizedString($ire[$iet[abs($re)]['ench']], 'name'); } - $this->lvTabs[] = [ItemList::$brickFile, array( - 'data' => array_values($data), + $this->extendGlobalData($randItems->getJSGlobals(GLOBALINFO_SELF)); + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $data, 'id' => 'used-by-rand', 'name' => '$LANG.tab_usedby + \' \' + \''.Lang::item('_rndEnchants').'\'', 'extraCols' => ['$Listview.extraCols.percent'] - )]; - - $this->extendGlobalData($randItems->getJSGlobals(GLOBALINFO_SELF)); + ), ItemList::$brickFile)); } } } + + parent::generate(); } - protected function generateTitle() + private function getDistinctType() : int { - array_unshift($this->title, $this->name, Util::ucFirst(Lang::game('enchantment'))); - } + $type = 0; + for ($i = 1; $i < 4; $i++) + { + if ($_ = $this->subject->getField('type'.$i)) + { + if ($type && $type != $_) // already set + return 0; + else + $type = $_; + } + } - protected function generatePath() - { - if ($_ = $this->getDistinctType()) - $this->path[] = $_; + return $type; } } diff --git a/endpoints/enchantments/enchantments.php b/endpoints/enchantments/enchantments.php new file mode 100644 index 00000000..1d35f2b2 --- /dev/null +++ b/endpoints/enchantments/enchantments.php @@ -0,0 +1,128 @@ + ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]] + ); + protected array $validCats = [1, 2, 3, 4, 5, 6, 7, 8]; + + public function __construct(string $pageParam) + { + $this->getCategoryFromUrl($pageParam); + + parent::__construct($pageParam); + + if ($this->category) + $this->forward('?enchantments&filter=ty='.$this->category[0]); + + $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; + $this->filter = new EnchantmentListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); + $this->filterError = $this->filter->error; + } + + protected function generate() : void + { + $this->h1 = Util::ucFirst(Lang::game('enchantments')); + + $this->filter->evalCriteria(); + + $conditions = []; + + if (!User::isInGroup(U_GROUP_EMPLOYEE)) + $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; + + if ($_ = $this->filter->getConditions()) + $conditions[] = $_; + + $this->filterError = $this->filter->error; // maybe the evalX() caused something + + + /**************/ + /* Page Title */ + /**************/ + + $fiForm = $this->filter->values; + + array_unshift($this->title, $this->h1); + if (isset($fiForm['ty']) && count($fiForm['ty']) == 1 && $fiForm['ty'][0] > ENCHANTMENT_TYPE_NONE && $fiForm['ty'][0] <= ENCHANTMENT_TYPE_PRISMATIC_SOCKET) + array_unshift($this->title, Lang::enchantment('types', $fiForm['ty'][0])); + + + /*************/ + /* Menu Path */ + /*************/ + + if (isset($fiForm['ty']) && count($fiForm['ty']) == 1) + $this->breadcrumb[] = $fiForm['ty'][0]; + + + /****************/ + /* Main Content */ + /****************/ + + $this->redButtons[BUTTON_WOWHEAD] = false; + + $tabData = array( + 'data' => [], + 'name' => Util::ucFirst(Lang::game('enchantments')) + ); + + $ench = new EnchantmentList($conditions, ['calcTotal' => true]); + + $tabData['data'] = $ench->getListviewData(); + $this->extendGlobalData($ench->getJSGlobals()); + + $xCols = []; + foreach (Stat::getFilterCriteriumIdFor() as $idx => $fiId) + if (array_filter(array_column($tabData['data'], Stat::getJsonString($idx)))) + $xCols[] = $fiId; + + // some kind of declaration conflict going on here..., expects colId for WEAPON_DAMAGE_MAX but jsonString is WEAPON_DAMAGE + if (array_filter(array_column($tabData['data'], 'dmg'))) + $xCols[] = Stat::getFilterCriteriumId(Stat::WEAPON_DAMAGE_MAX); + + if ($xCols) + $this->filter->fiExtraCols = array_merge($this->filter->fiExtraCols, $xCols); + + if ($this->filter->fiExtraCols) + $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; + + if (array_filter(array_column($tabData['data'], 'spells'))) + $tabData['visibleCols'] = ['trigger']; + + if (!$ench->hasSetFields('skillLine')) + $tabData['hiddenCols'] = ['skill']; + + if ($ench->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) + { + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); + $tabData['_truncated'] = 1; + } + + $this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]); + + $this->lvTabs->addListviewTab(new Listview($tabData, EnchantmentList::$brickFile, 'enchantment')); + + parent::generate(); + } +} + +?> diff --git a/includes/dbtypes/enchantment.class.php b/includes/dbtypes/enchantment.class.php index fb173f3a..4fbcbb64 100644 --- a/includes/dbtypes/enchantment.class.php +++ b/includes/dbtypes/enchantment.class.php @@ -10,18 +10,18 @@ class EnchantmentList extends DBTypeList { use listviewHelper; - public static $type = Type::ENCHANTMENT; - public static $brickFile = 'enchantment'; - public static $dataTable = '?_itemenchantment'; + public static int $type = Type::ENCHANTMENT; + public static string $brickFile = 'enchantment'; + public static string $dataTable = '?_itemenchantment'; - private array $jsonStats = []; + private array $jsonStats = []; private ?SpellList $relSpells = null; - private array $triggerIds = []; + private array $triggerIds = []; - protected $queryBase = 'SELECT ie.*, ie.id AS ARRAY_KEY FROM ?_itemenchantment ie'; - protected $queryOpts = array( // 502 => Type::ENCHANTMENT - 'ie' => [['is']], - 'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 502 AND `is`.`typeId` = `ie`.`id`', true], 's' => ', `is`.*'], + protected string $queryBase = 'SELECT ie.*, ie.id AS ARRAY_KEY FROM ?_itemenchantment ie'; + protected array $queryOpts = array( // 502 => Type::ENCHANTMENT + 'ie' => [['is']], + 'is' => ['j' => ['?_item_stats `is` ON `is`.`type` = 502 AND `is`.`typeId` = `ie`.`id`', true], 's' => ', `is`.*'], ); public function __construct(array $conditions = [], array $miscData = []) @@ -60,7 +60,7 @@ class EnchantmentList extends DBTypeList // issue with scaling stats enchantments // stats are stored as NOT NULL to be usable by the search filters and such become indistinguishable from scaling enchantments that _actually_ use the value 0 // so filter the stats container and if it is empty, rebuild from self. .. there are no mixed scaling/static enchantments, right!? - $this->jsonStats[$this->id] = (new StatsContainer())->fromJson($curTpl, true)->filter(); + $this->jsonStats[$this->id] = (new StatsContainer)->fromJson($curTpl, true)->filter(); if (!count($this->jsonStats[$this->id])) $this->jsonStats[$this->id]->fromEnchantment($curTpl); } diff --git a/includes/defines.php b/includes/defines.php index b50eee78..d0c124cf 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -1034,7 +1034,7 @@ define('ITEM_FLAG_SMARTLOOT', 0x02000000); define('ITEM_FLAG_ACCOUNTBOUND', 0x08000000); define('ITEM_FLAG_MILLABLE', 0x20000000); -// ItemEnchantment types +// SpellItemEnchantmentCondition types define('ENCHANTMENT_TYPE_NONE', 0); define('ENCHANTMENT_TYPE_COMBAT_SPELL', 1); define('ENCHANTMENT_TYPE_DAMAGE', 2); @@ -1045,6 +1045,16 @@ define('ENCHANTMENT_TYPE_TOTEM', 6); define('ENCHANTMENT_TYPE_USE_SPELL', 7); define('ENCHANTMENT_TYPE_PRISMATIC_SOCKET', 8); +// SpellItemEnchantmentCondition operators - only 2, 3, 5 in use +// define('ENCHANT_CONDITION_EQUAL_COMPARE', ?); +// define('ENCHANT_CONDITION_EQUAL_VALUE', ?); +define('ENCHANT_CONDITION_LESS_VALUE', 2); +define('ENCHANT_CONDITION_MORE_COMPARE', 3); +// define('ENCHANT_CONDITION_MORE_EQUAL_COMPARE', ?); +define('ENCHANT_CONDITION_MORE_VALUE', 5); +// define('ENCHANT_CONDITION_NOT_EQUAL_COMPARE', ?); +// define('ENCHANT_CONDITION_NOT_EQUAL_VALUE', ?); + // Spell Effects and Auras define('SPELL_EFFECT_NONE', 0); define('SPELL_EFFECT_INSTAKILL', 1); diff --git a/includes/game/misc.php b/includes/game/misc.php index 12199e20..44d6727d 100644 --- a/includes/game/misc.php +++ b/includes/game/misc.php @@ -335,6 +335,47 @@ class Game return [$reqLevel]; } } + + public static function getEnchantmentCondition(int $conditionId, bool $interactive = false) : string + { + $gemCnd = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantmentcondition WHERE `id` = ?d', $conditionId); + if (!$gemCnd) + return ''; + + $x = ''; + for ($i = 1; $i < 6; $i++) + { + if (!$gemCnd['color'.$i]) + continue; + + $fiColors = function (int $idx) + { + return match ($idx) + { + 2 => '0:3:5', // red + 3 => '2:4:5', // yellow + 4 => '1:3:4', // blue + default => '' // uhhh.... + }; + }; + + $bLink = $gemCnd['color'.$i] ? ($interactive ? ''. Lang::item('gemColors', $gemCnd['color'.$i] - 1).'' : Lang::item('gemColors', $gemCnd['color'.$i] - 1)) : ''; + $cLink = $gemCnd['cmpColor'.$i] ? ($interactive ? ''.Lang::item('gemColors', $gemCnd['cmpColor'.$i] - 1).'' : Lang::item('gemColors', $gemCnd['cmpColor'.$i] - 1)) : ''; + + switch ($gemCnd['comparator'.$i]) + { + case ENCHANT_CONDITION_LESS_VALUE: // requires less than N gems + case ENCHANT_CONDITION_MORE_VALUE: // requires at least N gems + $x .= ''.Lang::item('gemRequires').Lang::item('gemConditions', $gemCnd['comparator'.$i], [$gemCnd['value'.$i], $bLink]).'
'; + break; + case ENCHANT_CONDITION_MORE_COMPARE: // requires more gems than gems + $x .= ''.Lang::item('gemRequires').Lang::item('gemConditions', $gemCnd['comparator'.$i], [$bLink, $cLink]).'
'; + break; + } + } + + return $x; + } } ?> diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 5bf20b79..8b6484f0 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -65,7 +65,7 @@ $lang = array( // filter 'extSearch' => "Erweiterte Suche", 'addFilter' => "Weiteren Filter hinzufügen", - 'match' => "Verwendete Filter", + 'match' => "Verwendete Filter: ", 'allFilter' => "Alle Filter", 'oneFilter' => "Mindestens einer", 'applyFilter' => "Filter anwenden", @@ -2118,10 +2118,11 @@ $lang = array( 'gemColors' => array( // *_GEM "Meta", "Rot", "Gelb", "Blau" ), + 'gemRequires' => "Benötigt ", // ENCHANT_CONDITION_REQUIRES 'gemConditions' => array( // ENCHANT_CONDITION_* in GlobalStrings.lua; 2 not in use (use as PH) - 2 => "weniger als %d |4Edelstein:Edelsteine; der Kategorie %s", - 3 => "mehr Edelsteine der Kategorie %s als Edelsteine der Kategorie %s", - 5 => "mindestens %d |4Edelstein:Edelsteine; der Kategorie %s" + ENCHANT_CONDITION_LESS_VALUE => "weniger als %d |4Edelstein:Edelsteine; der Kategorie %s", + ENCHANT_CONDITION_MORE_COMPARE => "mehr Edelsteine der Kategorie %s als Edelsteine der Kategorie %s", + ENCHANT_CONDITION_MORE_VALUE => "mindestens %d |4Edelstein:Edelsteine; der Kategorie %s" ), 'reqRating' => array( // ITEM_REQ_ARENA_RATING* "Benötigt eine persönliche Arenawertung und Teamwertung von %d.", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 4ee8b007..4943a7b6 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -65,7 +65,7 @@ $lang = array( // filter 'extSearch' => "Extended search", 'addFilter' => "Add another Filter", - 'match' => "Match", + 'match' => "Match: ", 'allFilter' => "All filters", 'oneFilter' => "At least one", 'applyFilter' => "Apply filter", @@ -2118,10 +2118,11 @@ $lang = array( 'gemColors' => array( // *_GEM "meta", "red", "yellow", "blue" ), + 'gemRequires' => "Requires ", // ENCHANT_CONDITION_REQUIRES 'gemConditions' => array( // ENCHANT_CONDITION_* in GlobalStrings.lua - 2 => "less than %d %s |4gem:gems;", - 3 => "more %s gems than %s gems", - 5 => "at least %d %s |4gem:gems;" + ENCHANT_CONDITION_LESS_VALUE => "less than %d %s |4gem:gems;", + ENCHANT_CONDITION_MORE_COMPARE => "more %s gems than %s gems", + ENCHANT_CONDITION_MORE_VALUE => "at least %d %s |4gem:gems;" ), 'reqRating' => array( // ITEM_REQ_ARENA_RATING* "Requires personal and team arena rating of %d", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 990a72e8..6b433f51 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -65,7 +65,7 @@ $lang = array( // filter 'extSearch' => "Extender búsqueda", 'addFilter' => "Añadir otro filtro", - 'match' => "Aplicar", + 'match' => "Aplicar: ", 'allFilter' => "Todos los filtros", 'oneFilter' => "Por lo menos uno", 'applyFilter' => "Aplicar filtro", @@ -2118,10 +2118,11 @@ $lang = array( 'gemColors' => array( // *_GEM "meta", "roja(s)", "amarilla(s)", "azul(es)" ), + 'gemRequires' => "Requiere ", // ENCHANT_CONDITION_REQUIRES 'gemConditions' => array( // ENCHANT_CONDITION_* - 2 => "menos de %d |4gema:gemas; %s", - 3 => "más gemas %s que gemas %s", - 5 => "al menos %d |4gema:gemas; %s" + ENCHANT_CONDITION_LESS_VALUE => "menos de %d |4gema:gemas; %s", + ENCHANT_CONDITION_MORE_COMPARE => "más gemas %s que gemas %s", + ENCHANT_CONDITION_MORE_VALUE => "al menos %d |4gema:gemas; %s" ), 'reqRating' => array( // ITEM_REQ_ARENA_RATING* "Requiere un índice de arena personal y de equipo de %d", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 9ec26785..0c98bea8 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -65,7 +65,7 @@ $lang = array( // filter 'extSearch' => "Recherche avancée", 'addFilter' => "Ajouter un autre filtre", - 'match' => "Critère", + 'match' => "Critère : ", 'allFilter' => "Tous les filtres", 'oneFilter' => "Au moins un", 'applyFilter' => "Appliquer le filtre", @@ -2118,10 +2118,11 @@ $lang = array( 'gemColors' => array( // *_GEM "Méta", "rouge(s)", "jaune(s)", "bleue(s)" ), + 'gemRequires' => "Nécessite ", // ENCHANT_CONDITION_REQUIRES 'gemConditions' => array( // ENCHANT_CONDITION_* - 2 => "moins de %d |4gemme:gemmes; %s", - 3 => "plus de gemmes %s que |2 %s", - 5 => "au moins %d |4gemme:gemmes; %s" + ENCHANT_CONDITION_LESS_VALUE => "moins de %d |4gemme:gemmes; %s", + ENCHANT_CONDITION_MORE_COMPARE => "plus de gemmes %s que |2 %s", + ENCHANT_CONDITION_MORE_VALUE => "au moins %d |4gemme:gemmes; %s" ), 'reqRating' => array( // ITEM_REQ_ARENA_RATING* "Nécessite une cote d'arène personnelle et en équipe de %d", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index eb19d8c7..d9fc189b 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -65,7 +65,7 @@ $lang = array( // filter 'extSearch' => "Расширенный поиск", 'addFilter' => "Добавить другой фильтр", - 'match' => "Совпадение", + 'match' => "Совпадение: ", 'allFilter' => "Все фильтры", 'oneFilter' => "Любое совпадение", 'applyFilter' => "Применить фильтр", @@ -2119,10 +2119,11 @@ $lang = array( 'gemColors' => array( // *_GEM "Особый", "Красный", "Желтый", "Синий" ), + 'gemRequires' => "Требуется ", // ENCHANT_CONDITION_REQUIRES 'gemConditions' => array( // ENCHANT_CONDITION_* - 2 => "меньше, чем %d |4камень:камня:камней; |3-1(%s) цвета", - 3 => "больше |3-7(%s), чем |3-7(%s) камней", - 5 => "хотя бы %d |4камень:камня:камней; |3-1(%s) цвета" + ENCHANT_CONDITION_LESS_VALUE => "меньше, чем %d |4камень:камня:камней; |3-1(%s) цвета", + ENCHANT_CONDITION_MORE_COMPARE => "больше |3-7(%s), чем |3-7(%s) камней", + ENCHANT_CONDITION_MORE_VALUE => "хотя бы %d |4камень:камня:камней; |3-1(%s) цвета" ), 'reqRating' => array( // ITEM_REQ_ARENA_RATING* "Требуется личный и командный рейтинг на арене не ниже %d", diff --git a/localization/locale_zhcn.php b/localization/locale_zhcn.php index eee9b77b..fe0920a4 100644 --- a/localization/locale_zhcn.php +++ b/localization/locale_zhcn.php @@ -10,7 +10,6 @@ if (!defined('AOWOW_REVISION')) - $lang = array( // page variables 'timeUnits' => array( @@ -66,7 +65,7 @@ $lang = array( // filter 'extSearch' => "扩展搜索", 'addFilter' => "添加一个过滤器", - 'match' => "匹配", + 'match' => "匹配:", 'allFilter' => "所有过滤器", 'oneFilter' => "至少一个", 'applyFilter' => "应用过滤", @@ -2118,10 +2117,11 @@ $lang = array( 'gemColors' => array( "多彩", "红色", "黄色", "蓝色" ), + 'gemRequires' => "需要 ", 'gemConditions' => array( - 2 => "少于%d颗%s宝石", - 3 => "%s宝石的数量多于%s宝石", - 5 => "至少%d颗%s宝石" + ENCHANT_CONDITION_LESS_VALUE => "少于%d颗%s宝石", + ENCHANT_CONDITION_MORE_COMPARE => "%s宝石的数量多于%s宝石", + ENCHANT_CONDITION_MORE_VALUE => "至少%d颗%s宝石" ), 'reqRating' => array( "需要个人竞技场等级和战队竞技场等级达到%d", diff --git a/pages/enchantments.php b/pages/enchantments.php deleted file mode 100644 index fb346dee..00000000 --- a/pages/enchantments.php +++ /dev/null @@ -1,108 +0,0 @@ - ['filter' => FILTER_UNSAFE_RAW]]; - - public function __construct($pageCall, $pageParam) - { - $this->getCategoryFromUrl($pageParam); - - parent::__construct($pageCall, $pageParam); - - $this->filterObj = new EnchantmentListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); - - $this->name = Util::ucFirst(Lang::game('enchantments')); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; - } - - protected function generateContent() - { - $tabData = array( - 'data' => [], - 'name' => Util::ucFirst(Lang::game('enchantments')) - ); - - $conditions = []; - - if (!User::isInGroup(U_GROUP_EMPLOYEE)) - $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; - - $this->filterObj->evalCriteria(); - - if ($_ = $this->filterObj->getConditions()) - $conditions[] = $_; - - $ench = new EnchantmentList($conditions, ['calcTotal' => true]); - - $tabData['data'] = array_values($ench->getListviewData()); - $this->extendGlobalData($ench->getJSGlobals()); - - $xCols = []; - foreach (Stat::getFilterCriteriumIdFor() as $idx => $fiId) - if (array_filter(array_column($tabData['data'], Stat::getJsonString($idx)))) - $xCols[] = $fiId; - - // some kind of declaration conflict going on here..., expects colId for WEAPON_DAMAGE_MAX but jsonString is WEAPON_DAMAGE - if (array_filter(array_column($tabData['data'], 'dmg'))) - $xCols[] = Stat::getFilterCriteriumId(Stat::WEAPON_DAMAGE_MAX); - - if ($xCols) - $this->filterObj->fiExtraCols = array_merge($this->filterObj->fiExtraCols, $xCols); - - if ($this->filterObj->fiExtraCols) - $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; - - if ($ench->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) - { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); - $tabData['_truncated'] = 1; - } - - if (array_filter(array_column($tabData['data'], 'spells'))) - $tabData['visibleCols'] = ['trigger']; - - if (!$ench->hasSetFields('skillLine')) - $tabData['hiddenCols'] = ['skill']; - - if ($this->filterObj->error) - $tabData['_errors'] = '$1'; - - $this->lvTabs[] = [EnchantmentList::$brickFile, $tabData, 'enchantment']; - } - - protected function generateTitle() - { - $form = $this->filterObj->values; - if (count($form['ty']) == 1) - array_unshift($this->title, Lang::enchantment('types', $form['ty'][0])); - - array_unshift($this->title, $this->name); - } - - protected function generatePath() - { - $form = $this->filterObj->values; - if (count($form['ty']) == 1) - $this->path[] = $form['ty'][0]; - } -} - -?> diff --git a/template/pages/enchantment.tpl.php b/template/pages/enchantment.tpl.php index 8cfc6bdc..83f1350f 100644 --- a/template/pages/enchantment.tpl.php +++ b/template/pages/enchantment.tpl.php @@ -1,7 +1,10 @@ - +brick('header'); ?> + use \Aowow\Lang; + $this->brick('header'); +?>
@@ -18,11 +21,11 @@ brick('redButtons'); ?> -

name; ?>

+

h1; ?>

-brick('article'); ?> +brick('markup', ['markup' => $this->article]); ?>

@@ -34,7 +37,7 @@ activation)): +if ($this->activation): ?> @@ -49,17 +52,17 @@ foreach ($this->effects as $i => $e): )' : '').''; + echo ' '.$e['name'].($e['tip'] ? Lang::main('colon').'()' : '').''; - if (isset($e['value'])): - echo '
'.Lang::spell('_value').Lang::main('colon').$e['value']; + if ($e['value']): + echo '
'.Lang::spell('_value').Lang::main('colon').$e['value']; endif; - if (!empty($e['proc'])): - echo '
'; + if ($e['proc']): + echo '
'; if ($e['proc'] < 0): - echo sprintf(Lang::spell('ppm'), Lang::nf(-$e['proc'], 1)); + echo Lang::spell('ppm', [Lang::nf(-$e['proc'], 1)]); elseif ($e['proc'] < 100.0): echo Lang::spell('procChance').Lang::main('colon').$e['proc'].'%'; endif; @@ -67,12 +70,12 @@ foreach ($this->effects as $i => $e): echo "
\n"; - if (!empty($e['tip'])): + if ($e['tip']): ?> brick('lvTabs', ['relTabs' => true]); +$this->brick('lvTabs'); $this->brick('contribute'); ?> diff --git a/template/pages/enchantments.tpl.php b/template/pages/enchantments.tpl.php index a00c8bd8..3fbb0ad6 100644 --- a/template/pages/enchantments.tpl.php +++ b/template/pages/enchantments.tpl.php @@ -1,10 +1,11 @@ - - brick('header'); -$f = $this->filterObj->values // shorthand -?> + namespace Aowow\Template; + use \Aowow\Lang; + +$this->brick('header'); +$f = $this->filter->values; // shorthand +?>
@@ -12,31 +13,32 @@ $f = $this->filterObj->values // shorthand brick('announcement'); -$this->brick('pageTemplate', ['fiQuery' => $this->filterObj->query, 'fiMenuItem' => [101]]); +$this->brick('pageTemplate', ['fiQuery' => $this->filter->query, 'fiMenuItem' => [101]]); ?> - -
+
+
+brick('headIcons'); + +$this->brick('redButtons'); +?> +

h1; ?>

+
-
+
- + @@ -45,7 +47,7 @@ endforeach;
- /> /> + /> />
@@ -59,7 +61,7 @@ endforeach;
-brick('filter'); ?> +renderFilter(12); ?> brick('lvTabs'); ?>
ucFirst(Lang::main('name')).Lang::main('colon'); ?> - +
 /> />