Esempio n. 1
0
 def test_remove_card_for_proclamation(self):
     coded_game_deck_example = 254779
     decoded_game_deck_example = hf.decode_deck(coded_game_deck_example)
     discarted_deck_example = decoded_game_deck_example
     discarted_deck_example.pop(0)
     coded_game_deck_example = hf.encode_deck(discarted_deck_example)
     result = coded_game_deck_example
     expected = 123707
     self.assertEqual(expected, result)
def get_three_cards(game_id: int):
    """
    Returns the three first cards of the deck
    """
    coded_game_deck = dbe.Game[game_id].game_board.board_deck_codification
    decoded_game_deck = hf.decode_deck(coded_game_deck)
    prophecy_cards = md.Prophecy(prophecy_card_0=decoded_game_deck[0],
                                 prophecy_card_1=decoded_game_deck[1],
                                 prophecy_card_2=decoded_game_deck[2])
    return prophecy_cards
def remove_card_for_proclamation(game_id: int):
    """
    Sets the new deck (discards de first card)
    """
    coded_game_deck = dbe.Game[game_id].game_board.board_deck_codification
    decoded_game_deck = hf.decode_deck(coded_game_deck)
    discarted_deck = decoded_game_deck
    upper_card = discarted_deck.pop(0)
    # Coded new board_deck for db
    coded_game_deck = hf.encode_deck(discarted_deck)
    dbe.Game[game_id].game_board.board_deck_codification = coded_game_deck
    return upper_card
def get_relative_game_information(user_id: int, game_id: int):
    current_player = get_player_from_game(user_id, game_id)
    current_game = dbe.Game[game_id]
    players = current_game.game_players
    playersDict = {}
    relative_roles = get_roles_relative_to_player(current_player.player_id,
                                                  game_id)
    for player in players:
        playersDict[player.player_nick] = {
            "nick": player.player_nick,
            "player_number": player.player_number,
            "connected": None,
            "role": relative_roles[player.player_nick],
            "is_alive": player.player_is_alive,
            "is_candidate": player.player_is_candidate,
            "has_voted": player.player_has_voted,
            "vote": player.player_vote,
            "icon": player.player_user.user_default_icon_id,
            "house": player.player_user.user_house
        }

    strmessage = current_player.player_last_message
    if (strmessage != ''):
        last_message = json.loads()
    else:
        last_message = {}

    returnDict = {
        "game_id": game_id,
        "game_step_turn": current_game.game_step_turn,
        "player_id": current_player.player_id,
        "player_nick": current_player.player_nick,
        "chat_blocked": current_player.player_chat_blocked,
        "current_minister": current_game.game_actual_minister,
        "current_director": current_game.game_candidate_director,
        "player_array": playersDict,
        "election_counter": current_game.game_failed_elections,
        "cards_in_deck": len(hf.decode_deck(get_coded_deck(game_id))),
        "proclaimed_phoenix": current_game.game_board.board_promulged_fenix,
        "proclaimed_death_eater":
        current_game.game_board.board_promulged_death_eater,
        "last_message": last_message
    }

    return returnDict
def discardCard(index: int, game_id: int, is_minister: bool,
                is_director: bool):
    """
    Return a list of deck without index card
    """
    coded_game_deck = dbe.Game[game_id].game_board.board_deck_codification
    decoded_game_deck = hf.decode_deck(coded_game_deck)
    discarted_deck = decoded_game_deck
    discarted_deck.pop(index - 1)  # Isnt it + 1?

    # Coded new board_deck for db
    coded_game_deck = hf.encode_deck(discarted_deck)
    dbe.Game[game_id].game_board.board_deck_codification = coded_game_deck

    if (is_minister):
        print(f"-> Minister: Card removed OK ≧◉ᴥ◉≦\n")
        return discarted_deck[:2]
    if (is_director):
        print(f"-> Director: Card removed OK ≧◉ᴥ◉≦\n")
        return discarted_deck[:1]
Esempio n. 6
0
 def test_decode_deck(self):
     deck_example = 254779
     result = hf.decode_deck(deck_example)
     expected = [1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1]
     self.assertEqual(expected, result)
def get_decoded_deck(coded_game_deck: int):
    return hf.decode_deck(coded_game_deck)
def get_amount_deck(game_id: int):
    coded_deck = dbe.Game[game_id].game_board.board_deck_codification
    return len(hf.decode_deck(coded_deck))