コード例 #1
0
def get_box(num_victory):
  """
  Input: the number of victory cards
  Returns: a dictionary of cards
  The number of "Gardens" is determined by the # of victory cards
  """
  box = {}
  box["Woodcutter"] = [Dominion.Woodcutter()] * 10
  box["Smithy"] = [Dominion.Smithy()] * 10
  box["Laboratory"] = [Dominion.Laboratory()] * 10
  box["Village"] = [Dominion.Village()] * 10
  box["Festival"] = [Dominion.Festival()] * 10
  box["Market"] = [Dominion.Market()] * 10
  box["Chancellor"] = [Dominion.Chancellor()] * 10
  box["Workshop"] = [Dominion.Workshop()] * 10
  box["Moneylender"] = [Dominion.Moneylender()] * 10
  box["Chapel"] = [Dominion.Chapel()] * 10
  box["Cellar"] = [Dominion.Cellar()] * 10
  box["Remodel"] = [Dominion.Remodel()] * 10
  box["Adventurer"] = [Dominion.Adventurer()] * 10
  box["Feast"] = [Dominion.Feast()] * 10
  box["Mine"] = [Dominion.Mine()] * 10
  box["Library"] = [Dominion.Library()] * 10
  box["Gardens"] = [Dominion.Gardens()] * num_victory
  box["Moat"] = [Dominion.Moat()] * 10
  box["Council Room"] = [Dominion.Council_Room()] * 10
  box["Witch"] = [Dominion.Witch()] * 10
  box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10
  box["Militia"] = [Dominion.Militia()] * 10
  box["Spy"] = [Dominion.Spy()] * 10
  box["Thief"] = [Dominion.Thief()] * 10
  box["Throne Room"] = [Dominion.Throne_Room()] * 10
  return box
コード例 #2
0
def define_box(nV):
    box = {}
    box["Woodcutter"]=[Dominion.Woodcutter()]*10
    box["Smithy"]=[Dominion.Smithy()]*10
    box["Laboratory"]=[Dominion.Laboratory()]*10
    box["Village"]=[Dominion.Village()]*10
    box["Festival"]=[Dominion.Festival()]*10
    box["Market"]=[Dominion.Market()]*10
    box["Chancellor"]=[Dominion.Chancellor()]*10
    box["Workshop"]=[Dominion.Workshop()]*10
    box["Moneylender"]=[Dominion.Moneylender()]*10
    box["Chapel"]=[Dominion.Chapel()]*10
    box["Cellar"]=[Dominion.Cellar()]*10
    box["Remodel"]=[Dominion.Remodel()]*10
    box["Adventurer"]=[Dominion.Adventurer()]*10
    box["Feast"]=[Dominion.Feast()]*10
    box["Mine"]=[Dominion.Mine()]*10
    box["Library"]=[Dominion.Library()]*10
    box["Gardens"]=[Dominion.Gardens()]*nV
    box["Moat"]=[Dominion.Moat()]*10
    box["Council Room"]=[Dominion.Council_Room()]*10
    box["Witch"]=[Dominion.Witch()]*10
    box["Bureaucrat"]=[Dominion.Bureaucrat()]*10
    box["Militia"]=[Dominion.Militia()]*10
    box["Spy"]=[Dominion.Spy()]*10
    box["Thief"]=[Dominion.Thief()]*10
    box["Throne Room"]=[Dominion.Throne_Room()]*10

    supply_order = {0: ['Curse', 'Copper'], 2: ['Estate', 'Cellar', 'Chapel', 'Moat'],
                    3: ['Silver', 'Chancellor', 'Village', 'Woodcutter', 'Workshop'],
                    4: ['Gardens', 'Bureaucrat', 'Feast', 'Militia', 'Moneylender', 'Remodel', 'Smithy', 'Spy', 'Thief',
                        'Throne Room'],
                    5: ['Duchy', 'Market', 'Council Room', 'Festival', 'Laboratory', 'Library', 'Mine', 'Witch'],
                    6: ['Gold', 'Adventurer'], 8: ['Province']}
    return box, supply_order
