python -m pip install -r requirements.txt
python -m uvicorn main:app --reload
python -m unittest discover tests/
- All tests using the FastAPI test client should extend the TestCaseFastAPI class
There's a set of x,y coordinates assigned to every square in the board. If a player steps into a square that leads to a room, that player is considered to be in that room. Invalid squares (i.e, the square (1,1)) are set as null.
Lobby:
{'name': str, 'host': str, 'current_players': int, 'players': [str] }
Match:
{'name': self.name, 'players': [str], 'turn': str, 'player_positions': [{pos_x: <int>, pos_y: <int>, player_name: <string>}]}
Card:
{'type': CardType, 'name': str}
CardType = {MONSTER, VICTIM, ROOM, SALEM_WITCH}
Error:
{'action': 'failed', 'info': str}
- All endpoints return Error if there was one
Takes:
{'action': 'lobby_join', 'player_name': str, 'lobby_name': str}
Returns:
To sender
{'action': 'joined_lobby', 'lobby': Lobby }
To other players in the room
{'action': 'new_player', 'player_name': str}
Takes: {'action': 'lobby_create', 'player_name': str, 'lobby_name': str}
Returns:
{'action': 'new_lobby', 'lobby': Lobby}
Takes:
{'action': 'lobby_leave', 'player_name': <str>, 'lobby_name': <str>}
Returns:
{'action': 'player_left', 'player_name': <str>}
Takes:
{'action': 'lobby_start_match', 'player_name': str, 'lobby_name': str}
Returns:
{'action': 'match_started', 'match': Match }
Takes:
{'action': 'match_roll_dice', 'match_name': str}
Returns:
To every player in the match
{'action': 'roll_dice', 'dice': int}
Description: Returns an array of the specified player's cards
Takes:
{'action': 'match_get_hand', 'player_name': str, 'match_name': str}
Returns:
To sender
{'action': 'get_hand', 'hand': [Card]}
Description: Allows the player to use the witch of salem, then removes
Takes:
{'action': 'match_use_witch', 'player_name': str, 'match_name': str, card_type: CardType}
Returns:
To sender
{'action': 'mystery_card', 'card': Card}
Description: Ends player's turn, returns whose turns it is next
Takes:
{'action': 'match_end_turn', 'match_name': str}
Returns:
To every player in the match
{'action': 'turn_passed', 'current_turn': str}
Takes:
{'action': 'match_move', 'match_name': <str>, 'pos_x': <int>, 'pos_y': <int>}
Returns:
To every player in the match
{'action': 'player_position', 'pos_x': <int>, 'pos_y': <int>, 'square': <str>}
Takes:
{'action': 'match_accuse', 'match_name': <str>, 'monster': <str>, 'victim': <str>, 'room': <str>}
Returns:
To sender
- In victory
{'action': 'game_over', 'winner': <str>}
- In defeat
{'action': 'player_deleted', 'loser': <str>}
Takes:
{'action': 'match_suspect', 'player_name': <str>, 'match_name': <str>, 'monster': <str>, 'victim': <str>, 'room': <str>}
Returns:
To next player
{'action': 'question', 'monster': <str>, 'victim': <str>, 'room': <str>}
Takes:
- Affirmative response (when the player has a card)
{'action': 'match_question_res', 'response': 'affirmative', 'player_name': <str>, 'reply_to': <str>, 'match_name': <str>, 'reply_card': <str>}
- Negative response (when the player hasn't a card)
{'action': 'match_question_res', 'response': 'negative', 'player_name': <str>, 'reply_to': <str>, 'match_name': <str>, 'reply_card': <str>, 'monster': <str>, 'victim': <str>, 'room': <str>'}
Returns:
If the next player is not the one who made the suspect:
{'action': 'question', 'monster': monster, 'victim': victim, 'room': room}
If the next player is the one who made the suspect:
{'action': 'suspect_response', 'card': <str>}