From 04e55b54983aaaee564e06f1cf71fe717fd67237 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Fri, 25 Mar 2022 15:24:51 +0100 Subject: [PATCH] NPCs/Vendors * show restock time if available --- includes/types/item.class.php | 14 ++++++++------ pages/npc.php | 13 ++++++++++--- static/js/locale_dede.js | 2 ++ static/js/locale_enus.js | 2 ++ static/js/locale_eses.js | 2 ++ static/js/locale_frfr.js | 2 ++ static/js/locale_ruru.js | 2 ++ static/js/locale_zhcn.js | 2 ++ template/listviews/vendorRestockCol.tpl.php | 14 ++++++++++++++ 9 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 template/listviews/vendorRestockCol.tpl.php diff --git a/includes/types/item.class.php b/includes/types/item.class.php index 2354f50a..139c11e8 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -102,9 +102,9 @@ class ItemList extends BaseType $itemz = []; $xCostData = []; $rawEntries = DB::World()->select(' - SELECT nv.item, nv.entry, 0 AS eventId, nv.maxcount, nv.extendedCost FROM npc_vendor nv WHERE {nv.entry IN (?a) AND} nv.item IN (?a) + SELECT nv.item, nv.entry, 0 AS eventId, nv.maxcount, nv.extendedCost, nv.incrtime FROM npc_vendor nv WHERE {nv.entry IN (?a) AND} nv.item IN (?a) UNION - SELECT genv.item, c.id AS `entry`, ge.eventEntry AS eventId, genv.maxcount, genv.extendedCost FROM game_event_npc_vendor genv LEFT JOIN game_event ge ON genv.eventEntry = ge.eventEntry JOIN creature c ON c.guid = genv.guid WHERE {c.id IN (?a) AND} genv.item IN (?a)', + SELECT genv.item, c.id AS `entry`, ge.eventEntry AS eventId, genv.maxcount, genv.extendedCost, genv.incrtime FROM game_event_npc_vendor genv LEFT JOIN game_event ge ON genv.eventEntry = ge.eventEntry JOIN creature c ON c.guid = genv.guid WHERE {c.id IN (?a) AND} genv.item IN (?a)', empty($filter[Type::NPC]) || !is_array($filter[Type::NPC]) ? DBSIMPLE_SKIP : $filter[Type::NPC], array_keys($this->templates), empty($filter[Type::NPC]) || !is_array($filter[Type::NPC]) ? DBSIMPLE_SKIP : $filter[Type::NPC], @@ -136,9 +136,10 @@ class ItemList extends BaseType if (!empty($xCostData[$vInfo['extendedCost']])) $costs = $xCostData[$vInfo['extendedCost']]; - $data = array( + $data = array( 'stock' => $vInfo['maxcount'] ?: -1, 'event' => $vInfo['eventId'], + 'restock' => $vInfo['incrtime'], 'reqRating' => $costs ? $costs['reqPersonalRating'] : 0, 'reqBracket' => $costs ? $costs['reqArenaSlot'] : 0 ); @@ -360,9 +361,10 @@ class ItemList extends BaseType $currency[] = [-$k, $qty]; } - $costArr['stock'] = $entries['stock'];// display as column in lv - $costArr['avail'] = $entries['stock'];// display as number on icon - $costArr['cost'] = [empty($entries[0]) ? 0 : $entries[0]]; + $costArr['stock'] = $entries['stock'];// display as column in lv + $costArr['avail'] = $entries['stock'];// display as number on icon + $costArr['cost'] = [empty($entries[0]) ? 0 : $entries[0]]; + $costArr['restock'] = $entries['restock']; if ($entries['event']) { diff --git a/pages/npc.php b/pages/npc.php index b94c4a59..a791b153 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -621,12 +621,19 @@ class NpcPage extends GenericPage $soldItems = new ItemList(array(['id', $sells])); if (!$soldItems->error) { + $colAddIn = ''; $extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; - if ($soldItems->hasSetFields(['condition'])) - $extraCols[] = '$Listview.extraCols.condition'; + if ($soldItems->hasSetFields(['condition'])) + $extraCols[] = '$Listview.extraCols.condition'; $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [Type::NPC => [$this->typeId]]); + if (array_filter(array_column($lvData, 'restock'))) + { + $extraCols[] = '$_'; + $colAddIn = 'vendorRestockCol'; + } + $sc = Util::getServerConditions(CND_SRC_NPC_VENDOR, $this->typeId); if (!empty($sc[0])) { @@ -645,7 +652,7 @@ class NpcPage extends GenericPage 'name' => '$LANG.tab_sells', 'id' => 'currency-for', 'extraCols' => array_unique($extraCols) - )]; + ), $colAddIn]; $this->extendGlobalData($soldItems->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } diff --git a/static/js/locale_dede.js b/static/js/locale_dede.js index 5280c9cc..f0333879 100644 --- a/static/js/locale_dede.js +++ b/static/js/locale_dede.js @@ -4850,6 +4850,8 @@ var LANG = { guideAuthor: 'Leitfadenautor', autoresizetextbox: 'Textfeld automatisch anpassen', + restock: 'Nachschub', + descriptionlengthlong_tip: 'Oh nein! Deine Beschreibung ist zu lang bei $1. Es wird wahrscheinlich gekürzt werden.', descriptionlengthoptimal_tip: 'Ihre Beschreibung hat eine gute Länge. Gut gemacht! Sie können sicher bis zu $1 hinzufügen, wenn nötig.', descriptionlengthshort_tip: 'Ihre Beschreibung ist zu kurz! $1 fehlen noch ...', diff --git a/static/js/locale_enus.js b/static/js/locale_enus.js index 7927e634..bf81bafe 100644 --- a/static/js/locale_enus.js +++ b/static/js/locale_enus.js @@ -4898,6 +4898,8 @@ var LANG = { guideAuthor: 'Guide Author', autoresizetextbox: 'Auto-Resize Text Box', + restock: 'Restock', + descriptionlengthlong_tip: 'Oh no! Your description is $1 too long! It will most likely be truncated.', descriptionlengthoptimal_tip: 'Your description is a good length. Good job! You can safely add up to $1 if needed.', descriptionlengthshort_tip: 'Your description is too short! $1 to go...', diff --git a/static/js/locale_eses.js b/static/js/locale_eses.js index 0cb9de05..b3c0243b 100644 --- a/static/js/locale_eses.js +++ b/static/js/locale_eses.js @@ -4853,6 +4853,8 @@ var LANG = { guideAuthor: '[Guide Author]', autoresizetextbox: 'Redimensionar automáticamente el cuadro de texto', + restock: '[Restock]', + descriptionlengthlong_tip: '¡Oh, no! Tu descripción es demasido larga por $1. Es muy posible que sea cortada', descriptionlengthoptimal_tip: 'Tu descripción es de la longitud óptima. ¡Buen trabajo! Si es necesario, puedes agregar hasta $1.', descriptionlengthshort_tip: '¡Tu descripción es demasiado corta! Te faltan $1...', diff --git a/static/js/locale_frfr.js b/static/js/locale_frfr.js index 607fcfcd..0d6242fe 100644 --- a/static/js/locale_frfr.js +++ b/static/js/locale_frfr.js @@ -4852,6 +4852,8 @@ var LANG = { guideAuthor: 'Auteur du guide', autoresizetextbox: 'Redimensionner automatiquement le champ texte', + restock: '[Restock]', + descriptionlengthlong_tip: 'Fichtre ! Votre description $1 est trop longue ! Elle sera probablement tronquée.', descriptionlengthoptimal_tip: 'Votre description est de longueur appropriée. Bien joué ! Vous pouvez sans problème ajouter jusqu\'à $1 si besoin.', descriptionlengthshort_tip: 'Votre description est trop courte ! Encore $1...', diff --git a/static/js/locale_ruru.js b/static/js/locale_ruru.js index 6d9b3d77..bf26973a 100644 --- a/static/js/locale_ruru.js +++ b/static/js/locale_ruru.js @@ -4854,6 +4854,8 @@ var LANG = { guideAuthor: 'Автор руководства', autoresizetextbox: 'Автоматически изменять размер поля с текстом', + restock: '[Restock]', + descriptionlengthlong_tip: 'Не может быть! Ваше описание $1 слишком велико! Вероятнее всего, оно будет сокращено.', descriptionlengthoptimal_tip: 'Ваше описание имеет оптимальную длину. Отлично! Если необходимо, вы можете добавить ещё $1 символов.', descriptionlengthshort_tip: 'Ваше описание слишком короткое! $1 чтобы', diff --git a/static/js/locale_zhcn.js b/static/js/locale_zhcn.js index a0b02959..e5f37443 100644 --- a/static/js/locale_zhcn.js +++ b/static/js/locale_zhcn.js @@ -4877,6 +4877,8 @@ var LANG = { guideAuthor: '[Guide Author]', autoresizetextbox: '自动缩放文字框', + restock: '[Restock]', + descriptionlengthlong_tip: '欧漏,你的描述超出了$1个字!可能会被删减哦。', descriptionlengthoptimal_tip: '你的注释已经达到了合理的长度。干的漂亮!', descriptionlengthshort_tip: '你的注释太短了!请再输入$1$个字。', diff --git a/template/listviews/vendorRestockCol.tpl.php b/template/listviews/vendorRestockCol.tpl.php new file mode 100644 index 00000000..11e17540 --- /dev/null +++ b/template/listviews/vendorRestockCol.tpl.php @@ -0,0 +1,14 @@ +var _ = { + id: 'restock', + name: LANG.restock, + width: '10%', + value: 'restock', + after: 'stack', + compute: function(data, td) { + if (data.restock) { + let t = g_formatTimeElapsed(data.restock); + + $WH.ae(td, $WH.ct(t)); + } + } +};