Ejemplo n.º 1
0
 def test_discard_question_cards(self):
     state = GameState()
     state.question_cards = [(2, 'H'), (7, 'H'), (5, '$')]
     state.discard_deck = []
     discard_question_cards(state.question_cards, state.discard_deck)
     self.assertEqual([(2, 'H'), (7, 'H'), (5, '$')], state.discard_deck)
     self.assertEqual([], state.question_cards)
Ejemplo n.º 2
0
    def test_draw_question_cards_when_there_are_not_enough_cards_in_the_interrogation_deck(self):
        state = GameState()
        state.interrogation_deck = [(4, 'L')]
        state.discard_deck = [(3, '$'), (6, 'H'), (7, 'L')]

        draw_question_cards(state)
        self.assertEqual(3, len(state.question_cards))
        self.assertIn((4, 'L'), state.question_cards)
        self.assertEqual(0, len(state.discard_deck))
        self.assertEqual(1, len(state.interrogation_deck))
Ejemplo n.º 3
0
def main():
    print 'Welcome to Deduce or Die! IA'
    print
    nb_players = ask_for('Number of players : ', int, ['3', '4', '5', '6'])
    human_player_name = ask_for('Type your name : ')

    state = GameState()

    players, state.human_player = prepare_players(nb_players, human_player_name)
    state.players = players

    motive_deck = prepare_game_deck(nb_decks=1)

    state.interrogation_deck = prepare_game_deck(nb_decks=2)
    state.discard_deck = []

    state.evidence_cards = [motive_deck.pop(), motive_deck.pop()]

    deal_deck(motive_deck, players)

    assert len(motive_deck) <= 1

    if len(motive_deck) == 1:
        state.extra_card = motive_deck[0]
    else:
        state.extra_card = None

    for player in state.players:
        if not player.is_human():
            player.setup_ai(state)

    print_summary(state)

    determine_low_suit(state)
    print
    print_low_suit(players)

    state.turn = 1
    while state.status != 'ended':
        play_turn(state)

    end_game_summary(state)
    print