protected function extract()
{
$this->comment('Extracting definitions ...');
$db = new \SQLite3($this->versionDb);
// extract Grimoire definition
$grimoire = $db->prepare("SELECT json FROM DestinyGrimoireDefinition WHERE id = 0")->execute()->fetchArray(SQLITE3_ASSOC);
$this->export("Grimoire", 0, json_decode($grimoire['json'], true));
// extract all the other definitions
$map = ["ActivityBundle" => "bundleHash", "Activity" => "activityHash", "ActivityType" => "activityTypeHash", "Class" => "classHash", "Combatant" => "combatantHash", "Destination" => "destinationHash", "DirectorBook" => "bookHash", "EnemyRace" => "raceHash", "Faction" => "factionHash", "Gender" => "genderHash", "GrimoireCard" => "cardId", "HistoricalStats" => "statId", "InventoryBucket" => "bucketHash", "InventoryItem" => "itemHash", "Place" => "placeHash", "Progression" => "progressionHash", "Objective" => "objectiveHash", "Race" => "raceHash", "SandboxPerk" => "perkHash", "ScriptedSkull" => "skullHash", "SpecialEvent" => "eventHash", "Stat" => "statHash", "StatGroup" => "statGroupHash", "TalentGrid" => "gridHash", "UnlockFlag" => "flagHash", "VendorCategory" => "categoryHash", "Vendor" => "summary.vendorHash"];
foreach ($map as $folder => $key) {
$table = "Destiny{$folder}Definition";
$result = $db->prepare("SELECT json FROM {$table}")->execute();
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$json = json_decode($row['json'], true);
$hash = (string) array_get($json, $key);
$this->export($folder, $hash, $json);
}
$this->line($folder);
}
$db->close();
}