Skip to content

Commit

Permalink
Merge pull request #61 from TukiLaCosa/hotfix-change-places
Browse files Browse the repository at this point in the history
Hotfix change places
  • Loading branch information
ezeluduena authored Nov 12, 2023
2 parents 3d0bedb + 46089d1 commit 3d869db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 15 additions & 9 deletions app/routers/games/action_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ async def send_players_chagnge_event(game: Game, player_id: int, objective_playe
"player_id": player_id,
"objective_player_id": objective_player_id
}
await player_connections.send_event_to_other_players_in_game(game.name, json_msg, player_id)
await player_connections.send_event_to_all_players_in_game(game.name, json_msg)


async def send_players_exchagnge_event(game: Game, player_id: int, objective_player_id: int):
json_msg = {
"event": Events.EXCHANGE_DONE,
"player_id": player_id,
"objective_player_id": objective_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_other_players_in_game(game.name, json_msg, player_id)
await player_connections.send_event_to_all_players_in_game(game.name, json_msg)


async def send_resolute_card_played_event(game: Game, player_id: int, option_cards: list[int]):
Expand Down Expand Up @@ -88,6 +88,10 @@ def process_flamethrower_card(game: Game, player: Player, objective_player: Play
p.position -= 1
objective_player.position = -1

# Reacomodo el turno
if game.turn != 0 and objective_player.position < player.position:
game.turn = game.turn - 1

asyncio.ensure_future(send_players_eliminated_event(game=game,
killer_id=player.id,
killer_name=player.name,
Expand Down Expand Up @@ -161,6 +165,7 @@ def process_change_places_card(game: Game, player: Player, objective_player: Pla
tempPosition = player.position
player.position = objective_player.position
objective_player.position = tempPosition
game.turn = player.position

asyncio.ensure_future(send_players_chagnge_event(
game, player.id, objective_player.id))
Expand All @@ -171,6 +176,7 @@ def process_better_run_card(game: Game, player: Player, objective_player: Player
tempPosition = player.position
player.position = objective_player.position
objective_player.position = tempPosition
game.turn = player.position

asyncio.ensure_future(send_players_chagnge_event(
game, player.id, objective_player.id))
Expand All @@ -194,9 +200,6 @@ def process_card_exchange(game : Game ,player: Player, objective_player: Player,
objective_player.hand.remove(objective_player_card)
objective_player.hand.add(player_card)

asyncio.ensure_future(send_players_exchagnge_event(
game, player.id, objective_player.id))


@db_session
def process_seduction_card(game: Game, player: Player, objective_player: Player,
Expand All @@ -209,5 +212,8 @@ def process_seduction_card(game: Game, player: Player, objective_player: Player,
process_card_exchange(game, player, objective_player,
card_to_exchange, random_card)

asyncio.ensure_future(send_seduction_done_event(
player.id, objective_player.id))
asyncio.ensure_future(send_players_exchagnge_event(
game, player.id, objective_player.id))

# asyncio.ensure_future(send_seduction_done_event(
# player.id, objective_player.id))
3 changes: 0 additions & 3 deletions app/routers/games/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ def play_action_card(game_name: str, play_info: PlayInformation):
objective_player: Player = find_player_by_id(
play_info.objective_player_id)

if game.turn != 0 and objective_player.position < player.position:
game.turn = game.turn - 1

create_intention_in_game(
game, ActionType.FLAMETHROWER, player, objective_player)

Expand Down

0 comments on commit 3d869db

Please sign in to comment.