コード例 #3
0
    def test_init(self):
        actionCard = Dominion.Woodcutter()

        self.assertEqual(actionCard.name, 'Woodcutter')
        self.assertEqual(actionCard.cost, 3)
        self.assertEqual(actionCard.actions, 0)
        self.assertEqual(actionCard.cards, 0)
        self.assertEqual(actionCard.buys, 1)
        self.assertEqual(actionCard.coins, 2)

        actionCard = Dominion.Village()

        self.assertEqual(actionCard.name, 'Village')
        self.assertEqual(actionCard.cost, 3)
        self.assertEqual(actionCard.actions, 2)
        self.assertEqual(actionCard.cards, 1)
        self.assertEqual(actionCard.buys, 0)
        self.assertEqual(actionCard.coins, 0)

        actionCard = FakeCard("TotallyFake", -100, -50, -100, -100, -100)

        self.assertEqual(actionCard.name, 'TotallyFake')
        self.assertEqual(actionCard.cost, -100)
        self.assertEqual(actionCard.actions, -50)
        self.assertEqual(actionCard.cards, -100)
        self.assertEqual(actionCard.buys, -100)
        self.assertEqual(actionCard.coins, -100)
コード例 #4
0
ファイル: testUtility.py プロジェクト: lathan2/CS362-W2020
def get_boxes(nV):
    """
    :param nV: starting number of each victory card, used here
    for calculating number of garden cards
    :return: box, a dictionary containing starting lists of action cards
    """
    box = {}
    box["Woodcutter"] = [Dominion.Woodcutter()] * 10
    box["Smithy"] = [Dominion.Smithy()] * 10
    box["Laboratory"] = [Dominion.Laboratory()] * 10
    box["Village"] = [Dominion.Village()] * 10
    box["Festival"] = [Dominion.Festival()] * 10
    box["Market"] = [Dominion.Market()] * 10
    box["Chancellor"] = [Dominion.Chancellor()] * 10
    box["Workshop"] = [Dominion.Workshop()] * 10
    box["Moneylender"] = [Dominion.Moneylender()] * 10
    box["Chapel"] = [Dominion.Chapel()] * 10
    box["Cellar"] = [Dominion.Cellar()] * 10
    box["Remodel"] = [Dominion.Remodel()] * 10
    box["Adventurer"] = [Dominion.Adventurer()] * 10
    box["Feast"] = [Dominion.Feast()] * 10
    box["Mine"] = [Dominion.Mine()] * 10
    box["Library"] = [Dominion.Library()] * 10
    box["Gardens"] = [Dominion.Gardens()] * nV
    box["Moat"] = [Dominion.Moat()] * 10
    box["Council Room"] = [Dominion.Council_Room()] * 10
    box["Witch"] = [Dominion.Witch()] * 10
    box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10
    box["Militia"] = [Dominion.Militia()] * 10
    box["Spy"] = [Dominion.Spy()] * 10
    box["Thief"] = [Dominion.Thief()] * 10
    box["Throne Room"] = [Dominion.Throne_Room()] * 10

    return box
