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)) $setOut['classes'][] = $i + 1; } 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; } ?>