예제 #1
0
 def __init__(self, hand: Hand, hand_dllnode: dllistnode,
              hand_pointer_nodes: List[HandPointerNode]) -> None:
     self.hand = Hand.copy(hand)
     self._num_cards_selected = 0
     self._card_nodes: List[CardNode] = list()
     for card, hand_pointer_node in zip(hand, hand_pointer_nodes):
         hand_pointer_node.set_hand_dllnode(hand_dllnode)
         card_node = CardNode(card, hand_pointer_node.hand_pointer_dllnode)
         self._card_nodes.append(card_node)
     self.store_hand()
예제 #2
0
def play_hand(hand: Hand, room: str, player_sid: str, name: str):
    hand_copy = Hand.copy(hand)
    hand_in_play_dict[room] = hand_copy
    client_update_hand_in_play(hand_copy, room)
    message_hand_played(hand_copy, room, name)
    card_hand_chamber = get_card_hand_chamber(player_sid)
    client_clear_current_hand(player_sid)
    winning_last_dict[room] = False
    # TODO: put this in a function called server clear current hand or something
    for card in hand_copy:
        card_hand_chamber.remove_card(card)
    consecutive_passes_dict[room] = 0
    next_player(room)
예제 #3
0
def store():
    """
    stores currently selected cards in a hand
    """
    player_sid = get_sid()
    hand = Hand.copy(get_current_hand(player_sid))
    if not hand.is_valid:
        alert_invalid_hand_storage()
        return
    elif hand.is_single:
        alert_single_storage()
        return
    card_hand_chamber = get_card_hand_chamber(player_sid)
    if card_hand_chamber.contains_hand(hand):
        alert_hand_already_stored()
        return
    client_clear_current_hand(player_sid)
    card_hand_chamber.add_hand(hand)