示例#1
0
my_hand = Hand()
deck_size = len(my_deck.cards)
count = 0
draw_3_of = 0

while count < 10000:
    my_deck.shuffle_deck()

    my_hand.draw_starting_hand(my_deck)
    my_hand.draw(turn, my_deck)

    for card in my_hand.cards:
        if card.name == surgical.name:
            draw_3_of += 1
            break

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

    if len(my_deck.cards) != deck_size:
        print('Error resetting game state')
        break

    count += 1

percent = draw_3_of / count * 100
print("There is a {}% chance that you will draw the "
      "specific card by turn ()".format(percent, turn))

示例#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)
示例#3
0
    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 = []

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

    gb_delirium.shuffle_deck()
    count += 1

    # Check to see if deck was properly reset
示例#4
0
    def test_put_in_deck(self):
        test_deck = Deck()

        test_deck.put_in_deck('Island')

        self.assertIn('Island', test_deck.cards)
示例#5
0
            land_count += 1

    if creature_count < 2:
        keep_hand = False

    if land_count < 2:
        keep_hand = False

    if discard_count < 1:
        keep_hand = False

    if vengevine_count < 2:
        keep_hand = False

    if keep_hand:
        keep_count += 1

    count += 1

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

    # Check to see if deck was properly reset
    if len(gr_vv.cards) != deck_size:
        print('Error resetting play state')
        break

# Run statistics on model and report
percent = (keep_count / count) * 100
print('There is a {}% chance to have the nut draw'.format(percent))