volleyballsimtypes 0.0.445 → 0.0.447
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.
|
@@ -24,7 +24,7 @@ function getMultipliers(statName, performanceStats) {
|
|
|
24
24
|
return {
|
|
25
25
|
spike: 0.55,
|
|
26
26
|
backAttack: 0.1,
|
|
27
|
-
power: performanceStats == null ? 0.125 : performanceStats.power
|
|
27
|
+
power: performanceStats == null ? 0.125 : performanceStats.power >= performanceStats.quick ? 0.2 : 0.05,
|
|
28
28
|
quick: performanceStats == null ? 0.125 : performanceStats.quick > performanceStats.power ? 0.2 : 0.05,
|
|
29
29
|
awareness: 0.05,
|
|
30
30
|
attack: 0.05
|
|
@@ -54,7 +54,7 @@ function getMultipliers(statName, performanceStats) {
|
|
|
54
54
|
case StatsEnum.BLOCK:
|
|
55
55
|
return {
|
|
56
56
|
block: 0.65,
|
|
57
|
-
read: performanceStats == null ? 0.125 : performanceStats.read
|
|
57
|
+
read: performanceStats == null ? 0.125 : performanceStats.read >= performanceStats.commit ? 0.2 : 0.05,
|
|
58
58
|
commit: performanceStats == null ? 0.125 : performanceStats.commit > performanceStats.read ? 0.2 : 0.05,
|
|
59
59
|
focus: 0.04,
|
|
60
60
|
defense: 0.04,
|
|
@@ -33,6 +33,18 @@ function makeStats(base = 50, overrides = {}) {
|
|
|
33
33
|
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
34
34
|
(0, globals_1.expect)(total).toBeCloseTo(1, 10);
|
|
35
35
|
});
|
|
36
|
+
// Regression: on a tie the `>` comparisons used to give BOTH sides 0.05 (pair = 0.10), dropping the stat's
|
|
37
|
+
// weights to 0.85. With `>=` the higher-or-equal side keeps 0.2 so the pair is 0.25 and the total stays 1.
|
|
38
|
+
(0, globals_1.it)('on a power === quick tie, power keeps 0.2 and quick 0.05 (pair sums to 0.25)', () => {
|
|
39
|
+
const m = (0, stats_1.getMultipliers)(stats_1.StatsEnum.ATTACK, makeStats(50, { power: 50, quick: 50 }));
|
|
40
|
+
(0, globals_1.expect)(m.power).toBe(0.2);
|
|
41
|
+
(0, globals_1.expect)(m.quick).toBe(0.05);
|
|
42
|
+
});
|
|
43
|
+
(0, globals_1.it)('multipliers sum to 1 on a power === quick tie', () => {
|
|
44
|
+
const m = (0, stats_1.getMultipliers)(stats_1.StatsEnum.ATTACK, makeStats(50, { power: 50, quick: 50 }));
|
|
45
|
+
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
46
|
+
(0, globals_1.expect)(total).toBeCloseTo(1, 10);
|
|
47
|
+
});
|
|
36
48
|
});
|
|
37
49
|
(0, globals_1.describe)('SET', () => {
|
|
38
50
|
(0, globals_1.it)('multipliers sum to 1', () => {
|
|
@@ -91,6 +103,17 @@ function makeStats(base = 50, overrides = {}) {
|
|
|
91
103
|
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
92
104
|
(0, globals_1.expect)(total).toBeCloseTo(1, 10);
|
|
93
105
|
});
|
|
106
|
+
// Regression: same tie bug as ATTACK's power/quick. On read === commit both used to fall to 0.05.
|
|
107
|
+
(0, globals_1.it)('on a read === commit tie, read keeps 0.2 and commit 0.05 (pair sums to 0.25)', () => {
|
|
108
|
+
const m = (0, stats_1.getMultipliers)(stats_1.StatsEnum.BLOCK, makeStats(50, { read: 50, commit: 50 }));
|
|
109
|
+
(0, globals_1.expect)(m.read).toBe(0.2);
|
|
110
|
+
(0, globals_1.expect)(m.commit).toBe(0.05);
|
|
111
|
+
});
|
|
112
|
+
(0, globals_1.it)('multipliers sum to 1 on a read === commit tie', () => {
|
|
113
|
+
const m = (0, stats_1.getMultipliers)(stats_1.StatsEnum.BLOCK, makeStats(50, { read: 50, commit: 50 }));
|
|
114
|
+
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
115
|
+
(0, globals_1.expect)(total).toBeCloseTo(1, 10);
|
|
116
|
+
});
|
|
94
117
|
});
|
|
95
118
|
(0, globals_1.describe)('STAMINA', () => {
|
|
96
119
|
(0, globals_1.it)('returns exactly { stamina: 1 }', () => {
|
|
@@ -131,3 +154,43 @@ function makeStats(base = 50, overrides = {}) {
|
|
|
131
154
|
(0, globals_1.expect)((0, stats_1.calculateStatScore)(stats, stats_1.StatsEnum.SERVE)).toBe(84);
|
|
132
155
|
});
|
|
133
156
|
});
|
|
157
|
+
// ─── invariants (every stat, every branch) ────────────────────────────────────
|
|
158
|
+
// These are the catch-all guards. The per-stat suites above each test one branch by hand; the original
|
|
159
|
+
// power===quick / read===commit weight-sum bug slipped through precisely because no suite swept ALL branches.
|
|
160
|
+
(0, globals_1.describe)('multiplier + score invariants (every stat)', () => {
|
|
161
|
+
const ALL_STATS = Object.values(stats_1.StatsEnum);
|
|
162
|
+
// Profiles that exercise the conditional ATTACK/BLOCK branches: the omitted-stats default, the equal tie (the
|
|
163
|
+
// edge the `>` comparisons mishandled), and both `>` orderings. Non-conditional stats are weight-stable across
|
|
164
|
+
// all four, which is itself worth pinning. Every branch MUST keep the weights summing to 1 or the general stat
|
|
165
|
+
// silently mis-scales.
|
|
166
|
+
const profiles = [
|
|
167
|
+
['omitted', undefined],
|
|
168
|
+
['uniform (power===quick, read===commit)', makeStats(50)],
|
|
169
|
+
['power & read dominant', makeStats(50, { power: 80, quick: 20, read: 80, commit: 20 })],
|
|
170
|
+
['quick & commit dominant', makeStats(50, { quick: 80, power: 20, commit: 80, read: 20 })]
|
|
171
|
+
];
|
|
172
|
+
for (const stat of ALL_STATS) {
|
|
173
|
+
for (const [label, ps] of profiles) {
|
|
174
|
+
(0, globals_1.it)(`${stat}: multipliers sum to 1 (${label})`, () => {
|
|
175
|
+
const m = (0, stats_1.getMultipliers)(stat, ps);
|
|
176
|
+
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
177
|
+
(0, globals_1.expect)(total).toBeCloseTo(1, 10);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// The strongest single guard: because the weights sum to 1, a uniformly-rated player scores that exact rating.
|
|
182
|
+
// Uniform stats also create the power===quick / read===commit ties, so this fails loudly on any mis-summed branch
|
|
183
|
+
// (pre-fix, ATTACK/BLOCK would have scored ~54 here, not 63).
|
|
184
|
+
for (const stat of ALL_STATS) {
|
|
185
|
+
(0, globals_1.it)(`${stat}: a uniformly-rated player scores that exact rating`, () => {
|
|
186
|
+
(0, globals_1.expect)((0, stats_1.calculateStatScore)(makeStats(63), stat)).toBe(63);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// The general stat shares the substat scale, so an all-99 (SPECIAL-cap) player must not exceed 99 either way:
|
|
190
|
+
// this catches the opposite failure of weights summing to MORE than 1.
|
|
191
|
+
for (const stat of ALL_STATS) {
|
|
192
|
+
(0, globals_1.it)(`${stat}: an all-99 player does not exceed the 99 cap`, () => {
|
|
193
|
+
(0, globals_1.expect)((0, stats_1.calculateStatScore)(makeStats(99), stat)).toBeLessThanOrEqual(99);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
});
|
|
@@ -19,7 +19,7 @@ export function getMultipliers(statName, performanceStats) {
|
|
|
19
19
|
return {
|
|
20
20
|
spike: 0.55,
|
|
21
21
|
backAttack: 0.1,
|
|
22
|
-
power: performanceStats == null ? 0.125 : performanceStats.power
|
|
22
|
+
power: performanceStats == null ? 0.125 : performanceStats.power >= performanceStats.quick ? 0.2 : 0.05,
|
|
23
23
|
quick: performanceStats == null ? 0.125 : performanceStats.quick > performanceStats.power ? 0.2 : 0.05,
|
|
24
24
|
awareness: 0.05,
|
|
25
25
|
attack: 0.05
|
|
@@ -49,7 +49,7 @@ export function getMultipliers(statName, performanceStats) {
|
|
|
49
49
|
case StatsEnum.BLOCK:
|
|
50
50
|
return {
|
|
51
51
|
block: 0.65,
|
|
52
|
-
read: performanceStats == null ? 0.125 : performanceStats.read
|
|
52
|
+
read: performanceStats == null ? 0.125 : performanceStats.read >= performanceStats.commit ? 0.2 : 0.05,
|
|
53
53
|
commit: performanceStats == null ? 0.125 : performanceStats.commit > performanceStats.read ? 0.2 : 0.05,
|
|
54
54
|
focus: 0.04,
|
|
55
55
|
defense: 0.04,
|
|
@@ -31,6 +31,18 @@ describe('getMultipliers()', () => {
|
|
|
31
31
|
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
32
32
|
expect(total).toBeCloseTo(1, 10);
|
|
33
33
|
});
|
|
34
|
+
// Regression: on a tie the `>` comparisons used to give BOTH sides 0.05 (pair = 0.10), dropping the stat's
|
|
35
|
+
// weights to 0.85. With `>=` the higher-or-equal side keeps 0.2 so the pair is 0.25 and the total stays 1.
|
|
36
|
+
it('on a power === quick tie, power keeps 0.2 and quick 0.05 (pair sums to 0.25)', () => {
|
|
37
|
+
const m = getMultipliers(StatsEnum.ATTACK, makeStats(50, { power: 50, quick: 50 }));
|
|
38
|
+
expect(m.power).toBe(0.2);
|
|
39
|
+
expect(m.quick).toBe(0.05);
|
|
40
|
+
});
|
|
41
|
+
it('multipliers sum to 1 on a power === quick tie', () => {
|
|
42
|
+
const m = getMultipliers(StatsEnum.ATTACK, makeStats(50, { power: 50, quick: 50 }));
|
|
43
|
+
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
44
|
+
expect(total).toBeCloseTo(1, 10);
|
|
45
|
+
});
|
|
34
46
|
});
|
|
35
47
|
describe('SET', () => {
|
|
36
48
|
it('multipliers sum to 1', () => {
|
|
@@ -89,6 +101,17 @@ describe('getMultipliers()', () => {
|
|
|
89
101
|
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
90
102
|
expect(total).toBeCloseTo(1, 10);
|
|
91
103
|
});
|
|
104
|
+
// Regression: same tie bug as ATTACK's power/quick. On read === commit both used to fall to 0.05.
|
|
105
|
+
it('on a read === commit tie, read keeps 0.2 and commit 0.05 (pair sums to 0.25)', () => {
|
|
106
|
+
const m = getMultipliers(StatsEnum.BLOCK, makeStats(50, { read: 50, commit: 50 }));
|
|
107
|
+
expect(m.read).toBe(0.2);
|
|
108
|
+
expect(m.commit).toBe(0.05);
|
|
109
|
+
});
|
|
110
|
+
it('multipliers sum to 1 on a read === commit tie', () => {
|
|
111
|
+
const m = getMultipliers(StatsEnum.BLOCK, makeStats(50, { read: 50, commit: 50 }));
|
|
112
|
+
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
113
|
+
expect(total).toBeCloseTo(1, 10);
|
|
114
|
+
});
|
|
92
115
|
});
|
|
93
116
|
describe('STAMINA', () => {
|
|
94
117
|
it('returns exactly { stamina: 1 }', () => {
|
|
@@ -129,3 +152,43 @@ describe('calculateStatScore()', () => {
|
|
|
129
152
|
expect(calculateStatScore(stats, StatsEnum.SERVE)).toBe(84);
|
|
130
153
|
});
|
|
131
154
|
});
|
|
155
|
+
// ─── invariants (every stat, every branch) ────────────────────────────────────
|
|
156
|
+
// These are the catch-all guards. The per-stat suites above each test one branch by hand; the original
|
|
157
|
+
// power===quick / read===commit weight-sum bug slipped through precisely because no suite swept ALL branches.
|
|
158
|
+
describe('multiplier + score invariants (every stat)', () => {
|
|
159
|
+
const ALL_STATS = Object.values(StatsEnum);
|
|
160
|
+
// Profiles that exercise the conditional ATTACK/BLOCK branches: the omitted-stats default, the equal tie (the
|
|
161
|
+
// edge the `>` comparisons mishandled), and both `>` orderings. Non-conditional stats are weight-stable across
|
|
162
|
+
// all four, which is itself worth pinning. Every branch MUST keep the weights summing to 1 or the general stat
|
|
163
|
+
// silently mis-scales.
|
|
164
|
+
const profiles = [
|
|
165
|
+
['omitted', undefined],
|
|
166
|
+
['uniform (power===quick, read===commit)', makeStats(50)],
|
|
167
|
+
['power & read dominant', makeStats(50, { power: 80, quick: 20, read: 80, commit: 20 })],
|
|
168
|
+
['quick & commit dominant', makeStats(50, { quick: 80, power: 20, commit: 80, read: 20 })]
|
|
169
|
+
];
|
|
170
|
+
for (const stat of ALL_STATS) {
|
|
171
|
+
for (const [label, ps] of profiles) {
|
|
172
|
+
it(`${stat}: multipliers sum to 1 (${label})`, () => {
|
|
173
|
+
const m = getMultipliers(stat, ps);
|
|
174
|
+
const total = Object.values(m).reduce((s, v) => s + (v ?? 0), 0);
|
|
175
|
+
expect(total).toBeCloseTo(1, 10);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// The strongest single guard: because the weights sum to 1, a uniformly-rated player scores that exact rating.
|
|
180
|
+
// Uniform stats also create the power===quick / read===commit ties, so this fails loudly on any mis-summed branch
|
|
181
|
+
// (pre-fix, ATTACK/BLOCK would have scored ~54 here, not 63).
|
|
182
|
+
for (const stat of ALL_STATS) {
|
|
183
|
+
it(`${stat}: a uniformly-rated player scores that exact rating`, () => {
|
|
184
|
+
expect(calculateStatScore(makeStats(63), stat)).toBe(63);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// The general stat shares the substat scale, so an all-99 (SPECIAL-cap) player must not exceed 99 either way:
|
|
188
|
+
// this catches the opposite failure of weights summing to MORE than 1.
|
|
189
|
+
for (const stat of ALL_STATS) {
|
|
190
|
+
it(`${stat}: an all-99 player does not exceed the 99 cap`, () => {
|
|
191
|
+
expect(calculateStatScore(makeStats(99), stat)).toBeLessThanOrEqual(99);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|