Fable will fix it! Pt 3

This commit is contained in:
2026-06-12 01:13:11 -07:00
parent 6dcb2a9ae9
commit 3a00774b50
21 changed files with 259 additions and 56 deletions

View File

@@ -756,6 +756,97 @@ def test_gat_tax_refuse_and_fail(session):
assert p2.rank == p2_start_rank
assert p2.tax_banned
def test_name_tax_refuse_steals_name_string(session):
game, deep, (p2, p3) = make_scene_game(session, num_pirats=2)
obs = game.obstacles[0]
obs.current_value = 13
# p2 has a gat but no Name; p3 has both and a fancy name
p2.completed_personal_1 = True
p2.avatar_smell = "smells like burnt cheese"
p3.completed_personal_1 = True
p3.completed_personal_2 = True
p3.name = "Bloodfang the Unforgiven"
p3.avatar_smell = "faintly of gunpowder"
p2.hand_cards = json.dumps(["2C"])
session.add_all([obs, p2, p3])
session.commit()
ok, msg = crud.create_challenge(session, game.id, deep.id, p2.id, [obs.id])
assert ok
session.refresh(game)
challenge = game.challenges[0]
ok, msg = crud.request_tax(session, challenge.id, p2.id, p3.id)
assert ok, msg
assert challenge.tax_type == "name"
ok, msg = crud.respond_tax(session, challenge.id, p3.id, accept=False)
assert ok
session.refresh(p2)
session.refresh(p3)
# The name string itself is stolen; the refuser is demoted to their smell
assert p2.name == "Bloodfang the Unforgiven"
assert p2.completed_personal_2
assert not p2.needs_name
assert p3.name == "Recruit Gunpowder"
assert not p3.completed_personal_2
# The thief fails the challenge: the name returns and the thief is demoted
ok, msg, res = crud.play_challenge_card(session, p2.id, obs.id, "2C")
assert ok and not res["success"]
ok, msg = crud.resolve_challenge(session, challenge.id, deep.id)
assert ok
session.refresh(p2)
session.refresh(p3)
assert p3.name == "Bloodfang the Unforgiven"
assert p3.completed_personal_2
assert p2.name == "Recruit Burnt cheese"
assert not p2.completed_personal_2
assert p2.tax_banned
def test_name_tax_refuse_success_keeps_stolen_name(session):
game, deep, (p2, p3) = make_scene_game(session, num_pirats=2)
obs = game.obstacles[0]
obs.current_value = 1
p2.completed_personal_1 = True
p2.avatar_smell = "old rum"
p3.completed_personal_1 = True
p3.completed_personal_2 = True
p3.name = "Captain Calculus"
p3.avatar_smell = "chalk dust"
p2.hand_cards = json.dumps(["10C"])
session.add_all([obs, p2, p3])
session.commit()
ok, _ = crud.create_challenge(session, game.id, deep.id, p2.id, [obs.id])
assert ok
session.refresh(game)
challenge = game.challenges[0]
ok, _ = crud.request_tax(session, challenge.id, p2.id, p3.id)
assert ok
ok, _ = crud.respond_tax(session, challenge.id, p3.id, accept=False)
assert ok
ok, msg, res = crud.play_challenge_card(session, p2.id, obs.id, "10C")
assert ok and res["success"]
ok, _ = crud.resolve_challenge(session, challenge.id, deep.id)
assert ok
session.refresh(p2)
session.refresh(p3)
# Success: the stolen name stays stolen
assert p2.name == "Captain Calculus"
assert p2.completed_personal_2
assert p3.name == "Recruit Chalk dust"
assert not p3.completed_personal_2
def test_recruit_name_helper():
assert crud.recruit_name_from_smell("smells like burnt cheese") == "Recruit Burnt cheese"
assert crud.recruit_name_from_smell("faintly of gunpowder") == "Recruit Gunpowder"
assert crud.recruit_name_from_smell("") == "Recruit"
assert crud.recruit_name_from_smell("", fallback="Tim") == "Recruit Tim"
def test_pvp_challenge(session):
game, deep, (p2, p3) = make_scene_game(session, num_pirats=2)
p2.hand_cards = json.dumps(["7C"])