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 pokemon : ILeaguePokemon = {
...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: {
great: [],
ultra: [],
@ -96,6 +154,13 @@ fs.mkdirSync(outPath, { recursive: true });
combinedStatsDistribution[league][combinedStats] = combinedStatsDistribution[league][combinedStats] || [];
combinedStatsDistribution[league][combinedStats].push(pokemonWithIvs);
// 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--) {
const combinedStats = orderedCombinedStats[index];
const percent = (combinedStats - offset) / max;
// remove all `Grade.F` stats (to save space in the DB)
if (percent < 0.6) {
// remove all `Grade.F` stats (to save space in the DB), except
// for the very worst one
if (percent < 0.6 && index !== 0) {
delete combinedStatsDistribution[league][combinedStats];
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>;
}
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 (
<div className={ styles.wrapper }>
<div>
@ -322,17 +329,17 @@ export class PokemonExplorer extends React.Component<IPokemonExplorerProps, ISta
<StatDisplay
statLabel={ `HP${ String.fromCharCode(160) }` }
statValue={ rankedHp }
statRank={ leaguePokemon.statsRank.staminaRank }
statRank={ staminaStatRank }
/>
<StatDisplay
statLabel="ATK"
statValue={ rankedAtk }
statRank={ leaguePokemon.statsRank.attackRank }
statRank={ attackStatRank }
/>
<StatDisplay
statLabel="DEF"
statValue={ rankedDef }
statRank={ leaguePokemon.statsRank.defenseRank }
statRank={ defenseStatRank }
/>
</div>
</div>

View File

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