Ejemplo n.º 1
0
 def __init__(self, methodName='runTest'):
     self.swamp = CardMock(name='Swamp', type='Basic Land \u2014 Swamp')
     self.prism = CardMock(name="Prophetic Prism", type="Artifact")
     self.bolt = CardMock(name='Lightning Bolt', type='Instant')
     self.amalgam = CardMock(name='Prized Amalgam',
                             type='Creature \u2014 '
                             'Zombie')
     self.ballista = CardMock(name='Walking Ballista',
                              type='Artifact Creature \u2014 Construct')
     unittest.TestCase.__init__(self, methodName)
Ejemplo n.º 2
0
    def __init__(self, methodName='runTest'):
        self.island = CardMock(name='Island', type='')
        self.mountain = CardMock(name='Mountain', type='')
        self.tireless = CardMock(name='Tireless Tracker', type='')

        self.test_deck = Deck()
        self.my_hand = Hand()

        deck_location = 'D:\\code\\delirium\\tests\\test_data\\delirium.txt'
        self.gb_delirium = Deck()
        self.gb_delirium.load_text_list(deck_location)

        unittest.TestCase.__init__(self, methodName)
Ejemplo n.º 3
0
"""
This script will determine the likely hood that you draw a specific card that
you only have three copies of by a specific turn.  Assumption is that you draw
first.
"""

from lib.hand import Hand
from lib.mtgsdk_wrapper import CardMock
from lib.deck import Deck

surgical = CardMock(name='Surgical Extraction')

my_deck = Deck()
my_deck.load_text_list('D:\\code\\delirium\\tests\\test_data\\draw_3_of.txt')

turn = 3  # Change this variable to change the turn number to find the card by

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
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def test_card_mock_undefined_args_and_name_and_type(self):
        card_mock = CardMock(name='Lava Spike', type='Sorcery \u2014 Arcane',
                             cmc=1, text='Deal 3 damage to target player.')

        self.assertEqual(card_mock.name, 'Lava Spike')
        self.assertEqual(card_mock.type, 'Sorcery \u2014 Arcane')
Ejemplo n.º 6
0
    def test_card_mock_undefined_arguments(self):
        undefined_args = CardMock(cmc=3, text='Ach Hans Run!')

        self.assertEqual(undefined_args.name, None)
        self.assertEqual(undefined_args.type, None)
Ejemplo n.º 7
0
    def test_card_mock_name_and_type(self):
        card_mock = CardMock(name='Lightning Bolt', type='Instant')

        self.assertEqual(card_mock.name, 'Lightning Bolt')
        self.assertEqual(card_mock.type, 'Instant')
Ejemplo n.º 8
0
    def test_card_mock_type_only(self):
        card_type = CardMock(type='Instant')

        self.assertEqual(card_type.type, 'Instant')
Ejemplo n.º 9
0
    def test_card_mock_name_only(self):
        name = CardMock(name='Lightning Bolt')

        self.assertEqual(name.name, 'Lightning Bolt')
Ejemplo n.º 10
0
# Start timer for profiling purposes
start_time = time.time()

# import the deck list
gb_delirium = Deck()
gb_delirium.load_text_list(
    'D:\\code\\delirium\\tests\\test_data\\delirium.txt')

# Initialize hand, battlefield, and graveyard
my_hand = Hand()
my_graveyard = Graveyard()
battlefield = []

# Mock cards to be used in model
forest = CardMock(name='Forest')
swamp = CardMock(name='Swamp')
vessel = CardMock(name='Vessel of Nascency')

# Variables
deck_size = len(gb_delirium.cards)  # Initial size of imported deck
count = 0  # Number of times model ran
times_delirious = 0  # Number of times model found delirium was achieved

# Run model 10000 times
while count < 10000:
    gb_delirium.shuffle_deck()

    # Get swamp, forest, and vessel in hand then draw 4 more cards
    my_hand.get_card_from_deck(forest, gb_delirium)
    my_hand.get_card_from_deck(swamp, gb_delirium)