Files
aowow/setup/tools/dataset-assembler/gems.php
Sarjuuk 19d08d1d18 added scripts to generate datasets and icon-textures for the talent-calculator
that should make everyone with some client-mods or custom database entires happy

removed previously supplied datasets (which were partially erronous anyway)

usage:
    - read the requirements per file and run via ?build=<filename> This may take up to several minutes, depending on the complexity and your machine

todo:
    - expects parsed dbcs in DB named "dbc" and world-DB to be named "world". Needs to be configurable
    - no error handling. If it fails, it fails badly.
    - pets: locations are inaccurate (see comment in file)
    - itemsets: the fragmented data in itemsets.dbc has to be fixed manually before this script yields propper results (see comment in file)
2012-12-27 21:19:44 +01:00

109 lines
3.2 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
// Create 'gems'-file for available locales
// this script requires the following dbc-files to be parsed and available
// ItemEnchantment, GemProperties, Spells, Icons
/* Example
22460: {
name:'Prismatic Sphere',
quality:3,
icon:'INV_Enchant_PrismaticSphere',
enchantment:'+3 Resist All',
jsonequip:{"arcres":3,"avgbuyout":242980,"firres":3,"frores":3,"holres":3,"natres":3,"shares":3},
colors:14,
expansion:1
gearscore:8 // as if.....
},
*/
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
include 'includes/class.spell.php';
$gemQuery = "
SELECT
it.entry,
it.name,
li.*,
IF (it.entry < 36000 OR it.ItemLevel < 70, 1 , 2) AS expansion,
(it.Quality) AS quality,
i.iconname as icon,
ie.*,
gp.colorMask as colors
FROM
item_template it,
locales_item li,
?_gemProperties gp,
?_icons i,
?_itemEnchantment ie
WHERE
it.GemProperties <> 0 AND
li.entry = it.entry AND
gp.Id = it.GemProperties AND
i.Id = it.displayid AND
gp.itemEnchantmentId = ie.Id
ORDER BY
it.entry DESC
;
";
$gems = Db::Aowow()->Select($gemQuery);
$locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU];
$jsonGems = [];
// check directory-structure
foreach (Util::$localeStrings as $dir)
if (!is_dir('datasets\\'.$dir))
mkdir('datasets\\'.$dir, 0755, true);
echo "script set up in ".Util::execTime()."<br>\n";
foreach ($locales as $lId)
{
User::useLocale($lId);
$gemsOut = [];
foreach ($gems as $pop)
{
// costy and locale-independant -> cache
if (!isset($jsonGems[$pop['entry']]))
$jsonGems[$pop['entry']] = Util::parseItemEnchantment($pop);
$gemsOut[$pop['entry']] = array(
'name' => Util::jsEscape(Util::localizedString($pop, 'name')),
'quality' => $pop['quality'],
'icon' => strToLower($pop['icon']),
'enchantment' => Util::jsEscape(Util::localizedString($pop, 'text')),
'jsonequip' => $jsonGems[$pop['entry']],
'colors' => $pop['colors'],
'expansion' => $pop['expansion']
);
}
$toFile = "var g_gems = ";
$toFile .= json_encode($gemsOut, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
$toFile .= ";";
$file = 'datasets\\'.User::$localeString.'\\gems';
$handle = fOpen($file, "w");
fWrite($handle, $toFile);
fClose($handle);
echo "done gems loc: ".$lId." in ".Util::execTime()."<br>\n";
}
echo "<br>\nall done";
User::useLocale(LOCALE_EN);
$stats = DB::Aowow()->getStatistics();
echo "<br>\n".$stats['count']." queries in: ".Util::formatTime($stats['time'] * 1000);
?>