Skip to content

Commit

Permalink
arreglo intercambio y fin de partida
Browse files Browse the repository at this point in the history
  • Loading branch information
ezeluduena committed Nov 13, 2023
1 parent 375847d commit e6fcd5f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/routers/games/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async def card_interchange_response(game_name: str, game_data: InterchangeInform
with db_session:
json_msg = {
"event": utils.Events.EXCHANGE_DONE,
"player_name": get_player_name_by_id(game_data.player_id),
"player_name": get_player_name_by_id(player.id),
"objective_player_name": get_player_name_by_id(objective_player.id)
}
await player_connections.send_event_to_all_players_in_game(game_name, json_msg)
Expand Down
7 changes: 4 additions & 3 deletions app/routers/games/intention.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
)


async def send_intention_event(action_type: ActionType, objective_player: Player):
async def send_intention_event(action_type: ActionType, player: Player, objective_player: Player):
json_msg = {
"event": action_type,
"defense_cards": player_cards_to_defend_himself(action_type, objective_player)
"defense_cards": player_cards_to_defend_himself(action_type, objective_player),
"player_id": player.id
}

await player_connections.send_event_to(objective_player.id, json_msg)
Expand All @@ -33,7 +34,7 @@ def create_intention_in_game(game: Game, action_type: ActionType, player: Player
)
game.intention = intention

asyncio.ensure_future(send_intention_event(action_type, objective_player))
asyncio.ensure_future(send_intention_event(action_type, player, objective_player))

return intention

Expand Down
6 changes: 3 additions & 3 deletions app/routers/games/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def draw_card(game_name: str, game_data: DrawInformationIn) -> DrawInformationOu

@db_session
def get_game_result(name: str) -> GameResult:
game: Game = find_game_by_name(name)
game : Game = find_game_by_name(name)

if game.status != GameStatus.ENDED:
raise HTTPException(
Expand Down Expand Up @@ -435,8 +435,8 @@ def get_game_result(name: str) -> GameResult:
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 = list(game.players.select(
lambda p: p.rol == PlayerRol.ELIMINATED)[:])
losers.append(game.last_infected)

# elif the_thing_declared_a_wrong_victory(game):
Expand Down

0 comments on commit e6fcd5f

Please sign in to comment.