Skip to content

Commit

Permalink
correccion en card-interchange-response
Browse files Browse the repository at this point in the history
  • Loading branch information
anelioalvarez committed Nov 12, 2023
1 parent fe0aa5c commit c9dde31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions app/routers/games/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,19 @@ async def card_interchange_response(game_name: str, game_data: InterchangeInform
utils.verify_if_interchange_response_can_be_done(game_name, game_data)
services.card_interchange_response(game_name, game_data)

with db_session:
game: Game = find_game_by_name(game_name)
# with db_session:
# game: Game = find_game_by_name(game_name)

intention: Intention = get_intention_in_game(game_name)
# intention: Intention = get_intention_in_game(game_name)

player = find_player_by_id(intention.player.id)
objective_player = find_player_by_id(intention.objective_player.id)
# player = find_player_by_id(intention.player.id)
# objective_player = find_player_by_id(intention.objective_player.id)

player_card = find_card_by_id(intention.exchange_payload['card_id'])
objective_player_card = find_card_by_id(game_data.card_id)
# player_card = find_card_by_id(intention.exchange_payload['card_id'])
# objective_player_card = find_card_by_id(game_data.card_id)

process_card_exchange(game, player, objective_player,
player_card, objective_player_card)
# process_card_exchange(game, player, objective_player,
# player_card, objective_player_card)

clean_intention_in_game(game_name)

Expand Down
2 changes: 0 additions & 2 deletions app/routers/games/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ class InterchangeInformationIn(BaseModel):

player_id: int # ID jugador que recibe la intencion
card_id: int # Card ID del jugador que recibe la intencion
objective_player_id: int # ID jugador que inicia la intencion
objective_card_id: int # Card ID del jugador que inicia la intencion


class ResoluteExchangeIn(BaseModel):
Expand Down
7 changes: 4 additions & 3 deletions app/routers/games/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .panic_functions import *
import random
from app.routers.games import utils
from .intention import create_intention_in_game, ActionType
from .intention import create_intention_in_game, ActionType, get_intention_in_game


def get_unstarted_games() -> List[GameResponse]:
Expand Down Expand Up @@ -555,9 +555,10 @@ def register_card_exchange_intention(game_name: str, player_id: int, card_id: in
@db_session
def card_interchange_response(game_name: str, game_data: InterchangeInformationIn):
game: Game = find_game_by_name(game_name)
player: Player = find_player_by_id(game_data.objective_player_id)
intention: Intention = get_intention_in_game(game_name)
player: Player = intention.objective_player
player_card: Card = cards_services.find_card_by_id(
game_data.objective_card_id)
intention.exchange_payload['card_id'])

next_player: Player = find_player_by_id(game_data.player_id)
next_player_card: Card = cards_services.find_card_by_id(game_data.card_id)
Expand Down

0 comments on commit c9dde31

Please sign in to comment.