From 86f4e1709129d5918a7782f5bb59a7ca3cb15001 Mon Sep 17 00:00:00 2001 From: ezeluduena Date: Wed, 8 Nov 2023 16:24:08 -0300 Subject: [PATCH] =?UTF-8?q?=C3=9Altimo=20infectado=20pierde=20al=20finaliz?= =?UTF-8?q?ar=20partida?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/database/models.py | 4 ++++ app/routers/games/services.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/database/models.py b/app/database/models.py index 1518fe3..fa1daea 100644 --- a/app/database/models.py +++ b/app/database/models.py @@ -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): @@ -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): diff --git a/app/routers/games/services.py b/app/routers/games/services.py index 8fdd920..4e41498 100644 --- a/app/routers/games/services.py +++ b/app/routers/games/services.py @@ -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: