reduce size of pogo-protos in bundle

This commit is contained in:
Jeff Colombo 2019-03-19 01:08:22 -04:00
parent 5fe3cd98c1
commit d0c2bd552e
32 changed files with 105684 additions and 826 deletions

File diff suppressed because one or more lines are too long

2
dist/global.css vendored

File diff suppressed because one or more lines are too long

22
dist/main-bundle.js vendored

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
syntax = "proto3";
package POGOProtos;
import public "/Users/jeff/Documents/repositories/pvpokemon/node_modules/pogo-protos/proto/Enums/Form.proto";
import public "/Users/jeff/Documents/repositories/pvpokemon/node_modules/pogo-protos/proto/Enums/PokemonFamilyId.proto";
import public "/Users/jeff/Documents/repositories/pvpokemon/node_modules/pogo-protos/proto/Enums/PokemonId.proto";
import public "/Users/jeff/Documents/repositories/pvpokemon/node_modules/pogo-protos/proto/Enums/PokemonMove.proto";
import public "/Users/jeff/Documents/repositories/pvpokemon/node_modules/pogo-protos/proto/Enums/PokemonType.proto";

1179
externals/generated/PvPogoProtos.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

2410
externals/generated/PvPogoProtos.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,12 @@
"start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.js --progress --colors --debug --output-pathinfo --port 8000 --env.WARN_ON_LINT", "start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.js --progress --colors --debug --output-pathinfo --port 8000 --env.WARN_ON_LINT",
"build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile", "build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile",
"clean": "rm -rf ./dist/*", "clean": "rm -rf ./dist/*",
"tsnode": "node -r ts-node/register -r tsconfig-paths/register" "tsnode": "node -r ts-node/register -r tsconfig-paths/register",
"generate": "node_modules/.bin/run-s protobuf pbjs pbts pokemondata",
"protobuf": "yarn tsnode ./src/scripts/generatePogoProtocolBuffer.ts PokemonId.proto Form.proto PokemonMove.proto PokemonFamilyId.proto PokemonType.proto",
"pbjs": "node_modules/.bin/pbjs --keep-case -t static-module --no-verify --no-create --no-delimited -o ./externals/generated/PvPogoProtos.js ./externals/generated/POGOProtos.generated.proto",
"pbts": "node_modules/.bin/pbts --no-comments -o ./externals/generated/PvPogoProtos.d.ts ./externals/generated/PvPogoProtos.js",
"pokemondata": "yarn tsnode ./src/scripts/generatePokemonData.ts"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.2.2", "@babel/core": "^7.2.2",
@ -38,9 +43,11 @@
"glob": "^7.1.3", "glob": "^7.1.3",
"mini-css-extract-plugin": "^0.5.0", "mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.11.0", "node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"path": "^0.12.7", "path": "^0.12.7",
"pogo-protos": "^2.31.1", "pogo-protos": "^2.33.2",
"pokemongo-game-master": "^1.0.4", "pokemongo-game-master": "^1.0.4",
"protobufjs": "^6.8.8",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"source-map-concat": "^1.0.1", "source-map-concat": "^1.0.1",
"source-map-dummy": "^1.0.0", "source-map-dummy": "^1.0.0",

View File

@ -1,6 +1,7 @@
const POGOProtos = require('pogo-protos'); const POGOProtos = require('pogo-protos');
const fs = require('fs'); const fs = require('fs');
const path = require('path');
const gamemaster = fs.readFileSync('externals/pokemongo-game-master/versions/latest/GAME_MASTER.protobuf'); const gamemaster = fs.readFileSync(path.resolve('externals/pokemongo-game-master/versions/latest', 'GAME_MASTER.protobuf'));
const decoded = POGOProtos.Networking.Responses.DownloadItemTemplatesResponse.decode(gamemaster); const decoded = POGOProtos.Networking.Responses.DownloadItemTemplatesResponse.decode(gamemaster);
fs.writeFileSync(`gamemaster_${ decoded.timestamp_ms }.json`, JSON.stringify(decoded, null, 2)); fs.writeFileSync(path.resolve('externals/generated', `gamemaster_${ decoded.timestamp_ms }.json`), JSON.stringify(decoded, null, 2));

View File

@ -0,0 +1,43 @@
// based on pogo-protos/proto/compile.js
let fs = require('fs').promises;
let path = require('path');
let pathToModule = path.dirname(require.resolve('pogo-protos'));
let args = process.argv.slice(2);
async function parseDir(directory : string, rel : string) {
let content = '';
for (let child of await fs.readdir(directory)) {
let sub = path.join(directory, child);
let stat = await fs.stat(sub);
if (stat.isDirectory()) {
content += await parseDir(sub, `${rel}/${child}`);
} else if (child.endsWith('.proto')) {
if (args.indexOf(child) === -1) {
continue;
}
content += `import public "${pathToModule}/${rel}/${child}";\n`;
}
}
return content;
}
async function build() {
let content = '';
content += 'syntax = "proto3";\n';
content += 'package POGOProtos;\n\n';
for (let child of await fs.readdir(pathToModule)) {
let sub = path.join(pathToModule, child);
let stat = await fs.stat(sub);
if (stat.isDirectory()) {
content += await parseDir(sub, child);
}
}
await fs.writeFile(path.resolve('externals/generated', 'POGOProtos.generated.proto'), content);
}
build();

View File

