mechanic: clump stat gains on prime stats only

This commit is contained in:
Dash committed 2026-10-17 15:55:45 +02:00
1 parent ab179c1eb0
commit 17e1b91a18
5 files changed
+2864 -2869

No files matched your search

+3 -3
View File
@@ -398,12 +398,12 @@ class Player(SignalMixin):
chosen_stat = random.choice(list(StatType)) chosen_stat = random.choice(list(StatType))
else: else:
# favor the best stat so it will tend to clump # favor the best stat so it will tend to clump
t = sum(value**2 for _stat, value in self.stats) t = sum(self.stats[stat] ** 2 for stat in PRIME_STATS)
t = random.below(t) t = random.below(t)
chosen_stat = None chosen_stat = None
for stat, value in self.stats: for stat in PRIME_STATS:
chosen_stat = stat chosen_stat = stat
t -= value**2 t -= self.stats[stat] ** 2
if t < 0: if t < 0:
break break
+761 -775
View File
File diff suppressed because it is too large. Load diff
+976 -980
View File
File diff suppressed because it is too large. Load diff
+1106 -1110
View File
File diff suppressed because it is too large. Load diff
+18 -1
View File
@@ -1,7 +1,9 @@
import datetime import datetime
import pytest
from pqcli import random from pqcli import random
from pqcli.config import StatType from pqcli.config import PRIME_STATS, StatType
from pqcli.game_data import load_game_data from pqcli.game_data import load_game_data
from pqcli.mechanic import Player, Simulation, Stats, level_up_time from pqcli.mechanic import Player, Simulation, Stats, level_up_time
@@ -36,3 +38,18 @@ def test_quest_length_matches_upstream() -> None:
lengths.add(simulation.player.quest_book.quest_bar.max_) lengths.add(simulation.player.quest_book.quest_bar.max_)
assert min(lengths) == 50 assert min(lengths) == 50
assert max(lengths) == 149 assert max(lengths) == 149
def test_weighted_stat_gain_skips_hp_and_mp(
monkeypatch: pytest.MonkeyPatch,
) -> None:
# the "favor the best stat" branch only covers prime stats, pq-web 48c42e6
monkeypatch.setattr(random, "odds", lambda chance, out_of: False)
random.seed("stats")
player = make_simulation().player
player.stats.increment(StatType.hp_max, 1000)
for _ in range(500):
player.win_stat()
assert player.stats[StatType.hp_max] == 1010
assert player.stats[StatType.mp_max] == 10
assert sum(player.stats[stat] for stat in PRIME_STATS) == 60 + 500