Quiiz system

This commit is contained in:
2026-07-26 16:46:41 +02:00
parent 7f17d69f5c
commit 4780016980
192 changed files with 15031 additions and 566 deletions
+56 -3
View File
@@ -195,7 +195,9 @@ def test_yield_perk_and_prestige_boost_harvest_coins(local_db):
_warp(user)
result = store.harvest(user, 0)
crop = economy.crop_for("shell")
assert result["coins"] == economy.effective_reward_coins(crop, 4, 1)
assert result["coins"] == economy.realizable_harvest_coins(
crop, 4, 1, golden=result["golden"]
)
assert result["coins"] > crop.reward_coins
@@ -599,7 +601,7 @@ def _ripen_past_grace(user, slot=0):
)
def test_steal_transfers_coins_and_clears_plot(local_db):
def test_steal_transfers_a_share_and_leaves_the_build(local_db):
owner = _reset("unit_owner")
thief = _reset("unit_thief", coins=0)
store.plant(owner, 0, "shell")
@@ -608,7 +610,57 @@ def test_steal_transfers_coins_and_clears_plot(local_db):
assert result["coins"] > 0
assert _coins(thief) == result["coins"]
farm = store.get_farm(owner["uid"])
assert (store._plot_at(farm["uid"], 0).get("crop_key") or "") == ""
plot = store._plot_at(farm["uid"], 0)
assert (plot.get("crop_key") or "") == "shell"
assert 0 < float(plot.get("raided_fraction") or 0) <= 1.0
def test_owner_still_harvests_the_unraided_remainder(local_db):
owner = _reset("unit_owner")
thief = _reset("unit_thief", coins=0)
store.plant(owner, 0, "shell")
_ripen_past_grace(owner)
before = _coins(owner)
stolen = store.steal(thief, owner, 0)["coins"]
result = store.harvest(owner, 0)
harvested = result["coins"]
assert harvested > 0
assert _coins(owner) == before + harvested
full = economy.realizable_harvest_coins(
economy.crop_for("shell"), golden=result["golden"]
)
assert harvested + stolen <= full
def test_steal_blocked_once_the_build_is_fully_stripped(local_db):
owner = _reset("unit_owner")
store.plant(owner, 0, "shell")
_ripen_past_grace(owner)
farm = store.get_farm(owner["uid"])
plot = store._plot_at(farm["uid"], 0)
get_table("game_plots").update(
{"uid": plot["uid"], "raided_fraction": 1.0}, ["uid"]
)
thief = _reset("unit_thief", coins=0)
with pytest.raises(GameError):
store.steal(thief, owner, 0)
def test_steal_capped_per_victim_per_day(local_db):
owner = _reset("unit_owner")
store.plant(owner, 0, "shell")
_ripen_past_grace(owner)
for index in range(economy.STEAL_MAX_PER_VICTIM_PER_DAY):
thief = _reset(f"unit_thief_{index}", coins=0)
store.steal(thief, owner, 0)
farm = store.get_farm(owner["uid"])
plot = store._plot_at(farm["uid"], 0)
get_table("game_plots").update(
{"uid": plot["uid"], "raided_fraction": 0.0}, ["uid"]
)
blocked = _reset("unit_thief_last", coins=0)
with pytest.raises(GameError):
store.steal(blocked, owner, 0)
def test_steal_protected_within_grace(local_db):
@@ -631,6 +683,7 @@ def test_steal_cooldown_blocks_second_raid(local_db):
store.plant(owner, 0, "shell")
_ripen_past_grace(owner)
store.steal(thief, owner, 0)
store.harvest(owner, 0)
store.plant(owner, 0, "shell")
_ripen_past_grace(owner)
with pytest.raises(GameError):