Skip to content

Commit

Permalink
Último infectado pierde al finalizar partida
Browse files Browse the repository at this point in the history
  • Loading branch information
ezeluduena committed Nov 8, 2023
1 parent acbb683 commit 86f4e17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Player(db.Entity):
hand = Set('Card')
intention_creator = Optional('Intention', reverse='player')
intention_objective = Optional('Intention', reverse='objective_player')
game_last_infected = Optional(
'Game', reverse='last_infected', nullable=True)


class Game(db.Entity):
Expand All @@ -30,6 +32,8 @@ class Game(db.Entity):
draw_deck_order = Required(Json, default=[])
round_direction = Required(str, default=RoundDirection.CLOCKWISE)
intention = Optional('Intention', reverse='game')
last_infected = Optional(
Player, reverse='game_last_infected', nullable=True)


class Card(db.Entity):
Expand Down
4 changes: 3 additions & 1 deletion app/routers/games/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,13 @@ def get_game_result(name: str) -> GameResult:
lambda p: p.rol != PlayerRol.THE_THING)[:]

elif no_human_remains(game):
reason = "No queda ningún Humano en la partida."
reason = '''No queda ningún Humano en la partida. Todos fueron infectados o eliminados.
Pierden los eliminados y el último infectado.'''
winners = game.players.select(
lambda p: p.rol in [PlayerRol.THE_THING, PlayerRol.INFECTED])[:]
losers = game.players.select(
lambda p: p.rol == PlayerRol.ELIMINATED)[:]
losers.append(game.last_infected)

# elif the_thing_declared_a_wrong_victory(game):
else:
Expand Down

0 comments on commit 86f4e17

Please sign in to comment.