fix grades
This commit is contained in:
parent
2a610fad28
commit
4f56dd213c
@ -77,7 +77,6 @@ Pokemon.forEach((mon) => {
|
||||
metaGrade: Grade.F,
|
||||
};
|
||||
pokemonWithIvs.total = pokemonWithIvs.hp + pokemonWithIvs.atk + pokemonWithIvs.def;
|
||||
stats.pvp[league].push(pokemonWithIvs);
|
||||
|
||||
const combinedStats = maxLeagueCp + pokemonWithIvs.total;
|
||||
combinedStatsDistribution[league][combinedStats] = combinedStatsDistribution[league][combinedStats] || [];
|
||||
@ -90,17 +89,12 @@ Pokemon.forEach((mon) => {
|
||||
// process the pokemon stats for league-worthiness
|
||||
Object.keys(stats.pvp).forEach((key) => {
|
||||
const league = key as League;
|
||||
stats.pvp[league].sort((a, b) => {
|
||||
if (a.total === b.total) {
|
||||
return a.total > b.total ? 0 : 1;
|
||||
}
|
||||
return a.level > b.level ? 0 : 1;
|
||||
});
|
||||
|
||||
const orderedCombinedStats = Object.keys(combinedStatsDistribution[league]).map(cpTotal => parseInt(cpTotal)).sort();
|
||||
const offset = orderedCombinedStats[orderedCombinedStats.length - 1];
|
||||
const max = orderedCombinedStats[1] - offset; // index 0 is always `Grade.S`
|
||||
for (let index = orderedCombinedStats.length - 1; index >= 0; index--) {
|
||||
const len = orderedCombinedStats.length - 1;
|
||||
const offset = orderedCombinedStats[1];
|
||||
const max = orderedCombinedStats[len] - offset; // index 0 is always `Grade.S`
|
||||
for (let index = len; index >= 0; index--) {
|
||||
const combinedStats = orderedCombinedStats[index];
|
||||
const percent = (combinedStats - offset) / max;
|
||||
|
||||
@ -111,7 +105,7 @@ Pokemon.forEach((mon) => {
|
||||
}
|
||||
|
||||
combinedStatsDistribution[league][combinedStats].forEach((pokemonStats) => {
|
||||
if (index === 0) {
|
||||
if (index === len) {
|
||||
pokemonStats.speciesGrade = Grade.S;
|
||||
} else {
|
||||
if (percent >= 0.9) {
|
||||
@ -124,7 +118,18 @@ Pokemon.forEach((mon) => {
|
||||
pokemonStats.speciesGrade = Grade.D;
|
||||
}
|
||||
}
|
||||
stats.pvp[league].push(pokemonStats);
|
||||
});
|
||||
combinedStatsDistribution[league][combinedStats].sort((a, b) => {
|
||||
if (a.total !== b.total) {
|
||||
return a.total < b.total ? -1 : 1;
|
||||
}
|
||||
if (a.level !== b.level) {
|
||||
return a.level < b.level ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
stats.pvp[league].push(...combinedStatsDistribution[league][combinedStats]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
{
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"#": "DO NOT ADD '-d' OPTION TO WEBPACK OR ALL SOURCEMAPS WILL BREAK: https://webpack.js.org/api/cli/#shortcuts",
|
||||
"package": "yarn build -- --config webpack.config.prod.js --bail --display-used-exports -p",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user