コード例 #5
0
def initBox(nV):
#Define box
    box = {}
    box["Woodcutter"]=[Dominion.Woodcutter()]*10
    box["Smithy"]=[Dominion.Smithy()]*10
    box["Laboratory"]=[Dominion.Laboratory()]*10
    box["Village"]=[Dominion.Village()]*10
    box["Festival"]=[Dominion.Festival()]*10
    box["Market"]=[Dominion.Market()]*10
    box["Chancellor"]=[Dominion.Chancellor()]*10
    box["Workshop"]=[Dominion.Workshop()]*10
    box["Moneylender"]=[Dominion.Moneylender()]*10
    box["Chapel"]=[Dominion.Chapel()]*10
    box["Cellar"]=[Dominion.Cellar()]*10
    box["Remodel"]=[Dominion.Remodel()]*10
    box["Adventurer"]=[Dominion.Adventurer()]*10
    box["Feast"]=[Dominion.Feast()]*10
    box["Mine"]=[Dominion.Mine()]*10
    box["Library"]=[Dominion.Library()]*10
    box["Gardens"]=[Dominion.Gardens()]*nV
    box["Moat"]=[Dominion.Moat()]*10
    box["Council Room"]=[Dominion.Council_Room()]*10
    box["Witch"]=[Dominion.Witch()]*10
    box["Bureaucrat"]=[Dominion.Bureaucrat()]*10
    box["Militia"]=[Dominion.Militia()]*10
    box["Spy"]=[Dominion.Spy()]*10
    box["Thief"]=[Dominion.Thief()]*10
    box["Throne Room"]=[Dominion.Throne_Room()]*10

    return box
コード例 #6
0
 def testActionCardInit(self):
     woodcutter = Dominion.Woodcutter()
     smithy = Dominion.Smithy()
     ac = Dominion.Action_card(self, "Woodcutter", 3, 0,  1, 2)
     ac.cards = [woodcutter, smithy]
     ac.coins = 2
     ac.actions = "Karate Chop"
     assert ac.actions == "Karate Chop"
     assert ac.coins == 2
     assert len(ac.cards) == 2
コード例 #7
0
    def test_calcpoints(self):
        player = Dominion.Player("Annie")
        self.assertEqual(10, len(player.stack()))
        vpbal = player.calcpoints()

        print(vpbal)
        assert vpbal == 3
        player.deck = [Dominion.Woodcutter()]
        vpbal2 = player.calcpoints()
        # //expected action balance after adding woodcutters to the deck is -20.0
        print(vpbal2)
        assert vpbal2 == 1

        pass
コード例 #8
0
    def test_action_balance(self):
        player = Dominion.Player("Annie")
        self.assertEqual(10, len(player.stack()))
        acbal = player.action_balance()

        print(acbal)
        assert acbal == 0.0
        player.deck = [Dominion.Woodcutter()] * 2
        acbal2 = player.action_balance()
        # //expected action balance after adding woodcutters to the deck is -20.0

        print(acbal2)
        assert acbal2 == -20.0
        pass
コード例 #9
0
 def test_use(self):
     self = Dominion.Woodcutter
     player = Dominion.Player("Annie")
     trash = []
     woodcutter = Dominion.Woodcutter()
     smithy = Dominion.Smithy()
     player.hand.append(woodcutter)
     ac = Dominion.Action_card(self, player.name, 3, 0, 1, 2)
     ac.cards = [woodcutter, smithy]
     ac.coins = 2
     ac.actions = "Karate Chop"
     assert ac.actions == "Karate Chop"
     assert ac.coins == 2
     assert len(ac.cards) == 2
     ac = player.hand[1]
     ac.use(self, trash)
     assert len(ac.cards) == 2
コード例 #10
0
    def setUp(self):
        # Set Up Test Utility Values
        self.trash = []
        self.player = Dominion.Player('Annie')
        self.hand = [Dominion.Woodcutter()] * 2 + [Dominion.Gardens()]
        self.player.played = []

        # Initialize action card props
        self.name = "Adventurer"
        self.cost = 6
        self.actions = 0
        self.cards = 0
        self.buys = 0
        self.coins = 0

        # Instantiate Feast and Adventurer Action cards
        self.Feast_card = Dominion.Feast()
        self.Adventurer_card = Dominion.Adventurer()
