Esempio n. 1
0
def main():
    '''
    main execution loop
    '''
    
    number_of_players = get_number_of_players()
    player_colours = get_players(number_of_players)
    game = Game(player_colours)
    controlled_player = get_controlled_player(number_of_players)
    game.set_controlled_player(controlled_player)
    controlled_player_cards_held = game.get_number_of_cards_held(controlled_player-1)
    controlled_player_cards = get_controlled_player_cards(controlled_player_cards_held)
    game.set_player_cards_held(controlled_player, controlled_player_cards)
    
    guesser_player_index = 1
    
    #main play loop
    while (game.is_complete() is not True):
        
        play_string = get_next_play(guesser_player_index)
       
        
        if check_play_input(play_string):
            
            #response loop
            while True:
                responder_player_index = get_responding_player()
                
                if check_response_input(responder_player_index):
                    
                    if responder_player_index== controlled_player:
                        card_seen = get_cards_played(1)
                    else:
                        card_seen = None
                        
                    #play the turn
                    play = play_string.split(' ')
                    game.turn(guesser_player_index, play[0], play[1], play[2], responder_player_index, card_seen)
                    
                else:
                    print("Response was in an inconsistant format")
                    continue
                
                break
                
        else:
            print("Play was in an inconsistant format")
            continue
        
        # needs testing
        if guesser_player_index >= number_of_players:
            guesser_player_index = 1
        else:
            guesser_player_index += 1
            
    else:
        game.end()
Esempio n. 2
0
 def test_incorrect_player_card_number(self):
     players = [("white", 3), ("plum", 2)]
     test_game = Game(players)
     number_of_cards_held = test_game.get_number_of_cards_held(1)
     self.assertFalse(-1 == number_of_cards_held)
Esempio n. 3
0
 def test_correct_player_card_number_2(self):
     players = [("white", 3), ("plum", 2)]
     test_game = Game(players)
     number_of_cards_held = test_game.get_number_of_cards_held(1)
     self.assertEqual(2, number_of_cards_held)
Esempio n. 4
0
 def test_correct_player_card_setting_2(self):
     players = [("white", 6), ("plum", 2), ("scarlett", 6)]
     test_game = Game(players)
     test_game.set_player_cards_held(1, ["rope","wrench"])
     self.assertTrue(test_game.get_number_of_cards_held(1) == 2)    
Esempio n. 5
0
 def test_correct_player_card_setting_1(self):
     players = [("white", 6), ("plum", 6), ("scarlett", 6)]
     test_game = Game(players)
     test_game.set_player_cards_held(0, ["rope","wrench","revolver","plum","white","scarlett"])
     self.assertTrue(test_game.get_number_of_cards_held(0) == 6)