volleyballsimtypes 0.0.433 → 0.0.434
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.
|
@@ -123,10 +123,27 @@ function selectImprovableStat(rarity, trainingFocus, currentStats) {
|
|
|
123
123
|
if ((multipliers[key] ?? 0) > 0)
|
|
124
124
|
focusPool.push(col);
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
if (fallbackPool.length === 0)
|
|
126
|
+
const pool = focusPool.length > 0 ? focusPool : fallbackPool;
|
|
127
|
+
if (pool.length === 0)
|
|
130
128
|
return null;
|
|
131
|
-
return
|
|
129
|
+
return weightedPickByRoom(pool, currentStats, cap);
|
|
130
|
+
}
|
|
131
|
+
// Pick a stat biased toward the ones furthest below the cap (weight = cap - stat), so improvements fill a
|
|
132
|
+
// player's weaknesses first and they are far less likely to end lopsided by chance. The bias is linear and
|
|
133
|
+
// soft: a low stat is more likely but a higher one can still be picked, so players keep some natural variance
|
|
134
|
+
// rather than converging on an identical flat sheet. Capped stats carry weight 0 (and are already excluded).
|
|
135
|
+
function weightedPickByRoom(pool, currentStats, cap) {
|
|
136
|
+
let total = 0;
|
|
137
|
+
for (const col of pool)
|
|
138
|
+
total += Math.max(0, cap - (currentStats[col] ?? 0));
|
|
139
|
+
// Degenerate guard: if every stat is at the cap (total room 0), fall back to a uniform pick.
|
|
140
|
+
if (total <= 0)
|
|
141
|
+
return pool[Math.floor(Math.random() * pool.length)];
|
|
142
|
+
let r = Math.random() * total;
|
|
143
|
+
for (const col of pool) {
|
|
144
|
+
r -= Math.max(0, cap - (currentStats[col] ?? 0));
|
|
145
|
+
if (r < 0)
|
|
146
|
+
return col;
|
|
147
|
+
}
|
|
148
|
+
return pool[pool.length - 1];
|
|
132
149
|
}
|
|
@@ -113,10 +113,27 @@ export function selectImprovableStat(rarity, trainingFocus, currentStats) {
|
|
|
113
113
|
if ((multipliers[key] ?? 0) > 0)
|
|
114
114
|
focusPool.push(col);
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (fallbackPool.length === 0)
|
|
116
|
+
const pool = focusPool.length > 0 ? focusPool : fallbackPool;
|
|
117
|
+
if (pool.length === 0)
|
|
120
118
|
return null;
|
|
121
|
-
return
|
|
119
|
+
return weightedPickByRoom(pool, currentStats, cap);
|
|
120
|
+
}
|
|
121
|
+
// Pick a stat biased toward the ones furthest below the cap (weight = cap - stat), so improvements fill a
|
|
122
|
+
// player's weaknesses first and they are far less likely to end lopsided by chance. The bias is linear and
|
|
123
|
+
// soft: a low stat is more likely but a higher one can still be picked, so players keep some natural variance
|
|
124
|
+
// rather than converging on an identical flat sheet. Capped stats carry weight 0 (and are already excluded).
|
|
125
|
+
function weightedPickByRoom(pool, currentStats, cap) {
|
|
126
|
+
let total = 0;
|
|
127
|
+
for (const col of pool)
|
|
128
|
+
total += Math.max(0, cap - (currentStats[col] ?? 0));
|
|
129
|
+
// Degenerate guard: if every stat is at the cap (total room 0), fall back to a uniform pick.
|
|
130
|
+
if (total <= 0)
|
|
131
|
+
return pool[Math.floor(Math.random() * pool.length)];
|
|
132
|
+
let r = Math.random() * total;
|
|
133
|
+
for (const col of pool) {
|
|
134
|
+
r -= Math.max(0, cap - (currentStats[col] ?? 0));
|
|
135
|
+
if (r < 0)
|
|
136
|
+
return col;
|
|
137
|
+
}
|
|
138
|
+
return pool[pool.length - 1];
|
|
122
139
|
}
|