class DominionTest(unittest.TestCase): def setUp(self): self.game = Dominion() self.game.run() def tearDown(self): pass def test_game_sets_starting_player(self): self.assertIsInstance(self.game.starting_player, Player) def test_game_has_two_players_if_none_specified(self): self.assertEqual(2, len(self.game.players)) def test_game_has_specified_number_of_players(self): game = Dominion(4) self.assertEqual(4, len(game.players)) def test_game_cannot_have_more_than_four_players(self): game = Dominion(20) self.assertEqual(4, len(game.players)) def test_game_players_type_is_player_object(self): for player in self.game.players: self.assertIsInstance(player, Player) def test_game_has_board(self): self.assertIsInstance(self.game.board, Board) def test_game_generates_turn_when_run(self): turn = self.game.run() self.assertIsInstance(turn, Turn)
def index(): d = Dominion() sets = ['Base', 'Alchemy', 'Cornucopia', 'Dark Ages', 'Hinterlands', 'Intrigue', 'Prosperity', 'Seaside'] selected = request.args.getlist('selected[]') result = d.get_random_cards(selected) if (selected == None): selected = [] return render_template("index.html", sets=sets, selected=selected, result=result)
def main(): dominion=Dominion() dominion.newPlayer("ender") dominion.newPlayer("pepe") dominion.initGame()
def get(self): game = Dominion() game.url = '/' + str(id(game)) games.append(game) application.add_handlers(r'.*$', [(r'/' + str(id(game)), NewPlayerHandler, {'game': game})]) self.redirect('/' + str(id(game)))
def setUp(self): self.game = Dominion() self.game.run()
# Pick 10 cards from box to be in the supply. boxlist, supply = testUtility.GetSupplyCards(box) # The supply always has these cards testUtility.DefaultSupply(supply, player_names, nV, nC) # initialize the trash trash = [] # Construct the Player objects players = [] testUtility.MakePlayers(players, player_names) # Play the game turn = 0 while not Dominion.gameover(supply): turn += 1 print("\r") for value in supply_order: print(value) for stack in supply_order[value]: if stack in supply: print(stack, len(supply[stack])) print("\r") for player in players: print(player.name,player.calcpoints()) print("\rStart of turn " + str(turn)) for player in players: if not Dominion.gameover(supply): print("\r") player.turn(players,supply,trash)
import random from collections import defaultdict #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) #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
# Get player names player_names = testUtility.GetPlayers() # number of curses and victory cards nV, nC = testUtility.SetNumVC(player_names) # Define box box = testUtility.GetBoxes(nV) supply_order = testUtility.SetSupplyOrder() # Pick 10 cards from box to be in the supply. boxlist, supply = testUtility.GetSupplyCards(box) # The supply always has these cards testUtility.DefaultSupply(supply, player_names, nV, nC) supply["Province"] = [Dominion.Estate()] * nV # initialize the trash trash = [] # Construct the Player objects players = [] testUtility.MakePlayers(players, player_names) # Play the game turn = 0 while not Dominion.gameover(supply): turn += 1 print("\r") for value in supply_order: print(value) for stack in supply_order[value]: