From 06e5fb72785a608f8bc2213b82bc1afeee8cdf7c Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 3 Aug 2013 21:10:49 +0200 Subject: [PATCH] * added quests to search * added forgotten localizations --- includes/class.item.php | 30 +++++++++++++----- includes/class.quest.php | 47 ++++++++++++++++++++++++----- includes/utilities.php | 12 +++++--- localization/locale_dede.php | 6 +++- localization/locale_enus.php | 8 +++-- localization/locale_eses.php | 6 +++- localization/locale_frfr.php | 6 +++- localization/locale_ruru.php | 6 +++- pages/itemset.php | 2 +- search.php | 45 +++++++++++++++++++++------ template/bricks/listviews/item.tpl | 16 ++++++++-- template/bricks/listviews/quest.tpl | 19 +++++++++--- 12 files changed, 160 insertions(+), 43 deletions(-) diff --git a/includes/class.item.php b/includes/class.item.php index 7f9f210f..22391367 100644 --- a/includes/class.item.php +++ b/includes/class.item.php @@ -5,6 +5,8 @@ if (!defined('AOWOW_REVISION')) class ItemList extends BaseType { + use ListviewHelper; + public static $type = TYPE_ITEM; public $tooltip = ''; @@ -34,6 +36,15 @@ class ItemList extends BaseType // readdress itemset .. is wrong for virtual sets if ($pieceToSet && isset($pieceToSet[$this->id])) $this->json[$this->id]['itemset'] = $pieceToSet[$this->id]; + + // unify those pesky masks + $_ = $this->curTpl['AllowableClass']; + if ($_ < 0 || ($_ & CLASS_MASK_ALL) == CLASS_MASK_ALL) + $this->templates[$this->id]['AllowableClass'] = 0; + + $_ = $this->curTpl['AllowableRace']; + if ($_ < 0 || ($_ & RACE_MASK_ALL) == RACE_MASK_ALL) + $this->templates[$this->id]['AllowableRace'] = 0; } $this->reset(); // restore 'iterator' @@ -134,13 +145,15 @@ class ItemList extends BaseType if ($x = $this->curTpl['ContainerSlots']) $data[$this->id]['nslots'] = $x; + $_ = $this->curTpl['AllowableRace']; + if ($_ && $_ & RACE_MASK_ALLIANCE != RACE_MASK_ALLIANCE && $_ & RACE_MASK_HORDE != RACE_MASK_HORDE) + $data[$this->id]['reqrace'] = $_; - if (!in_array($this->curTpl['AllowableRace'], [-1, 0]) && $this->curTpl['AllowableRace'] & RACE_MASK_ALL != RACE_MASK_ALL && - $this->curTpl['AllowableRace'] & RACE_MASK_ALLIANCE != RACE_MASK_ALLIANCE && $this->curTpl['AllowableRace'] & RACE_MASK_HORDE != RACE_MASK_HORDE) - $data[$this->id]['reqrace'] = $this->curTpl['AllowableRace']; + if ($_ = $this->curTpl['AllowableClass']) + $data[$this->id]['reqclass'] = $_; // $data[$this->id]['classes'] ?? - if (!in_array($this->curTpl['AllowableClass'], [-1, 0]) && $this->curTpl['AllowableClass'] & CLASS_MASK_ALL != CLASS_MASK_ALL) - $data[$this->id]['reqclass'] = $this->curTpl['AllowableClass']; // $data[$this->id]['classes'] ?? + if ($this->curTpl['Flags'] & ITEM_FLAG_HEROIC) + $data[$this->id]['heroic'] = true; } /* even more complicated crap @@ -486,7 +499,8 @@ class ItemList extends BaseType // required races if ($races = Lang::getRaceString($this->curTpl['AllowableRace'])) - $x .= Lang::$game['races'].Lang::$colon.$races['name'].'
'; + if ($races['side'] != SIDE_BOTH) + $x .= Lang::$game['races'].Lang::$colon.$races['name'].'
'; // required honorRank (not used anymore) if ($this->curTpl['requiredhonorrank']) @@ -876,7 +890,7 @@ class ItemList extends BaseType } foreach ($this->json[$this->id] as $k => $v) - if (!isset($v) || $v === "false" || (!in_array($k, ['classs', 'subclass', 'quality']) && $v == "0")) + if (!isset($v) || $v === "false" || (!in_array($k, ['classs', 'subclass', 'quality', 'side']) && $v == "0")) unset($this->json[$this->id][$k]); } @@ -1049,7 +1063,7 @@ class ItemList extends BaseType // clear zero-values afterwards foreach ($json as $k => $v) - if (!isset($v) || $v === "false" || (!in_array($k, ['classs', 'subclass', 'quality']) && $v == "0")) + if (!isset($v) || $v === "false" || (!in_array($k, ['classs', 'subclass', 'quality', 'side']) && $v == "0")) unset($json[$k]); $this->json[$json['id']] = $json; diff --git a/includes/class.quest.php b/includes/class.quest.php index 284b722d..393b6f71 100644 --- a/includes/class.quest.php +++ b/includes/class.quest.php @@ -11,7 +11,7 @@ class QuestList extends BaseType public $cat2 = 0; protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM quest_template qt LEFT JOIN locales_quest lq ON qt.Id = lq.entry WHERE [filter] [cond] ORDER BY Id ASC'; - protected $matchQuery = 'SELECT COUNT(1) FROM quest_template WHERE [filter] [cond]'; + protected $matchQuery = 'SELECT COUNT(1) FROM quest_template qt LEFT JOIN locales_quest lq ON qt.Id = lq.entry WHERE [filter] [cond]'; // parent::__construct does the job @@ -61,11 +61,13 @@ class QuestList extends BaseType return Util::localizedString($n, 'title'); } - public static function RewardXP($QuestLevel, $XPId) + public static function getXPReward($questLevel, $xpId) { - if ($xp = DB::Aowow()->SelectCell('SELECT Field?d FROM ?_questxp WHERE Id = ?d', $XPId, $QuestLevel)) { + if (!is_numeric($xpId) || $xpId < 0 || $xpId > 8) + return 0; + + if ($xp = DB::Aowow()->selectCell('SELECT Field?d FROM ?_questxp WHERE Id = ?d', $xpId, $questLevel)) return $xp; - } else return 0; } @@ -102,7 +104,9 @@ class QuestList extends BaseType 'level' => $this->curTpl['Level'], 'reqlevel' => $this->curTpl['MinLevel'], 'name' => $this->getField('Title', true), - 'side' => Util::sideByRaceMask($this->curTpl['RequiredRaces']) + 'side' => Util::sideByRaceMask($this->curTpl['RequiredRaces']), + 'wflags' => 0x0, + 'xp' => self::getXPReward($this->curTpl['Level'], $this->curTpl['RewardXPId']) ); $rewards = []; @@ -121,8 +125,37 @@ class QuestList extends BaseType if ($choices) $data[$this->id]['itemchoices'] = $choices; - if ($this->curTpl['RewardTitleId']) - $data[$this->id]['titlereward'] = $this->curTpl['RewardTitleId']; + if ($_ = $this->curTpl['RewardTitleId']) + $data[$this->id]['titlereward'] = $_; + + if ($_ = $this->curTpl['Type']) + $data[$this->id]['type'] = $_; + + if ($_ = $this->curTpl['RequiredClasses']) + $data[$this->id]['reqclass'] = $_; + + if ($_ = $this->curTpl['RequiredRaces']) + $data[$this->id]['reqrace'] = $_; + + if ($_ = $this->curTpl['RewardOrRequiredMoney']) + if ($_ > 0) + $data[$this->id]['money'] = $_; + + if ($this->curTpl['Flags'] & 0x1000) + $data[$this->id]['daily'] = true; + + if ($this->curTpl['Flags'] & 0x8000) + $data[$this->id]['weekly'] = true; + + // flags & 64: Hostile - there are quests, that flag the player for pvp when taken .. where is that set..? + if ($this->curTpl['Flags'] & 0x4000) // Unavailable (todo (med): get disables) + { + $data[$this->id]['historical'] = true; // post 5.0 + $data[$this->id]['wflags'] |= 0x1; // pre 5.0 + } + + if ($this->curTpl['Flags'] & 0x80000) // Auto Accept + $data[$this->id]['wflags'] |= 0x20; // todo reprewards .. accesses QuestFactionReward.dbc } diff --git a/includes/utilities.php b/includes/utilities.php index e68ef1fc..c772acab 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -400,6 +400,7 @@ class Lang public static $error; public static $search; + public static $profiler; public static $compare; public static $talent; @@ -1722,16 +1723,19 @@ class Util public static function sideByRaceMask($race) { - if (!$race || $race == RACE_MASK_ALL) // Any + // Any + if (!$race || ($race & RACE_MASK_ALL) == RACE_MASK_ALL) return 3; - if ($race & RACE_MASK_HORDE) // Horde + // Horde + if ($race & RACE_MASK_HORDE && !($race & RACE_MASK_ALLIANCE)) return 2; - if ($race & RACE_MASK_ALLIANCE) // Alliance + // Alliance + if ($race & RACE_MASK_ALLIANCE && !($race & RACE_MASK_HORDE)) return 1; - return 0; + return 3; } public static function asHex($val) diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 160ffb45..d46de014 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -68,6 +68,8 @@ $lang = array( 'applyFilter' => "Filter anwenden", 'resetForm' => "Formular zurücksetzen", 'refineSearch' => "Tipp: Präzisiere deine Suche mit Durchsuchen einer Unterkategorie.", + 'clear' => "leeren", + 'exactMatch' => "Exakt passend", // infobox 'unavailable' => "Nicht für Spieler verfügbar", @@ -116,6 +118,8 @@ $lang = array( 'pets' => "Begleiter", 'petCalc' => "Begleiterrechner", 'requires' => "Benötigt %s", + 'profile' => "", + 'profiles' => "Profile", 'requires2' => "Benötigt", 'reqLevel' => "Benötigt Stufe %s", 'reqLevelHlm' => "Benötigt Stufe %s", @@ -297,8 +301,8 @@ $lang = array( '_conveyBonus' => "Das Tragen mehrerer Gegenstände aus diesem Set gewährt Eurem Charakter Boni.", '_pieces' => "Teile", '_unavailable' => "Dieses Ausrüstungsset ist nicht für Spieler verfügbar.", - '_type' => "Art", '_tag' => "Tag", + '_type' => "Art", 'notes' => array( null, "Dungeon-Set 1", "Dungeon-Set 2", "Tier 1 Raid-Set", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index ad348a24..fb082bcb 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -16,7 +16,7 @@ $lang = array( 'numSQL' => "Number of MySQL queries", 'timeSQL' => "Time of MySQL queries", 'noJScript' => "This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.", - 'profiles' => "Your Characters", + 'profiles' => "My Profiles", 'pageNotFound' => "This %s doesn't exist.", 'gender' => "Gender", 'sex' => [null, 'Male', 'Female'], @@ -63,6 +63,8 @@ $lang = array( 'applyFilter' => "Apply filter", 'resetForm' => "Reset Form", 'refineSearch' => "Tip: Refine your search by browsing a subcategory.", + 'clear' => "clear", + 'exactMatch' => "Exact match", // infobox 'unavailable' => "Not available to players", @@ -110,6 +112,8 @@ $lang = array( 'pet' => "Pet", 'pets' => "Hunter Pets", 'petCalc' => "Hunter Pet Calculator", + 'profile' => "profile", + 'profiles' => "Profiles", 'requires' => "Requires %s", 'requires2' => "Requires", 'reqLevel' => "Requires Level %s", @@ -119,7 +123,6 @@ $lang = array( 'school' => "School", 'spell' => "spell", 'spells' => "Spells", - 'type' => "Type", 'valueDelim' => " to ", 'zone' => "zone", 'zones' => "Zones", @@ -294,6 +297,7 @@ $lang = array( '_pieces' => "pieces", '_unavailable' => "This item set is not available to players.", '_tag' => "Tag", + '_type' => "Type", 'notes' => array( null, "Dungeon Set 1", "Dungeon Set 2", "Tier 1 Raid Set", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index c08e0de8..da98d2f3 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -60,6 +60,8 @@ $lang = array( 'applyFilter' => "Aplicar filtro", 'resetForm' => "Reiniciar formulario", 'refineSearch' => "Sugerencia: Refina tu búsqueda llendo a una subcategoría.", + 'clear' => "borrar", + 'exactMatch' => "Coincidencia exacta", // infobox 'unavailable' => "No está disponible a los jugadores", @@ -107,6 +109,8 @@ $lang = array( 'pet' => "Mascota", 'pets' => "Mascotas de cazador", 'petCalc' => "Calculadora de mascotas", + 'profile' => "", + 'profiles' => "Perfiles", 'requires' => "Requiere %s", 'requires2' => "Requiere", 'reqLevel' => "Necesitas ser de nivel %s", @@ -116,7 +120,6 @@ $lang = array( 'school' => "Escuela", 'spell' => "hechizo", 'spells' => "Hechizos", - 'type' => "Tipo", 'valueDelim' => " - ", 'zone' => "zona", 'zones' => "Zonas", @@ -252,6 +255,7 @@ $lang = array( '_pieces' => "piezas", '_unavailable' => "Este conjunto de objetos no está disponible para jugadores.", '_tag' => "Etiqueta", + '_type' => "Tipo", 'notes' => array( null, "Set de mazmorra 1", "Set de mazmorra 2", "Set de banda tier 1", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 327398a0..4ff3e9c9 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -60,6 +60,8 @@ $lang = array( 'applyFilter' => "Appliquer le filtre", 'resetForm' => "Rétablir", 'refineSearch' => "Astuce : Affinez votre recherche en utilisant une sous-catégorie.", + 'clear' => "effacer", + 'exactMatch' => "Concordance exacte", // infobox 'unavailable' => "Non disponible aux joueurs", @@ -107,6 +109,8 @@ $lang = array( 'pet' => "Familier", 'pets' => "Familiers de chasseur", 'petCalc' => "Calculateur de familiers", + 'profile' => "", + 'profiles' => "Profils", 'requires' => "%s requis", 'requires2' => "Requiert", 'reqLevel' => "Niveau %s requis", @@ -116,7 +120,6 @@ $lang = array( 'school' => "École", 'spell' => "sort", 'spells' => "Sorts", - 'type' => "Type", 'valueDelim' => " - ", 'zone' => "zone", 'zones' => "Zones", @@ -251,6 +254,7 @@ $lang = array( '_pieces' => "pièces", '_unavailable' => "Cet objet n'est plus disponible aux joueurs.", '_tag' => "Étiquette", + '_type' => "Type", 'notes' => array( null, "Ensemble de donjon 1", "Ensemble de donjon 2", "Ensemble de raid palier 1", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 08451d27..d37e68ee 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -60,6 +60,8 @@ $lang = array( 'applyFilter' => "Применить фильтр", 'resetForm' => "Очистить форму", 'refineSearch' => "Совет: Уточните поиск, добавив подкатегорию.", + 'clear' => "Очистить", + 'exactMatch' => "Полное совпадение", // infobox 'unavailable' => "Недоступно игрокам", @@ -106,6 +108,8 @@ $lang = array( 'mechAbbr' => "Механика", 'pet' => "Питомец", 'pets' => "Питомцы охотников", + 'profile' => "", + 'profiles' => "Профили", 'petCalc' => "Расчёт умений питомцев", 'requires' => "Требует %s", 'requires2' => "Требуется:", @@ -116,7 +120,6 @@ $lang = array( 'school' => "Школа", 'spell' => "заклинание", 'spells' => "Заклинания", - 'type' => "Тип", 'valueDelim' => " - ", 'zone' => "игровая зона", 'zones' => "Местности", @@ -251,6 +254,7 @@ $lang = array( '_pieces' => "частей", '_unavailable' => "Этот набор предметов не доступен игрокам.", '_tag' => "Тэг", + '_type' => "Тип", 'notes' => array( null, "Комплект подземелий 1", "Комплект подземелий 2", "Рейдовый комплект Tier 1", diff --git a/pages/itemset.php b/pages/itemset.php index 42b831fc..8c8ba9f9 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -68,7 +68,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) // type if ($ty) - $infobox[] = Lang::$game['type'].lang::$colon.Lang::$itemset['types'][$ty]; + $infobox[] = Lang::$itemset['_type'].lang::$colon.Lang::$itemset['types'][$ty]; // tag if ($ta) diff --git a/search.php b/search.php index 6fda6e86..5cc20e70 100644 --- a/search.php +++ b/search.php @@ -34,7 +34,7 @@ if (!defined('AOWOW_REVISION')) 13: Listview - template: 'spell', id: 'companions', name: LANG.tab_companions, 14: Listview - template: 'spell', id: 'mounts', name: LANG.tab_mounts, todo 15: Listview - template: 'npc', id: 'npcs', name: LANG.tab_npcs, -todo 16: Listview - template: 'quest', id: 'quests', name: LANG.tab_quests, + 16: Listview - template: 'quest', id: 'quests', name: LANG.tab_quests, 17: Listview - template: 'achievement', id: 'achievements', name: LANG.tab_achievements, 18: Listview - template: 'achievement', id: 'statistics', name: LANG.tab_statistics, todo 19: Listview - template: 'zone', id: 'zones', name: LANG.tab_zones, @@ -698,7 +698,36 @@ if ($searchMask & 0x4000) } // 16 Quests -// if ($searchMask & 0x8000) +if ($searchMask & 0x8000) +{ + $conditions = array( +// [['cuFlags', MASK, '&'], 0], // todo (med): identify disabled quests + [User::$localeId ? 'Title_loc'.User::$localeId : 'Title', $query], // todo (high): unify name-fields + $maxResults + ); + + $quests = new QuestList($conditions); + + if ($data = $quests->getListviewData()) + { + $quests->addGlobalsToJScript($smarty); + + $found['quest'] = array( + 'type' => TYPE_QUEST, + 'appendix' => ' (Quest)', + 'matches' => $quests->getMatches(), + 'file' => 'quest', + 'data' => $data, + 'params' => ['tabs' => '$myTabs'] + ); + } + + if ($quests->getMatches() > $maxResults) + { + $found['quest']['params']['note'] = '$'.sprintf(Util::$narrowResultString, 'LANG.lvnote_questsfound', $quests->getMatches(), $maxResults); + $found['quest']['params']['_truncated'] = 1; + } +} // 17 Achievements if ($searchMask & 0x10000) @@ -726,7 +755,7 @@ if ($searchMask & 0x10000) 'data' => $data, 'params' => [ 'tabs' => '$myTabs', - 'visibleCols' => "\$['category']" + 'visibleCols' => "$['category']" ] ); @@ -760,8 +789,8 @@ if ($searchMask & 0x20000) 'data' => $data, 'params' => [ 'tabs' => '$myTabs', - 'visibleCols' => "\$['category']", - 'hiddenCols' => "\$['side', 'points', 'rewards']", + 'visibleCols' => "$['category']", + 'hiddenCols' => "$['side', 'points', 'rewards']", 'name' => '$LANG.tab_statistics', 'id' => 'statistics' ] @@ -803,9 +832,7 @@ if ($searchMask & 0x400000) 'matches' => $pets->getMatches(), 'file' => 'pet', 'data' => $data, - 'params' => [ - 'tabs' => '$myTabs', - ] + 'params' => ['tabs' => '$myTabs'] ); if ($pets->getMatches() > $maxResults) @@ -960,7 +987,7 @@ if ($searchMask & SEARCH_TYPE_JSON) } else if ($searchMask & SEARCH_TYPE_OPEN) { - // this one is funny: we want 10 results, ideally equally destributed over each type + // this one is funny: we want 10 results, ideally equally distributed over each type $foundTotal = 0; $maxResults = 10; $names = []; diff --git a/template/bricks/listviews/item.tpl b/template/bricks/listviews/item.tpl index 4d71a25e..a1544b78 100644 --- a/template/bricks/listviews/item.tpl +++ b/template/bricks/listviews/item.tpl @@ -21,10 +21,20 @@ {if isset($curr.reqlevel)} reqlevel:{$curr.reqlevel}, {/if} - classs:{$curr.classs}, - subclass:{$curr.subclass}, + classs:{$curr.classs}, + subclass:{$curr.subclass}, + side:{$curr.side}, + {if isset($curr.reqclass)} + reqclass:{$curr.reqclass}, + {/if} + {if isset($curr.reqrace)} + reqrace:{$curr.reqrace}, + {/if} + {if isset($curr.heroic)} + heroic:1, + {/if} {if isset($curr.maxcount)} - {if $curr.maxcount>1} + {if $curr.maxcount > 1} stack:[{$curr.mincount},{$curr.maxcount}], {/if} {/if} diff --git a/template/bricks/listviews/quest.tpl b/template/bricks/listviews/quest.tpl index 806d05a0..956c137b 100644 --- a/template/bricks/listviews/quest.tpl +++ b/template/bricks/listviews/quest.tpl @@ -17,9 +17,15 @@ id:'{$curr.id}', name:'{$curr.name|escape:"quotes"}', level:'{$curr.level}', - {if ($curr.reqlevel)} + {if isset($curr.reqlevel)} reqlevel:{$curr.reqlevel}, {/if} + {if isset($curr.reqclass)} + reqclass:{$curr.reqclass}, + {/if} + {if isset($curr.reqrace)} + reqrace:{$curr.reqrace}, + {/if} side:'{$curr.side}' {if isset($curr.itemrewards)} ,itemrewards:[ @@ -37,7 +43,7 @@ {/section} ] {/if} - {if isset($curr.xp)} + {if $curr.xp} ,xp:{$curr.xp} {/if} {if isset($curr.titlereward)} @@ -55,11 +61,14 @@ {if isset($curr.type)} ,type:{$curr.type} {/if} - {if isset($curr.Daily)} + {if isset($curr.daily)} ,daily:1 {/if} - {if isset($curr.flags)} - ,wflags:$curr.flags {* wflags: &1: disabled/historical; &32: AutoAccept; &64: Hostile(?) *} + {if isset($curr.weekly)} + ,weekly:1 + {/if} + {if $curr.wflags} + ,wflags:{$curr.wflags} {* wflags: &1: disabled/historical; &32: AutoAccept; &64: Hostile(?) *} {/if} {rdelim} {if $smarty.foreach.i.last}{else},{/if}