@ -1,5 +1,4 @@
import fs from 'fs'; import fs from 'fs';
import POGOProtos from 'pogo-protos';
import { parseGameMaster } from './parseGameMaster'; import { parseGameMaster } from './parseGameMaster';
@ -10,6 +9,8 @@ import { ILeaguePokemonJson } from 'api/PokemonService';
import { ILeaguePokemon, League, MaxCpByLeague } from 'app/models/League'; import { ILeaguePokemon, League, MaxCpByLeague } from 'app/models/League';
import { Grade, IMaxStats, IStats } from 'app/models/Pokemon'; import { Grade, IMaxStats, IStats } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
type ICpAndTotalFound = Record<number, Array<IStats>>; type ICpAndTotalFound = Record<number, Array<IStats>>;
interface IStatsDistribution { interface IStatsDistribution {
[ League.GREAT ] : ICpAndTotalFound; [ League.GREAT ] : ICpAndTotalFound;
@ -208,7 +209,7 @@ fs.mkdirSync(outPokemonPath, { recursive: true });
}); });
try { try {
const filename = mon.form === POGOProtos.Enums.Form.FORM_UNSET ? POGOProtos.Enums.PokemonId[mon.id] : POGOProtos.Enums.Form[mon.form]; const filename = mon.form === PVPogoProtos.PokemonForm.FORM_UNSET ? PVPogoProtos.PokemonId[mon.id] : PVPogoProtos.PokemonForm[mon.form];
const pokemonJson : ILeaguePokemonJson = { const pokemonJson : ILeaguePokemonJson = {
...pokemon, ...pokemon,
effectiveness: [ ...pokemon.effectiveness ], effectiveness: [ ...pokemon.effectiveness ],

View File

@ -1,25 +1,28 @@
import fs from 'fs'; import fs from 'fs';
import POGOProtos from 'pogo-protos'; import path from 'path';
import { ApiService } from 'api/ApiService'; import { ApiService } from 'api/ApiService';
import { CombatMoveStats, IBaseStatsRank, IPokemon, TypeEffectiveness, TypeOrder } from 'app/models/Pokemon'; import { CombatMoveStats, IBaseStatsRank, IPokemon, TypeEffectiveness, TypeOrder } from 'app/models/Pokemon';
import { LegacyMoves } from 'common/models/LegacyMoves'; import { LegacyMoves } from 'common/models/LegacyMoves';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
interface ICalculateRelativeStats { interface ICalculateRelativeStats {
id : POGOProtos.Enums.PokemonId; id : PVPogoProtos.PokemonId;
form : POGOProtos.Enums.Form; form : PVPogoProtos.PokemonForm;
value : number; value : number;
} }
export const parseGameMaster = async () => { export const parseGameMaster = async () => {
const POGOProtos = await import('pogo-protos');
const apiService = new ApiService(); const apiService = new ApiService();
const pokemonDataByPokemonId : Map<POGOProtos.Enums.PokemonId, Array<IPokemon>> = new Map(); const pokemonDataByPokemonId : Map<PVPogoProtos.PokemonId, Array<IPokemon>> = new Map();
const pokemonFormsByPokemonId : Map<POGOProtos.Enums.PokemonId, Array<POGOProtos.Enums.Form>> = new Map(); const pokemonFormsByPokemonId : Map<PVPogoProtos.PokemonId, Array<PVPogoProtos.PokemonForm>> = new Map();
const pokemonTypeEffectiveness : Map<POGOProtos.Enums.PokemonType, Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>> = new Map(); const pokemonTypeEffectiveness : Map<PVPogoProtos.PokemonType, Map<PVPogoProtos.PokemonType, TypeEffectiveness>> = new Map();
const pokemonTypeWeaknesses : Map<POGOProtos.Enums.PokemonType, Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>> = new Map(); const pokemonTypeWeaknesses : Map<PVPogoProtos.PokemonType, Map<PVPogoProtos.PokemonType, TypeEffectiveness>> = new Map();
const pokemonTypes : Map<POGOProtos.Enums.PokemonType, Array<number>> = new Map(); const pokemonTypes : Map<PVPogoProtos.PokemonType, Array<number>> = new Map();
const combatMoves : CombatMoveStats = new Map(); const combatMoves : CombatMoveStats = new Map();
const pokemonBaseStamina : Array<ICalculateRelativeStats> = []; const pokemonBaseStamina : Array<ICalculateRelativeStats> = [];
@ -27,7 +30,7 @@ export const parseGameMaster = async () => {
const pokemonBaseDefense : Array<ICalculateRelativeStats> = []; const pokemonBaseDefense : Array<ICalculateRelativeStats> = [];
const pokemonOrderById : Record<string, IBaseStatsRank> = {}; const pokemonOrderById : Record<string, IBaseStatsRank> = {};
const GameMasterProto = fs.readFileSync('externals/pokemongo-game-master/versions/latest/GAME_MASTER.protobuf'); const GameMasterProto = fs.readFileSync(path.resolve('externals/pokemongo-game-master/versions/latest', 'GAME_MASTER.protobuf'));
const GameMaster = POGOProtos.Networking.Responses.DownloadItemTemplatesResponse.decode(GameMasterProto); const GameMaster = POGOProtos.Networking.Responses.DownloadItemTemplatesResponse.decode(GameMasterProto);
const version = GameMaster.timestamp_ms; const version = GameMaster.timestamp_ms;
@ -39,11 +42,11 @@ export const parseGameMaster = async () => {
// POKEMON // POKEMON
if (entry.template_id.match(/^V(\d{4})_POKEMON_(\w+)$/) && entry.pokemon_settings) { if (entry.template_id.match(/^V(\d{4})_POKEMON_(\w+)$/) && entry.pokemon_settings) {
const pokemonId = entry.pokemon_settings.pokemon_id || POGOProtos.Enums.PokemonId.MISSINGNO; const pokemonId = entry.pokemon_settings.pokemon_id || PVPogoProtos.PokemonId.MISSINGNO;
const pokemonData = pokemonDataByPokemonId.get(pokemonId) || []; const pokemonData = pokemonDataByPokemonId.get(pokemonId) || [];
const dex = parseInt(RegExp.$1, 10); const dex = parseInt(RegExp.$1, 10);
const defaultName = POGOProtos.Enums.PokemonId[pokemonId].toLowerCase() const defaultName = PVPogoProtos.PokemonId[pokemonId].toLowerCase()
.split(' ') .split(' ')
.map((s) => s.charAt(0).toUpperCase() + s.substring(1)) .map((s) => s.charAt(0).toUpperCase() + s.substring(1))
.join(' '); .join(' ');
@ -55,10 +58,10 @@ export const parseGameMaster = async () => {
const mon = { const mon = {
...speciesInfo, ...speciesInfo,
id: pokemonId, id: pokemonId,
form: entry.pokemon_settings.form || POGOProtos.Enums.Form.FORM_UNSET, form: entry.pokemon_settings.form || PVPogoProtos.PokemonForm.FORM_UNSET,
family: entry.pokemon_settings.family_id || POGOProtos.Enums.PokemonFamilyId.FAMILY_UNSET, family: entry.pokemon_settings.family_id || PVPogoProtos.PokemonFamilyId.FAMILY_UNSET,
types: { types: {
type1: entry.pokemon_settings.type || POGOProtos.Enums.PokemonType.POKEMON_TYPE_NONE, type1: entry.pokemon_settings.type || PVPogoProtos.PokemonType.POKEMON_TYPE_NONE,
type2: entry.pokemon_settings.type_2 || null, type2: entry.pokemon_settings.type_2 || null,
}, },
effectiveness: new Map(), effectiveness: new Map(),
@ -97,7 +100,7 @@ export const parseGameMaster = async () => {
pokemonData.push(mon); pokemonData.push(mon);
pokemonDataByPokemonId.set(pokemonId, pokemonData); pokemonDataByPokemonId.set(pokemonId, pokemonData);
const key = POGOProtos.Enums.PokemonId[mon.id] + POGOProtos.Enums.Form[mon.form]; const key = PVPogoProtos.PokemonId[mon.id] + PVPogoProtos.PokemonForm[mon.form];
pokemonBaseStamina.push({ pokemonBaseStamina.push({
id: mon.id, id: mon.id,
@ -124,10 +127,10 @@ export const parseGameMaster = async () => {
} else if (entry.template_id.indexOf('FORMS_V') === 0 && entry.form_settings) { } else if (entry.template_id.indexOf('FORMS_V') === 0 && entry.form_settings) {
// typings say `forms` can be undefined, but in practice, it's not // typings say `forms` can be undefined, but in practice, it's not
if (entry.form_settings.forms && entry.form_settings.forms.length > 0) { if (entry.form_settings.forms && entry.form_settings.forms.length > 0) {
const pokemonId = entry.form_settings.pokemon || POGOProtos.Enums.PokemonId.MISSINGNO; const pokemonId = entry.form_settings.pokemon || PVPogoProtos.PokemonId.MISSINGNO;
// console.log(entry); // console.log(entry);
let pokemonData = pokemonFormsByPokemonId.get(pokemonId) || []; let pokemonData = pokemonFormsByPokemonId.get(pokemonId) || [];
pokemonData = entry.form_settings.forms.reduce((output : Array<POGOProtos.Enums.Form>, form) => { pokemonData = entry.form_settings.forms.reduce((output : Array<PVPogoProtos.PokemonForm>, form) => {
if (form.form) { if (form.form) {
output.push(form.form); output.push(form.form);
} }
@ -143,7 +146,7 @@ export const parseGameMaster = async () => {
// COMBAT MOVES // COMBAT MOVES
} else if (entry.template_id.indexOf('COMBAT_V') === 0 && entry.combat_move && entry.combat_move.unique_id) { } else if (entry.template_id.indexOf('COMBAT_V') === 0 && entry.combat_move && entry.combat_move.unique_id) {
const combatMoveId = entry.combat_move.unique_id || POGOProtos.Enums.PokemonMove.MOVE_UNSET; const combatMoveId = entry.combat_move.unique_id || PVPogoProtos.PokemonMove.MOVE_UNSET;
const formatMoveName = (moveId : string) => { const formatMoveName = (moveId : string) => {
let moveName = moveId; let moveName = moveId;
@ -165,8 +168,8 @@ export const parseGameMaster = async () => {
}; };
combatMoves.set(combatMoveId, { combatMoves.set(combatMoveId, {
id: combatMoveId, id: combatMoveId,
name: formatMoveName(POGOProtos.Enums.PokemonMove[combatMoveId]), name: formatMoveName(PVPogoProtos.PokemonMove[combatMoveId]),
type: entry.combat_move.type || POGOProtos.Enums.PokemonType.POKEMON_TYPE_NONE, type: entry.combat_move.type || PVPogoProtos.PokemonType.POKEMON_TYPE_NONE,
power: entry.combat_move.power || 0, power: entry.combat_move.power || 0,
energyDelta: entry.combat_move.energy_delta || 0, energyDelta: entry.combat_move.energy_delta || 0,
}); });
@ -175,7 +178,7 @@ export const parseGameMaster = async () => {
// organize pokemon type effectiveness data // organize pokemon type effectiveness data
pokemonTypes.forEach((effectiveness, type) => { pokemonTypes.forEach((effectiveness, type) => {
const pokemonTypeEffectivenessValues : Map<POGOProtos.Enums.PokemonType, TypeEffectiveness> = new Map(); const pokemonTypeEffectivenessValues : Map<PVPogoProtos.PokemonType, TypeEffectiveness> = new Map();
effectiveness.forEach((effectValue, effectiveTypeIndex) => { effectiveness.forEach((effectValue, effectiveTypeIndex) => {
let typeEffectiveness : TypeEffectiveness; let typeEffectiveness : TypeEffectiveness;
if (effectValue === TypeEffectiveness.NEUTRAL) { if (effectValue === TypeEffectiveness.NEUTRAL) {
@ -236,34 +239,34 @@ export const parseGameMaster = async () => {
return a.value - b.value; return a.value - b.value;
}); });
pokemonBaseStamina.forEach((stats, index, array) => { pokemonBaseStamina.forEach((stats, index, array) => {
const key = POGOProtos.Enums.PokemonId[stats.id] + POGOProtos.Enums.Form[stats.form]; const key = PVPogoProtos.PokemonId[stats.id] + PVPogoProtos.PokemonForm[stats.form];
pokemonOrderById[key].staminaRank = Math.floor((index / (array.length - 1)) * 100); pokemonOrderById[key].staminaRank = Math.floor((index / (array.length - 1)) * 100);
}); });
pokemonBaseAttack.sort((a, b) => { pokemonBaseAttack.sort((a, b) => {
return a.value - b.value; return a.value - b.value;
}); });
pokemonBaseAttack.forEach((stats, index, array) => { pokemonBaseAttack.forEach((stats, index, array) => {
const key = POGOProtos.Enums.PokemonId[stats.id] + POGOProtos.Enums.Form[stats.form]; const key = PVPogoProtos.PokemonId[stats.id] + PVPogoProtos.PokemonForm[stats.form];
pokemonOrderById[key].attackRank = Math.floor((index / (array.length - 1)) * 100); pokemonOrderById[key].attackRank = Math.floor((index / (array.length - 1)) * 100);
}); });
pokemonBaseDefense.sort((a, b) => { pokemonBaseDefense.sort((a, b) => {
return a.value - b.value; return a.value - b.value;
}); });
pokemonBaseDefense.forEach((stats, index, array) => { pokemonBaseDefense.forEach((stats, index, array) => {
const key = POGOProtos.Enums.PokemonId[stats.id] + POGOProtos.Enums.Form[stats.form]; const key = PVPogoProtos.PokemonId[stats.id] + PVPogoProtos.PokemonForm[stats.form];
pokemonOrderById[key].defenseRank = Math.floor((index / (array.length - 1)) * 100); pokemonOrderById[key].defenseRank = Math.floor((index / (array.length - 1)) * 100);
}); });
flatOrderedPokemon.forEach((mon) => { flatOrderedPokemon.forEach((mon) => {
const key = POGOProtos.Enums.PokemonId[mon.id] + POGOProtos.Enums.Form[mon.form]; const key = PVPogoProtos.PokemonId[mon.id] + PVPogoProtos.PokemonForm[mon.form];
mon.statsRank = { ...pokemonOrderById[key] }; mon.statsRank = { ...pokemonOrderById[key] };
TypeOrder.forEach((type) => { TypeOrder.forEach((type) => {
const type1Effectiveness = pokemonTypeWeaknesses.get(mon.types.type1); const type1Effectiveness = pokemonTypeWeaknesses.get(mon.types.type1);
if (typeof type1Effectiveness === 'undefined') { if (typeof type1Effectiveness === 'undefined') {
throw new Error(`Unexpected missing type 1 "${mon.types.type1}" for pokemonId "${mon.id}"`); throw new Error(`Unexpected missing type 1 "${mon.types.type1}" for PVPogoProtos.pokemonId "${mon.id}"`);
} }
const type2Effectiveness = mon.types.type2 !== null ? pokemonTypeWeaknesses.get(mon.types.type2) : null; const type2Effectiveness = mon.types.type2 !== null ? pokemonTypeWeaknesses.get(mon.types.type2) : null;
if (typeof type2Effectiveness === 'undefined') { if (typeof type2Effectiveness === 'undefined') {
throw new Error(`Unexpected missing type 2 "${mon.types.type2}" for pokemonId "${mon.id}"`); throw new Error(`Unexpected missing type 2 "${mon.types.type2}" for PVPogoProtos.pokemonId "${mon.id}"`);
} }
const type1EffectiveValue = type1Effectiveness.get(type); const type1EffectiveValue = type1Effectiveness.get(type);
const type2EffectiveValue = type2Effectiveness ? type2Effectiveness.get(type) : TypeEffectiveness.NEUTRAL; const type2EffectiveValue = type2Effectiveness ? type2Effectiveness.get(type) : TypeEffectiveness.NEUTRAL;
@ -310,3 +313,4 @@ export const parseGameMaster = async () => {
combatMoves, combatMoves,
}; };
}; };
parseGameMaster();

View File

@ -1,11 +1,12 @@
import csv from 'csvtojson'; import csv from 'csvtojson';
import POGOProtos from 'pogo-protos';
import xhr2 from 'xhr2'; import xhr2 from 'xhr2';
import { AjaxRequest } from 'api/AjaxRequest'; import { AjaxRequest } from 'api/AjaxRequest';
import { DEFAULT_POKEMON_NAME, IPokemonSpecies } from 'app/models/Pokemon'; import { DEFAULT_POKEMON_NAME, IPokemonSpecies } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
interface IPokeApiSpeciesNameJSON { interface IPokeApiSpeciesNameJSON {
pokemon_species_id : string; pokemon_species_id : string;
local_language_id : '9' | string; local_language_id : '9' | string;
@ -35,7 +36,7 @@ interface ILivePokeApiSpeciesListJSON {
interface IApiService { interface IApiService {
getLivePokemonSpeciesKeys() : Promise<Array<string>>; getLivePokemonSpeciesKeys() : Promise<Array<string>>;
getPokemonSpeciesInfo(pokemonId : POGOProtos.Enums.PokemonId, defaultDex : number, defaultName : string) : Promise<IPokemonSpecies>; getPokemonSpeciesInfo(pokemonId : PVPogoProtos.PokemonId, defaultDex : number, defaultName : string) : Promise<IPokemonSpecies>;
getLivePokemonSpeciesInfo(dex : number) : Promise<IPokemonSpecies>; getLivePokemonSpeciesInfo(dex : number) : Promise<IPokemonSpecies>;
} }
@ -46,7 +47,7 @@ export class ApiService implements IApiService {
this.AjaxRequest = new AjaxRequest(xhr2); this.AjaxRequest = new AjaxRequest(xhr2);
} }
public async getPokemonSpeciesInfo(pokemonId : POGOProtos.Enums.PokemonId, defaultDex : number, defaultName : string) { public async getPokemonSpeciesInfo(pokemonId : PVPogoProtos.PokemonId, defaultDex : number, defaultName : string) {
const formattedName = this.formatPokemonIdToPokeApiNameKey(pokemonId); const formattedName = this.formatPokemonIdToPokeApiNameKey(pokemonId);
const speciesArray : Array<IPokeApiSpeciesJSON> = await csv().fromFile('externals/PokeApi/data/v2/csv/pokemon_species.csv'); const speciesArray : Array<IPokeApiSpeciesJSON> = await csv().fromFile('externals/PokeApi/data/v2/csv/pokemon_species.csv');
@ -96,7 +97,7 @@ export class ApiService implements IApiService {
}); });
} }
public async getLivePokemonSpeciesInfo(pokemonId : POGOProtos.Enums.PokemonId) { public async getLivePokemonSpeciesInfo(pokemonId : PVPogoProtos.PokemonId) {
const formattedName = this.formatPokemonIdToPokeApiNameKey(pokemonId); const formattedName = this.formatPokemonIdToPokeApiNameKey(pokemonId);
const queryParameters = { const queryParameters = {
@ -132,14 +133,14 @@ export class ApiService implements IApiService {
return serializedResponse; return serializedResponse;
} }
private formatPokemonIdToPokeApiNameKey(pokemonId : POGOProtos.Enums.PokemonId) { private formatPokemonIdToPokeApiNameKey(pokemonId : PVPogoProtos.PokemonId) {
let key : string; let key : string;
if (pokemonId === POGOProtos.Enums.PokemonId.NIDORAN_MALE) { if (pokemonId === PVPogoProtos.PokemonId.NIDORAN_MALE) {
key = 'nidoran-m'; key = 'nidoran-m';
} else if (pokemonId === POGOProtos.Enums.PokemonId.NIDORAN_FEMALE) { } else if (pokemonId === PVPogoProtos.PokemonId.NIDORAN_FEMALE) {
key = 'nidoran-f'; key = 'nidoran-f';
} else { } else {
key = POGOProtos.Enums.PokemonId[pokemonId]; key = PVPogoProtos.PokemonId[pokemonId];
} }
return key.toLowerCase().replace(/_/, '-'); return key.toLowerCase().replace(/_/, '-');
} }

View File

@ -1,20 +1,20 @@
import POGOProtos from 'pogo-protos';
import { AjaxRequest } from 'api/AjaxRequest'; import { AjaxRequest } from 'api/AjaxRequest';
import { AttackTypeEffectivenessSerializingTuple, IConfig, IConfigJson } from 'app/models/Config'; import { AttackTypeEffectivenessSerializingTuple, IConfig, IConfigJson } from 'app/models/Config';
import { ILeaguePokemon } from 'app/models/League'; import { ILeaguePokemon } from 'app/models/League';
import { IPokemon, TypeEffectiveness } from 'app/models/Pokemon'; import { IPokemon, TypeEffectiveness } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export interface ILeaguePokemonJson extends Omit<ILeaguePokemon, 'effectiveness'> { export interface ILeaguePokemonJson extends Omit<ILeaguePokemon, 'effectiveness'> {
effectiveness : Array<[POGOProtos.Enums.PokemonType, TypeEffectiveness]>; effectiveness : Array<[PVPogoProtos.PokemonType, TypeEffectiveness]>;
} }
interface IPokemonService { interface IPokemonService {
getConfig() : Promise<IConfig>; getConfig() : Promise<IConfig>;
getPokemonList() : Promise<Array<IPokemon>>; getPokemonList() : Promise<Array<IPokemon>>;
getPokemonLeagueStats(pokemonId : POGOProtos.Enums.PokemonId, form : POGOProtos.Enums.Form) : Promise<ILeaguePokemon>; getPokemonLeagueStats(pokemonId : PVPogoProtos.PokemonId, form : PVPogoProtos.PokemonForm) : Promise<ILeaguePokemon>;
} }
export class PokemonService implements IPokemonService { export class PokemonService implements IPokemonService {
@ -52,8 +52,8 @@ export class PokemonService implements IPokemonService {
return response; return response;
} }
public async getPokemonLeagueStats(pokemonId : POGOProtos.Enums.PokemonId, form : POGOProtos.Enums.Form) { public async getPokemonLeagueStats(pokemonId : PVPogoProtos.PokemonId, form : PVPogoProtos.PokemonForm) {
const fileName = form === POGOProtos.Enums.Form.FORM_UNSET ? POGOProtos.Enums.PokemonId[pokemonId] : POGOProtos.Enums.Form[form]; const fileName = form === PVPogoProtos.PokemonForm.FORM_UNSET ? PVPogoProtos.PokemonId[pokemonId] : PVPogoProtos.PokemonForm[form];
const queryParameters = { const queryParameters = {
}; };

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router-dom'; import { RouteComponentProps } from 'react-router-dom';
@ -20,6 +18,8 @@ import { Header } from 'app/components/Header';
import { ConnectedPokemonExplorer } from 'app/components/PokemonExplorer/PokemonExplorer'; import { ConnectedPokemonExplorer } from 'app/components/PokemonExplorer/PokemonExplorer';
import { PokemonSelectList } from 'app/components/PokemonSelectList/PokemonSelectList'; import { PokemonSelectList } from 'app/components/PokemonSelectList/PokemonSelectList';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/styles/PokemonApp.scss'; import * as styles from 'app/styles/PokemonApp.scss';
type PokemonAppProps = ReturnType<typeof appReducers>; type PokemonAppProps = ReturnType<typeof appReducers>;
@ -62,8 +62,8 @@ class PokemonApp extends React.Component<IConnectedPokemonAppProps, IState> {
const pokemonId = id ? parseInt(id, 10) : null; const pokemonId = id ? parseInt(id, 10) : null;
const pokemonForm = form ? parseInt(form, 10) : null; const pokemonForm = form ? parseInt(form, 10) : null;
if (pokemonId !== null && typeof POGOProtos.Enums.PokemonId[pokemonId] !== 'undefined' && if (pokemonId !== null && typeof PVPogoProtos.PokemonId[pokemonId] !== 'undefined' &&
pokemonForm !== null && typeof POGOProtos.Enums.Form[pokemonForm] !== 'undefined' pokemonForm !== null && typeof PVPogoProtos.PokemonForm[pokemonForm] !== 'undefined'
) { ) {
this.handleActivatePokemon(pokemonId, pokemonForm); this.handleActivatePokemon(pokemonId, pokemonForm);
} }
@ -174,7 +174,7 @@ class PokemonApp extends React.Component<IConnectedPokemonAppProps, IState> {
this.handleSearchInterruption(true); this.handleSearchInterruption(true);
} }
private readonly handleActivatePokemon = (pokemonId : POGOProtos.Enums.PokemonId, form : POGOProtos.Enums.Form) => { private readonly handleActivatePokemon = (pokemonId : PVPogoProtos.PokemonId, form : PVPogoProtos.PokemonForm) => {
const { dispatch } = this.props; const { dispatch } = this.props;
dispatch(ActionsPokemonSelectList.fetchPokemonLeagueStats(pokemonId, form)) dispatch(ActionsPokemonSelectList.fetchPokemonLeagueStats(pokemonId, form))

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import { ContentRect, default as Measure } from 'react-measure'; import { ContentRect, default as Measure } from 'react-measure';
import { FixedSizeList } from 'react-window'; import { FixedSizeList } from 'react-window';
@ -9,11 +7,13 @@ import classNames from 'classnames';
import { IIndividualValues } from 'app/components/PokemonExplorer/types'; import { IIndividualValues } from 'app/components/PokemonExplorer/types';
import { Grade, IStats } from 'app/models/Pokemon'; import { Grade, IStats } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/LeagueStatsList.scss'; import * as styles from 'app/components/PokemonExplorer/styles/LeagueStatsList.scss';
export interface ILeagueStatsListProps { export interface ILeagueStatsListProps {
activePokemonId : POGOProtos.Enums.PokemonId; activePokemonId : PVPogoProtos.PokemonId;
activePokemonForm : POGOProtos.Enums.Form; activePokemonForm : PVPogoProtos.PokemonForm;
activeIndividualValues : IIndividualValues; activeIndividualValues : IIndividualValues;
leagueStatsList : Array<IStats>; leagueStatsList : Array<IStats>;
@ -21,8 +21,8 @@ export interface ILeagueStatsListProps {
} }
interface IState { interface IState {
activePokemonId : POGOProtos.Enums.PokemonId; activePokemonId : PVPogoProtos.PokemonId;
activePokemonForm : POGOProtos.Enums.Form; activePokemonForm : PVPogoProtos.PokemonForm;
hasSetActiveStats : boolean; hasSetActiveStats : boolean;
listRef : React.RefObject<FixedSizeList>; listRef : React.RefObject<FixedSizeList>;
activeIndex : number; activeIndex : number;
@ -94,8 +94,8 @@ export class LeagueStatsList extends React.Component<ILeagueStatsListProps, ISta
super(props); super(props);
this.state = { this.state = {
activePokemonId: POGOProtos.Enums.PokemonId.MISSINGNO, activePokemonId: PVPogoProtos.PokemonId.MISSINGNO,
activePokemonForm: POGOProtos.Enums.Form.FORM_UNSET, activePokemonForm: PVPogoProtos.PokemonForm.FORM_UNSET,
hasSetActiveStats: false, hasSetActiveStats: false,
listRef: React.createRef(), listRef: React.createRef(),
activeIndex: -1, activeIndex: -1,

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import { ContentRect, default as Measure } from 'react-measure'; import { ContentRect, default as Measure } from 'react-measure';
import { FixedSizeList } from 'react-window'; import { FixedSizeList } from 'react-window';
@ -13,6 +11,8 @@ import { TypeIndicator, TypeTheme } from './TypeIndicator';
import { formatType } from 'app/utils/formatter'; import { formatType } from 'app/utils/formatter';
import { getMoveType } from 'app/utils/types'; import { getMoveType } from 'app/utils/types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/MovesDropdown.scss'; import * as styles from 'app/components/PokemonExplorer/styles/MovesDropdown.scss';
export interface IMovesDropdownProps { export interface IMovesDropdownProps {
@ -87,7 +87,7 @@ export class MovesDropdown extends React.Component<IMovesDropdownProps, IState>
}; };
let moveName = 'Select a move'; let moveName = 'Select a move';
let moveType : POGOProtos.Enums.PokemonType | null = null; let moveType : PVPogoProtos.PokemonType | null = null;
if (selectedMove !== null) { if (selectedMove !== null) {
const moveStats = movesById.get(selectedMove.id); const moveStats = movesById.get(selectedMove.id);
if (moveStats) { if (moveStats) {

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
@ -14,6 +12,8 @@ import { EffectivenessMode, TypeEffectiveDisplay } from './TypeEffectiveDisplay'
import { calculateTypeCoverage } from 'app/utils/types'; import { calculateTypeCoverage } from 'app/utils/types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/MovesExplorer.scss'; import * as styles from 'app/components/PokemonExplorer/styles/MovesExplorer.scss';
export interface IMovesExplorerProps { export interface IMovesExplorerProps {
@ -21,7 +21,7 @@ export interface IMovesExplorerProps {
quickMoves : Array<IPokemonMove>; quickMoves : Array<IPokemonMove>;
chargeMoves : Array<IPokemonMove>; chargeMoves : Array<IPokemonMove>;
selectedMoves : SelectedCombatMoves; selectedMoves : SelectedCombatMoves;
pokemonTypeWeaknesses : Array<POGOProtos.Enums.PokemonType>; pokemonTypeWeaknesses : Array<PVPogoProtos.PokemonType>;
attackTypeEffectiveness : AttackTypeEffectiveness; attackTypeEffectiveness : AttackTypeEffectiveness;
combatMoveSelectorsOpen : CombatMoveSelectorsOpen; combatMoveSelectorsOpen : CombatMoveSelectorsOpen;
handleToggleDropdownOpen : (menu : keyof CombatMoveSelectorsOpen, isOpen : boolean) => void; handleToggleDropdownOpen : (menu : keyof CombatMoveSelectorsOpen, isOpen : boolean) => void;

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
@ -11,6 +9,8 @@ import { formatDexNumber, formatForm, Forms } from 'app/utils/formatter';
import { StatDisplay } from './StatDisplay'; import { StatDisplay } from './StatDisplay';
import { TypeIndicator, TypeTheme } from './TypeIndicator'; import { TypeIndicator, TypeTheme } from './TypeIndicator';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/PokemonDisplay.scss'; import * as styles from 'app/components/PokemonExplorer/styles/PokemonDisplay.scss';
export interface IPokemonDisplay { export interface IPokemonDisplay {
@ -110,7 +110,7 @@ export class PokemonDisplay extends React.Component<IPokemonDisplay> {
{ type1 } { type1 }
{ type2 } { type2 }
</div> </div>
{ leaguePokemon.form !== POGOProtos.Enums.Form.FORM_UNSET && { leaguePokemon.form !== PVPogoProtos.PokemonForm.FORM_UNSET &&
<h6 className={ styles.formHeader }>{ formatForm(leaguePokemon.form) } Form</h6> <h6 className={ styles.formHeader }>{ formatForm(leaguePokemon.form) } Form</h6>
} }
</div> </div>

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router-dom'; import { RouteComponentProps } from 'react-router-dom';
@ -28,6 +26,8 @@ import { EffectivenessMode, TypeEffectiveDisplay } from 'app/components/PokemonE
import { appendQueryString } from 'app/utils/navigation'; import { appendQueryString } from 'app/utils/navigation';
import { calculateTypeCoverage } from 'app/utils/types'; import { calculateTypeCoverage } from 'app/utils/types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/styles/PokemonApp.scss'; import * as styles from 'app/styles/PokemonApp.scss';
// TODO: better way to expose IRouterProps than just passing them in??? // TODO: better way to expose IRouterProps than just passing them in???
@ -201,8 +201,8 @@ class PokemonExplorer extends React.Component<IConnectedPokemonExplorerProps, IS
); );
} }
private readonly getSuperEffectiveTypes = (effectiveness : Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>) => { private readonly getSuperEffectiveTypes = (effectiveness : Map<PVPogoProtos.PokemonType, TypeEffectiveness>) => {
const superEffectiveTypes : Array<POGOProtos.Enums.PokemonType> = []; const superEffectiveTypes : Array<PVPogoProtos.PokemonType> = [];
Array.from(effectiveness).reduce((accumulator, currentValue) => { Array.from(effectiveness).reduce((accumulator, currentValue) => {
if (currentValue[1] > TypeEffectiveness.NEUTRAL) { if (currentValue[1] > TypeEffectiveness.NEUTRAL) {
accumulator.push(currentValue[0]); accumulator.push(currentValue[0]);

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
@ -8,6 +6,8 @@ import { IPokemon, TypeEffectiveness } from 'app/models/Pokemon';
import { TypeIndicator, TypeTheme } from './TypeIndicator'; import { TypeIndicator, TypeTheme } from './TypeIndicator';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/TypeEffectiveDisplay.scss'; import * as styles from 'app/components/PokemonExplorer/styles/TypeEffectiveDisplay.scss';
export enum EffectivenessMode { export enum EffectivenessMode {
@ -18,7 +18,7 @@ export enum EffectivenessMode {
export interface ITypeEffectiveDisplayProps { export interface ITypeEffectiveDisplayProps {
mode : EffectivenessMode; mode : EffectivenessMode;
effectiveness : IPokemon['effectiveness']; effectiveness : IPokemon['effectiveness'];
coverage : Array<POGOProtos.Enums.PokemonType>; coverage : Array<PVPogoProtos.PokemonType>;
} }
export class TypeEffectiveDisplay extends React.Component<ITypeEffectiveDisplayProps> { export class TypeEffectiveDisplay extends React.Component<ITypeEffectiveDisplayProps> {
@ -164,7 +164,7 @@ export class TypeEffectiveDisplay extends React.Component<ITypeEffectiveDisplayP
); );
} }
private readonly isTypeCovered = (type : POGOProtos.Enums.PokemonType) => { private readonly isTypeCovered = (type : PVPogoProtos.PokemonType) => {
return this.props.coverage.some((coverageType) => { return this.props.coverage.some((coverageType) => {
return coverageType === type; return coverageType === type;
}); });

View File

@ -1,11 +1,11 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { formatType } from 'app/utils/formatter'; import { formatType } from 'app/utils/formatter';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/TypeIndicator.scss'; import * as styles from 'app/components/PokemonExplorer/styles/TypeIndicator.scss';
export enum TypeTheme { export enum TypeTheme {
@ -15,7 +15,7 @@ export enum TypeTheme {
export interface ITypeEffectiveDisplayProps { export interface ITypeEffectiveDisplayProps {
className? : string; className? : string;
type : POGOProtos.Enums.PokemonType; type : PVPogoProtos.PokemonType;
theme : TypeTheme; theme : TypeTheme;
} }

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react'; import React from 'react';
import { ContentRect, default as Measure } from 'react-measure'; import { ContentRect, default as Measure } from 'react-measure';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -12,17 +10,19 @@ import { appendQueryString } from 'app/utils/navigation';
import { DEFAULT_POKEMON_NAME, IPokemon } from 'app/models/Pokemon'; import { DEFAULT_POKEMON_NAME, IPokemon } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from './styles/PokemonSelectList.scss'; import * as styles from './styles/PokemonSelectList.scss';
export interface IPokemonSelectListProps { export interface IPokemonSelectListProps {
isLoading : boolean; isLoading : boolean;
isListOpen : boolean; isListOpen : boolean;
activePokemonId : POGOProtos.Enums.PokemonId | null; activePokemonId : PVPogoProtos.PokemonId | null;
activePokemonForm : POGOProtos.Enums.Form | null; activePokemonForm : PVPogoProtos.PokemonForm | null;
pokemonList : Array<IPokemon>; pokemonList : Array<IPokemon>;
filterTerm : string; filterTerm : string;
handleActivatePokemon : (pokemonId : POGOProtos.Enums.PokemonId, form : POGOProtos.Enums.Form) => void; handleActivatePokemon : (pokemonId : PVPogoProtos.PokemonId, form : PVPogoProtos.PokemonForm) => void;
handleChangeFilter : (filterTerm : string) => Promise<void>; handleChangeFilter : (filterTerm : string) => Promise<void>;
} }
@ -180,7 +180,7 @@ export class PokemonSelectList extends React.Component<IPokemonSelectListProps,
} }
private readonly calculateRowHeight = (index : number) => { private readonly calculateRowHeight = (index : number) => {
return this.props.pokemonList[index].form === POGOProtos.Enums.Form.FORM_UNSET ? 25 : 40; return this.props.pokemonList[index].form === PVPogoProtos.PokemonForm.FORM_UNSET ? 25 : 40;
} }
private rowFactory({ index, style } : IRowFactory) { private rowFactory({ index, style } : IRowFactory) {
@ -226,14 +226,14 @@ export class PokemonSelectList extends React.Component<IPokemonSelectListProps,
<span>{ pokemon.name }</span> <span>{ pokemon.name }</span>
<span className={ dexCss }>#{ dex }</span> <span className={ dexCss }>#{ dex }</span>
{ /* <i className={ menuIconCss } /> */ } { /* <i className={ menuIconCss } /> */ }
{ pokemon.form !== POGOProtos.Enums.Form.FORM_UNSET && { pokemon.form !== PVPogoProtos.PokemonForm.FORM_UNSET &&
<span className={ formCss }>{ formatForm(pokemon.form) } Form</span> <span className={ formCss }>{ formatForm(pokemon.form) } Form</span>
} }
</Link> </Link>
); );
} }
private readonly getActivatePokemonHandler = (pokemonId : POGOProtos.Enums.PokemonId, form : POGOProtos.Enums.Form) => { private readonly getActivatePokemonHandler = (pokemonId : PVPogoProtos.PokemonId, form : PVPogoProtos.PokemonForm) => {
const handlerKey = `${ pokemonId }~${ form }`; const handlerKey = `${ pokemonId }~${ form }`;
if (!this.activatePokemonClickHandlers.has(handlerKey)) { if (!this.activatePokemonClickHandlers.has(handlerKey)) {
this.activatePokemonClickHandlers.set(handlerKey, () => this.props.handleActivatePokemon(pokemonId, form)); this.activatePokemonClickHandlers.set(handlerKey, () => this.props.handleActivatePokemon(pokemonId, form));

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import { action } from 'typesafe-actions'; import { action } from 'typesafe-actions';
import { ILeaguePokemon } from 'app/models/League'; import { ILeaguePokemon } from 'app/models/League';
@ -8,15 +6,17 @@ import { IPokemon } from 'app/models/Pokemon';
import { ThunkResult } from 'app/types'; import { ThunkResult } from 'app/types';
import { PokemonSelectListActionTypes } from './types'; import { PokemonSelectListActionTypes } from './types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
export const setIsLoading = (isLoading : boolean) => action(PokemonSelectListActionTypes.SET_IS_LOADING, { isLoading }); export const setIsLoading = (isLoading : boolean) => action(PokemonSelectListActionTypes.SET_IS_LOADING, { isLoading });
export const setPokemonList = (pokemonList : Array<IPokemon>) => action(PokemonSelectListActionTypes.SET_POKEMON_LIST, { pokemonList }); export const setPokemonList = (pokemonList : Array<IPokemon>) => action(PokemonSelectListActionTypes.SET_POKEMON_LIST, { pokemonList });
export const setPokemonListFiltered = (filterTerm : string, pokemonListFiltered : Array<IPokemon>) => action(PokemonSelectListActionTypes.SET_POKEMON_LIST_FILTERED, { filterTerm, pokemonListFiltered }); export const setPokemonListFiltered = (filterTerm : string, pokemonListFiltered : Array<IPokemon>) => action(PokemonSelectListActionTypes.SET_POKEMON_LIST_FILTERED, { filterTerm, pokemonListFiltered });
export const setActivePokemonId = (activePokemonId : POGOProtos.Enums.PokemonId | null, activePokemonForm : POGOProtos.Enums.Form | null) => action(PokemonSelectListActionTypes.SET_ACTIVE_POKEMON_ID, { activePokemonId, activePokemonForm }); export const setActivePokemonId = (activePokemonId : PVPogoProtos.PokemonId | null, activePokemonForm : PVPogoProtos.PokemonForm | null) => action(PokemonSelectListActionTypes.SET_ACTIVE_POKEMON_ID, { activePokemonId, activePokemonForm });
export const setPokemonLeagueStats = (pokemonId : POGOProtos.Enums.PokemonId, pokemonLeagueStats : ILeaguePokemon) => action(PokemonSelectListActionTypes.SET_POKEMON_LEAGUE_STATS, { pokemonId, pokemonLeagueStats }); export const setPokemonLeagueStats = (pokemonId : PVPogoProtos.PokemonId, pokemonLeagueStats : ILeaguePokemon) => action(PokemonSelectListActionTypes.SET_POKEMON_LEAGUE_STATS, { pokemonId, pokemonLeagueStats });
export const filterPokemonList = ( export const filterPokemonList = (
filterTerm : string filterTerm : string
@ -29,7 +29,7 @@ export const filterPokemonList = (
pokemonListFiltered = pokemonList.reduce((result : Array<IPokemon>, pokemon) => { pokemonListFiltered = pokemonList.reduce((result : Array<IPokemon>, pokemon) => {
const pokemonName = pokemon.name.toLowerCase(); const pokemonName = pokemon.name.toLowerCase();
const pokemonDex = '' + pokemon.dex; const pokemonDex = '' + pokemon.dex;
const pokemonForm = pokemon.form === null ? '' : POGOProtos.Enums.Form[pokemon.form].toLowerCase(); const pokemonForm = pokemon.form === null ? '' : PVPogoProtos.PokemonForm[pokemon.form].toLowerCase();
if (pokemonName.indexOf(normalizedFilterTerm) === 0 || if (pokemonName.indexOf(normalizedFilterTerm) === 0 ||
pokemonDex.indexOf(normalizedFilterTerm) === 0 || pokemonDex.indexOf(normalizedFilterTerm) === 0 ||
normalizedFilterTerm === pokemonForm normalizedFilterTerm === pokemonForm
@ -52,8 +52,8 @@ export const fetchPokemonList = (
}; };
export const fetchPokemonLeagueStats = ( export const fetchPokemonLeagueStats = (
pokemonId : POGOProtos.Enums.PokemonId, pokemonId : PVPogoProtos.PokemonId,
form : POGOProtos.Enums.Form form : PVPogoProtos.PokemonForm
) : ThunkResult<Promise<ILeaguePokemon>> => { ) : ThunkResult<Promise<ILeaguePokemon>> => {
return async (dispatch, getState, extraArguments) => { return async (dispatch, getState, extraArguments) => {
const pokemonLeagueStats = await extraArguments.services.pokemonService.getPokemonLeagueStats(pokemonId, form); const pokemonLeagueStats = await extraArguments.services.pokemonService.getPokemonLeagueStats(pokemonId, form);

View File

@ -1,16 +1,16 @@
import POGOProtos from 'pogo-protos';
import { ILeaguePokemon } from 'app/models/League'; import { ILeaguePokemon } from 'app/models/League';
import { IPokemon } from 'app/models/Pokemon'; import { IPokemon } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
export interface IPokemonSelectListState { export interface IPokemonSelectListState {
isLoading : boolean; isLoading : boolean;
activePokemonId : POGOProtos.Enums.PokemonId | null; activePokemonId : PVPogoProtos.PokemonId | null;
activePokemonForm : POGOProtos.Enums.Form | null; activePokemonForm : PVPogoProtos.PokemonForm | null;
pokemonList : Array<IPokemon>; pokemonList : Array<IPokemon>;
pokemonListFiltered : Array<IPokemon>; pokemonListFiltered : Array<IPokemon>;
filterTerm : string; filterTerm : string;
pokemonLeagueStats : { [id in keyof typeof POGOProtos.Enums.PokemonId]? : ILeaguePokemon }; pokemonLeagueStats : { [id in keyof typeof PVPogoProtos.PokemonId]? : ILeaguePokemon };
} }
export const PokemonSelectListActionTypes = { export const PokemonSelectListActionTypes = {

View File

@ -1,18 +1,18 @@
import POGOProtos from 'pogo-protos';
import { CombatMoveStats, ICombatMoveStats, IMaxStats, TypeEffectiveness } from 'app/models/Pokemon'; import { CombatMoveStats, ICombatMoveStats, IMaxStats, TypeEffectiveness } from 'app/models/Pokemon';
type TypeEffectivenessByTypeJson = Array<[POGOProtos.Enums.PokemonType, TypeEffectiveness]>; import * as PVPogoProtos from 'common/models/PvPogoProtos';
type AttackTypeEffectivenessJson = Array<[POGOProtos.Enums.PokemonType, TypeEffectivenessByTypeJson]>;
type TypeEffectivenessByTypeJson = Array<[PVPogoProtos.PokemonType, TypeEffectiveness]>;
type AttackTypeEffectivenessJson = Array<[PVPogoProtos.PokemonType, TypeEffectivenessByTypeJson]>;
export interface IConfigJson { export interface IConfigJson {
maxPossibleStats : IMaxStats; maxPossibleStats : IMaxStats;
attackTypeEffectiveness : AttackTypeEffectivenessJson; attackTypeEffectiveness : AttackTypeEffectivenessJson;
combatMoves : Array<[POGOProtos.Enums.PokemonMove, ICombatMoveStats]>; combatMoves : Array<[PVPogoProtos.PokemonMove, ICombatMoveStats]>;
} }
export type TypeEffectivenessByType = Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>; export type TypeEffectivenessByType = Map<PVPogoProtos.PokemonType, TypeEffectiveness>;
export type AttackTypeEffectiveness = Map<POGOProtos.Enums.PokemonType, TypeEffectivenessByType>; export type AttackTypeEffectiveness = Map<PVPogoProtos.PokemonType, TypeEffectivenessByType>;
export interface IConfig { export interface IConfig {
maxPossibleStats : IMaxStats; maxPossibleStats : IMaxStats;
@ -20,4 +20,4 @@ export interface IConfig {
combatMoves : CombatMoveStats; combatMoves : CombatMoveStats;
} }
export type AttackTypeEffectivenessSerializingTuple = [POGOProtos.Enums.PokemonType, TypeEffectivenessByType]; export type AttackTypeEffectivenessSerializingTuple = [PVPogoProtos.PokemonType, TypeEffectivenessByType];

View File

@ -1,4 +1,4 @@
import POGOProtos from 'pogo-protos'; import * as PVPogoProtos from 'common/models/PvPogoProtos';
export const DEFAULT_POKEMON_NAME = 'MissingNo.'; export const DEFAULT_POKEMON_NAME = 'MissingNo.';
@ -22,24 +22,24 @@ export enum TypeEffectiveness {
} }
export const TypeOrder = [ export const TypeOrder = [
POGOProtos.Enums.PokemonType.POKEMON_TYPE_NORMAL, PVPogoProtos.PokemonType.POKEMON_TYPE_NORMAL,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIGHTING, PVPogoProtos.PokemonType.POKEMON_TYPE_FIGHTING,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FLYING, PVPogoProtos.PokemonType.POKEMON_TYPE_FLYING,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_POISON, PVPogoProtos.PokemonType.POKEMON_TYPE_POISON,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_GROUND, PVPogoProtos.PokemonType.POKEMON_TYPE_GROUND,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_ROCK, PVPogoProtos.PokemonType.POKEMON_TYPE_ROCK,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_BUG, PVPogoProtos.PokemonType.POKEMON_TYPE_BUG,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_GHOST, PVPogoProtos.PokemonType.POKEMON_TYPE_GHOST,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_STEEL, PVPogoProtos.PokemonType.POKEMON_TYPE_STEEL,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIRE , PVPogoProtos.PokemonType.POKEMON_TYPE_FIRE ,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_WATER, PVPogoProtos.PokemonType.POKEMON_TYPE_WATER,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_GRASS, PVPogoProtos.PokemonType.POKEMON_TYPE_GRASS,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_ELECTRIC, PVPogoProtos.PokemonType.POKEMON_TYPE_ELECTRIC,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_PSYCHIC, PVPogoProtos.PokemonType.POKEMON_TYPE_PSYCHIC,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_ICE, PVPogoProtos.PokemonType.POKEMON_TYPE_ICE,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_DRAGON, PVPogoProtos.PokemonType.POKEMON_TYPE_DRAGON,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_DARK, PVPogoProtos.PokemonType.POKEMON_TYPE_DARK,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FAIRY, PVPogoProtos.PokemonType.POKEMON_TYPE_FAIRY,
]; ];
export interface IBaseStats { export interface IBaseStats {
@ -66,19 +66,19 @@ export interface IPokemonSpecies {
} }
export interface IPokemonMove { export interface IPokemonMove {
id : POGOProtos.Enums.PokemonMove; id : PVPogoProtos.PokemonMove;
isLegacy : boolean; isLegacy : boolean;
} }
export interface IPokemon extends IPokemonSpecies { export interface IPokemon extends IPokemonSpecies {
id : POGOProtos.Enums.PokemonId; id : PVPogoProtos.PokemonId;
form : POGOProtos.Enums.Form; form : PVPogoProtos.PokemonForm;
family : POGOProtos.Enums.PokemonFamilyId; family : PVPogoProtos.PokemonFamilyId;
types : { types : {
type1 : POGOProtos.Enums.PokemonType; type1 : PVPogoProtos.PokemonType;
type2 : POGOProtos.Enums.PokemonType | null; type2 : PVPogoProtos.PokemonType | null;
}; };
effectiveness : Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>; effectiveness : Map<PVPogoProtos.PokemonType, TypeEffectiveness>;
stats : IBaseStats; stats : IBaseStats;
statsRank : IBaseStatsRank; statsRank : IBaseStatsRank;
moves : { moves : {
@ -102,11 +102,11 @@ export interface IStats {
} }
export interface ICombatMoveStats { export interface ICombatMoveStats {
id : POGOProtos.Enums.PokemonMove; id : PVPogoProtos.PokemonMove;
name : string; name : string;
type : POGOProtos.Enums.PokemonType; type : PVPogoProtos.PokemonType;
power : number; power : number;
energyDelta : number; energyDelta : number;
} }
export type CombatMoveStats = Map<POGOProtos.Enums.PokemonMove, ICombatMoveStats>; export type CombatMoveStats = Map<PVPogoProtos.PokemonMove, ICombatMoveStats>;

View File

@ -1,4 +1,4 @@
import POGOProtos from 'pogo-protos'; import * as PVPogoProtos from 'common/models/PvPogoProtos';
export const formatDexNumber = (dex : number) => { export const formatDexNumber = (dex : number) => {
let prefix : string = ''; let prefix : string = '';
@ -11,45 +11,45 @@ export const formatDexNumber = (dex : number) => {
return prefix + dex; return prefix + dex;
}; };
export const formatType = (type : POGOProtos.Enums.PokemonType) => { export const formatType = (type : PVPogoProtos.PokemonType) => {
switch (type) { switch (type) {
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_NORMAL: case PVPogoProtos.PokemonType.POKEMON_TYPE_NORMAL:
return 'normal'; return 'normal';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIGHTING: case PVPogoProtos.PokemonType.POKEMON_TYPE_FIGHTING:
return 'fighting'; return 'fighting';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FLYING: case PVPogoProtos.PokemonType.POKEMON_TYPE_FLYING:
return 'flying'; return 'flying';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_POISON: case PVPogoProtos.PokemonType.POKEMON_TYPE_POISON:
return 'poison'; return 'poison';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_GROUND: case PVPogoProtos.PokemonType.POKEMON_TYPE_GROUND:
return 'ground'; return 'ground';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_ROCK: case PVPogoProtos.PokemonType.POKEMON_TYPE_ROCK:
return 'rock'; return 'rock';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_BUG: case PVPogoProtos.PokemonType.POKEMON_TYPE_BUG:
return 'bug'; return 'bug';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_GHOST: case PVPogoProtos.PokemonType.POKEMON_TYPE_GHOST:
return 'ghost'; return 'ghost';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_STEEL: case PVPogoProtos.PokemonType.POKEMON_TYPE_STEEL:
return 'steel'; return 'steel';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIRE: case PVPogoProtos.PokemonType.POKEMON_TYPE_FIRE:
return 'fire'; return 'fire';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_WATER: case PVPogoProtos.PokemonType.POKEMON_TYPE_WATER:
return 'water'; return 'water';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_GRASS: case PVPogoProtos.PokemonType.POKEMON_TYPE_GRASS:
return 'grass'; return 'grass';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_ELECTRIC: case PVPogoProtos.PokemonType.POKEMON_TYPE_ELECTRIC:
return 'electric'; return 'electric';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_PSYCHIC: case PVPogoProtos.PokemonType.POKEMON_TYPE_PSYCHIC:
return 'psychic'; return 'psychic';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_ICE: case PVPogoProtos.PokemonType.POKEMON_TYPE_ICE:
return 'ice'; return 'ice';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_DRAGON: case PVPogoProtos.PokemonType.POKEMON_TYPE_DRAGON:
return 'dragon'; return 'dragon';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_DARK: case PVPogoProtos.PokemonType.POKEMON_TYPE_DARK:
return 'dark'; return 'dark';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FAIRY: case PVPogoProtos.PokemonType.POKEMON_TYPE_FAIRY:
return 'fairy'; return 'fairy';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_NONE: case PVPogoProtos.PokemonType.POKEMON_TYPE_NONE:
default: default:
return ''; return '';
} }
@ -57,172 +57,172 @@ export const formatType = (type : POGOProtos.Enums.PokemonType) => {
export const Forms = { export const Forms = {
normal: [ normal: [
POGOProtos.Enums.Form.CASTFORM_NORMAL, PVPogoProtos.PokemonForm.CASTFORM_NORMAL,
POGOProtos.Enums.Form.DEOXYS_NORMAL, PVPogoProtos.PokemonForm.DEOXYS_NORMAL,
POGOProtos.Enums.Form.RATTATA_NORMAL, PVPogoProtos.PokemonForm.RATTATA_NORMAL,
POGOProtos.Enums.Form.RATICATE_NORMAL, PVPogoProtos.PokemonForm.RATICATE_NORMAL,
POGOProtos.Enums.Form.RAICHU_NORMAL, PVPogoProtos.PokemonForm.RAICHU_NORMAL,
POGOProtos.Enums.Form.SANDSHREW_NORMAL, PVPogoProtos.PokemonForm.SANDSHREW_NORMAL,
POGOProtos.Enums.Form.SANDSLASH_NORMAL, PVPogoProtos.PokemonForm.SANDSLASH_NORMAL,
POGOProtos.Enums.Form.VULPIX_NORMAL, PVPogoProtos.PokemonForm.VULPIX_NORMAL,
POGOProtos.Enums.Form.NINETALES_NORMAL, PVPogoProtos.PokemonForm.NINETALES_NORMAL,
POGOProtos.Enums.Form.DIGLETT_NORMAL, PVPogoProtos.PokemonForm.DIGLETT_NORMAL,
POGOProtos.Enums.Form.DUGTRIO_NORMAL, PVPogoProtos.PokemonForm.DUGTRIO_NORMAL,
POGOProtos.Enums.Form.MEOWTH_NORMAL, PVPogoProtos.PokemonForm.MEOWTH_NORMAL,
POGOProtos.Enums.Form.PERSIAN_NORMAL, PVPogoProtos.PokemonForm.PERSIAN_NORMAL,
POGOProtos.Enums.Form.GEODUDE_NORMAL, PVPogoProtos.PokemonForm.GEODUDE_NORMAL,
POGOProtos.Enums.Form.GRAVELER_NORMAL, PVPogoProtos.PokemonForm.GRAVELER_NORMAL,
POGOProtos.Enums.Form.GOLEM_NORMAL, PVPogoProtos.PokemonForm.GOLEM_NORMAL,
POGOProtos.Enums.Form.GRIMER_NORMAL, PVPogoProtos.PokemonForm.GRIMER_NORMAL,
POGOProtos.Enums.Form.MUK_NORMAL, PVPogoProtos.PokemonForm.MUK_NORMAL,
POGOProtos.Enums.Form.EXEGGUTOR_NORMAL, PVPogoProtos.PokemonForm.EXEGGUTOR_NORMAL,
POGOProtos.Enums.Form.MAROWAK_NORMAL, PVPogoProtos.PokemonForm.MAROWAK_NORMAL,
POGOProtos.Enums.Form.ROTOM_NORMAL, PVPogoProtos.PokemonForm.ROTOM_NORMAL,
POGOProtos.Enums.Form.ARCEUS_NORMAL, PVPogoProtos.PokemonForm.ARCEUS_NORMAL,
], ],
alola: [ alola: [
POGOProtos.Enums.Form.RATTATA_ALOLA, PVPogoProtos.PokemonForm.RATTATA_ALOLA,
POGOProtos.Enums.Form.RATICATE_ALOLA, PVPogoProtos.PokemonForm.RATICATE_ALOLA,
POGOProtos.Enums.Form.RAICHU_ALOLA, PVPogoProtos.PokemonForm.RAICHU_ALOLA,
POGOProtos.Enums.Form.SANDSHREW_ALOLA, PVPogoProtos.PokemonForm.SANDSHREW_ALOLA,
POGOProtos.Enums.Form.SANDSLASH_ALOLA, PVPogoProtos.PokemonForm.SANDSLASH_ALOLA,
POGOProtos.Enums.Form.VULPIX_ALOLA, PVPogoProtos.PokemonForm.VULPIX_ALOLA,
POGOProtos.Enums.Form.NINETALES_ALOLA, PVPogoProtos.PokemonForm.NINETALES_ALOLA,
POGOProtos.Enums.Form.DIGLETT_ALOLA, PVPogoProtos.PokemonForm.DIGLETT_ALOLA,
POGOProtos.Enums.Form.DUGTRIO_ALOLA, PVPogoProtos.PokemonForm.DUGTRIO_ALOLA,
POGOProtos.Enums.Form.MEOWTH_ALOLA, PVPogoProtos.PokemonForm.MEOWTH_ALOLA,
POGOProtos.Enums.Form.PERSIAN_ALOLA, PVPogoProtos.PokemonForm.PERSIAN_ALOLA,
POGOProtos.Enums.Form.GEODUDE_ALOLA, PVPogoProtos.PokemonForm.GEODUDE_ALOLA,
POGOProtos.Enums.Form.GRAVELER_ALOLA, PVPogoProtos.PokemonForm.GRAVELER_ALOLA,
POGOProtos.Enums.Form.GOLEM_ALOLA, PVPogoProtos.PokemonForm.GOLEM_ALOLA,
POGOProtos.Enums.Form.GRIMER_ALOLA, PVPogoProtos.PokemonForm.GRIMER_ALOLA,
POGOProtos.Enums.Form.MUK_ALOLA, PVPogoProtos.PokemonForm.MUK_ALOLA,
POGOProtos.Enums.Form.EXEGGUTOR_ALOLA, PVPogoProtos.PokemonForm.EXEGGUTOR_ALOLA,
POGOProtos.Enums.Form.MAROWAK_ALOLA, PVPogoProtos.PokemonForm.MAROWAK_ALOLA,
], ],
plant: [ plant: [
POGOProtos.Enums.Form.WORMADAM_PLANT, PVPogoProtos.PokemonForm.WORMADAM_PLANT,
POGOProtos.Enums.Form.BURMY_PLANT, PVPogoProtos.PokemonForm.BURMY_PLANT,
], ],
sandy: [ sandy: [
POGOProtos.Enums.Form.WORMADAM_SANDY, PVPogoProtos.PokemonForm.WORMADAM_SANDY,
POGOProtos.Enums.Form.BURMY_SANDY, PVPogoProtos.PokemonForm.BURMY_SANDY,
], ],
trash: [ trash: [
POGOProtos.Enums.Form.WORMADAM_TRASH, PVPogoProtos.PokemonForm.WORMADAM_TRASH,
POGOProtos.Enums.Form.BURMY_TRASH, PVPogoProtos.PokemonForm.BURMY_TRASH,
], ],
westSea: [ westSea: [
POGOProtos.Enums.Form.SHELLOS_WEST_SEA, PVPogoProtos.PokemonForm.SHELLOS_WEST_SEA,
POGOProtos.Enums.Form.GASTRODON_WEST_SEA, PVPogoProtos.PokemonForm.GASTRODON_WEST_SEA,
], ],
eastSea: [ eastSea: [
POGOProtos.Enums.Form.SHELLOS_EAST_SEA, PVPogoProtos.PokemonForm.SHELLOS_EAST_SEA,
POGOProtos.Enums.Form.GASTRODON_EAST_SEA, PVPogoProtos.PokemonForm.GASTRODON_EAST_SEA,
], ],
altered: [ altered: [
POGOProtos.Enums.Form.GIRATINA_ALTERED, PVPogoProtos.PokemonForm.GIRATINA_ALTERED,
], ],
origin: [ origin: [
POGOProtos.Enums.Form.GIRATINA_ORIGIN, PVPogoProtos.PokemonForm.GIRATINA_ORIGIN,
], ],
frost: [ frost: [
POGOProtos.Enums.Form.ROTOM_FROST, PVPogoProtos.PokemonForm.ROTOM_FROST,
], ],
fan: [ fan: [
POGOProtos.Enums.Form.ROTOM_FAN, PVPogoProtos.PokemonForm.ROTOM_FAN,
], ],
mow: [ mow: [
POGOProtos.Enums.Form.ROTOM_MOW, PVPogoProtos.PokemonForm.ROTOM_MOW,
], ],
wash: [ wash: [
POGOProtos.Enums.Form.ROTOM_WASH, PVPogoProtos.PokemonForm.ROTOM_WASH,
], ],
heat: [ heat: [
POGOProtos.Enums.Form.ROTOM_HEAT, PVPogoProtos.PokemonForm.ROTOM_HEAT,
], ],
sky: [ sky: [
POGOProtos.Enums.Form.SHAYMIN_SKY, PVPogoProtos.PokemonForm.SHAYMIN_SKY,
], ],
land: [ land: [
POGOProtos.Enums.Form.SHAYMIN_LAND, PVPogoProtos.PokemonForm.SHAYMIN_LAND,
], ],
overcast: [ overcast: [
POGOProtos.Enums.Form.CHERRIM_OVERCAST, PVPogoProtos.PokemonForm.CHERRIM_OVERCAST,
], ],
sunny: [ sunny: [
POGOProtos.Enums.Form.CASTFORM_SUNNY, PVPogoProtos.PokemonForm.CASTFORM_SUNNY,
POGOProtos.Enums.Form.CHERRIM_SUNNY, PVPogoProtos.PokemonForm.CHERRIM_SUNNY,
], ],
rainy: [ rainy: [
POGOProtos.Enums.Form.CASTFORM_RAINY, PVPogoProtos.PokemonForm.CASTFORM_RAINY,
], ],
snowy: [ snowy: [
POGOProtos.Enums.Form.CASTFORM_SNOWY, PVPogoProtos.PokemonForm.CASTFORM_SNOWY,
], ],
attack: [ attack: [
POGOProtos.Enums.Form.DEOXYS_ATTACK, PVPogoProtos.PokemonForm.DEOXYS_ATTACK,
], ],
defense: [ defense: [
POGOProtos.Enums.Form.DEOXYS_DEFENSE, PVPogoProtos.PokemonForm.DEOXYS_DEFENSE,
], ],
speed: [ speed: [
POGOProtos.Enums.Form.DEOXYS_SPEED, PVPogoProtos.PokemonForm.DEOXYS_SPEED,
], ],
fighting: [ fighting: [
POGOProtos.Enums.Form.ARCEUS_FIGHTING, PVPogoProtos.PokemonForm.ARCEUS_FIGHTING,
], ],
flying: [ flying: [
POGOProtos.Enums.Form.ARCEUS_FLYING, PVPogoProtos.PokemonForm.ARCEUS_FLYING,
], ],
poison: [ poison: [
POGOProtos.Enums.Form.ARCEUS_POISON, PVPogoProtos.PokemonForm.ARCEUS_POISON,
], ],
ground: [ ground: [
POGOProtos.Enums.Form.ARCEUS_GROUND, PVPogoProtos.PokemonForm.ARCEUS_GROUND,
], ],
rock: [ rock: [
POGOProtos.Enums.Form.ARCEUS_ROCK, PVPogoProtos.PokemonForm.ARCEUS_ROCK,
], ],
bug: [ bug: [
POGOProtos.Enums.Form.ARCEUS_BUG, PVPogoProtos.PokemonForm.ARCEUS_BUG,
], ],
ghost: [ ghost: [
POGOProtos.Enums.Form.ARCEUS_GHOST, PVPogoProtos.PokemonForm.ARCEUS_GHOST,
], ],
steel: [ steel: [
POGOProtos.Enums.Form.ARCEUS_STEEL, PVPogoProtos.PokemonForm.ARCEUS_STEEL,
], ],
fire: [ fire: [
POGOProtos.Enums.Form.ARCEUS_FIRE, PVPogoProtos.PokemonForm.ARCEUS_FIRE,
], ],
water: [ water: [
POGOProtos.Enums.Form.ARCEUS_WATER, PVPogoProtos.PokemonForm.ARCEUS_WATER,
], ],
grass: [ grass: [
POGOProtos.Enums.Form.ARCEUS_GRASS, PVPogoProtos.PokemonForm.ARCEUS_GRASS,
], ],
electric: [ electric: [
POGOProtos.Enums.Form.ARCEUS_ELECTRIC, PVPogoProtos.PokemonForm.ARCEUS_ELECTRIC,
], ],
psychic: [ psychic: [
POGOProtos.Enums.Form.ARCEUS_PSYCHIC, PVPogoProtos.PokemonForm.ARCEUS_PSYCHIC,
], ],
ice: [ ice: [
POGOProtos.Enums.Form.ARCEUS_ICE, PVPogoProtos.PokemonForm.ARCEUS_ICE,
], ],
dragon: [ dragon: [
POGOProtos.Enums.Form.ARCEUS_DRAGON, PVPogoProtos.PokemonForm.ARCEUS_DRAGON,
], ],
dark: [ dark: [
POGOProtos.Enums.Form.ARCEUS_DARK, PVPogoProtos.PokemonForm.ARCEUS_DARK,
], ],
fairy: [ fairy: [
POGOProtos.Enums.Form.ARCEUS_FAIRY, PVPogoProtos.PokemonForm.ARCEUS_FAIRY,
], ],
}; };
export const formatForm = (form : POGOProtos.Enums.Form) => { export const formatForm = (form : PVPogoProtos.PokemonForm) => {
if (Forms.normal.indexOf(form) > -1) { if (Forms.normal.indexOf(form) > -1) {
return 'Normal'; return 'Normal';
} else if (Forms.alola.indexOf(form) > -1) { } else if (Forms.alola.indexOf(form) > -1) {

View File

@ -1,16 +1,16 @@
import POGOProtos from 'pogo-protos';
import { AttackTypeEffectiveness } from 'app/models/Config'; import { AttackTypeEffectiveness } from 'app/models/Config';
import { CombatMoveStats, ICombatMoveStats, IPokemonMove, TypeEffectiveness } from 'app/models/Pokemon'; import { CombatMoveStats, ICombatMoveStats, IPokemonMove, TypeEffectiveness } from 'app/models/Pokemon';
import { SelectedCombatMoves } from 'app/components/PokemonExplorer/types'; import { SelectedCombatMoves } from 'app/components/PokemonExplorer/types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
export const calculateTypeCoverage = ( export const calculateTypeCoverage = (
selectedMoves : SelectedCombatMoves, selectedMoves : SelectedCombatMoves,
movesById : CombatMoveStats, movesById : CombatMoveStats,
attackTypeEffectiveness : AttackTypeEffectiveness, attackTypeEffectiveness : AttackTypeEffectiveness,
) => { ) => {
const calculatedffectiveness : Map<POGOProtos.Enums.PokemonType, TypeEffectiveness> = new Map(); const calculatedffectiveness : Map<PVPogoProtos.PokemonType, TypeEffectiveness> = new Map();
Object.values(selectedMoves).forEach((move) => { Object.values(selectedMoves).forEach((move) => {
const moveType = getMoveType(move, movesById); const moveType = getMoveType(move, movesById);
if (moveType !== null) { if (moveType !== null) {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
import { POGOProtos } from 'externals/generated/PvPogoProtos';
export const PokemonId = POGOProtos.Enums.PokemonId;
export type PokemonId = POGOProtos.Enums.PokemonId;
export const PokemonMove = POGOProtos.Enums.PokemonMove;
export type PokemonMove = POGOProtos.Enums.PokemonMove;
export const PokemonFamilyId = POGOProtos.Enums.PokemonFamilyId;
export type PokemonFamilyId = POGOProtos.Enums.PokemonFamilyId;
export const PokemonType = POGOProtos.Enums.PokemonType;
export type PokemonType = POGOProtos.Enums.PokemonType;
export const PokemonForm = POGOProtos.Enums.Form;
export type PokemonForm = POGOProtos.Enums.Form;
// this worked, until i realized that i needed to access the values of the enums and not just the types
// export declare const PokemonId : import('pogo-protos').Enums.PokemonId;
// export type PokemonId = import('pogo-protos').Enums.PokemonId;

585
yarn.lock

File diff suppressed because it is too large Load Diff