mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* restructure setup to allow for self contained setup steps to self register (just the sql for now) * should ease adding new scripts in future
94 lines
3.6 KiB
PHP
94 lines
3.6 KiB
PHP
<?php
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
if (!CLI)
|
|
die('not in cli mode');
|
|
|
|
|
|
SqlGen::register(new class extends SetupScript
|
|
{
|
|
use TrCustomData;
|
|
|
|
protected $command = 'currencies';
|
|
|
|
protected $tblDependancyAowow = ['icons'];
|
|
protected $tblDependancyTC = ['item_template', 'item_template_locale'];
|
|
protected $dbcSourceFiles = ['itemdisplayinfo', 'currencytypes'];
|
|
|
|
// hide test tokens and move them to unused
|
|
private $customData = array(
|
|
1 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
|
|
2 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
|
|
4 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
|
|
22 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
|
|
141 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
|
|
103 => ['cap' => 10000], // Arena Points
|
|
104 => ['cap' => 75000] // Honor Points
|
|
);
|
|
|
|
public function generate(array $ids = []) : bool
|
|
{
|
|
if (!$ids)
|
|
DB::Aowow()->query('REPLACE INTO ?_currencies (id, category, itemId) SELECT id, category, itemId FROM dbc_currencytypes');
|
|
|
|
$moneyItems = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, itemId FROM dbc_currencytypes{ WHERE id IN (?a)}', $ids ?: DBSIMPLE_SKIP);
|
|
|
|
// apply names & cap
|
|
$moneyNames = DB::World()->select('
|
|
SELECT
|
|
it.entry AS ARRAY_KEY,
|
|
it.name AS name_loc0, IFNULL(itl2.Name, "") AS name_loc2, IFNULL(itl3.Name, "") AS name_loc3, IFNULL(itl4.Name, "") AS name_loc4, IFNULL(itl6.Name, "") AS name_loc6, IFNULL(itl8.Name, "") AS name_loc8,
|
|
it.maxCount AS cap
|
|
FROM
|
|
item_template it
|
|
LEFT JOIN
|
|
item_template_locale itl2 ON it.entry = itl2.ID AND itl2.locale = "frFR"
|
|
LEFT JOIN
|
|
item_template_locale itl3 ON it.entry = itl3.ID AND itl3.locale = "deDE"
|
|
LEFT JOIN
|
|
item_template_locale itl4 ON it.entry = itl4.ID AND itl4.locale = "zhCN"
|
|
LEFT JOIN
|
|
item_template_locale itl6 ON it.entry = itl6.ID AND itl6.locale = "esES"
|
|
LEFT JOIN
|
|
item_template_locale itl8 ON it.entry = itl8.ID AND itl8.locale = "ruRU"
|
|
WHERE
|
|
it.entry IN (?a)',
|
|
$moneyItems);
|
|
|
|
foreach ($moneyItems as $cId => $itemId)
|
|
{
|
|
if (!empty($moneyNames[$itemId]))
|
|
$strings = $moneyNames[$itemId];
|
|
else
|
|
{
|
|
CLI::write('item #'.$itemId.' required by currency #'.$cId.' not in item_template', CLI::LOG_WARN);
|
|
$strings = ['name_loc0' => 'Item #'.$itemId.' not in DB', 'iconId' => 0, 'cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3];
|
|
}
|
|
|
|
DB::Aowow()->query('UPDATE ?_currencies SET ?a WHERE itemId = ?d', $strings, $itemId);
|
|
}
|
|
|
|
// apply icons
|
|
$displayIds = DB::World()->selectCol('SELECT entry AS ARRAY_KEY, displayid FROM item_template WHERE entry IN (?a)', $moneyItems);
|
|
foreach ($displayIds as $itemId => $iconId)
|
|
DB::Aowow()->query('
|
|
UPDATE
|
|
?_currencies c,
|
|
?_icons i,
|
|
dbc_itemdisplayinfo idi
|
|
SET
|
|
c.iconId = i.id
|
|
WHERE
|
|
i.name = LOWER(idi.inventoryIcon1) AND
|
|
idi.id = ?d AND
|
|
c.itemId = ?d
|
|
', $iconId, $itemId);
|
|
|
|
return true;
|
|
}
|
|
});
|
|
|
|
?>
|