Created
December 31, 2016 11:51
-
-
Save voxx/2ba487b1a90273e49584fedce6b25154 to your computer and use it in GitHub Desktop.
Parse pokemongo game master meta json file and output valid php for src/Api/Pokemon/Data/PokemonMetaRegistry.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = file_get_contents('051_meta.json'); | |
$json = json_decode($str, true); | |
//echo count($json["itemTemplates"]); | |
//var_dump($json["itemTemplates"][327]); //Chikorita | |
//var_dump($json["itemTemplates"][469]); //Celebi | |
echo '<pre>'; | |
$count = 0; | |
$pokedexNumber = 152; | |
foreach($json["itemTemplates"] as $template){ | |
if(($count > 326) && ($count < 470) && (strpos($template["templateId"], 'POKEMON') !== false)){ | |
//var_dump($template["templateId"]); | |
$templateId = $template["templateId"]; | |
$familyId = $template["pokemonSettings"]["familyId"]; | |
$rarity = isset($template["pokemonSettings"]["rarity"]) ? $template["pokemonSettings"]["rarity"] : "NONE"; | |
$type2 = isset($template["pokemonSettings"]["type2"]) ? $template["pokemonSettings"]["type2"] : "POKEMON_TYPE_NONE"; | |
$pokedexHeightM = $template["pokemonSettings"]["pokedexHeightM"]; | |
$heightStdDev = $template["pokemonSettings"]["heightStdDev"]; | |
$baseStamina = $template["pokemonSettings"]["stats"]["baseStamina"]; | |
$cylRadiusM = $template["pokemonSettings"]["camera"]["cylinderRadiusM"]; | |
$baseFleeRate = $template["pokemonSettings"]["encounter"]["baseFleeRate"]; | |
$baseAttack = $template["pokemonSettings"]["stats"]["baseAttack"]; | |
$diskRadiusM = $template["pokemonSettings"]["camera"]["diskRadiusM"]; | |
$collisionRadiusM = $template["pokemonSettings"]["encounter"]["collisionRadiusM"]; | |
$pokedexWeightKg = $template["pokemonSettings"]["pokedexWeightKg"]; | |
$movementType = $template["pokemonSettings"]["encounter"]["movementType"]; | |
$type = $template["pokemonSettings"]["type"]; | |
$collisionHeadRadiusM = $template["pokemonSettings"]["encounter"]["collisionHeadRadiusM"]; | |
$movementTimerS = $template["pokemonSettings"]["encounter"]["movementTimerS"]; | |
$jumpTimeS = $template["pokemonSettings"]["encounter"]["jumpTimeS"]; | |
$modelScale = $template["pokemonSettings"]["modelScale"]; | |
$uniqueId = $template["pokemonSettings"]["pokemonId"]; | |
$baseDefense = $template["pokemonSettings"]["stats"]["baseDefense"]; | |
$attackTimerS = $template["pokemonSettings"]["encounter"]["attackTimerS"]; | |
$weightStdDev = $template["pokemonSettings"]["weightStdDev"]; | |
$cylHeightM = $template["pokemonSettings"]["camera"]["cylinderHeightM"]; | |
$candyToEvolve = isset($template["pokemonSettings"]["candyToEvolve"]) ? $template["pokemonSettings"]["candyToEvolve"] : 0; | |
$collisionHeightM = $template["pokemonSettings"]["encounter"]["collisionHeightM"]; | |
$shoulderModeScale = $template["pokemonSettings"]["camera"]["shoulderModeScale"]; | |
$baseCaptureRate = $template["pokemonSettings"]["encounter"]["baseCaptureRate"]; | |
$parentId = isset($template["pokemonSettings"]["parentPokemonId"]) ? $template["pokemonSettings"]["parentPokemonId"] : "MISSINGNO"; | |
$cylGroundM = isset($template["pokemonSettings"]["camera"]["cylinderGroundM"]) ? $template["pokemonSettings"]["camera"]["cylinderGroundM"] : "0"; | |
$quickMoves = $template["pokemonSettings"]["quickMoves"]; // array | |
$cinematicMoves = $template["pokemonSettings"]["cinematicMoves"]; // array | |
$number = $pokedexNumber++; | |
echo '$pokemonMeta = new PokemonMeta();' . PHP_EOL; | |
echo '$pokemonMeta->setTemplateId("' . $templateId . '");' . PHP_EOL; | |
echo '$pokemonMeta->setFamily(PokemonFamilyId::' . $familyId . ');' . PHP_EOL; | |
echo '$pokemonMeta->setPokemonClass(PokemonClass::' . $rarity . ');' . PHP_EOL; | |
echo '$pokemonMeta->setType2(PokemonType::' . $type2 . ');' . PHP_EOL; | |
echo '$pokemonMeta->setPokedexHeightM(' . $pokedexHeightM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setHeightStdDev(' . $heightStdDev . ');' . PHP_EOL; | |
echo '$pokemonMeta->setBaseStamina(' . $baseStamina . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCylRadiusM(' . $cylRadiusM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setBaseFleeRate(' . $baseFleeRate . ');' . PHP_EOL; | |
echo '$pokemonMeta->setBaseAttack(' . $baseAttack . ');' . PHP_EOL; | |
echo '$pokemonMeta->setDiskRadiusM(' . $diskRadiusM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCollisionRadiusM(' . $collisionRadiusM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setPokedexWeightKg(' . $pokedexWeightKg . ');' . PHP_EOL; | |
echo '$pokemonMeta->setMovementType(MovementType::' . $movementType . ');' . PHP_EOL; | |
echo '$pokemonMeta->setType1(PokemonType::' . $type . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCollisionHeadRadiusM(' . $collisionHeadRadiusM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setMovementTimerS(' . $movementTimerS . ');' . PHP_EOL; | |
echo '$pokemonMeta->setJumpTimeS(' . $jumpTimeS . ');' . PHP_EOL; | |
echo '$pokemonMeta->setModelScale(' . $modelScale . ');' . PHP_EOL; | |
echo '$pokemonMeta->setUniqueId("' . $templateId . '");' . PHP_EOL; | |
echo '$pokemonMeta->setBaseDefense(' . $baseDefense . ');' . PHP_EOL; | |
echo '$pokemonMeta->setAttackTimerS(' . $attackTimerS . ');' . PHP_EOL; | |
echo '$pokemonMeta->setWeightStdDev(' . $weightStdDev . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCylHeightM(' . $cylHeightM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCandyToEvolve(' . $candyToEvolve . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCollisionHeightM(' . $collisionHeightM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setShoulderModeScale(' . $shoulderModeScale . ');' . PHP_EOL; | |
echo '$pokemonMeta->setBaseCaptureRate(' . $baseCaptureRate . ');' . PHP_EOL; | |
echo '$pokemonMeta->setParentId(PokemonId::' . $parentId . ');' . PHP_EOL; | |
echo '$pokemonMeta->setCylGroundM(' . $cylGroundM . ');' . PHP_EOL; | |
echo '$pokemonMeta->setQuickMoves(new PokemonMoveData(array(' . PHP_EOL; | |
foreach($quickMoves as $qm){ | |
echo ' ' . 'PokemonMove::' . $qm . ',' . PHP_EOL; | |
} | |
echo ')));' . PHP_EOL; | |
echo '$pokemonMeta->setCinematicMoves(new PokemonMoveData(array(' . PHP_EOL; | |
foreach($cinematicMoves as $cm){ | |
echo ' ' . 'PokemonMove::' . $cm . ',' . PHP_EOL; | |
} | |
echo ')));' . PHP_EOL; | |
echo '$pokemonMeta->setNumber(' . $number . ');' . PHP_EOL; | |
echo 'self::$POKEMON_META[PokemonId::' . $uniqueId . '] = $pokemonMeta;' . PHP_EOL; | |
echo PHP_EOL; | |
} | |
$count++; | |
} | |
echo '</pre>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment