Exemplo n.º 1
0
    def test_load_deck_list(self):
        # John wants to calculate how often he will hit delirium off of a
        # turn 1 Vessel of Nascency in his GB Delirium deck.  To do this
        # he needs to load his deck list.
        gb_delirium = Deck()
        gb_delirium.load_text_list('D:\\code\\delirium\\tests\\test_data\\'
                                   'delirium.txt')

        # He knows the deck has sixty cards in it
        self.assertEqual(gb_delirium.size(), 60)

        # John then shuffles the deck
        gb_delirium.shuffle_deck()

        # John then draws 7 cards to his hand
        my_hand = Hand()

        my_hand.draw_starting_hand(gb_delirium)
        self.assertEqual(my_hand.size(), 7)

        # John realizes that he meant to get a a few specific cards in hand
        # first so he puts his hand back in the deck.

        count = 0
        while (my_hand.size() > 0) and (count < 400):
            my_hand.put_in_deck(my_hand.cards[0], gb_delirium)
            count += 1

        self.assertEqual(my_hand.size(), 0)

        # John gets a forest, swamp, and vessel in hand,
        # shuffles the deck, and then draws 4 more cards
        forest = CardMock(name='Forest', type='')
        swamp = CardMock(name='Swamp', type='')
        vessel = CardMock(name='Vessel of Nascency', type='')

        my_hand.get_card_from_deck(forest, gb_delirium)
        my_hand.get_card_from_deck(swamp, gb_delirium)
        my_hand.get_card_from_deck(vessel, gb_delirium)
        gb_delirium.shuffle_deck()
        my_hand.draw(4, gb_delirium)

        test_list = []
        for item in my_hand.cards:
            test_list.append(item.name)
        self.assertEqual(my_hand.size(), 7)
        self.assertIn(forest.name, test_list)
        self.assertIn(swamp.name, test_list)
        self.assertIn(vessel.name, test_list)

        # John plays the forest and the vessel on turn 1
        battlefield = []
        my_hand.play(forest, battlefield)
        my_hand.play(vessel, battlefield)

        self.assertEqual(my_hand.size(), 5)

        # On his next turn John draws a card, plays a swamp, and cracks the
        # Vessel choosing to put all cards in graveyard
        my_hand.draw(1, gb_delirium)
        my_hand.play(swamp, battlefield)

        self.assertEqual(my_hand.size(), 5)

        my_graveyard = Graveyard()

        for item in battlefield:
            if item.name == vessel.name:
                battlefield.remove(item)
                my_graveyard.cards.append(item)
                break

        gb_delirium.put_cards_in_graveyard(4, my_graveyard.cards)

        self.assertEqual(5, len(my_graveyard.cards))

        # check graveyard to see if delirium has been achieved
        my_graveyard.check_delirium()
        print(my_graveyard.delirium)
Exemplo n.º 2
0
class TestDeckAPI(unittest.TestCase):
    # noinspection PyPep8Naming
    # This warning has been suppressed because naming convention of
    # methodName and runTest is required for unittest
    def __init__(self, methodName='runTest'):
        deck_location = 'D:\\code\\delirium\\tests\\test_data\\delirium.txt'
        self.deck = Deck()
        self.deck.load_text_list(deck_location)

        unittest.TestCase.__init__(self, methodName)

    def setUp(self):
        pass

    def tearDown(self):
        self.deck.shuffle_deck()

    def test_get_card(self):
        card = get_card('Noxious Gearhulk')

        self.assertEqual(card.name, 'Noxious Gearhulk')

    def test_load_text_list(self):
        card_list = [
            'Emrakul, the Promised End',
            'Grim Flayer',
            'Grim Flayer',
            'Grim Flayer',
            'Grim Flayer',
            'Ishkanah, Grafwidow',
            'Ishkanah, Grafwidow',
            'Ishkanah, Grafwidow',
            'Kalitas, Traitor of Ghet',
            'Kalitas, Traitor of Ghet',
            'Mindwrack Demon',
            'Mindwrack Demon',
            'Tireless Tracker',
            'Liliana, the Last Hope',
            'Liliana, the Last Hope',
            'Liliana, the Last Hope',
            'Liliana, the Last Hope',
            'Dead Weight',
            'Grapple with the Past',
            'Grapple with the Past',
            'Grasp of Darkness',
            'Grasp of Darkness',
            'Grasp of Darkness',
            'Grasp of Darkness',
            'Murder',
            'Murder',
            'Noxious Gearhulk',
            "Pilgrim's Eye",
            "Pilgrim's Eye",
            'Ruinous Path',
            'Traverse the Ulvenwald',
            'Traverse the Ulvenwald',
            'Traverse the Ulvenwald',
            'Traverse the Ulvenwald',
            'Vessel of Nascency',
            'Vessel of Nascency',
            'Vessel of Nascency',
            'Blooming Marsh',
            'Blooming Marsh',
            'Blooming Marsh',
            'Blooming Marsh',
            'Evolving Wilds',
            'Forest',
            'Forest',
            'Forest',
            'Forest',
            'Forest',
            'Forest',
            'Forest',
            'Hissing Quagmire',
            'Hissing Quagmire',
            'Hissing Quagmire',
            'Hissing Quagmire',
            'Swamp',
            'Swamp',
            'Swamp',
            'Swamp',
            'Swamp',
            'Swamp',
            'Swamp',
        ]

        loaded_deck = []

        for item in self.deck.cards:
            loaded_deck.append(item.name)

        self.maxDiff = None
        self.assertEqual(len(card_list), len(loaded_deck))
        self.assertEqual(sorted(card_list), sorted(loaded_deck))

    def test_draw(self):
        card = self.deck.draw()

        self.assertEqual(len(self.deck.cards), 59)

        self.deck.put_in_deck(card)

    def test_put_cards_in_graveyard(self):
        graveyard = []

        self.deck.put_cards_in_graveyard(4, graveyard)

        self.assertEqual(56, self.deck.size())
        self.assertEqual(4, len(graveyard))

        for item in graveyard:
            self.deck.put_in_deck(item)
Exemplo n.º 3
0
    # Turn 1
    my_hand.play(forest, battlefield)
    my_hand.play(vessel, battlefield)

    # Turn 2
    #  Assumption: You do not return a card from vessel
    my_hand.draw(1, gb_delirium)
    my_hand.play(swamp, battlefield)

    for item in battlefield:
        if item.name == vessel.name:
            battlefield.remove(item)
            my_graveyard.cards.append(item)
            break

    gb_delirium.put_cards_in_graveyard(4, my_graveyard.cards)

    my_graveyard.check_delirium()
    if my_graveyard.delirium:
        times_delirious += 1

    # Reset hand, deck, graveyard, and battlefield to original condition
    # so that we can rerun the model
    for card in my_graveyard.cards:
        gb_delirium.put_in_deck(card)
    my_graveyard.cards = []
    my_graveyard.delirium = False

    for card in my_hand.cards:
        gb_delirium.put_in_deck(card)
    my_hand.cards = []