def process(self): current_room_id = self._player.get_current_room() current_room = self._game.get_room(current_room_id) if current_room: cards_parsing = [] try: for arg in self._arguments: value = int(arg) if value in range(0,52): cards_parsing.append(value) else: raise(Exception('Invalid card\'s value')) if len(cards_parsing) != 52: raise(Exception('Invalid deck length')) deck = Deck() deck.set_card_list(cards_parsing) current_room.debug_only_set_deck(deck) self._game.send_output(self._player, 'DEBUGDEAL 00') except: self._game.send_output(self._player, 'DEBUGDEAL 02') return False #current_room.ready(self._player) return True else: self._game.send_output(self._player, 'DEBUGDEAL 01') return False
def test_play_and_part(self): username1 = 'onlylinh1' username2 = 'onlylinh2' username3 = 'onlylinh3' username4 = 'onlylinh4' command = {"command":'join', "arguments":[100]} command_str = json.dumps(command) self._process_message(username1, command_str) self._process_message(username2, command_str) self._process_message(username3, command_str) self._process_message(username4, command_str) cardset1 = [46,49,25,6,33,35,39,37,20,12,8,32,48] cardset2 = [24,34,40,17,3,1,4,9,44,45,47,14,15] cardset3 = [2,0,23,10,31,28,27,26,5,43,16,18,42] cardset4 = [51,50,41,36,38,29,30,22,13,7,11,19,21] card_list_test = mix_card_set([cardset1, cardset2, cardset3, cardset4]) custom_deck = Deck() custom_deck.set_card_list(card_list_test) room_id = self._game.get_player(username1).get_current_room() room_instance = self._game.get_room(room_id) room_instance.debug_only_set_deck(custom_deck) command = {"command":'ready', "arguments":[]} command_str = json.dumps(command) self._process_message(username1, command_str) self._process_message(username2, command_str) self._process_message(username3, command_str) self._process_message(username4, command_str) command = {"command":'part', "arguments":[]} command_str = json.dumps(command) self._process_message(username3, command_str) command = {"command":'submit', "arguments": cardset1} command_str = json.dumps(command) self._process_message(username1, command_str) command = {"command":'submit', "arguments": cardset2} command_str = json.dumps(command) self._process_message(username2, command_str) #command = {"command":'submit', "arguments": cardset3} #command_str = json.dumps(command) #self._process_message(username3, command_str) command = {"command":'submit', "arguments": cardset4} command_str = json.dumps(command) self._process_message(username4, command_str)