コード例 #11
0
    def test_use(self):
        player = Dominion.Player('Tony')
        self.assertEqual(10, len(player.stack()))
        trash = []

        # makes sure player has no played cards and 5 cards in their hand
        self.assertEqual(5, len(player.hand))
        self.assertEqual(0, len(player.played))

        # adds woodcutter to hand
        player.hand += [Dominion.Woodcutter()]
        self.assertEqual(6, len(player.hand))

        # asserts woodcutter is correct card and uses it
        self.assertEqual('Woodcutter', player.hand[5].name)
        player.hand[5].use(player, trash)

        # makes sure the player has the correct amount of cards played and cards in their hand
        self.assertEqual(1, len(player.played))
        self.assertEqual(5, len(player.hand))
コード例 #12
0
    def test_use(self):
        # All startup information
        self.setUp()
        self.player = Dominion.Player('Annie')
        actionCard = Dominion.Woodcutter()

        # Add the woodcutter to Annie's hand
        self.player.hand.append(actionCard)

        self.assertNotIn(actionCard, self.player.played)
        self.assertIn(actionCard, self.player.hand,
                      "Action card is not in the hand list.")

        actionCard.use(self.player, self.trash)

        self.assertIn(
            actionCard, self.player.played,
            "Action card was not in the played list, but it should be.")
        self.assertNotIn(actionCard, self.player.hand,
                         "Action card was in the hand, but it should not be.")
コード例 #13
0
    def test_cardsummary(self):
        self.player = Dominion.Player("Annie")

        # Clear the hand and deck completely
        self.player.hand = []
        self.player.deck = []

        # Deal with an empty summary
        summary = self.player.cardsummary()

        self.assertEqual(summary['VICTORY POINTS'], 0)

        card = Dominion.Woodcutter()
        self.player.hand.append(card)

        summary = self.player.cardsummary()

        # There's only one card inside the summary so far.
        self.assertEqual(len(summary), 2)
        self.assertIn(card.name, summary)

        self.player.hand.remove(card)

        summary = self.player.cardsummary()
        # Now the summary should only have the victory point entry again.
        self.assertNotIn(card.name, summary)

        newCard = Dominion.Cellar()
        self.player.hand.append(newCard)
        self.player.deck.append(card)

        summary = self.player.cardsummary()
        self.assertIn(card.name, summary)
        self.assertEqual(summary[card.name], 1)
        self.assertIn(newCard.name, summary)
        self.assertEqual(summary[newCard.name], 1)

        self.player.discard.append(card)

        summary = self.player.cardsummary()
        self.assertEqual(summary[card.name], 2)
コード例 #14
0
def getBoxes(nV):
    """
    Returns a box object
    takes nV as an argument that represents 
    the number of Victory Cards in play
    """

    #Create a box object
    box = {}
    box["Woodcutter"] = [Dominion.Woodcutter()] * 10
    box["Smithy"] = [Dominion.Smithy()] * 10
    box["Laboratory"] = [Dominion.Laboratory()] * 10
    box["Village"] = [Dominion.Village()] * 10
    box["Festival"] = [Dominion.Festival()] * 10
    box["Market"] = [Dominion.Market()] * 10
    box["Chancellor"] = [Dominion.Chancellor()] * 10
    box["Workshop"] = [Dominion.Workshop()] * 10
    box["Moneylender"] = [Dominion.Moneylender()] * 10
    box["Chapel"] = [Dominion.Chapel()] * 10
    box["Cellar"] = [Dominion.Cellar()] * 10
    box["Remodel"] = [Dominion.Remodel()] * 10
    box["Adventurer"] = [Dominion.Adventurer()] * 10
    box["Feast"] = [Dominion.Feast()] * 10
    box["Mine"] = [Dominion.Mine()] * 10
    box["Library"] = [Dominion.Library()] * 10
    box["Gardens"] = [Dominion.Gardens()] * nV
    box["Moat"] = [Dominion.Moat()] * 10
    box["Council Room"] = [Dominion.Council_Room()] * 10
    box["Witch"] = [Dominion.Witch()] * 10
    box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10
    box["Militia"] = [Dominion.Militia()] * 10
    box["Spy"] = [Dominion.Spy()] * 10
    box["Thief"] = [Dominion.Thief()] * 10
    box["Throne Room"] = [Dominion.Throne_Room()] * 10

    return box
