@pkmn/stats 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{chunk-SSJQE7LM.mjs → chunk-KRAJIBBW.mjs} +99 -78
- package/build/chunk-KRAJIBBW.mjs.map +1 -0
- package/build/index.js +98 -77
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -1
- package/build/test/integration.js +98 -77
- package/build/test/integration.js.map +1 -1
- package/build/test/integration.mjs +1 -1
- package/package.json +1 -1
- package/build/chunk-SSJQE7LM.mjs.map +0 -1
|
@@ -2864,14 +2864,14 @@ var Reports = new class {
|
|
|
2864
2864
|
} else {
|
|
2865
2865
|
sorted.sort((a, b) => b[1].usage.weighted - a[1].usage.weighted || a[0].localeCompare(b[0]));
|
|
2866
2866
|
}
|
|
2867
|
-
let s = `
|
|
2867
|
+
let s = `Total battles: ${stats.battles}
|
|
2868
2868
|
`;
|
|
2869
2869
|
const avg = stats.battles ? roundStr(stats.usage.weighted / stats.battles / 12, 1e3) : "0.0";
|
|
2870
|
-
s += `
|
|
2870
|
+
s += `Avg. weight/team: ${avg}
|
|
2871
2871
|
`;
|
|
2872
|
-
s += "
|
|
2873
|
-
s += "
|
|
2874
|
-
s += "
|
|
2872
|
+
s += "+ ---- + ------------------ + --------- + ------ + ------- + ------ + ------- + \n";
|
|
2873
|
+
s += "| Rank | Pokemon | Usage % | Raw | % | Real | % | \n";
|
|
2874
|
+
s += "+ ---- + ------------------ + --------- + ------ + ------- + ------ + ------- + \n";
|
|
2875
2875
|
const total = {
|
|
2876
2876
|
raw: Math.max(1, stats.usage.raw),
|
|
2877
2877
|
real: Math.max(1, stats.usage.real),
|
|
@@ -2888,18 +2888,18 @@ var Reports = new class {
|
|
|
2888
2888
|
const rawp = (100 * usage.raw / total.raw * 6).toFixed(3).padStart(6);
|
|
2889
2889
|
const real = usage.real.toFixed().padEnd(6);
|
|
2890
2890
|
const realp = (100 * usage.real / total.real * 6).toFixed(3).padStart(6);
|
|
2891
|
-
s +=
|
|
2891
|
+
s += `| ${rank2} | ${poke} | ${use}% | ${raw} | ${rawp}% | ${real} | ${realp}% |
|
|
2892
2892
|
`;
|
|
2893
2893
|
}
|
|
2894
|
-
s += "
|
|
2894
|
+
s += "+ ---- + ------------------ + --------- + ------ + ------- + ------ + ------- + \n";
|
|
2895
2895
|
return s;
|
|
2896
2896
|
}
|
|
2897
2897
|
leadsReport(gen, stats, legacy = true) {
|
|
2898
|
-
let s = `
|
|
2898
|
+
let s = `Total leads: ${stats.battles * 2}
|
|
2899
2899
|
`;
|
|
2900
|
-
s += "
|
|
2901
|
-
s += "
|
|
2902
|
-
s += "
|
|
2900
|
+
s += "+ ---- + ------------------ + --------- + ------ + ------- + \n";
|
|
2901
|
+
s += "| Rank | Pokemon | Usage % | Raw | % | \n";
|
|
2902
|
+
s += "+ ---- + ------------------ + --------- + ------ + ------- + \n";
|
|
2903
2903
|
const total = { raw: 0, weighted: 0 };
|
|
2904
2904
|
total.raw = Math.max(1, stats.lead.raw);
|
|
2905
2905
|
total.weighted = Math.max(1, stats.lead.weighted);
|
|
@@ -2915,10 +2915,10 @@ var Reports = new class {
|
|
|
2915
2915
|
const use = (100 * usage.weighted / total.weighted).toFixed(5).padStart(8);
|
|
2916
2916
|
const raw = usage.raw.toFixed().padEnd(6);
|
|
2917
2917
|
const pct = (100 * usage.raw / total.raw).toFixed(3).padStart(6);
|
|
2918
|
-
s +=
|
|
2918
|
+
s += `| ${rank2} | ${poke} | ${use}% | ${raw} | ${pct}% |
|
|
2919
2919
|
`;
|
|
2920
2920
|
}
|
|
2921
|
-
s += "
|
|
2921
|
+
s += "+ ---- + ------------------ + --------- + ------ + ------- + \n";
|
|
2922
2922
|
return s;
|
|
2923
2923
|
}
|
|
2924
2924
|
movesetReports(gen, format, stats, cutoff = 1500, tag2 = null, min = MIN, legacy = true) {
|
|
@@ -2932,23 +2932,24 @@ var Reports = new class {
|
|
|
2932
2932
|
movesetStats = movesetStats || toMovesetStatistics(gen, format, stats, min[0]);
|
|
2933
2933
|
gen = ignoreGen(gen, legacy);
|
|
2934
2934
|
const WIDTH = 40;
|
|
2935
|
-
const
|
|
2936
|
-
const
|
|
2937
|
-
const display = (n, w) =>
|
|
2938
|
-
const
|
|
2935
|
+
const padLine = (s2) => s2.padEnd(WIDTH + 1) + "|";
|
|
2936
|
+
const heading = (n) => padLine(`| ${n}`) + "\n";
|
|
2937
|
+
const display = (n, w) => padLine(`| ${n} ${(100 * w).toFixed(3)}%`) + "\n";
|
|
2938
|
+
const other = (t, f = 1) => padLine(`| Other ${Math.abs(f * 100 * (1 - t)).toFixed(3)}%`) + "\n";
|
|
2939
|
+
const sep = `+${"-".repeat(WIDTH)}+
|
|
2939
2940
|
`;
|
|
2940
2941
|
let s = "";
|
|
2941
2942
|
for (const [species, moveset] of movesetStats.entries()) {
|
|
2942
2943
|
if (moveset.usage < 1e-4) break;
|
|
2943
2944
|
const p = stats.pokemon[species];
|
|
2944
2945
|
s += sep;
|
|
2945
|
-
s +=
|
|
2946
|
+
s += padLine(`| ${displaySpecies(gen, species, legacy)}`) + "\n";
|
|
2946
2947
|
s += sep;
|
|
2947
|
-
s +=
|
|
2948
|
+
s += padLine(`| Raw count: ${moveset["Raw count"]}`) + "\n";
|
|
2948
2949
|
const avg = p.saved.count ? roundStr(p.saved.weight / p.saved.count, 1e12) : "---";
|
|
2949
|
-
s +=
|
|
2950
|
+
s += padLine(`| Avg. weight: ${avg}`) + "\n";
|
|
2950
2951
|
const ceiling = Math.floor(moveset["Viability Ceiling"][1]);
|
|
2951
|
-
s +=
|
|
2952
|
+
s += padLine(`| Viability Ceiling: ${ceiling}`) + "\n";
|
|
2952
2953
|
s += sep;
|
|
2953
2954
|
let total = 0;
|
|
2954
2955
|
s += heading("Abilities");
|
|
@@ -2977,18 +2978,6 @@ var Reports = new class {
|
|
|
2977
2978
|
}
|
|
2978
2979
|
s += sep;
|
|
2979
2980
|
total = 0;
|
|
2980
|
-
s += heading("Tera Types");
|
|
2981
|
-
for (const teraType of Object.keys(moveset["Tera Types"])) {
|
|
2982
|
-
if (total > 0.95) {
|
|
2983
|
-
s += other(total);
|
|
2984
|
-
break;
|
|
2985
|
-
}
|
|
2986
|
-
const weight = moveset["Tera Types"][teraType] / p.raw.weight;
|
|
2987
|
-
s += display(teraType[0].toUpperCase() + teraType.slice(1), weight);
|
|
2988
|
-
total += weight;
|
|
2989
|
-
}
|
|
2990
|
-
s += sep;
|
|
2991
|
-
total = 0;
|
|
2992
2981
|
s += heading("Spreads");
|
|
2993
2982
|
for (const [i, spread] of Object.keys(moveset["Spreads"]).entries()) {
|
|
2994
2983
|
if (total > 0.95 || i > 5) {
|
|
@@ -3014,6 +3003,21 @@ var Reports = new class {
|
|
|
3014
3003
|
}
|
|
3015
3004
|
s += sep;
|
|
3016
3005
|
total = 0;
|
|
3006
|
+
const entries = Object.entries(moveset["Tera Types"]);
|
|
3007
|
+
if (!(entries.length === 1 && toID5(entries[0][0]) === "nothing")) {
|
|
3008
|
+
s += heading("Tera Types");
|
|
3009
|
+
for (const teraType of Object.keys(moveset["Tera Types"])) {
|
|
3010
|
+
if (total > 0.95) {
|
|
3011
|
+
s += other(total);
|
|
3012
|
+
break;
|
|
3013
|
+
}
|
|
3014
|
+
const weight = moveset["Tera Types"][teraType] / p.raw.weight;
|
|
3015
|
+
s += display(teraType[0].toUpperCase() + teraType.slice(1), weight);
|
|
3016
|
+
total += weight;
|
|
3017
|
+
}
|
|
3018
|
+
s += sep;
|
|
3019
|
+
total = 0;
|
|
3020
|
+
}
|
|
3017
3021
|
s += heading("Teammates");
|
|
3018
3022
|
for (const [i, teammate] of Object.keys(moveset["Teammates"]).entries()) {
|
|
3019
3023
|
if (total > 0.95 || i > 10) break;
|
|
@@ -3021,29 +3025,31 @@ var Reports = new class {
|
|
|
3021
3025
|
if (w < 5e-3 * p.raw.weight) break;
|
|
3022
3026
|
const weight = w / p.raw.weight;
|
|
3023
3027
|
const val = 100 * weight;
|
|
3024
|
-
s +=
|
|
3028
|
+
s += padLine(`| ${teammate} ${val.toFixed(3)}%`) + "\n";
|
|
3025
3029
|
total += weight / 5;
|
|
3026
3030
|
}
|
|
3027
3031
|
s += sep;
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3032
|
+
if (Object.values(moveset["Checks and Counters"]).some((entry) => entry.p - 4 * entry.d >= 0.5)) {
|
|
3033
|
+
s += heading("Checks and Counters");
|
|
3034
|
+
for (const [i, cc] of Object.keys(moveset["Checks and Counters"]).entries()) {
|
|
3035
|
+
if (i > 11) break;
|
|
3036
|
+
const v = moveset["Checks and Counters"][cc];
|
|
3037
|
+
if (v.score < min[1]) break;
|
|
3038
|
+
const score = (100 * v.score).toFixed(3);
|
|
3039
|
+
const vp = (100 * v.p).toFixed(2);
|
|
3040
|
+
const vd = (100 * v.d).toFixed(2);
|
|
3041
|
+
let line = `| ${cc} ${score} (${vp}\xB1${vd})`.padEnd(WIDTH + 1) + "|\n";
|
|
3042
|
+
const ko = 100 * v.koed / v.n;
|
|
3043
|
+
const koed = ko.toFixed(1);
|
|
3044
|
+
const sw = 100 * v.switched / v.n;
|
|
3045
|
+
const switched = sw.toFixed(1);
|
|
3046
|
+
line += `| (${koed}% KOed / ${switched}% switched out)`;
|
|
3047
|
+
if (ko < 10) line += " ";
|
|
3048
|
+
if (sw < 10) line += " ";
|
|
3049
|
+
s += line + "\n";
|
|
3050
|
+
}
|
|
3051
|
+
s += sep;
|
|
3045
3052
|
}
|
|
3046
|
-
s += sep;
|
|
3047
3053
|
}
|
|
3048
3054
|
return s;
|
|
3049
3055
|
}
|
|
@@ -3075,8 +3081,8 @@ var Reports = new class {
|
|
|
3075
3081
|
);
|
|
3076
3082
|
let s = "";
|
|
3077
3083
|
for (const [tag2, weight] of tags) {
|
|
3078
|
-
|
|
3079
|
-
s += `${(100 * weight / W).toFixed(5)
|
|
3084
|
+
const dots = ".".repeat(Math.max(0, 18 - tag2.length));
|
|
3085
|
+
s += `${tag2}${dots}${(100 * weight / W * 6).toFixed(5)}%
|
|
3080
3086
|
`;
|
|
3081
3087
|
}
|
|
3082
3088
|
s += "\n";
|
|
@@ -3089,23 +3095,23 @@ var Reports = new class {
|
|
|
3089
3095
|
const MAX_BLOCKS = 30;
|
|
3090
3096
|
const blockSize = max / MAX_BLOCKS;
|
|
3091
3097
|
if (blockSize <= 0) return s;
|
|
3092
|
-
s += `
|
|
3098
|
+
s += `Stalliness (mean: ${mean.toFixed(3)})
|
|
3093
3099
|
`;
|
|
3094
3100
|
for (const h of histogram) {
|
|
3095
|
-
let line = "
|
|
3101
|
+
let line = " |";
|
|
3096
3102
|
if (fmod(h[0], 2 * binSize) < binSize / 2) {
|
|
3097
|
-
line = "
|
|
3103
|
+
line = "";
|
|
3098
3104
|
if (h[0] > 0) {
|
|
3099
3105
|
line += "+";
|
|
3100
3106
|
} else if (h[0] === 0) {
|
|
3101
3107
|
line += " ";
|
|
3102
3108
|
}
|
|
3103
|
-
line += `${h[0].toFixed(1)
|
|
3109
|
+
line += `${h[0].toFixed(1)}|`;
|
|
3104
3110
|
}
|
|
3105
|
-
s += line + "#".repeat(Math.
|
|
3111
|
+
s += line + "#".repeat(Math.round(h[1] / blockSize)) + "\n";
|
|
3106
3112
|
}
|
|
3107
|
-
s += "
|
|
3108
|
-
s += `
|
|
3113
|
+
s += "more negative = more offensive, more positive = more stall\n";
|
|
3114
|
+
s += `one # = ${(100 * blockSize / total).toFixed(2)}%
|
|
3109
3115
|
`;
|
|
3110
3116
|
return s;
|
|
3111
3117
|
}
|
|
@@ -3422,7 +3428,7 @@ function getTeammates(gen, teammates, stats, legacy = true) {
|
|
|
3422
3428
|
function forDetailed(cc) {
|
|
3423
3429
|
const obj = {};
|
|
3424
3430
|
for (const [k, v] of Object.entries(cc)) {
|
|
3425
|
-
obj[k] =
|
|
3431
|
+
obj[k] = { n: round3(v.n), p: round3(v.p), d: round3(v.d) };
|
|
3426
3432
|
}
|
|
3427
3433
|
return obj;
|
|
3428
3434
|
}
|
|
@@ -3950,6 +3956,7 @@ var FIX = {
|
|
|
3950
3956
|
};
|
|
3951
3957
|
var SPECIES = /\| (.*) [-+.0-9]+ \([-+.0-9]+±[-+.0-9]+\)/;
|
|
3952
3958
|
var OUTCOME = /\|\W+\(([-+.0-9]+)% KOed \/ ([-+.0-9]+)% switched out\)/;
|
|
3959
|
+
var WEIGHT = /\d[\d.]*/;
|
|
3953
3960
|
var Display2 = new class {
|
|
3954
3961
|
fromStatistics(gen, format, stats, min = 20) {
|
|
3955
3962
|
const N = (n) => {
|
|
@@ -4232,26 +4239,39 @@ function parseLeadsReport(report) {
|
|
|
4232
4239
|
return { total, usage };
|
|
4233
4240
|
}
|
|
4234
4241
|
function partialParseMovesetReport(report) {
|
|
4242
|
+
var _a, _b, _c;
|
|
4235
4243
|
const movesets = {};
|
|
4236
|
-
let section = 0;
|
|
4237
|
-
let i = 0;
|
|
4238
4244
|
let species = "";
|
|
4239
4245
|
let s = "";
|
|
4246
|
+
let inCC = false;
|
|
4247
|
+
let ccLine = 0;
|
|
4248
|
+
let sectionLines = 0;
|
|
4249
|
+
let prevSectionEmpty = false;
|
|
4240
4250
|
for (const line of report.split("\n")) {
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4251
|
+
if (line.trimStart().startsWith("+")) {
|
|
4252
|
+
prevSectionEmpty = sectionLines === 0;
|
|
4253
|
+
inCC = false;
|
|
4254
|
+
ccLine = 0;
|
|
4255
|
+
sectionLines = 0;
|
|
4245
4256
|
continue;
|
|
4246
4257
|
}
|
|
4247
|
-
|
|
4248
|
-
|
|
4258
|
+
sectionLines++;
|
|
4259
|
+
if (line.includes("Checks and Counters")) {
|
|
4260
|
+
inCC = true;
|
|
4261
|
+
ccLine = 0;
|
|
4262
|
+
continue;
|
|
4263
|
+
}
|
|
4264
|
+
if (sectionLines === 1 && prevSectionEmpty) {
|
|
4265
|
+
species = (_b = (_a = line.split("|")[1]) == null ? void 0 : _a.trim()) != null ? _b : "";
|
|
4266
|
+
continue;
|
|
4249
4267
|
}
|
|
4250
|
-
if (
|
|
4251
|
-
movesets[species] = { weight: Number(
|
|
4268
|
+
if (!movesets[species] && line.includes("Avg. weight")) {
|
|
4269
|
+
movesets[species] = { weight: Number((_c = WEIGHT.exec(line)) == null ? void 0 : _c[0]), outcomes: {} };
|
|
4270
|
+
continue;
|
|
4252
4271
|
}
|
|
4253
|
-
if (
|
|
4254
|
-
|
|
4272
|
+
if (inCC) {
|
|
4273
|
+
ccLine++;
|
|
4274
|
+
if (ccLine % 2 === 1) {
|
|
4255
4275
|
s = SPECIES.exec(line)[1];
|
|
4256
4276
|
} else {
|
|
4257
4277
|
const outcome = OUTCOME.exec(line);
|
|
@@ -4269,10 +4289,11 @@ function parseMetagameReport(report) {
|
|
|
4269
4289
|
const lines = report.split("\n");
|
|
4270
4290
|
let i = 0;
|
|
4271
4291
|
for (; i < lines.length; i++) {
|
|
4272
|
-
const
|
|
4292
|
+
const line = lines[i].trimStart();
|
|
4293
|
+
const d = line.indexOf(".");
|
|
4273
4294
|
if (d < 0) break;
|
|
4274
|
-
const tag2 =
|
|
4275
|
-
const weight = Number(
|
|
4295
|
+
const tag2 = line.slice(0, d);
|
|
4296
|
+
const weight = Number(line.slice(line.search(/\d/), line.lastIndexOf("%"))) / 100;
|
|
4276
4297
|
tags[tag2] = weight;
|
|
4277
4298
|
}
|
|
4278
4299
|
i++;
|
|
@@ -4325,4 +4346,4 @@ export {
|
|
|
4325
4346
|
Stats2 as Stats,
|
|
4326
4347
|
Display2 as Display
|
|
4327
4348
|
};
|
|
4328
|
-
//# sourceMappingURL=chunk-
|
|
4349
|
+
//# sourceMappingURL=chunk-KRAJIBBW.mjs.map
|