ipdatepppdate

This commit is contained in:
2026-07-26 16:46:41 +02:00
parent 2620ecc0f1
commit ac04cf6817
30 changed files with 915 additions and 10309 deletions
+49 -5
View File
@@ -371,6 +371,7 @@ def _insert_quest(user, kind, goal, progress=0, claimed=0, reward_coins=50, rewa
"user_uid": user["uid"],
"day": store._today(),
"slot_index": 0,
"scope": "daily",
"kind": kind,
"label": f"{kind} {goal}",
"goal": goal,
@@ -723,7 +724,9 @@ def test_harvest_records_market_tick_and_saturates_reward(local_db):
from devplacepy.utils import generate_uid
now = datetime.now(timezone.utc)
worst_tier_count = economy.MARKET_SATURATION_TIERS[-1][0]
crop = economy.crop_for("shell")
worst_days = economy.MARKET_SATURATION_TIERS[-1][0]
worst_tier_count = int(worst_days * 86400 / crop.grow_seconds) + 1
get_table("game_market_ticks").insert(
{
"uid": generate_uid(),
@@ -735,11 +738,52 @@ def test_harvest_records_market_tick_and_saturates_reward(local_db):
)
store.plant(user, 0, "shell")
_warp(user)
crop = economy.crop_for("shell")
result = store.harvest(user, 0)
assert result["coins"] < crop.reward_coins
def _seed_market_ticks(crop_key, harvests):
from devplacepy.services.game.store import market as market_store
from devplacepy.utils import generate_uid
now = datetime.now(timezone.utc)
get_table("game_market_ticks").insert(
{
"uid": generate_uid(),
"crop_key": crop_key,
"hour_bucket": market_store._hour_bucket(now),
"harvests": harvests,
"updated_at": now.isoformat(),
}
)
market_store._saturation_cache.clear()
def _worst_tier_harvests(crop_key):
crop = economy.crop_for(crop_key)
worst_days = economy.MARKET_SATURATION_TIERS[-1][0]
return int(worst_days * 86400 / crop.grow_seconds) + 1
def test_starter_crop_boosted_when_market_saturated(local_db):
_reset("unit_a")
from devplacepy.services.game.store import market as market_store
_seed_market_ticks("kernel", _worst_tier_harvests("kernel"))
assert market_store.market_factor_for("kernel") == economy.MARKET_SATURATION_TIERS[-1][1]
assert market_store.market_factor_for("shell") == economy.MARKET_BUFF_CAP
assert market_store.market_factor_for("rust") == 1.0
def test_own_saturation_beats_boost(local_db):
_reset("unit_a")
from devplacepy.services.game.store import market as market_store
_seed_market_ticks("kernel", _worst_tier_harvests("kernel"))
_seed_market_ticks("shell", _worst_tier_harvests("shell"))
assert market_store.market_factor_for("shell") == economy.MARKET_SATURATION_TIERS[-1][1]
def test_harvest_records_a_market_tick_for_its_own_crop(local_db):
user = _reset("unit_a")
store.plant(user, 0, "shell")
@@ -952,11 +996,11 @@ def test_end_era_awards_stars_to_top_participant(local_db):
user = _reset("unit_era_top")
store.start_era("TestEra", 7)
_set(user, era_coins=50000, era_harvests=10)
before_stars = int(store.get_farm(user["uid"])["stars"])
before_stars = int(store.get_farm(user["uid"])["stars"] or 0)
store.end_era()
farm = store.get_farm(user["uid"])
assert int(farm["stars"]) > before_stars
assert int(farm["era_coins"]) == 0
assert int(farm["stars"] or 0) > before_stars
assert int(farm["era_coins"] or 0) == 0
def test_era_gates_new_crops_and_leaderboard(local_db):