rank pokemon stats within leagues

This commit is contained in:
Jeff Colombo 2019-02-10 01:02:44 -05:00
parent f053d72efa
commit fa83e7ce82
3 changed files with 93 additions and 5 deletions

View File

@ -45,6 +45,64 @@ fs.mkdirSync(outPath, { recursive: true });
const baseDef = mon.stats.baseDefense; const baseDef = mon.stats.baseDefense;
const pokemon : ILeaguePokemon = { const pokemon : ILeaguePokemon = {
...mon, ...mon,
statMax: {
great: {
stamina: {
best: -Infinity,
worst: Infinity,
},
attack: {
best: -Infinity,
worst: Infinity,
},
defense: {
best: -Infinity,
worst: Infinity,
},
},
ultra: {
stamina: {
best: -Infinity,
worst: Infinity,
},
attack: {
best: -Infinity,
worst: Infinity,
},
defense: {
best: -Infinity,
worst: Infinity,
},
},
master: {
stamina: {
best: -Infinity,
worst: Infinity,
},
attack: {
best: -Infinity,
worst: Infinity,
},
defense: {
best: -Infinity,
worst: Infinity,
},
},
custom: {
stamina: {
best: -Infinity,
worst: Infinity,
},
attack: {
best: -Infinity,
worst: Infinity,
},
defense: {
best: -Infinity,
worst: Infinity,
},
},
},
pvp: { pvp: {
great: [], great: [],
ultra: [], ultra: [],
@ -96,6 +154,13 @@ fs.mkdirSync(outPath, { recursive: true });
combinedStatsDistribution[league][combinedStats] = combinedStatsDistribution[league][combinedStats] || []; combinedStatsDistribution[league][combinedStats] = combinedStatsDistribution[league][combinedStats] || [];
combinedStatsDistribution[league][combinedStats].push(pokemonWithIvs); combinedStatsDistribution[league][combinedStats].push(pokemonWithIvs);
// console.log(pokemonWithIvs, key); // console.log(pokemonWithIvs, key);
pokemon.statMax[league].stamina.best = Math.max(pokemon.statMax[league].stamina.best, pokemonWithIvs.hp);
pokemon.statMax[league].stamina.worst = Math.min(pokemon.statMax[league].stamina.worst, pokemonWithIvs.hp);
pokemon.statMax[league].attack.best = Math.max(pokemon.statMax[league].attack.best, pokemonWithIvs.atk);
pokemon.statMax[league].attack.worst = Math.min(pokemon.statMax[league].attack.worst, pokemonWithIvs.atk);
pokemon.statMax[league].defense.best = Math.max(pokemon.statMax[league].defense.best, pokemonWithIvs.def);
pokemon.statMax[league].defense.worst = Math.min(pokemon.statMax[league].defense.worst, pokemonWithIvs.def);
}); });
} }
} }
@ -114,8 +179,9 @@ fs.mkdirSync(outPath, { recursive: true });
for (let index = len; index >= 0; index--) { for (let index = len; index >= 0; index--) {
const combinedStats = orderedCombinedStats[index]; const combinedStats = orderedCombinedStats[index];
const percent = (combinedStats - offset) / max; const percent = (combinedStats - offset) / max;
// remove all `Grade.F` stats (to save space in the DB) // remove all `Grade.F` stats (to save space in the DB), except
if (percent < 0.6) { // for the very worst one
if (percent < 0.6 && index !== 0) {
delete combinedStatsDistribution[league][combinedStats]; delete combinedStatsDistribution[league][combinedStats];
continue; continue;
} }

View File

@ -200,6 +200,13 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
type2 = <div className={ `${pokemonType} ${formatType(leaguePokemon.types.type2)}` }>{ formatType(leaguePokemon.types.type2) }</div>; type2 = <div className={ `${pokemonType} ${formatType(leaguePokemon.types.type2)}` }>{ formatType(leaguePokemon.types.type2) }</div>;
} }
const maxStamina = leaguePokemon.statMax[activeLeague].stamina;
const staminaStatRank = Math.floor(((rankedHp - maxStamina.worst) / (maxStamina.best - maxStamina.worst)) * 100);
const maxAttack = leaguePokemon.statMax[activeLeague].attack;
const attackStatRank = Math.floor(((rankedAtk - maxAttack.worst) / (maxAttack.best - maxAttack.worst)) * 100);
const maxDefense = leaguePokemon.statMax[activeLeague].defense;
const defenseStatRank = Math.floor(((rankedDef - maxDefense.worst) / (maxDefense.best - maxDefense.worst)) * 100);
return ( return (
<div className={ styles.wrapper }> <div className={ styles.wrapper }>
<div> <div>
@ -322,17 +329,17 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
<StatDisplay <StatDisplay
statLabel={ `HP${ String.fromCharCode(160) }` } statLabel={ `HP${ String.fromCharCode(160) }` }
statValue={ rankedHp } statValue={ rankedHp }
statRank={ leaguePokemon.statsRank.staminaRank } statRank={ staminaStatRank }
/> />
<StatDisplay <StatDisplay
statLabel="ATK" statLabel="ATK"
statValue={ rankedAtk } statValue={ rankedAtk }
statRank={ leaguePokemon.statsRank.attackRank } statRank={ attackStatRank }
/> />
<StatDisplay <StatDisplay
statLabel="DEF" statLabel="DEF"
statValue={ rankedDef } statValue={ rankedDef }
statRank={ leaguePokemon.statsRank.defenseRank } statRank={ defenseStatRank }
/> />
</div> </div>
</div> </div>

View File

@ -30,7 +30,22 @@ export const LeagueLabels : Array<{ id : League, label : string }> = [{
label: 'Custom' label: 'Custom'
}]; }];
interface IBestWorstStatSpread {
best : number;
worst : number;
}
interface IBestWorstStats {
stamina : IBestWorstStatSpread;
attack : IBestWorstStatSpread;
defense : IBestWorstStatSpread;
}
export interface ILeaguePokemon extends IPokemon { export interface ILeaguePokemon extends IPokemon {
statMax : {
great : IBestWorstStats;
ultra : IBestWorstStats;
master : IBestWorstStats;
custom : IBestWorstStats;
};
pvp : { pvp : {
great : Array<IStats>; great : Array<IStats>;
ultra : Array<IStats>; ultra : Array<IStats>;