Streamline dead Pi-Rat rank voting

Dead and awaiting-recruit Pi-Rats can no longer be nominated to rank up
(they'd reset to Rank 1 anyway). submit_rank_vote rejects them, and the
upkeep dropdown only lists living, in-play crewmates via the shared
eligible_vote_nominees helper.

When a voter has no eligible nominees (e.g. a lone survivor whose only
crewmates are the previous Deep and a dead rat) they now skip voting
entirely and can ready up directly, instead of deadlocking — which is
why dead players were previously left nominable. The roster shows such
players as "No vote".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 21:21:38 -07:00
parent 345ef4088f
commit d04e5013fa
4 changed files with 78 additions and 15 deletions

View File

@@ -1048,6 +1048,39 @@ def test_vote_validation(session):
ok, msg = crud.submit_rank_vote(session, game.id, p1.id, p2.id)
assert ok
# Dead and awaiting-recruit Pi-Rats can't be nominated
p3.is_dead = True
session.add(p3)
session.commit()
ok, msg = crud.submit_rank_vote(session, game.id, p1.id, p3.id)
assert not ok
p3.is_dead = False
p3.needs_reroll = True
session.add(p3)
session.commit()
ok, msg = crud.submit_rank_vote(session, game.id, p1.id, p3.id)
assert not ok
def test_vote_skips_when_only_dead_options(session):
# 3-player crew, one living Pi-Rat whose only crewmates are the previous
# Deep and a dead rat: they have no eligible nominee and skip voting.
game = crud.create_game(session)
deep = crud.add_player(session, game.id, "Deep")
living = crud.add_player(session, game.id, "Living")
dead = crud.add_player(session, game.id, "Dead")
deep.role = "deep"
living.role = "pirat"
dead.role = "pirat"
dead.is_dead = True
session.add_all([deep, living, dead])
session.commit()
# The living Pi-Rat has no one valid to nominate
assert crud.eligible_vote_nominees(game, living) == []
# The Deep can still nominate the living Pi-Rat
nominees = crud.eligible_vote_nominees(game, deep)
assert [p.id for p in nominees] == [living.id]
def test_rank_up_draws_immediately(session):
game, deep, (p2, p3) = make_scene_game(session, num_pirats=2)
# p2 is rank 1 (lowest -> max 2), p3 is rank 2 (highest -> max 4)