From 7631f9bf54747dd7f57f799ecd3e1a7d40023d0e Mon Sep 17 00:00:00 2001 From: broglep Date: Fri, 21 Dec 2018 16:20:50 +0100 Subject: [PATCH 1/2] feat: support legacy moves quick & dirty variant of adding legacy moves by processing additional game master files from https://github.com/pokemongo-dev-contrib/pokemongo-game-master/tree/master/special --- output/pokemon.json | 95 +++++++++++++++++++++++ src/app.ts | 4 +- src/processing/pokemon/pokemonPipeline.ts | 73 ++++++++++++++++- 3 files changed, 169 insertions(+), 3 deletions(-) diff --git a/output/pokemon.json b/output/pokemon.json index e704e25..b2262a4 100644 --- a/output/pokemon.json +++ b/output/pokemon.json @@ -262,6 +262,11 @@ { "name": "Solar Beam", "id": "SOLAR_BEAM" + }, + { + "name": "Frenzy Plant", + "id": "FRENZY_PLANT", + "legacy": true } ], "quickMoves": [ @@ -593,6 +598,11 @@ { "name": "Overheat", "id": "OVERHEAT" + }, + { + "name": "Blast Burn", + "id": "BLAST_BURN", + "legacy": true } ], "quickMoves": [ @@ -925,6 +935,11 @@ { "name": "Hydro Pump", "id": "HYDRO_PUMP" + }, + { + "name": "Hydro Cannon", + "id": "HYDRO_CANNON", + "legacy": true } ], "quickMoves": [ @@ -2863,6 +2878,11 @@ { "name": "Wild Charge", "id": "WILD_CHARGE" + }, + { + "name": "Surf", + "id": "SURF", + "legacy": true } ], "quickMoves": [ @@ -16198,6 +16218,11 @@ { "name": "Swift", "id": "SWIFT" + }, + { + "name": "Last Resort", + "id": "LAST_RESORT", + "legacy": true } ], "quickMoves": [ @@ -16328,6 +16353,11 @@ { "name": "Aqua Tail", "id": "AQUA_TAIL" + }, + { + "name": "Last Resort", + "id": "LAST_RESORT", + "legacy": true } ], "quickMoves": [ @@ -16424,6 +16454,11 @@ { "name": "Thunder", "id": "THUNDER" + }, + { + "name": "Last Resort", + "id": "LAST_RESORT", + "legacy": true } ], "quickMoves": [ @@ -16524,6 +16559,11 @@ { "name": "Overheat", "id": "OVERHEAT" + }, + { + "name": "Last Resort", + "id": "LAST_RESORT", + "legacy": true } ], "quickMoves": [ @@ -17357,6 +17397,11 @@ { "name": "Blizzard", "id": "BLIZZARD" + }, + { + "name": "Hurricane", + "id": "HURRICANE", + "legacy": true } ], "quickMoves": [ @@ -17456,6 +17501,11 @@ { "name": "Charge Beam Fast", "id": "CHARGE_BEAM_FAST" + }, + { + "name": "Thunder Shock Fast", + "id": "THUNDER_SHOCK_FAST", + "legacy": true } ], "family": { @@ -17543,6 +17593,11 @@ { "name": "Overheat", "id": "OVERHEAT" + }, + { + "name": "Sky Attack", + "id": "SKY_ATTACK", + "legacy": true } ], "quickMoves": [ @@ -17856,6 +17911,11 @@ { "name": "Outrage", "id": "OUTRAGE" + }, + { + "name": "Draco Meteor", + "id": "DRACO_METEOR", + "legacy": true } ], "quickMoves": [ @@ -18515,6 +18575,11 @@ { "name": "Earthquake", "id": "EARTHQUAKE" + }, + { + "name": "Frenzy Plant", + "id": "FRENZY_PLANT", + "legacy": true } ], "quickMoves": [ @@ -18842,6 +18907,11 @@ { "name": "Solar Beam", "id": "SOLAR_BEAM" + }, + { + "name": "Blast Burn", + "id": "BLAST_BURN", + "legacy": true } ], "quickMoves": [ @@ -21429,6 +21499,11 @@ { "name": "Thunder", "id": "THUNDER" + }, + { + "name": "Dragon Pulse", + "id": "DRAGON_PULSE", + "legacy": true } ], "quickMoves": [ @@ -23029,6 +23104,11 @@ { "name": "Futuresight", "id": "FUTURESIGHT" + }, + { + "name": "Last Resort", + "id": "LAST_RESORT", + "legacy": true } ], "quickMoves": [ @@ -23124,6 +23204,11 @@ { "name": "Foul Play", "id": "FOUL_PLAY" + }, + { + "name": "Last Resort", + "id": "LAST_RESORT", + "legacy": true } ], "quickMoves": [ @@ -28427,6 +28512,11 @@ { "name": "Iron Tail Fast", "id": "IRON_TAIL_FAST" + }, + { + "name": "Smack Down Fast", + "id": "SMACK_DOWN_FAST", + "legacy": true } ], "family": { @@ -42102,6 +42192,11 @@ { "name": "Earthquake", "id": "EARTHQUAKE" + }, + { + "name": "Meteor Mash", + "id": "METEOR_MASH", + "legacy": true } ], "quickMoves": [ diff --git a/src/app.ts b/src/app.ts index 9bf6a4b..542230d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -19,6 +19,8 @@ import { ItemLocalesPipeline } from './processing/item/locales/itemLocalesPipeli import { AvatarCustomizationLocalesPipeline } from './processing/avatarCustomization/locales/index'; const gameMaster = require('./data/GAME_MASTER.json'); +const specialGameMastersDirectory = path.resolve(__dirname, 'data/special'); +const specialGameMasters = fs.existsSync(specialGameMastersDirectory) ? fs.readdirSync(specialGameMastersDirectory).map(file => require(`./data/special/${file}`)) : []; const packageJson = require('../package.json'); const POKEMON_TRANSLATIONS = require('./data/POKEMON_TRANSLATIONS.json'); const MOVES_TRANSLATIONS = require('./data/MOVES_TRANSLATIONS.json'); @@ -69,7 +71,7 @@ console.log(`${chalk.blue('i')} Using GAME_MASTER version ${chalk.cyan(gameMaste const writePokemon = async () => { - const pokemons = await write('./output/pokemon.json', new PokemonPipeline(gameMaster), 'Pokemons'); + const pokemons = await write('./output/pokemon.json', new PokemonPipeline(gameMaster, specialGameMasters), 'Pokemons'); writeTranslations('pokemon.json', await new PokemonLocalesPipeline(POKEMON_TRANSLATIONS, pokemons, LOCALES), 'Pokemon Translations'); } diff --git a/src/processing/pokemon/pokemonPipeline.ts b/src/processing/pokemon/pokemonPipeline.ts index feec7aa..53a1d1a 100644 --- a/src/processing/pokemon/pokemonPipeline.ts +++ b/src/processing/pokemon/pokemonPipeline.ts @@ -1,6 +1,10 @@ -import { Pipeline } from '@core/pipeline'; +import { IComponent, Pipeline } from '@core/pipeline'; import { RootObject, ItemTemplate } from '@income'; import { Pokemon } from '@outcome/pokemon'; +import { forEachSeries, map } from 'p-iteration'; +import * as _ from 'lodash'; +import { Util } from '@util'; +import { Identifyable } from '@core'; /** * Represents the Pipeline which converts Game Master Pokemon related @@ -8,9 +12,11 @@ import { Pokemon } from '@outcome/pokemon'; */ export class PokemonPipeline extends Pipeline { private readonly pokemonRegex: string = '^(V[0-9]+_POKEMON_?.*)'; + private readonly specialMasterFiles: RootObject[]; - constructor(input: RootObject) { + constructor(input: RootObject, special: RootObject[]) { super(input, 'pokemon'); + this.specialMasterFiles = special; } private isPokemon(templateId: string) { @@ -28,4 +34,67 @@ export class PokemonPipeline extends Pipeline { const id = item.templateId; return this.isPokemon(id) && !this.isNormalPokemon(id); } + + + public async Run(): Promise { + const pokemonData = await super.Run(); + + // Handle special game master files + const specialInputs = await map(this.specialMasterFiles, input => input.itemTemplates.filter(p => this.isItemTemplate(p))); + const legacyMoveComponents = [new LegacyQuickMoves(), new LegacyCinematicMoves()]; + await forEachSeries(specialInputs, async specialInput => { + await forEachSeries(specialInput, async itemTemplate => { + const currentPokemon = pokemonData.find(value => value.id === itemTemplate.pokemonSettings.pokemonId); + await forEachSeries(legacyMoveComponents, component => component.Process(currentPokemon, itemTemplate)); + }); + }); + + return pokemonData; + } } + +abstract class LegacyMove implements IComponent { + private readonly moveType: string; + + protected constructor(moveType: string) { + this.moveType = moveType; + } + + Process(pokemon: Pokemon, rawPokemon: ItemTemplate): Pokemon { + const specialMoves = _ + .chain(rawPokemon.pokemonSettings[this.moveType]) + .uniq() + .map(Util.SnakeCase2Identifyable) + .filter(maybeSpecialMove => pokemon[this.moveType].find(move => move.id === maybeSpecialMove.id) === undefined) + .map(LegacyMove.ToLegacyMove) + .value(); + + pokemon[this.moveType] = pokemon[this.moveType].concat(specialMoves); + return pokemon; + } + + private static ToLegacyMove(move: Identifyable): IdentifiableMove { + return { + name: move.name, + id: move.id, + legacy: true + } + } +} + +class LegacyCinematicMoves extends LegacyMove { + constructor() { + super('cinematicMoves'); + } +} + +class LegacyQuickMoves extends LegacyMove { + constructor() { + super('quickMoves'); + } +} + +export interface IdentifiableMove extends Identifyable { + legacy: boolean; +} + From a3e82d69b2badd59b7344dd6619e16f66f288c22 Mon Sep 17 00:00:00 2001 From: Livio Date: Sat, 22 Dec 2018 19:51:41 +0100 Subject: [PATCH 2/2] Add pokemongo-game-master as submodule --- .gitmodules | 3 +++ pokemongo-game-master | 1 + src/app.ts | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 pokemongo-game-master diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..38a93ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "pokemongo-game-master"] + path = pokemongo-game-master + url = https://github.com/pokemongo-dev-contrib/pokemongo-game-master.git diff --git a/pokemongo-game-master b/pokemongo-game-master new file mode 160000 index 0000000..218afc7 --- /dev/null +++ b/pokemongo-game-master @@ -0,0 +1 @@ +Subproject commit 218afc758428b99be5ad5af4430468b236ea18e0 diff --git a/src/app.ts b/src/app.ts index 542230d..1edcfce 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,9 +18,9 @@ import { LocalesPipeline } from './core/pipeline/localePipeline'; import { ItemLocalesPipeline } from './processing/item/locales/itemLocalesPipeline'; import { AvatarCustomizationLocalesPipeline } from './processing/avatarCustomization/locales/index'; -const gameMaster = require('./data/GAME_MASTER.json'); -const specialGameMastersDirectory = path.resolve(__dirname, 'data/special'); -const specialGameMasters = fs.existsSync(specialGameMastersDirectory) ? fs.readdirSync(specialGameMastersDirectory).map(file => require(`./data/special/${file}`)) : []; +const gameMaster = require('../pokemongo-game-master/versions/latest/GAME_MASTER.json'); +const specialGameMastersDirectory = path.resolve(__dirname, '../pokemongo-game-master/special'); +const specialGameMasters = fs.existsSync(specialGameMastersDirectory) ? fs.readdirSync(specialGameMastersDirectory).map(file => require(`../pokemongo-game-master/special/${file}`)) : []; const packageJson = require('../package.json'); const POKEMON_TRANSLATIONS = require('./data/POKEMON_TRANSLATIONS.json'); const MOVES_TRANSLATIONS = require('./data/MOVES_TRANSLATIONS.json');