本文整理汇总了PHP中CLISetup::writeDir方法的典型用法代码示例。如果您正苦于以下问题:PHP CLISetup::writeDir方法的具体用法?PHP CLISetup::writeDir怎么用?PHP CLISetup::writeDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLISetup
的用法示例。
在下文中一共展示了CLISetup::writeDir方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init($firstrun = false)
{
self::$defaultExecTime = ini_get('max_execution_time');
$doScripts = [];
if (getopt(self::$shortOpts, self::$longOpts) || $firstrun) {
self::handleCLIOpts($doScripts);
} else {
self::printCLIHelp();
exit;
}
// check passed subscript names; limit to real scriptNames
self::$subScripts = array_merge(array_keys(self::$tplFiles), array_keys(self::$datasets));
if ($doScripts) {
self::$subScripts = array_intersect($doScripts, self::$subScripts);
}
if (!CLISetup::$localeIds) {
CLISetup::log('No valid locale specified. Check your config or --locales parameter, if used', CLISetup::LOG_ERROR);
exit;
}
// create directory structure
CLISetup::log('FileGen::init() - creating required directories');
$pathOk = 0;
foreach (self::$reqDirs as $rd) {
if (CLISetup::writeDir($rd)) {
$pathOk++;
}
}
CLISetup::log('created ' . $pathOk . ' extra paths' . ($pathOk == count(self::$reqDirs) ? '' : ' with errors'));
CLISetup::log();
}
示例2: build
function build()
{
require_once 'setup/tools/fileGen.class.php';
FileGen::init();
if (FileGen::$subScripts) {
$allOk = true;
// start file generation
CLISetup::log('begin generation of ' . implode(', ', FileGen::$subScripts));
CLISetup::log();
// files with template
foreach (FileGen::$tplFiles as $name => list($file, $destPath, $deps)) {
$reqDBC = [];
if (!in_array($name, FileGen::$subScripts)) {
continue;
}
if (!file_exists(FileGen::$tplPath . $file . '.in')) {
CLISetup::log(sprintf(ERR_MISSING_FILE, FileGen::$tplPath . $file . '.in'), CLISetup::LOG_ERROR);
$allOk = false;
continue;
}
if (!CLISetup::writeDir($destPath)) {
continue;
}
$syncIds = [];
// todo: fetch what exactly must be regenerated
$ok = FileGen::generate($name, $syncIds);
if (!$ok) {
$allOk = false;
}
CLISetup::log(' - subscript \'' . $file . '\' returned ' . ($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
set_time_limit(FileGen::$defaultExecTime);
// reset to default for the next script
}
// files without template
foreach (FileGen::$datasets as $file => $deps) {
if (!in_array($file, FileGen::$subScripts)) {
continue;
}
$syncIds = [];
// todo: fetch what exactly must be regenerated
$ok = FileGen::generate($file, $syncIds);
if (!$ok) {
$allOk = false;
}
CLISetup::log(' - subscript \'' . $file . '\' returned ' . ($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
set_time_limit(FileGen::$defaultExecTime);
// reset to default for the next script
}
// end
CLISetup::log();
if ($allOk) {
CLISetup::log('successfully finished file generation', CLISetup::LOG_OK);
} else {
CLISetup::log('finished file generation with errors', CLISetup::LOG_ERROR);
}
} else {
CLISetup::log('no valid script names supplied', CLISetup::LOG_ERROR);
}
}
示例3: gems
function gems()
{
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->Select('SELECT i.id AS itemId,
i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc4, i.name_loc6, i.name_loc8,
IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
i.quality,
ic.iconString AS icon,
i.gemEnchantmentId AS enchId,
i.gemColorMask AS colors
FROM ?_items i
JOIN ?_icons ic ON ic.id = -i.displayId
WHERE i.gemEnchantmentId <> 0
ORDER BY i.id DESC');
$success = true;
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($gems as $pop) {
$enchIds[] = $pop['enchId'];
}
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
if ($enchantments->error) {
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLISetup::LOG_ERROR);
CLISetup::log();
return false;
}
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(5);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$gemsOut = [];
foreach ($gems as $pop) {
if (!$enchantments->getEntry($pop['enchId'])) {
CLISetup::log(' * could not find enchantment #' . $pop['enchId'] . ' referenced by item #' . $gem['itemId'], CLISetup::LOG_WARN);
continue;
}
$gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => $enchantments->getField('name', true), 'jsonequip' => $enchantments->getStatGain(), 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
}
$toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
$file = 'datasets/' . User::$localeString . '/gems';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例4: glyphs
function glyphs()
{
$success = true;
$glyphList = DB::Aowow()->Select('SELECT i.id AS itemId,
i.*,
IF (g.typeFlags & 0x1, 2, 1) AS type,
i.subclass AS classs,
i.requiredLevel AS level,
s1.Id AS glyphSpell,
ic.iconString AS icon,
s1.skillLine1 AS skillId,
s2.Id AS glyphEffect,
s2.Id AS ARRAY_KEY
FROM ?_items i
JOIN ?_spell s1 ON s1.Id = i.spellid1
JOIN ?_glyphproperties g ON g.Id = s1.effect1MiscValue
JOIN ?_spell s2 ON s2.Id = g.spellId
JOIN ?_icons ic ON ic.Id = s1.iconIdAlt
WHERE i.classBak = 16');
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(30);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$glyphsOut = [];
foreach ($glyphSpells->iterate() as $__) {
$pop = $glyphList[$glyphSpells->id];
if (!$pop['glyphEffect']) {
continue;
}
if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) {
continue;
}
$glyphsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'description' => $glyphSpells->parseText()[0], 'icon' => $pop['icon'], 'type' => $pop['type'], 'classs' => $pop['classs'], 'skill' => $pop['skillId'], 'level' => $pop['level']);
}
$toFile = "var g_glyphs = " . Util::toJSON($glyphsOut) . ";";
$file = 'datasets/' . User::$localeString . '/glyphs';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例5: pets
function pets()
{
$success = true;
$locations = [];
$petList = DB::Aowow()->Select('SELECT cr. id,
cr.name_loc0, cr.name_loc2, cr.name_loc3, cr.name_loc6, cr.name_loc8,
cr.minLevel,
cr.maxLevel,
ft.A,
ft.H,
cr.rank AS classification,
cr.family,
cr.displayId1 AS displayId,
cr.textureString AS skin,
LOWER(SUBSTRING_INDEX(cf.iconString, "\\\\", -1)) AS icon,
cf.petTalentType AS type
FROM ?_creature cr
JOIN ?_factiontemplate ft ON ft.Id = cr.faction
JOIN dbc_creaturefamily cf ON cf.id = cr.family
WHERE cr.typeFlags & 0x1 AND (cr.cuFlags & 0x2) = 0
ORDER BY cr.id ASC');
// 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]);
$petsOut = [];
foreach ($petList as $pet) {
// get locations
// again: caching will save you time and nerves
if (!isset($locations[$pet['id']])) {
$locations[$pet['id']] = DB::Aowow()->SelectCol('SELECT DISTINCT areaId FROM ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $pet['id']);
}
$petsOut[$pet['id']] = array('id' => $pet['id'], 'name' => Util::localizedString($pet, 'name'), 'minlevel' => $pet['minLevel'], 'maxlevel' => $pet['maxLevel'], 'location' => $locations[$pet['id']], 'react' => [$pet['A'], $pet['H']], 'classification' => $pet['classification'], 'family' => $pet['family'], 'displayId' => $pet['displayId'], 'skin' => $pet['skin'], 'icon' => $pet['icon'], 'type' => $pet['type']);
}
$toFile = "var g_pets = " . Util::toJSON($petsOut) . ";";
$file = 'datasets/' . User::$localeString . '/pets';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例6: gems
function gems()
{
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->Select('SELECT i.id AS itemId,
i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc6, i.name_loc8,
IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
i.quality,
ic.iconString AS icon,
i.gemEnchantmentId AS enchId,
i.gemColorMask AS colors
FROM ?_items i
JOIN ?_icons ic ON ic.id = -i.displayId
WHERE i.gemEnchantmentId <> 0
ORDER BY i.id DESC');
$success = true;
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($gems as $pop) {
$enchIds[] = $pop['enchId'];
}
$enchMisc = [];
$enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(5);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$gemsOut = [];
foreach ($gems as $pop) {
$gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => Util::localizedString(@$enchMisc[$pop['enchId']]['text'] ?: [], 'text'), 'jsonequip' => @$enchJSON[$pop['enchId']] ?: [], 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
}
$toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
$file = 'datasets/' . User::$localeString . '/gems';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例7: weightPresets
function weightPresets()
{
// check directory-structure
if (!CLISetup::writeDir('datasets/')) {
return false;
}
$wtPresets = [];
$scales = DB::Aowow()->select('SELECT id, name, icon, class FROM ?_account_weightscales WHERE userId = 0 ORDER BY class, id ASC');
foreach ($scales as $s) {
$weights = DB::Aowow()->selectCol('SELECT field AS ARRAY_KEY, val FROM ?_account_weightscale_data WHERE id = ?d', $s['id']);
if (!$weights) {
CLISetup::log('WeightScale \'' . CLISetup::bold($s['name']) . '\' has no data set. Skipping...', CLISetup::LOG_WARN);
continue;
}
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
}
$toFile = "var wt_presets = " . Util::toJSON($wtPresets) . ";";
$file = 'datasets/weight-presets';
if (!CLISetup::writeFile($file, $toFile)) {
return false;
}
return true;
}
示例8: simpleImg
//.........这里部分代码省略.........
}
// filter by pasaed options
if (!$groups) {
// by default do not generate loadingscreens
unset($paths[11]);
} else {
foreach (array_keys($paths) as $k) {
if (!in_array($k, $groups)) {
unset($paths[$k]);
}
}
}
foreach (CLISetup::$expectedPaths as $xp => $__) {
if ($xp) {
// if in subDir add trailing slash
$xp .= '/';
}
if ($checkSourceDirs($xp, $missing)) {
$locStr = $xp;
break;
}
}
// if no subdir had sufficient data, diaf
if ($locStr === null) {
CLISetup::log('one or more required directories are missing:', CLISetup::LOG_ERROR);
foreach ($missing as $m) {
CLISetup::log(' - ' . $m, CLISetup::LOG_ERROR);
}
return;
}
// init directories
foreach (array_column($paths, 1) as $subDirs) {
foreach ($subDirs as $sd) {
if (!CLISetup::writeDir($destDir . $sd[0])) {
$success = false;
}
}
}
// ok, departure from std::procedure here
// scan ItemDisplayInfo.dbc and SpellIcon.dbc for expected images and save them to an array
// load all icon paths into another array and xor these two
// excess entries for the directory are fine, excess entries for the dbc's are not
$dbcEntries = [];
if (isset($paths[0]) || isset($paths[1])) {
if (isset($paths[0]) && !isset($paths[1])) {
$siRows = DB::Aowow()->selectCol('SELECT iconPath FROM dbc_spellicon WHERE iconPath NOT LIKE "%glyph-rune%"');
} else {
if (!isset($paths[0]) && isset($paths[1])) {
$siRows = DB::Aowow()->selectCol('SELECT iconPath FROM dbc_spellicon WHERE iconPath LIKE "%glyph-rune%"');
} else {
$siRows = DB::Aowow()->selectCol('SELECT iconPath FROM dbc_spellicon');
}
}
foreach ($siRows as $icon) {
$dbcEntries[] = strtolower(sprintf('setup/mpqdata/%s', $locStr) . strtr($icon, ['\\' => '/']) . '.blp');
}
}
if (isset($paths[0])) {
$itemIcons = DB::Aowow()->selectCol('SELECT inventoryIcon1 FROM dbc_itemdisplayinfo WHERE inventoryIcon1 <> ""');
foreach ($itemIcons as $icon) {
$dbcEntries[] = strtolower(sprintf($imgPath, $locStr) . 'Icons/' . $icon . '.blp');
}
$eventIcons = DB::Aowow()->selectCol('SELECT textureString FROM dbc_holidays WHERE textureString <> ""');
foreach ($eventIcons as $icon) {
$dbcEntries[] = strtolower(sprintf($imgPath, $locStr) . 'Calendar/Holidays/' . $icon . 'Start.blp');
}
示例9: complexImg
//.........这里部分代码省略.........
if (!CLISetup::fileExists($p)) {
$hasMissing = true;
$missing[] = $p;
}
}
return !$hasMissing;
};
// do not change order of params!
if ($_ = FileGen::hasOpt('talentbgs', 'maps', 'spawn-maps', 'artwork', 'area-maps')) {
$modeMask = $_;
}
foreach (CLISetup::$expectedPaths as $xp => $__) {
if ($xp) {
// if in subDir add trailing slash
$xp .= '/';
}
if ($checkSourceDirs($xp, $missing)) {
$locStr = $xp;
break;
}
}
// if no subdir had sufficient data, diaf
if ($locStr === null) {
CLISetup::log('one or more required directories are missing:', CLISetup::LOG_ERROR);
foreach ($missing as $m) {
CLISetup::log(' - ' . $m, CLISetup::LOG_ERROR);
}
return;
}
/**************/
/* TalentTabs */
/**************/
if ($modeMask & 0x1) {
if (CLISetup::writeDir($destDir . 'hunterpettalents/') && CLISetup::writeDir($destDir . 'talents/backgrounds/')) {
// [classMask, creatureFamilyMask, tabNr, textureStr]
$tTabs = DB::Aowow()->select('SELECT tt.creatureFamilyMask, tt.textureFile, tt.tabNumber, cc.fileString FROM dbc_talenttab tt LEFT JOIN dbc_chrclasses cc ON cc.Id = (LOG(2, tt.classMask) + 1)');
$order = array(['-TopLeft', '-TopRight'], ['-BottomLeft', '-BottomRight']);
if ($tTabs) {
$sum = 0;
$total = count($tTabs);
CLISetup::log('Processing ' . $total . ' files from TalentFrame/ ...');
foreach ($tTabs as $tt) {
ini_set('max_execution_time', 30);
// max 30sec per image (loading takes the most time)
$sum++;
$done = ' - ' . str_pad($sum . '/' . $total, 8) . str_pad('(' . number_format($sum * 100 / $total, 2) . '%)', 9);
if ($tt['creatureFamilyMask']) {
$size = [244, 364];
$name = $destDir . 'hunterpettalents/bg_' . (log($tt['creatureFamilyMask'], 2) + 1);
} else {
$size = [204, 554];
$name = $destDir . 'talents/backgrounds/' . strtolower($tt['fileString']) . '_' . ($tt['tabNumber'] + 1);
}
if (!isset(FileGen::$cliOpts['force']) && file_exists($name . '.jpg')) {
CLISetup::log($done . ' - file ' . $name . '.jpg was already processed');
continue;
}
$im = $assembleImage(sprintf($imgPath, $locStr) . 'TalentFrame/' . $tt['textureFile'], $order, 256 + 44, 256 + 75);
if (!$im) {
CLISetup::log(' - could not assemble file ' . $tt['textureFile'], CLISetup::LOG_ERROR);
continue;
}
if (!$writeImage($name, 'jpg', $im, $size[0], $size[1], $done)) {
$success = false;
}
}
示例10: profiler
//.........这里部分代码省略.........
/**************/
$scripts[] = function () {
$success = true;
$condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -6]);
$companionz = new SpellList($condition);
foreach (CLISetup::$localeIds as $l) {
set_time_limit(5);
User::useLocale($l);
Lang::load(Util::$localeStrings[$l]);
$buff = "var _ = g_spells;\n";
foreach ($companionz->getListviewData(ITEMINFO_MODEL) as $id => $data) {
$data['quality'] = $data['name'][0];
$data['name'] = mb_substr($data['name'], 1);
$buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
}
if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-companions', $buff)) {
$success = false;
}
}
return $success;
};
/************/
/* Factions */
/************/
$scripts[] = function () {
$success = true;
$condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]);
$factionz = new FactionList($condition);
foreach (CLISetup::$localeIds as $l) {
set_time_limit(5);
User::useLocale($l);
Lang::load(Util::$localeStrings[$l]);
$buff = "var _ = g_factions;\n";
foreach ($factionz->getListviewData() as $id => $data) {
$buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
}
$buff .= "\ng_faction_order = [0, 469, 891, 1037, 1118, 67, 1052, 892, 936, 1117, 169, 980, 1097];\n";
if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-factions', $buff)) {
$success = false;
}
}
return $success;
};
/***********/
/* Recipes */
/***********/
$scripts[] = function () {
// special case: secondary skills are always requested, so put them in one single file (185, 129, 356); it also contains g_skill_order
$skills = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, [185, 129, 356]];
$success = true;
$baseCnd = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], ['effect2Id', [118, 60], '!'], ['OR', ['typeCat', 9], ['typeCat', 11]]);
foreach ($skills as $s) {
$file = is_array($s) ? 'sec' : (string) $s;
$cnd = array_merge($baseCnd, [['skillLine1', $s]]);
$recipez = new SpellList($cnd);
$created = '';
foreach ($recipez->iterate() as $__) {
foreach ($recipez->canCreateItem() as $idx) {
$id = $recipez->getField('effect' . $idx . 'CreateItemId');
$created .= "g_items.add(" . $id . ", {'icon':'" . $recipez->relItems->getEntry($id)['iconString'] . "'});\n";
}
}
foreach (CLISetup::$localeIds as $l) {
set_time_limit(10);
User::useLocale($l);
Lang::load(Util::$localeStrings[$l]);
$buff = '';
foreach ($recipez->getListviewData() as $id => $data) {
$buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
}
if (!$buff) {
// this behaviour is intended, do not create an error
CLISetup::log('profiler - file datasets/' . User::$localeString . '/p-recipes-' . $file . ' has no content => skipping', CLISetup::LOG_WARN);
continue;
}
$buff = $created . "\nvar _ = g_spells;\n" . $buff;
if (is_array($s)) {
$buff .= "\ng_skill_order = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, 185, 129, 356];\n";
}
if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-recipes-' . $file, $buff)) {
$success = false;
}
}
}
return $success;
};
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
// run scripts
foreach ($scripts as $func) {
if (!$func()) {
$success = false;
}
}
return $success;
}
示例11: enchants
function enchants()
{
// from g_item_slots: 13:"One-Hand", 26:"Ranged", 17:"Two-Hand",
$slotPointer = [13, 17, 26, 26, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
$castItems = [];
$successs = true;
$enchantSpells = new SpellList([['effect1Id', 53], ['name_loc0', 'QA%', '!'], CFG_SQL_LIMIT_NONE]);
// enchantItemPermanent && !qualityAssurance
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($enchantSpells->iterate() as $__) {
$enchIds[] = $enchantSpells->getField('effect1MiscValue');
}
$enchMisc = [];
$enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(120);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$enchantsOut = [];
foreach ($enchantSpells->iterate() as $__) {
// slots have to be recalculated
$slot = 0;
if ($enchantSpells->getField('equippedItemClass') == 4) {
if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask')) {
$slot = $invType >> 1;
} else {
/* if (equippedItemSubClassMask == 64) */
// shields have it their own way <_<
$slot = 1 << 14 - 1;
}
} else {
if ($enchantSpells->getField('equippedItemClass') == 2) {
foreach ($slotPointer as $i => $sp) {
if (!$sp) {
continue;
}
if (1 << $i & $enchantSpells->getField('equippedItemSubClassMask')) {
if ($sp == 13) {
// also mainHand & offHand *siiigh*
$slot |= 1 << 21 - 1 | 1 << 22 - 1;
}
$slot |= 1 << $sp - 1;
}
}
}
}
$eId = $enchantSpells->getField('effect1MiscValue');
// defaults
$ench = array('name' => [], 'quality' => -1, 'icon' => strToLower($enchantSpells->getField('iconString')), 'source' => [], 'skill' => -1, 'slots' => [], 'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'), 'jsonequip' => @$enchJSON[$eId] ?: [], 'temp' => 0, 'classes' => 0);
if (isset($enchMisc[$eId]['reqskill'])) {
$ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskill'];
}
if (isset($enchMisc[$eId]['reqskillrank'])) {
$ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskillrank'];
}
if (isset($enchMisc[$eId]['requiredLevel'])) {
$ench['jsonequip']['requiredLevel'] = $enchMisc[$eId]['requiredLevel'];
}
// check if the spell has an entry in skill_line_ability -> Source:Profession
if ($skills = $enchantSpells->getField('skillLines')) {
$ench['name'][] = $enchantSpells->getField('name', true);
$ench['source'][] = $enchantSpells->id;
$ench['skill'] = $skills[0];
$ench['slots'][] = $slot;
}
// check if this spell can be cast via item -> Source:Item
if (!isset($castItems[$enchantSpells->id])) {
$castItems[$enchantSpells->id] = new ItemList([['spellId1', $enchantSpells->id], ['name_loc0', 'Scroll of Enchant%', '!']]);
}
// do not reuse enchantment scrolls
$cI =& $castItems[$enchantSpells->id];
// this construct is a bit .. unwieldy
foreach ($cI->iterate() as $__) {
$ench['name'][] = $cI->getField('name', true);
$ench['source'][] = -$cI->id;
$ench['icon'] = strTolower($cI->getField('iconString'));
$ench['slots'][] = $slot;
if ($cI->getField('quality') > $ench['quality']) {
$ench['quality'] = $cI->getField('quality');
}
if ($cI->getField('requiredClass') > 0) {
$ench['classes'] = $cI->getField('requiredClass');
$ench['jsonequip']['classes'] = $cI->getField('requiredClass');
}
if (!isset($ench['jsonequip']['reqlevel'])) {
if ($cI->getField('requiredLevel') > 0) {
$ench['jsonequip']['reqlevel'] = $cI->getField('requiredLevel');
}
}
}
// enchant spell not in use
if (empty($ench['source'])) {
continue;
}
//.........这里部分代码省略.........
示例12: talents
function talents()
{
$success = true;
$buildTree = function ($class) use(&$petFamIcons, &$tSpells) {
$petCategories = [];
$mask = $class ? 1 << $class - 1 : 0;
// All "tabs" of a given class talent
$tabs = DB::Aowow()->select('SELECT * FROM dbc_talenttab WHERE classMask = ?d ORDER BY `tabNumber`, `creatureFamilyMask`', $mask);
$result = [];
for ($l = 0; $l < count($tabs); $l++) {
$talents = DB::Aowow()->select('SELECT t.id AS tId, t.*, s.name_loc0, s.name_loc2, s.name_loc3, s.name_loc6, s.name_loc8, LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) AS iconString FROM dbc_talent t, dbc_spell s, dbc_spellicon si WHERE si.`Id` = s.`iconId` AND t.`tabId`= ?d AND s.`Id` = t.`rank1` ORDER by t.`row`, t.`column`', $tabs[$l]['Id']);
$result[$l] = array('n' => Util::localizedString($tabs[$l], 'name'), 't' => []);
if (!$class) {
$petFamId = log($tabs[$l]['creatureFamilyMask'], 2);
$result[$l]['icon'] = $petFamIcons[$petFamId];
$petCategories = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, categoryEnumID FROM dbc_creaturefamily WHERE petTalentType = ?d', $petFamId);
$result[$l]['f'] = array_keys($petCategories);
}
// talent dependencies go here
$depLinks = [];
$tNums = [];
for ($j = 0; $j < count($talents); $j++) {
$tNums[$talents[$j]['tId']] = $j;
$d = [];
$s = [];
$i = $talents[$j]['tId'];
$n = Util::localizedString($talents[$j], 'name');
$x = $talents[$j]['column'];
$y = $talents[$j]['row'];
$r = null;
$t = [];
$icon = $talents[$j]['iconString'];
$m = $talents[$j]['rank2'] == 0 ? 1 : ($talents[$j]['rank3'] == 0 ? 2 : ($talents[$j]['rank4'] == 0 ? 3 : ($talents[$j]['rank5'] == 0 ? 4 : 5)));
// duplet handling
$f = [];
foreach ($petCategories as $k => $v) {
// cant handle 64bit integer .. split
if ($v >= 32 && 1 << $v - 32 & $talents[$j]['petCategory2']) {
$f[] = $k;
} else {
if ($v < 32 && 1 << $v & $talents[$j]['petCategory1']) {
$f[] = $k;
}
}
}
for ($k = 0; $k <= $m - 1; $k++) {
if (!$tSpells->getEntry($talents[$j]['rank' . ($k + 1)])) {
continue;
}
$d[] = $tSpells->parseText()[0];
$s[] = $talents[$j]['rank' . ($k + 1)];
if ($talents[$j]['talentSpell']) {
$t[] = $tSpells->getTalentHeadForCurrent();
}
}
if ($talents[$j]['reqTalent']) {
// we didn't encounter the required talent yet => create reference
if (!isset($tNums[$talents[$j]['reqTalent']])) {
$depLinks[$talents[$j]['reqTalent']] = $j;
}
$r = @[$tNums[$talents[$j]['reqTalent']], $talents[$j]['reqRank'] + 1];
}
$result[$l]['t'][$j] = array('i' => $i, 'n' => $n, 'm' => $m, 'd' => $d, 's' => $s, 'x' => $x, 'y' => $y);
if (isset($r)) {
$result[$l]['t'][$j]['r'] = $r;
}
if (!empty($t)) {
$result[$l]['t'][$j]['t'] = $t;
}
if (!empty($f)) {
$result[$l]['t'][$j]['f'] = $f;
}
if ($class) {
$result[$l]['t'][$j]['iconname'] = $icon;
}
// If this talent is a reference, add it to the array of talent dependencies
if (isset($depLinks[$talents[$j]['tId']])) {
$result[$l]['t'][$depLinks[$talents[$j]['tId']]]['r'][0] = $j;
unset($depLinks[$talents[$j]['tId']]);
}
}
// Remove all dependencies for which the talent has not been found
foreach ($depLinks as $dep_link) {
unset($result[$l]['t'][$dep_link]['r']);
}
}
return $result;
};
// my neighbour is noisy as fuck and my head hurts, so ..
$petFamIcons = ['Ability_Druid_KingoftheJungle', 'Ability_Druid_DemoralizingRoar', 'Ability_EyeOfTheOwl'];
// .. i've no idea where to fetch these from
$classes = [CLASS_WARRIOR, CLASS_PALADIN, CLASS_HUNTER, CLASS_ROGUE, CLASS_PRIEST, CLASS_DEATHKNIGHT, CLASS_SHAMAN, CLASS_MAGE, CLASS_WARLOCK, CLASS_DRUID];
$petIcons = '';
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$tSpellIds = DB::Aowow()->selectCol('SELECT rank1 FROM dbc_talent UNION SELECT rank2 FROM dbc_talent UNION SELECT rank3 FROM dbc_talent UNION SELECT rank4 FROM dbc_talent UNION SELECT rank5 FROM dbc_talent');
//.........这里部分代码省略.........
示例13: itemsets
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'], '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;
}
示例14: talentIcons
function talentIcons()
{
$success = true;
$query = 'SELECT ic.iconString FROM ?_icons ic JOIN dbc_spell s ON s.iconId = ic.Id JOIN dbc_talent t ON t.rank1 = s.Id JOIN dbc_talenttab tt ON tt.Id = t.tabId WHERE tt.?# = ?d AND tt.tabNumber = ?d ORDER BY t.row, t.column, t.petCategory1 ASC';
$dims = 36;
//v-pets
$filenames = ['icons', 'warrior', 'paladin', 'hunter', 'rogue', 'priest', 'deathknight', 'shaman', 'mage', 'warlock', null, 'druid'];
// create directory if missing
if (!CLISetup::writeDir('static/images/wow/talents/icons')) {
$success = false;
}
if (!CLISetup::writeDir('static/images/wow/hunterpettalents')) {
$success = false;
}
foreach ($filenames as $k => $v) {
if (!$v) {
continue;
}
set_time_limit(10);
for ($tree = 0; $tree < 3; $tree++) {
$what = $k ? 'classMask' : 'creatureFamilyMask';
$set = $k ? 1 << $k - 1 : 1 << $tree;
$subset = $k ? $tree : 0;
$path = $k ? 'talents/icons' : 'hunterpettalents';
$outFile = 'static/images/wow/' . $path . '/' . $v . '_' . ($tree + 1) . '.jpg';
$icons = DB::Aowow()->SelectCol($query, $what, $set, $subset);
if (empty($icons)) {
CLISetup::log('talentIcons - query for ' . $v . ' tree: ' . $k . ' returned empty', CLISetup::LOG_ERROR);
$success = false;
continue;
}
if ($res = imageCreateTrueColor(count($icons) * $dims, 2 * $dims)) {
for ($i = 0; $i < count($icons); $i++) {
$imgFile = 'static/images/wow/icons/medium/' . strtolower($icons[$i]) . '.jpg';
if (!file_exists($imgFile)) {
CLISetup::log('talentIcons - raw image ' . CLISetup::bold($imgFile) . ' not found', CLISetup::LOG_ERROR);
$success = false;
break;
}
$im = imagecreatefromjpeg($imgFile);
// colored
imagecopymerge($res, $im, $i * $dims, 0, 0, 0, imageSX($im), imageSY($im), 100);
// grayscale
if (imageistruecolor($im)) {
imagetruecolortopalette($im, false, 256);
}
for ($j = 0; $j < imagecolorstotal($im); $j++) {
$color = imagecolorsforindex($im, $j);
$gray = round(0.299 * $color['red'] + 0.587 * $color['green'] + 0.114 * $color['blue']);
imagecolorset($im, $j, $gray, $gray, $gray);
}
imagecopymerge($res, $im, $i * $dims, $dims, 0, 0, imageSX($im), imageSY($im), 100);
}
if (@imagejpeg($res, $outFile)) {
CLISetup::log(sprintf(ERR_NONE, CLISetup::bold($outFile)), CLISetup::LOG_OK);
} else {
$success = false;
CLISetup::log('talentIcons - ' . CLISetup::bold($outFile . '.jpg') . ' could not be written', CLISetup::LOG_ERROR);
}
} else {
$success = false;
CLISetup::log('talentIcons - image resource not created', CLISetup::LOG_ERROR);
continue;
}
}
}
return $success;
}