コード例 #15
0
ファイル: playDominion.py プロジェクト: rtbowtie/CS362-W2020
import random
from collections import defaultdict

#Get player names
player_names = ["Randy", "*Comp1", "*Comp2"]

#number of curses and victory cards
if len(player_names) > 2:
    nV = 12
else:
    nV = 8
nC = -10 + 10 * len(player_names)

#Define box
box = {}
box["Woodcutter"] = [Dominion.Woodcutter()] * 10
box["Smithy"] = [Dominion.Smithy()] * 10
box["Laboratory"] = [Dominion.Laboratory()] * 10
box["Village"] = [Dominion.Village()] * 10
box["Festival"] = [Dominion.Festival()] * 10
box["Market"] = [Dominion.Market()] * 10
box["Chancellor"] = [Dominion.Chancellor()] * 10
box["Workshop"] = [Dominion.Workshop()] * 10
box["Moneylender"] = [Dominion.Moneylender()] * 10
box["Chapel"] = [Dominion.Chapel()] * 10
box["Cellar"] = [Dominion.Cellar()] * 10
box["Remodel"] = [Dominion.Remodel()] * 10
box["Adventurer"] = [Dominion.Adventurer()] * 10
box["Feast"] = [Dominion.Feast()] * 10
box["Mine"] = [Dominion.Mine()] * 10
box["Library"] = [Dominion.Library()] * 10
コード例 #16
0
ファイル: testDominion1.py プロジェクト: nraymon/CS362-W2020
import testUtility

# Get player names
player_names = ["Annie", "*Ben", "*Carla"]

# number of curses and victory cards
if len(player_names) > 2:
    nV = 12
else:
    nV = 8
nC = -10 + 10 * len(player_names)

#Refactored to testUtility.GetBoxes
box = testUtility.GetBoxes(nV)
#Test Scenario
box["Militia"] = [Dominion.Woodcutter()] * 10

#Refactored to testUtility.Supplies
supply_order = testUtility.Supplies()

# Pick 10 cards from box to be in the supply.
boxlist = [k for k in box]
random.shuffle(boxlist)
random10 = boxlist[:10]
supply = defaultdict(list, [(k, box[k]) for k in random10])

# The supply always has these cards
#Refactored to testUtility.SupplySetup
supply = testUtility.SupplySetup(supply, nV, nC, player_names)

# initialize the trash
コード例 #17
0
import Dominion
import testUtility

# Get player names
player_names = testUtility.getPlayerNames()

# number of curses and victory cards
nV = testUtility.getnV(player_names)
nC = testUtility.getnC(player_names)

# Get box
box = testUtility.getBoxes(nV)

# TEST SCENARIO BUG 1 -- MIX UP THE CARDS
box["Smithy"] = [Dominion.Woodcutter()] * 10
box["Laboratory"] = [Dominion.Smithy()] * 10
box["Village"] = [Dominion.Laboratory()] * 10
box["Festival"] = [Dominion.Village()] * 10
box["Market"] = [Dominion.Festival()] * 10
box["Chancellor"] = [Dominion.Market()] * 10
box["Workshop"] = [Dominion.Chancellor()] * 10
box["Moneylender"] = [Dominion.Workshop()] * 10
box["Chapel"] = [Dominion.Moneylender()] * 10
box["Cellar"] = [Dominion.Chapel()] * 10
box["Remodel"] = [Dominion.Cellar()] * 10
box["Adventurer"] = [Dominion.Remodel()] * 10
box["Feast"] = [Dominion.Adventurer()] * 10
box["Mine"] = [Dominion.Feast()] * 10
box["Library"] = [Dominion.Mine()] * 10
box["Gardens"] = [Dominion.Library()] * 10