forked from retoor/devplacepy
Quiiz system
This commit is contained in:
@@ -270,7 +270,7 @@ def test_market_buff_factor_only_applies_to_starter_crops():
|
||||
|
||||
def test_market_factor_bounds_across_domain():
|
||||
floor = economy.MARKET_SATURATION_TIERS[-1][1]
|
||||
for key in economy.MARKET_TRACKED_CROPS:
|
||||
for key in economy.MARKET_BUFFED_CROPS + economy.MARKET_PRESSURE_CROPS:
|
||||
crop = economy.crop_for(key)
|
||||
for harvests in range(0, 300000, 977):
|
||||
saturation = economy.market_saturation_factor(economy.supply_days(crop, harvests))
|
||||
@@ -365,11 +365,13 @@ def test_cosmetic_title_name_only_resolves_titles():
|
||||
|
||||
|
||||
def test_mastery_points_awarded_first_point_at_unlock():
|
||||
assert economy.mastery_points_awarded(49, 50) == 1
|
||||
assert economy.mastery_points_awarded(0, 49) == 0
|
||||
assert economy.mastery_points_awarded(55, 56) == 0
|
||||
assert economy.mastery_points_awarded(59, 60) == 1
|
||||
assert economy.mastery_points_awarded(50, 70) == 2
|
||||
step = economy.MASTERY_PRESTIGE_STEP
|
||||
unlock = economy.MASTERY_UNLOCK_PRESTIGE
|
||||
assert economy.mastery_points_awarded(unlock - 1, unlock) == 1
|
||||
assert economy.mastery_points_awarded(0, unlock - 1) == 0
|
||||
assert economy.mastery_points_awarded(unlock, unlock + step - 1) == 0
|
||||
assert economy.mastery_points_awarded(unlock + step - 1, unlock + step) == 1
|
||||
assert economy.mastery_points_awarded(unlock, unlock + step * 2) == 2
|
||||
|
||||
|
||||
def test_mastery_for_known_and_unknown():
|
||||
@@ -490,12 +492,182 @@ def test_refactor_carryover_zero_when_unaffordable():
|
||||
def test_grant_amount_capped_and_bounded():
|
||||
assert economy.grant_amount(0) == 0
|
||||
assert economy.grant_amount(-10) == 0
|
||||
assert economy.grant_amount(100) == 100
|
||||
assert economy.grant_amount(100) == 0
|
||||
assert economy.grant_amount(economy.GRANT_MIN_AMOUNT) == economy.GRANT_MIN_AMOUNT
|
||||
assert economy.grant_amount(10**9) == economy.GRANT_CAP
|
||||
|
||||
|
||||
def test_grant_amount_shares_between_eligible_farms():
|
||||
assert economy.grant_amount(10_000, 5) == 2_000
|
||||
assert economy.grant_amount(10**9, 4) == economy.GRANT_CAP
|
||||
assert economy.grant_amount(1_000, 10) == 0
|
||||
for eligible in range(1, 50):
|
||||
share = economy.grant_amount(10**6, eligible)
|
||||
assert 0 <= share <= economy.GRANT_CAP
|
||||
assert share * eligible <= 10**6 or share == economy.GRANT_CAP
|
||||
|
||||
|
||||
def test_legacy_carryover_upgrade_registered():
|
||||
upgrade = economy.legacy_for("carryover")
|
||||
assert upgrade is not None
|
||||
assert upgrade.max_level == 5
|
||||
assert upgrade.max_level == 10
|
||||
assert "carry-over" in economy.legacy_value_text(upgrade, 2)
|
||||
assert economy.refactor_carryover_fraction(upgrade.max_level) < 1.0
|
||||
|
||||
|
||||
def test_fertilize_is_never_profitable_across_the_input_domain():
|
||||
import itertools
|
||||
|
||||
for crop in economy.CROPS:
|
||||
for prestige in range(0, 201, 23):
|
||||
for yield_level in (0, 5, 10):
|
||||
for legacy in (0, 5, 10):
|
||||
for market in (0.40, 0.70, 1.0, 1.15):
|
||||
for golden, contract, underdog in itertools.product(
|
||||
(False, True), repeat=3
|
||||
):
|
||||
value = economy.realizable_harvest_coins(
|
||||
crop,
|
||||
yield_level,
|
||||
prestige,
|
||||
legacy,
|
||||
market,
|
||||
golden,
|
||||
contract,
|
||||
underdog,
|
||||
)
|
||||
cost = economy.fertilize_click_cost(
|
||||
value, crop.grow_seconds, crop.grow_seconds
|
||||
)
|
||||
assert cost >= value, (
|
||||
crop.key,
|
||||
prestige,
|
||||
golden,
|
||||
contract,
|
||||
underdog,
|
||||
cost,
|
||||
value,
|
||||
)
|
||||
|
||||
|
||||
def test_fertilize_priced_above_the_expected_canary_payout():
|
||||
for crop in economy.CROPS:
|
||||
for prestige in (0, 25, 100):
|
||||
plain = economy.realizable_harvest_coins(crop, 10, prestige, 10, 1.0)
|
||||
priced = economy.realizable_harvest_coins(
|
||||
crop, 10, prestige, 10, 1.0, canary=True
|
||||
)
|
||||
cost = economy.fertilize_click_cost(
|
||||
priced, crop.grow_seconds, crop.grow_seconds
|
||||
)
|
||||
expected = plain * (
|
||||
economy.CANARY_DOUBLE_CHANCE * 2
|
||||
+ (1 - economy.CANARY_DOUBLE_CHANCE - economy.CANARY_FAIL_CHANCE)
|
||||
) + economy.CANARY_FAIL_CHANCE * min(plain, crop.cost)
|
||||
assert cost >= expected
|
||||
|
||||
|
||||
def test_staged_fertilize_never_undercuts_the_payout():
|
||||
for key in ("shell", "api", "kernel", "secfort"):
|
||||
crop = economy.crop_for(key)
|
||||
value = economy.realizable_harvest_coins(crop, 10, 50, 10, 1.0, True, True, True)
|
||||
remaining, total = crop.grow_seconds, 0
|
||||
while True:
|
||||
reduce_by = int(remaining * economy.FERTILIZE_FRACTION)
|
||||
if reduce_by < 1:
|
||||
break
|
||||
total += economy.fertilize_click_cost(value, reduce_by, crop.grow_seconds)
|
||||
remaining -= reduce_by
|
||||
assert total >= value
|
||||
|
||||
|
||||
def test_every_defense_tier_reduces_the_raider_share():
|
||||
shares = []
|
||||
for tier in economy.DEFENSE_TIERS:
|
||||
share = economy.effective_steal_fraction(
|
||||
0, tier.steal_fraction_floor, tier.steal_reduction
|
||||
)
|
||||
shares.append(round(share, 4))
|
||||
assert len(set(shares)) == len(economy.DEFENSE_TIERS)
|
||||
assert shares == sorted(shares, reverse=True)
|
||||
|
||||
|
||||
def test_more_defense_never_increases_the_raider_share():
|
||||
previous = 1.0
|
||||
for tier in economy.DEFENSE_TIERS:
|
||||
for legacy in range(0, 6):
|
||||
share = economy.effective_steal_fraction(
|
||||
legacy, tier.steal_fraction_floor, tier.steal_reduction
|
||||
)
|
||||
assert 0.0 <= share <= 1.0
|
||||
top = economy.effective_steal_fraction(
|
||||
0, tier.steal_fraction_floor, tier.steal_reduction
|
||||
)
|
||||
assert top <= previous + 1e-9
|
||||
previous = top
|
||||
|
||||
|
||||
def test_observability_only_ever_lowers_the_raider_share():
|
||||
for tier in economy.DEFENSE_TIERS:
|
||||
for legacy in range(0, 6):
|
||||
without = economy.effective_steal_fraction(
|
||||
legacy, tier.steal_fraction_floor, tier.steal_reduction
|
||||
)
|
||||
with_suite = economy.effective_steal_fraction(
|
||||
legacy,
|
||||
tier.steal_fraction_floor,
|
||||
tier.steal_reduction,
|
||||
economy.OBSERVABILITY_STEAL_CAP,
|
||||
)
|
||||
assert with_suite <= without + 1e-9
|
||||
assert with_suite <= economy.OBSERVABILITY_STEAL_CAP + 1e-9
|
||||
|
||||
|
||||
def test_raid_share_plus_owner_remainder_never_exceeds_the_build():
|
||||
for crop in economy.CROPS:
|
||||
for prestige in range(0, 101, 17):
|
||||
for golden in (False, True):
|
||||
value = economy.realizable_harvest_coins(
|
||||
crop, 10, prestige, 10, 1.0, golden
|
||||
)
|
||||
for tier in economy.DEFENSE_TIERS:
|
||||
for legacy in range(0, 6):
|
||||
share = economy.effective_steal_fraction(
|
||||
legacy, tier.steal_fraction_floor, tier.steal_reduction
|
||||
)
|
||||
thief = min(max(1, round(value * share)), int(value * (1.0 - 0.0)))
|
||||
owner = int(value * (1.0 - share))
|
||||
assert thief + owner <= value
|
||||
|
||||
|
||||
def test_weekly_contract_stars_are_per_kind_not_per_goal():
|
||||
for kind in economy.QUEST_KINDS:
|
||||
for scale in (1.0, 13.5, 40.0):
|
||||
contract = economy.weekly_contract("user-a", "2026-W30", scale)
|
||||
if contract["kind"] != kind:
|
||||
continue
|
||||
assert contract["reward_stars"] == economy.QUEST_DEFS[kind].contract_stars
|
||||
assert contract["reward_stars"] <= 5
|
||||
|
||||
|
||||
def test_social_rewards_scale_with_the_earner_and_never_regress():
|
||||
assert economy.water_reward_coins(0, 0) == economy.WATER_REWARD_COINS
|
||||
assert economy.daily_reward(1) == economy.DAILY_BASE
|
||||
previous = 0
|
||||
for prestige in range(0, 101):
|
||||
reward = economy.water_reward_coins(prestige, 0)
|
||||
assert reward >= previous
|
||||
previous = reward
|
||||
|
||||
|
||||
def test_leaderboard_coin_contribution_is_capped():
|
||||
base = {"xp": 18050, "prestige": 50, "total_harvests": 5000, "ci_tier": 5}
|
||||
poor = economy.farm_score({**base, "coins": 0})
|
||||
rich = economy.farm_score({**base, "coins": 10**9})
|
||||
assert rich - poor <= economy.SCORE_COIN_CAP
|
||||
|
||||
|
||||
def test_market_saturation_is_per_capita():
|
||||
crop = economy.crop_for("kernel")
|
||||
assert economy.supply_days(crop, 288, 1) == economy.supply_days(crop, 2880, 10)
|
||||
assert economy.supply_days(crop, 288, 4) < economy.supply_days(crop, 288, 1)
|
||||
|
||||
Reference in New Issue
Block a user