Files
aowow/setup/tools/filegen/itemsets.func.php
Sarjuuk 51f2828f6f - moved shared setup functions from FileGen to new CLISetup
- removed web-setup
- new CLI parameters
  --account    : create initial account(s)
  --siteconfig : edit php/aowow config values
  --dbconfig   : set up db connection
  --sql        : create db content from world/dbc-tables
  --firstrun   : [NYI] step by step initial setup

- some fixes by the wayside
  * display required arena bracket for extendedCost
  * achievement chains are searchable again
  * category trees for factions should now be correct
  * trainer tab on spell detail page reapeared
  * userMenu item 'Settings' no longer breaks the page
  * display abilities of shapeshift in tab on spell detail page
  * corrected reading ?_sourcestrings for titles
  * fixed error on race detail page
  * added simple descriptions to skill detail page
  * fixed tab "reward from" (achievement) on title detail page
  * fixed alphabetical order of some filter-dropdowns
  * fixed skill colors for spells
  * fixed power display for rune-based spells, that also cost mana
  * added more information to zones
  * also check mail_loot_template for achivements
  * fixed bug, where loot_template-ids would be reused for multiple templates
  * display sourcemore for pvp-sources
2015-05-11 22:44:54 +02:00

135 lines
4.6 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
/* Example
"-447": { // internal id, freely chosen
"classes":["6"], // array
"elite":true,
"heroic":false,
"id":"-447",
"idbak":"924", // actual setId
"maxlevel":"390",
"minlevel":"390",
"name":"3Cataclysmic Gladiator's Desecration",
"note":"37", // contentGroup
"pieces":["73742","73741","73740","73739","73738"],
"reqclass":"32", // mask
"type":"4",
"setbonus":{
"2":{"resirtng":"400","str":"70"},
"4":{"str":"90"}
}
},
*/
// Create 'itemsets'-file for available locales
// this script requires the following dbc-files to be parsed and available
function itemsets()
{
$success = true;
$setList = DB::Aowow()->Select('SELECT * FROM ?_itemset ORDER BY refSetId DESC');
$jsonBonus = [];
// check directory-structure
foreach (Util::$localeStrings as $dir)
if (!CLISetup::writeDir('datasets/'.$dir))
$success = false;
foreach (CLISetup::$localeIds as $lId)
{
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$itemsetOut = [];
foreach ($setList as $set)
{
set_time_limit(15);
$setOut = array(
'id' => $set['id'],
'name' => (7 - $set['quality']).Util::jsEscape(Util::localizedString($set, 'name')),
'pieces' => [],
'heroic' => !!$set['heroic'], // should be bool
'maxlevel' => $set['maxLevel'],
'minlevel' => $set['minLevel'],
'type' => $set['type'],
'setbonus' => []
);
if ($set['classMask'])
{
$setOut['reqclass'] = $set['classMask'];
$setOut['classes'] = [];
for ($i = 0; $i < 12; $i++)
if ($set['classMask'] & (1 << ($i - 1)))
$setOut['classes'][] = $i;
}
if ($set['contentGroup'])
$setOut['note'] = $set['contentGroup'];
if ($set['id'] < 0)
$setOut['idbak'] = $set['refSetId'];
for ($i = 1; $i < 11; $i++)
if ($set['item'.$i])
$setOut['pieces'][] = $set['item'.$i];
for ($i = 1; $i < 9; $i++)
{
if (!$set['bonus'.$i] || !$set['spell'.$i])
continue;
// costy and locale-independant -> cache
if (!isset($jsonBonus[$set['spell'.$i]]))
$jsonBonus[$set['spell'.$i]] = (new SpellList(array(['s.id', (int)$set['spell'.$i]])))->getStatGain()[$set['spell'.$i]];
if (!isset($setOut['setbonus'][$set['bonus'.$i]]))
$setOut['setbonus'][$set['bonus'.$i]] = $jsonBonus[$set['spell'.$i]];
else
foreach ($jsonBonus[$set['spell'.$i]] as $k => $v)
@$setOut['setbonus'][$set['bonus'.$i]][$k] += $v;
}
foreach ($setOut['setbonus'] as $k => $v)
{
if (empty($v))
unset($setOut['setbonus'][$k]);
else
{
foreach ($v as $sk => $sv)
{
if ($str = Util::$itemMods[$sk])
{
$setOut['setbonus'][$k][$str] = $sv;
unset($setOut['setbonus'][$k][$sk]);
}
}
}
}
if (empty($setOut['setbonus']))
unset($setOut['setbonus']);
$itemsetOut[$setOut['id']] = $setOut;
}
$toFile = "var g_itemsets = ".Util::toJSON($itemsetOut).";";
$file = 'datasets/'.User::$localeString.'/itemsets';
if (!CLISetup::writeFile($file, $toFile))
$success = false;
}
return $success;
}
?>