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",
"build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile",
"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": {
"@babel/core": "^7.2.2",
@ -38,9 +43,11 @@
"glob": "^7.1.3",
"mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"path": "^0.12.7",
"pogo-protos": "^2.31.1",
"pogo-protos": "^2.33.2",
"pokemongo-game-master": "^1.0.4",
"protobufjs": "^6.8.8",
"sass-loader": "^7.1.0",
"source-map-concat": "^1.0.1",
"source-map-dummy": "^1.0.0",

View File

@ -1,6 +1,7 @@
const POGOProtos = require('pogo-protos');
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);
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 POGOProtos from 'pogo-protos';
import { parseGameMaster } from './parseGameMaster';
@ -10,6 +9,8 @@ import { ILeaguePokemonJson } from 'api/PokemonService';
import { ILeaguePokemon, League, MaxCpByLeague } from 'app/models/League';
import { Grade, IMaxStats, IStats } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
type ICpAndTotalFound = Record<number, Array<IStats>>;
interface IStatsDistribution {
[ League.GREAT ] : ICpAndTotalFound;
@ -208,7 +209,7 @@ fs.mkdirSync(outPokemonPath, { recursive: true });
});
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 = {
...pokemon,
effectiveness: [ ...pokemon.effectiveness ],

View File

@ -1,25 +1,28 @@
import fs from 'fs';
import POGOProtos from 'pogo-protos';
import path from 'path';
import { ApiService } from 'api/ApiService';
import { CombatMoveStats, IBaseStatsRank, IPokemon, TypeEffectiveness, TypeOrder } from 'app/models/Pokemon';
import { LegacyMoves } from 'common/models/LegacyMoves';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
interface ICalculateRelativeStats {
id : POGOProtos.Enums.PokemonId;
form : POGOProtos.Enums.Form;
id : PVPogoProtos.PokemonId;
form : PVPogoProtos.PokemonForm;
value : number;
}
export const parseGameMaster = async () => {
const POGOProtos = await import('pogo-protos');
const apiService = new ApiService();
const pokemonDataByPokemonId : Map<POGOProtos.Enums.PokemonId, Array<IPokemon>> = new Map();
const pokemonFormsByPokemonId : Map<POGOProtos.Enums.PokemonId, Array<POGOProtos.Enums.Form>> = new Map();
const pokemonTypeEffectiveness : Map<POGOProtos.Enums.PokemonType, Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>> = new Map();
const pokemonTypeWeaknesses : Map<POGOProtos.Enums.PokemonType, Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>> = new Map();
const pokemonTypes : Map<POGOProtos.Enums.PokemonType, Array<number>> = new Map();
const pokemonDataByPokemonId : Map<PVPogoProtos.PokemonId, Array<IPokemon>> = new Map();
const pokemonFormsByPokemonId : Map<PVPogoProtos.PokemonId, Array<PVPogoProtos.PokemonForm>> = new Map();
const pokemonTypeEffectiveness : Map<PVPogoProtos.PokemonType, Map<PVPogoProtos.PokemonType, TypeEffectiveness>> = new Map();
const pokemonTypeWeaknesses : Map<PVPogoProtos.PokemonType, Map<PVPogoProtos.PokemonType, TypeEffectiveness>> = new Map();
const pokemonTypes : Map<PVPogoProtos.PokemonType, Array<number>> = new Map();
const combatMoves : CombatMoveStats = new Map();
const pokemonBaseStamina : Array<ICalculateRelativeStats> = [];
@ -27,7 +30,7 @@ export const parseGameMaster = async () => {
const pokemonBaseDefense : Array<ICalculateRelativeStats> = [];
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 version = GameMaster.timestamp_ms;
@ -39,11 +42,11 @@ export const parseGameMaster = async () => {
// POKEMON
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 dex = parseInt(RegExp.$1, 10);
const defaultName = POGOProtos.Enums.PokemonId[pokemonId].toLowerCase()
const defaultName = PVPogoProtos.PokemonId[pokemonId].toLowerCase()
.split(' ')
.map((s) => s.charAt(0).toUpperCase() + s.substring(1))
.join(' ');
@ -55,10 +58,10 @@ export const parseGameMaster = async () => {
const mon = {
...speciesInfo,
id: pokemonId,
form: entry.pokemon_settings.form || POGOProtos.Enums.Form.FORM_UNSET,
family: entry.pokemon_settings.family_id || POGOProtos.Enums.PokemonFamilyId.FAMILY_UNSET,
form: entry.pokemon_settings.form || PVPogoProtos.PokemonForm.FORM_UNSET,
family: entry.pokemon_settings.family_id || PVPogoProtos.PokemonFamilyId.FAMILY_UNSET,
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,
},
effectiveness: new Map(),
@ -97,7 +100,7 @@ export const parseGameMaster = async () => {
pokemonData.push(mon);
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({
id: mon.id,
@ -124,10 +127,10 @@ export const parseGameMaster = async () => {
} else if (entry.template_id.indexOf('FORMS_V') === 0 && entry.form_settings) {
// typings say `forms` can be undefined, but in practice, it's not
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);
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) {
output.push(form.form);
}
@ -143,7 +146,7 @@ export const parseGameMaster = async () => {
// COMBAT MOVES
} 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) => {
let moveName = moveId;
@ -165,8 +168,8 @@ export const parseGameMaster = async () => {
};
combatMoves.set(combatMoveId, {
id: combatMoveId,
name: formatMoveName(POGOProtos.Enums.PokemonMove[combatMoveId]),
type: entry.combat_move.type || POGOProtos.Enums.PokemonType.POKEMON_TYPE_NONE,
name: formatMoveName(PVPogoProtos.PokemonMove[combatMoveId]),
type: entry.combat_move.type || PVPogoProtos.PokemonType.POKEMON_TYPE_NONE,
power: entry.combat_move.power || 0,
energyDelta: entry.combat_move.energy_delta || 0,
});
@ -175,7 +178,7 @@ export const parseGameMaster = async () => {
// organize pokemon type effectiveness data
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) => {
let typeEffectiveness : TypeEffectiveness;
if (effectValue === TypeEffectiveness.NEUTRAL) {
@ -236,34 +239,34 @@ export const parseGameMaster = async () => {
return a.value - b.value;
});
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);
});
pokemonBaseAttack.sort((a, b) => {
return a.value - b.value;
});
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);
});
pokemonBaseDefense.sort((a, b) => {
return a.value - b.value;
});
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);
});
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] };
TypeOrder.forEach((type) => {
const type1Effectiveness = pokemonTypeWeaknesses.get(mon.types.type1);
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;
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 type2EffectiveValue = type2Effectiveness ? type2Effectiveness.get(type) : TypeEffectiveness.NEUTRAL;
@ -310,3 +313,4 @@ export const parseGameMaster = async () => {
combatMoves,
};
};
parseGameMaster();

View File

@ -1,11 +1,12 @@
import csv from 'csvtojson';
import POGOProtos from 'pogo-protos';
import xhr2 from 'xhr2';
import { AjaxRequest } from 'api/AjaxRequest';
import { DEFAULT_POKEMON_NAME, IPokemonSpecies } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
interface IPokeApiSpeciesNameJSON {
pokemon_species_id : string;
local_language_id : '9' | string;
@ -35,7 +36,7 @@ interface ILivePokeApiSpeciesListJSON {
interface IApiService {
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>;
}
@ -46,7 +47,7 @@ export class ApiService implements IApiService {
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 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 queryParameters = {
@ -132,14 +133,14 @@ export class ApiService implements IApiService {
return serializedResponse;
}
private formatPokemonIdToPokeApiNameKey(pokemonId : POGOProtos.Enums.PokemonId) {
private formatPokemonIdToPokeApiNameKey(pokemonId : PVPogoProtos.PokemonId) {
let key : string;
if (pokemonId === POGOProtos.Enums.PokemonId.NIDORAN_MALE) {
if (pokemonId === PVPogoProtos.PokemonId.NIDORAN_MALE) {
key = 'nidoran-m';
} else if (pokemonId === POGOProtos.Enums.PokemonId.NIDORAN_FEMALE) {
} else if (pokemonId === PVPogoProtos.PokemonId.NIDORAN_FEMALE) {
key = 'nidoran-f';
} else {
key = POGOProtos.Enums.PokemonId[pokemonId];
key = PVPogoProtos.PokemonId[pokemonId];
}
return key.toLowerCase().replace(/_/, '-');
}

View File

@ -1,20 +1,20 @@
import POGOProtos from 'pogo-protos';
import { AjaxRequest } from 'api/AjaxRequest';
import { AttackTypeEffectivenessSerializingTuple, IConfig, IConfigJson } from 'app/models/Config';
import { ILeaguePokemon } from 'app/models/League';
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>>;
export interface ILeaguePokemonJson extends Omit<ILeaguePokemon, 'effectiveness'> {
effectiveness : Array<[POGOProtos.Enums.PokemonType, TypeEffectiveness]>;
effectiveness : Array<[PVPogoProtos.PokemonType, TypeEffectiveness]>;
}
interface IPokemonService {
getConfig() : Promise<IConfig>;
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 {
@ -52,8 +52,8 @@ export class PokemonService implements IPokemonService {
return response;
}
public async getPokemonLeagueStats(pokemonId : POGOProtos.Enums.PokemonId, form : POGOProtos.Enums.Form) {
const fileName = form === POGOProtos.Enums.Form.FORM_UNSET ? POGOProtos.Enums.PokemonId[pokemonId] : POGOProtos.Enums.Form[form];
public async getPokemonLeagueStats(pokemonId : PVPogoProtos.PokemonId, form : PVPogoProtos.PokemonForm) {
const fileName = form === PVPogoProtos.PokemonForm.FORM_UNSET ? PVPogoProtos.PokemonId[pokemonId] : PVPogoProtos.PokemonForm[form];
const queryParameters = {
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react';
import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router-dom';
@ -28,6 +26,8 @@ import { EffectivenessMode, TypeEffectiveDisplay } from 'app/components/PokemonE
import { appendQueryString } from 'app/utils/navigation';
import { calculateTypeCoverage } from 'app/utils/types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/styles/PokemonApp.scss';
// 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>) => {
const superEffectiveTypes : Array<POGOProtos.Enums.PokemonType> = [];
private readonly getSuperEffectiveTypes = (effectiveness : Map<PVPogoProtos.PokemonType, TypeEffectiveness>) => {
const superEffectiveTypes : Array<PVPogoProtos.PokemonType> = [];
Array.from(effectiveness).reduce((accumulator, currentValue) => {
if (currentValue[1] > TypeEffectiveness.NEUTRAL) {
accumulator.push(currentValue[0]);

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react';
import classNames from 'classnames';
@ -8,6 +6,8 @@ import { IPokemon, TypeEffectiveness } from 'app/models/Pokemon';
import { TypeIndicator, TypeTheme } from './TypeIndicator';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from 'app/components/PokemonExplorer/styles/TypeEffectiveDisplay.scss';
export enum EffectivenessMode {
@ -18,7 +18,7 @@ export enum EffectivenessMode {
export interface ITypeEffectiveDisplayProps {
mode : EffectivenessMode;
effectiveness : IPokemon['effectiveness'];
coverage : Array<POGOProtos.Enums.PokemonType>;
coverage : Array<PVPogoProtos.PokemonType>;
}
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 coverageType === type;
});

View File

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

View File

@ -1,5 +1,3 @@
import POGOProtos from 'pogo-protos';
import React from 'react';
import { ContentRect, default as Measure } from 'react-measure';
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 * as PVPogoProtos from 'common/models/PvPogoProtos';
import * as styles from './styles/PokemonSelectList.scss';
export interface IPokemonSelectListProps {
isLoading : boolean;
isListOpen : boolean;
activePokemonId : POGOProtos.Enums.PokemonId | null;
activePokemonForm : POGOProtos.Enums.Form | null;
activePokemonId : PVPogoProtos.PokemonId | null;
activePokemonForm : PVPogoProtos.PokemonForm | null;
pokemonList : Array<IPokemon>;
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>;
}
@ -180,7 +180,7 @@ export class PokemonSelectList extends React.Component<IPokemonSelectListProps,
}
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) {
@ -226,14 +226,14 @@ export class PokemonSelectList extends React.Component<IPokemonSelectListProps,
<span>{ pokemon.name }</span>
<span className={ dexCss }>#{ dex }</span>
{ /* <i className={ menuIconCss } /> */ }
{ pokemon.form !== POGOProtos.Enums.Form.FORM_UNSET &&
{ pokemon.form !== PVPogoProtos.PokemonForm.FORM_UNSET &&
<span className={ formCss }>{ formatForm(pokemon.form) } Form</span>
}
</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 }`;
if (!this.activatePokemonClickHandlers.has(handlerKey)) {
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 { ILeaguePokemon } from 'app/models/League';
@ -8,15 +6,17 @@ import { IPokemon } from 'app/models/Pokemon';
import { ThunkResult } from 'app/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 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 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 = (
filterTerm : string
@ -29,7 +29,7 @@ export const filterPokemonList = (
pokemonListFiltered = pokemonList.reduce((result : Array<IPokemon>, pokemon) => {
const pokemonName = pokemon.name.toLowerCase();
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 ||
pokemonDex.indexOf(normalizedFilterTerm) === 0 ||
normalizedFilterTerm === pokemonForm
@ -52,8 +52,8 @@ export const fetchPokemonList = (
};
export const fetchPokemonLeagueStats = (
pokemonId : POGOProtos.Enums.PokemonId,
form : POGOProtos.Enums.Form
pokemonId : PVPogoProtos.PokemonId,
form : PVPogoProtos.PokemonForm
) : ThunkResult<Promise<ILeaguePokemon>> => {
return async (dispatch, getState, extraArguments) => {
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 { IPokemon } from 'app/models/Pokemon';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
export interface IPokemonSelectListState {
isLoading : boolean;
activePokemonId : POGOProtos.Enums.PokemonId | null;
activePokemonForm : POGOProtos.Enums.Form | null;
activePokemonId : PVPogoProtos.PokemonId | null;
activePokemonForm : PVPogoProtos.PokemonForm | null;
pokemonList : Array<IPokemon>;
pokemonListFiltered : Array<IPokemon>;
filterTerm : string;
pokemonLeagueStats : { [id in keyof typeof POGOProtos.Enums.PokemonId]? : ILeaguePokemon };
pokemonLeagueStats : { [id in keyof typeof PVPogoProtos.PokemonId]? : ILeaguePokemon };
}
export const PokemonSelectListActionTypes = {

View File

@ -1,18 +1,18 @@
import POGOProtos from 'pogo-protos';
import { CombatMoveStats, ICombatMoveStats, IMaxStats, TypeEffectiveness } from 'app/models/Pokemon';
type TypeEffectivenessByTypeJson = Array<[POGOProtos.Enums.PokemonType, TypeEffectiveness]>;
type AttackTypeEffectivenessJson = Array<[POGOProtos.Enums.PokemonType, TypeEffectivenessByTypeJson]>;
import * as PVPogoProtos from 'common/models/PvPogoProtos';
type TypeEffectivenessByTypeJson = Array<[PVPogoProtos.PokemonType, TypeEffectiveness]>;
type AttackTypeEffectivenessJson = Array<[PVPogoProtos.PokemonType, TypeEffectivenessByTypeJson]>;
export interface IConfigJson {
maxPossibleStats : IMaxStats;
attackTypeEffectiveness : AttackTypeEffectivenessJson;
combatMoves : Array<[POGOProtos.Enums.PokemonMove, ICombatMoveStats]>;
combatMoves : Array<[PVPogoProtos.PokemonMove, ICombatMoveStats]>;
}
export type TypeEffectivenessByType = Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>;
export type AttackTypeEffectiveness = Map<POGOProtos.Enums.PokemonType, TypeEffectivenessByType>;
export type TypeEffectivenessByType = Map<PVPogoProtos.PokemonType, TypeEffectiveness>;
export type AttackTypeEffectiveness = Map<PVPogoProtos.PokemonType, TypeEffectivenessByType>;
export interface IConfig {
maxPossibleStats : IMaxStats;
@ -20,4 +20,4 @@ export interface IConfig {
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.';
@ -22,24 +22,24 @@ export enum TypeEffectiveness {
}
export const TypeOrder = [
POGOProtos.Enums.PokemonType.POKEMON_TYPE_NORMAL,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIGHTING,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FLYING,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_POISON,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_GROUND,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_ROCK,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_BUG,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_GHOST,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_STEEL,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIRE ,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_WATER,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_GRASS,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_ELECTRIC,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_PSYCHIC,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_ICE,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_DRAGON,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_DARK,
POGOProtos.Enums.PokemonType.POKEMON_TYPE_FAIRY,
PVPogoProtos.PokemonType.POKEMON_TYPE_NORMAL,
PVPogoProtos.PokemonType.POKEMON_TYPE_FIGHTING,
PVPogoProtos.PokemonType.POKEMON_TYPE_FLYING,
PVPogoProtos.PokemonType.POKEMON_TYPE_POISON,
PVPogoProtos.PokemonType.POKEMON_TYPE_GROUND,
PVPogoProtos.PokemonType.POKEMON_TYPE_ROCK,
PVPogoProtos.PokemonType.POKEMON_TYPE_BUG,
PVPogoProtos.PokemonType.POKEMON_TYPE_GHOST,
PVPogoProtos.PokemonType.POKEMON_TYPE_STEEL,
PVPogoProtos.PokemonType.POKEMON_TYPE_FIRE ,
PVPogoProtos.PokemonType.POKEMON_TYPE_WATER,
PVPogoProtos.PokemonType.POKEMON_TYPE_GRASS,
PVPogoProtos.PokemonType.POKEMON_TYPE_ELECTRIC,
PVPogoProtos.PokemonType.POKEMON_TYPE_PSYCHIC,
PVPogoProtos.PokemonType.POKEMON_TYPE_ICE,
PVPogoProtos.PokemonType.POKEMON_TYPE_DRAGON,
PVPogoProtos.PokemonType.POKEMON_TYPE_DARK,
PVPogoProtos.PokemonType.POKEMON_TYPE_FAIRY,
];
export interface IBaseStats {
@ -66,19 +66,19 @@ export interface IPokemonSpecies {
}
export interface IPokemonMove {
id : POGOProtos.Enums.PokemonMove;
id : PVPogoProtos.PokemonMove;
isLegacy : boolean;
}
export interface IPokemon extends IPokemonSpecies {
id : POGOProtos.Enums.PokemonId;
form : POGOProtos.Enums.Form;
family : POGOProtos.Enums.PokemonFamilyId;
id : PVPogoProtos.PokemonId;
form : PVPogoProtos.PokemonForm;
family : PVPogoProtos.PokemonFamilyId;
types : {
type1 : POGOProtos.Enums.PokemonType;
type2 : POGOProtos.Enums.PokemonType | null;
type1 : PVPogoProtos.PokemonType;
type2 : PVPogoProtos.PokemonType | null;
};
effectiveness : Map<POGOProtos.Enums.PokemonType, TypeEffectiveness>;
effectiveness : Map<PVPogoProtos.PokemonType, TypeEffectiveness>;
stats : IBaseStats;
statsRank : IBaseStatsRank;
moves : {
@ -102,11 +102,11 @@ export interface IStats {
}
export interface ICombatMoveStats {
id : POGOProtos.Enums.PokemonMove;
id : PVPogoProtos.PokemonMove;
name : string;
type : POGOProtos.Enums.PokemonType;
type : PVPogoProtos.PokemonType;
power : 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) => {
let prefix : string = '';
@ -11,45 +11,45 @@ export const formatDexNumber = (dex : number) => {
return prefix + dex;
};
export const formatType = (type : POGOProtos.Enums.PokemonType) => {
export const formatType = (type : PVPogoProtos.PokemonType) => {
switch (type) {
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_NORMAL:
case PVPogoProtos.PokemonType.POKEMON_TYPE_NORMAL:
return 'normal';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIGHTING:
case PVPogoProtos.PokemonType.POKEMON_TYPE_FIGHTING:
return 'fighting';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FLYING:
case PVPogoProtos.PokemonType.POKEMON_TYPE_FLYING:
return 'flying';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_POISON:
case PVPogoProtos.PokemonType.POKEMON_TYPE_POISON:
return 'poison';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_GROUND:
case PVPogoProtos.PokemonType.POKEMON_TYPE_GROUND:
return 'ground';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_ROCK:
case PVPogoProtos.PokemonType.POKEMON_TYPE_ROCK:
return 'rock';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_BUG:
case PVPogoProtos.PokemonType.POKEMON_TYPE_BUG:
return 'bug';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_GHOST:
case PVPogoProtos.PokemonType.POKEMON_TYPE_GHOST:
return 'ghost';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_STEEL:
case PVPogoProtos.PokemonType.POKEMON_TYPE_STEEL:
return 'steel';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FIRE:
case PVPogoProtos.PokemonType.POKEMON_TYPE_FIRE:
return 'fire';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_WATER:
case PVPogoProtos.PokemonType.POKEMON_TYPE_WATER:
return 'water';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_GRASS:
case PVPogoProtos.PokemonType.POKEMON_TYPE_GRASS:
return 'grass';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_ELECTRIC:
case PVPogoProtos.PokemonType.POKEMON_TYPE_ELECTRIC:
return 'electric';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_PSYCHIC:
case PVPogoProtos.PokemonType.POKEMON_TYPE_PSYCHIC:
return 'psychic';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_ICE:
case PVPogoProtos.PokemonType.POKEMON_TYPE_ICE:
return 'ice';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_DRAGON:
case PVPogoProtos.PokemonType.POKEMON_TYPE_DRAGON:
return 'dragon';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_DARK:
case PVPogoProtos.PokemonType.POKEMON_TYPE_DARK:
return 'dark';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_FAIRY:
case PVPogoProtos.PokemonType.POKEMON_TYPE_FAIRY:
return 'fairy';
case POGOProtos.Enums.PokemonType.POKEMON_TYPE_NONE:
case PVPogoProtos.PokemonType.POKEMON_TYPE_NONE:
default:
return '';
}
@ -57,172 +57,172 @@ export const formatType = (type : POGOProtos.Enums.PokemonType) => {
export const Forms = {
normal: [
POGOProtos.Enums.Form.CASTFORM_NORMAL,
POGOProtos.Enums.Form.DEOXYS_NORMAL,
POGOProtos.Enums.Form.RATTATA_NORMAL,
POGOProtos.Enums.Form.RATICATE_NORMAL,
POGOProtos.Enums.Form.RAICHU_NORMAL,
POGOProtos.Enums.Form.SANDSHREW_NORMAL,
POGOProtos.Enums.Form.SANDSLASH_NORMAL,
POGOProtos.Enums.Form.VULPIX_NORMAL,
POGOProtos.Enums.Form.NINETALES_NORMAL,
POGOProtos.Enums.Form.DIGLETT_NORMAL,
POGOProtos.Enums.Form.DUGTRIO_NORMAL,
POGOProtos.Enums.Form.MEOWTH_NORMAL,
POGOProtos.Enums.Form.PERSIAN_NORMAL,
POGOProtos.Enums.Form.GEODUDE_NORMAL,
POGOProtos.Enums.Form.GRAVELER_NORMAL,
POGOProtos.Enums.Form.GOLEM_NORMAL,
POGOProtos.Enums.Form.GRIMER_NORMAL,
POGOProtos.Enums.Form.MUK_NORMAL,
POGOProtos.Enums.Form.EXEGGUTOR_NORMAL,
POGOProtos.Enums.Form.MAROWAK_NORMAL,
POGOProtos.Enums.Form.ROTOM_NORMAL,
POGOProtos.Enums.Form.ARCEUS_NORMAL,
PVPogoProtos.PokemonForm.CASTFORM_NORMAL,
PVPogoProtos.PokemonForm.DEOXYS_NORMAL,
PVPogoProtos.PokemonForm.RATTATA_NORMAL,
PVPogoProtos.PokemonForm.RATICATE_NORMAL,
PVPogoProtos.PokemonForm.RAICHU_NORMAL,
PVPogoProtos.PokemonForm.SANDSHREW_NORMAL,
PVPogoProtos.PokemonForm.SANDSLASH_NORMAL,
PVPogoProtos.PokemonForm.VULPIX_NORMAL,
PVPogoProtos.PokemonForm.NINETALES_NORMAL,
PVPogoProtos.PokemonForm.DIGLETT_NORMAL,
PVPogoProtos.PokemonForm.DUGTRIO_NORMAL,
PVPogoProtos.PokemonForm.MEOWTH_NORMAL,
PVPogoProtos.PokemonForm.PERSIAN_NORMAL,
PVPogoProtos.PokemonForm.GEODUDE_NORMAL,
PVPogoProtos.PokemonForm.GRAVELER_NORMAL,
PVPogoProtos.PokemonForm.GOLEM_NORMAL,
PVPogoProtos.PokemonForm.GRIMER_NORMAL,
PVPogoProtos.PokemonForm.MUK_NORMAL,
PVPogoProtos.PokemonForm.EXEGGUTOR_NORMAL,
PVPogoProtos.PokemonForm.MAROWAK_NORMAL,
PVPogoProtos.PokemonForm.ROTOM_NORMAL,
PVPogoProtos.PokemonForm.ARCEUS_NORMAL,
],
alola: [
POGOProtos.Enums.Form.RATTATA_ALOLA,
POGOProtos.Enums.Form.RATICATE_ALOLA,
POGOProtos.Enums.Form.RAICHU_ALOLA,
POGOProtos.Enums.Form.SANDSHREW_ALOLA,
POGOProtos.Enums.Form.SANDSLASH_ALOLA,
POGOProtos.Enums.Form.VULPIX_ALOLA,
POGOProtos.Enums.Form.NINETALES_ALOLA,
POGOProtos.Enums.Form.DIGLETT_ALOLA,
POGOProtos.Enums.Form.DUGTRIO_ALOLA,
POGOProtos.Enums.Form.MEOWTH_ALOLA,
POGOProtos.Enums.Form.PERSIAN_ALOLA,
POGOProtos.Enums.Form.GEODUDE_ALOLA,
POGOProtos.Enums.Form.GRAVELER_ALOLA,
POGOProtos.Enums.Form.GOLEM_ALOLA,
POGOProtos.Enums.Form.GRIMER_ALOLA,
POGOProtos.Enums.Form.MUK_ALOLA,
POGOProtos.Enums.Form.EXEGGUTOR_ALOLA,
POGOProtos.Enums.Form.MAROWAK_ALOLA,
PVPogoProtos.PokemonForm.RATTATA_ALOLA,
PVPogoProtos.PokemonForm.RATICATE_ALOLA,
PVPogoProtos.PokemonForm.RAICHU_ALOLA,
PVPogoProtos.PokemonForm.SANDSHREW_ALOLA,
PVPogoProtos.PokemonForm.SANDSLASH_ALOLA,
PVPogoProtos.PokemonForm.VULPIX_ALOLA,
PVPogoProtos.PokemonForm.NINETALES_ALOLA,
PVPogoProtos.PokemonForm.DIGLETT_ALOLA,
PVPogoProtos.PokemonForm.DUGTRIO_ALOLA,
PVPogoProtos.PokemonForm.MEOWTH_ALOLA,
PVPogoProtos.PokemonForm.PERSIAN_ALOLA,
PVPogoProtos.PokemonForm.GEODUDE_ALOLA,
PVPogoProtos.PokemonForm.GRAVELER_ALOLA,
PVPogoProtos.PokemonForm.GOLEM_ALOLA,
PVPogoProtos.PokemonForm.GRIMER_ALOLA,
PVPogoProtos.PokemonForm.MUK_ALOLA,
PVPogoProtos.PokemonForm.EXEGGUTOR_ALOLA,
PVPogoProtos.PokemonForm.MAROWAK_ALOLA,
],
plant: [
POGOProtos.Enums.Form.WORMADAM_PLANT,
POGOProtos.Enums.Form.BURMY_PLANT,
PVPogoProtos.PokemonForm.WORMADAM_PLANT,
PVPogoProtos.PokemonForm.BURMY_PLANT,
],
sandy: [
POGOProtos.Enums.Form.WORMADAM_SANDY,
POGOProtos.Enums.Form.BURMY_SANDY,
PVPogoProtos.PokemonForm.WORMADAM_SANDY,
PVPogoProtos.PokemonForm.BURMY_SANDY,
],
trash: [
POGOProtos.Enums.Form.WORMADAM_TRASH,
POGOProtos.Enums.Form.BURMY_TRASH,
PVPogoProtos.PokemonForm.WORMADAM_TRASH,
PVPogoProtos.PokemonForm.BURMY_TRASH,
],
westSea: [
POGOProtos.Enums.Form.SHELLOS_WEST_SEA,
POGOProtos.Enums.Form.GASTRODON_WEST_SEA,
PVPogoProtos.PokemonForm.SHELLOS_WEST_SEA,
PVPogoProtos.PokemonForm.GASTRODON_WEST_SEA,
],
eastSea: [
POGOProtos.Enums.Form.SHELLOS_EAST_SEA,
POGOProtos.Enums.Form.GASTRODON_EAST_SEA,
PVPogoProtos.PokemonForm.SHELLOS_EAST_SEA,
PVPogoProtos.PokemonForm.GASTRODON_EAST_SEA,
],
altered: [
POGOProtos.Enums.Form.GIRATINA_ALTERED,
PVPogoProtos.PokemonForm.GIRATINA_ALTERED,
],
origin: [
POGOProtos.Enums.Form.GIRATINA_ORIGIN,
PVPogoProtos.PokemonForm.GIRATINA_ORIGIN,
],
frost: [
POGOProtos.Enums.Form.ROTOM_FROST,
PVPogoProtos.PokemonForm.ROTOM_FROST,
],
fan: [
POGOProtos.Enums.Form.ROTOM_FAN,
PVPogoProtos.PokemonForm.ROTOM_FAN,
],
mow: [
POGOProtos.Enums.Form.ROTOM_MOW,
PVPogoProtos.PokemonForm.ROTOM_MOW,
],
wash: [
POGOProtos.Enums.Form.ROTOM_WASH,
PVPogoProtos.PokemonForm.ROTOM_WASH,
],
heat: [
POGOProtos.Enums.Form.ROTOM_HEAT,
PVPogoProtos.PokemonForm.ROTOM_HEAT,
],
sky: [
POGOProtos.Enums.Form.SHAYMIN_SKY,
PVPogoProtos.PokemonForm.SHAYMIN_SKY,
],
land: [
POGOProtos.Enums.Form.SHAYMIN_LAND,
PVPogoProtos.PokemonForm.SHAYMIN_LAND,
],
overcast: [
POGOProtos.Enums.Form.CHERRIM_OVERCAST,
PVPogoProtos.PokemonForm.CHERRIM_OVERCAST,
],
sunny: [
POGOProtos.Enums.Form.CASTFORM_SUNNY,
POGOProtos.Enums.Form.CHERRIM_SUNNY,
PVPogoProtos.PokemonForm.CASTFORM_SUNNY,
PVPogoProtos.PokemonForm.CHERRIM_SUNNY,
],
rainy: [
POGOProtos.Enums.Form.CASTFORM_RAINY,
PVPogoProtos.PokemonForm.CASTFORM_RAINY,
],
snowy: [
POGOProtos.Enums.Form.CASTFORM_SNOWY,
PVPogoProtos.PokemonForm.CASTFORM_SNOWY,
],
attack: [
POGOProtos.Enums.Form.DEOXYS_ATTACK,
PVPogoProtos.PokemonForm.DEOXYS_ATTACK,
],
defense: [
POGOProtos.Enums.Form.DEOXYS_DEFENSE,
PVPogoProtos.PokemonForm.DEOXYS_DEFENSE,
],
speed: [
POGOProtos.Enums.Form.DEOXYS_SPEED,
PVPogoProtos.PokemonForm.DEOXYS_SPEED,
],
fighting: [
POGOProtos.Enums.Form.ARCEUS_FIGHTING,
PVPogoProtos.PokemonForm.ARCEUS_FIGHTING,
],
flying: [
POGOProtos.Enums.Form.ARCEUS_FLYING,
PVPogoProtos.PokemonForm.ARCEUS_FLYING,
],
poison: [
POGOProtos.Enums.Form.ARCEUS_POISON,
PVPogoProtos.PokemonForm.ARCEUS_POISON,
],
ground: [
POGOProtos.Enums.Form.ARCEUS_GROUND,
PVPogoProtos.PokemonForm.ARCEUS_GROUND,
],
rock: [
POGOProtos.Enums.Form.ARCEUS_ROCK,
PVPogoProtos.PokemonForm.ARCEUS_ROCK,
],
bug: [
POGOProtos.Enums.Form.ARCEUS_BUG,
PVPogoProtos.PokemonForm.ARCEUS_BUG,
],
ghost: [
POGOProtos.Enums.Form.ARCEUS_GHOST,
PVPogoProtos.PokemonForm.ARCEUS_GHOST,
],
steel: [
POGOProtos.Enums.Form.ARCEUS_STEEL,
PVPogoProtos.PokemonForm.ARCEUS_STEEL,
],
fire: [
POGOProtos.Enums.Form.ARCEUS_FIRE,
PVPogoProtos.PokemonForm.ARCEUS_FIRE,
],
water: [
POGOProtos.Enums.Form.ARCEUS_WATER,
PVPogoProtos.PokemonForm.ARCEUS_WATER,
],
grass: [
POGOProtos.Enums.Form.ARCEUS_GRASS,
PVPogoProtos.PokemonForm.ARCEUS_GRASS,
],
electric: [
POGOProtos.Enums.Form.ARCEUS_ELECTRIC,
PVPogoProtos.PokemonForm.ARCEUS_ELECTRIC,
],
psychic: [
POGOProtos.Enums.Form.ARCEUS_PSYCHIC,
PVPogoProtos.PokemonForm.ARCEUS_PSYCHIC,
],
ice: [
POGOProtos.Enums.Form.ARCEUS_ICE,
PVPogoProtos.PokemonForm.ARCEUS_ICE,
],
dragon: [
POGOProtos.Enums.Form.ARCEUS_DRAGON,
PVPogoProtos.PokemonForm.ARCEUS_DRAGON,
],
dark: [
POGOProtos.Enums.Form.ARCEUS_DARK,
PVPogoProtos.PokemonForm.ARCEUS_DARK,
],
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) {
return 'Normal';
} 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 { CombatMoveStats, ICombatMoveStats, IPokemonMove, TypeEffectiveness } from 'app/models/Pokemon';
import { SelectedCombatMoves } from 'app/components/PokemonExplorer/types';
import * as PVPogoProtos from 'common/models/PvPogoProtos';
export const calculateTypeCoverage = (
selectedMoves : SelectedCombatMoves,
movesById : CombatMoveStats,
attackTypeEffectiveness : AttackTypeEffectiveness,
) => {
const calculatedffectiveness : Map<POGOProtos.Enums.PokemonType, TypeEffectiveness> = new Map();
const calculatedffectiveness : Map<PVPogoProtos.PokemonType, TypeEffectiveness> = new Map();
Object.values(selectedMoves).forEach((move) => {
const moveType = getMoveType(move, movesById);
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