Exemplo n.º 1
0
    def test_City(self):
        tu.print_test_header("test City")
        city = prosperity.City(self.game, self.player1)

        cards_in_hand = len(self.player1.hand.card_array())

        city.play()
        self.assertTrue(self.player1.balance == 0)
        self.assertTrue(self.player1.actions == 2)
        self.assertTrue(
            len(self.player1.hand.card_array()) == cards_in_hand + 1)
        self.assertTrue(self.player1.buys == 1)
        self.assertTrue(self.player1.balance == 0)

        self.game.empty_piles = 1

        city.play()
        self.assertTrue(
            len(self.player1.hand.card_array()) == cards_in_hand + 3)
        self.assertTrue(self.player1.actions == 3)
        self.assertTrue(self.player1.buys == 1)
        self.assertTrue(self.player1.balance == 0)

        self.game.empty_piles = 2

        city.play()
        self.assertTrue(
            len(self.player1.hand.card_array()) == cards_in_hand + 5)
        self.assertTrue(self.player1.actions == 4)
        self.assertTrue(self.player1.buys == 2)
        self.assertTrue(self.player1.balance == 1)
Exemplo n.º 2
0
    def test_throne_room_throne_room(self):
        tu.print_test_header("Test throne room throne room")
        throneroom = base.Throne_Room(self.game, self.player1)
        throneroom2 = base.Throne_Room(self.game, self.player1)
        self.player1.hand.add(throneroom)
        self.player1.hand.add(throneroom2)
        yield tu.send_input(self.player1, "play", "Throne Room")
        yield tu.send_input(self.player1, "post_selection", ["Throne Room"])

        self.player1.end_turn()
        self.player2.end_turn()
        self.player3.end_turn()

        self.player1.hand.add(throneroom)
        self.player1.hand.add(throneroom2)
        self.player1.hand.add(base.Village(self.game, self.player1))
        self.player1.hand.add(base.Village(self.game, self.player1))
        self.player1.hand.add(base.Woodcutter(self.game, self.player1))
        yield tu.send_input(self.player1, "play", "Throne Room")
        yield tu.send_input(self.player1, "post_selection", ["Village"])
        self.assertTrue(self.player1.actions == 4)
        self.assertTrue(self.player1.last_mode["mode"] == "action")

        yield tu.send_input(self.player1, "play", "Throne Room")
        yield tu.send_input(self.player1, "post_selection", ["Woodcutter"])
        self.assertTrue(self.player1.balance == 4)
        self.assertTrue(self.player1.last_mode["mode"] == "action")
Exemplo n.º 3
0
    def test_Forge(self):
        tu.print_test_header("test Forge")
        forge = prosperity.Forge(self.game, self.player1)
        steward = intrigue.Steward(self.game, self.player1)
        minion = intrigue.Minion(self.game, self.player1)
        torturer = intrigue.Torturer(self.game, self.player1)
        secret_chamber = intrigue.Secret_Chamber(self.game, self.player1)
        gold = supply_cards.Gold(self.game, self.player1)

        self.player1.hand.add(steward)
        self.player1.hand.add(minion)
        self.player1.hand.add(torturer)
        self.player1.hand.add(secret_chamber)
        self.player1.hand.add(gold)

        forge.play()
        # trash prices total to 8
        yield tu.send_input(self.player1, "post_selection",
                            ["Steward", "Copper", "Copper", "Minion"])
        self.assertTrue(len(self.game.trash_pile) == 4)
        yield tu.send_input(self.player1, "selectSupply", ["Province"])
        self.assertTrue(self.player1.discard_pile[0].title == "Province")

        forge.play()
        # trash prices total to 13 -- nothing to gain
        yield tu.send_input(self.player1, "post_selection",
                            ["Torturer", "Secret Chamber", "Gold"])
        self.assertTrue(self.player1.cb is None)
Exemplo n.º 4
0
    def test_Mandarin(self):
        tu.print_test_header("test Mandarin")
        tu.add_many_to_hand(self.player1,
                            supply_cards.Silver(self.game, self.player1), 3)
        tu.add_many_to_hand(self.player1,
                            supply_cards.Gold(self.game, self.player1), 2)

        tu.send_input(self.player1, "play", "Gold")
        tu.send_input(self.player1, "play", "Silver")
        tu.send_input(self.player1, "play", "Silver")

        yield tu.send_input(self.player1, "buyCard", "Mandarin")

        self.assertTrue(self.player1.last_mode["mode"] == "select")
        yield tu.send_input(self.player1, "post_selection",
                            ["Silver", "Silver", "Gold"])
        self.assertTrue(len(self.player1.played_cards) == 0)
        self.assertTrue(self.player1.deck[-1].title == "Gold")
        self.assertTrue(self.player1.deck[-2].title == "Silver")
        self.assertTrue(self.player1.deck[-3].title == "Silver")

        self.player1.end_turn()
        self.player2.hand.add(hl.Mandarin(self.game, self.player2))
        self.player2.hand.add(supply_cards.Silver(self.game, self.player2))
        tu.send_input(self.player2, "play", "Mandarin")
        self.assertTrue(self.player2.balance == 3)
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        yield tu.send_input(self.player2, "post_selection", ["Copper"])
        self.assertTrue(self.player2.deck[-1].title == "Copper")
        self.assertTrue(len(self.player2.hand) == 5)
Exemplo n.º 5
0
    def test_Trader(self):
        tu.print_test_header("test Trader")
        witch = base.Witch(self.game, self.player1)
        trader = hl.Trader(self.game, self.player2)

        #2 curses left
        for i in range(0, self.game.supply.get_count("Curse") - 2):
            self.game.remove_from_supply("Curse")

        self.player1.hand.add(witch)
        self.player2.hand.add(trader)
        #reaction
        tu.send_input(self.player1, "play", "Witch")
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        yield tu.send_input(self.player2, "post_selection", ["Reveal"])
        self.assertTrue(len(self.game.trash_pile) == 0)
        #and gained a silver
        self.assertTrue(self.player2.discard_pile[-1].title == "Silver")
        yield gen.sleep(.1)
        self.assertTrue(self.player1.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.discard_pile[-1].title == "Curse")

        #one curse returned to supply
        self.assertTrue(self.game.supply.get_count("Curse") == 1)
        self.assertTrue(self.game.empty_piles == 0)

        self.player1.end_turn()

        self.player2.hand.add(supply_cards.Estate(self.game, self.player2))
        tu.send_input(self.player2, "play", "Trader")
        yield tu.send_input(self.player2, "post_selection", ["Estate"])
        self.assertTrue(len(self.player2.discard_pile) == 3)
Exemplo n.º 6
0
 def test_Spice_Merchant(self):
     tu.print_test_header("test Spice Merchant")
     spice_merchant1 = hl.Spice_Merchant(self.game, self.player1)
     spice_merchant2 = hl.Spice_Merchant(self.game, self.player1)
     copper = supply_cards.Copper(self.game, self.player1)
     silver = supply_cards.Silver(self.game, self.player1)
     self.player1.hand.add(spice_merchant1)
     self.player1.hand.add(spice_merchant2)
     self.player1.deck = [silver] * 5
     self.player1.hand.add(copper)
     yield tu.send_input(self.player1, "play", "Spice Merchant")
     yield tu.send_input(self.player1, "post_selection", ["Copper"])
     yield tu.send_input(self.player1, "post_selection",
                         ["+2 cards +1 action"])
     self.assertTrue(copper in self.game.trash_pile)
     self.assertTrue(
         len(self.player1.hand.card_array()) == 8
     )  # We started with 5 cards and then added 2 SMs and a copper (8 cards), then put one in
     yield tu.send_input(
         self.player1, "play", "Spice Merchant"
     )  # play and trashed the copper, then drew 2 brining us back to 8
     yield tu.send_input(self.player1, "post_selection", ["Copper"])
     yield tu.send_input(self.player1, "post_selection", ["+$2 +1 buy"])
     self.assertTrue(len(self.game.trash_pile) == 2)
     self.assertTrue(self.player1.buys == 2)
     self.assertTrue(self.player1.balance == 2)
Exemplo n.º 7
0
    def test_turn_timeout(self):
        tu.print_test_header("test Turn Timeout")
        self.assertTrue(self.player1.waiter.afk_timer != None)
        self.assertTrue(self.player2.waiter.afk_timer == None)
        self.assertTrue(self.player3.waiter.afk_timer == None)
        self.player1.end_turn()
        self.assertTrue(self.player1.waiter.afk_timer == None)
        self.assertTrue(self.player2.waiter.afk_timer != None)
        self.assertTrue(self.player3.waiter.afk_timer == None)
        self.player2.end_turn()
        self.assertTrue(self.player1.waiter.afk_timer == None)
        self.assertTrue(self.player2.waiter.afk_timer == None)
        self.assertTrue(self.player3.waiter.afk_timer != None)

        def player1_and_2_not_afk():
            self.assertTrue(self.player1.waiter.is_afk == False)
            self.assertTrue(self.player1.waiter.afk_timer == None)
            self.assertTrue(self.player2.waiter.is_afk == False)
            self.assertTrue(self.player3.waiter.is_afk)
            self.player3.end_turn()
            self.assertTrue(self.player3.waiter.is_afk == False)
            self.assertTrue(self.player3.waiter.afk_timer == None)
            self.stop()

        self.io_loop.call_later(3, player1_and_2_not_afk)
        self.wait()
Exemplo n.º 8
0
    def test_Royal_Seal(self):
        tu.print_test_header("test Royal Seal")
        royal_seal = prosperity.Royal_Seal(self.game, self.player1)
        workers_village = prosperity.Workers_Village(self.game, self.player1)
        copper = supply_cards.Copper(self.game, self.player1)
        self.player1.hand.add(royal_seal)
        self.player1.hand.add(copper)
        tu.add_many_to_hand(self.player1, workers_village, 3)

        workers_village.play()
        workers_village.play()
        workers_village.play()

        royal_seal.play()
        yield tu.send_input(self.player1, "buyCard", "Curse")
        self.assertTrue(self.player1.last_mode["mode"] == "select")
        yield tu.send_input(self.player1, "post_selection", ["Yes"])
        self.assertTrue(self.player1.deck[-1].title == "Curse")
        yield gen.sleep(.2)
        self.assertTrue(self.player1.last_mode["mode"] == "buy")

        yield tu.send_input(self.player1, "buyCard", "Silver")
        self.assertTrue(self.player1.last_mode["mode"] == "select")

        yield tu.send_input(self.player1, "post_selection", ["No"])
        self.assertTrue(self.player1.discard_pile[-1].title == "Silver")
        yield gen.sleep(.2)
        self.assertTrue(self.player1.last_mode["mode"] == "buy")
        yield tu.send_input(self.player1, "buyCard", "Mint")
        self.assertTrue(self.player1.last_mode["mode"] == "buy")
Exemplo n.º 9
0
    def test_Rabble(self):
        tu.print_test_header("test Rabble")
        rabble = prosperity.Rabble(self.game, self.player1)
        copper = supply_cards.Copper(self.game, self.player2)
        estate = supply_cards.Estate(self.game, self.player2)

        self.player2.deck.append(estate)
        self.player2.deck.append(copper)
        self.player2.deck.append(estate)

        duchy = supply_cards.Duchy(self.game, self.player3)
        gardens = base.Gardens(self.game, self.player3)
        great_hall = intrigue.Great_Hall(self.game, self.player3)

        self.player3.deck.append(duchy)
        self.player3.deck.append(gardens)
        self.player3.deck.append(great_hall)

        rabble.play()
        topdeck1 = self.player2.topdeck()
        topdeck2 = self.player2.topdeck()
        self.assertTrue(topdeck1.title == "Estate")
        self.assertTrue(topdeck2.title == "Estate")
        yield tu.send_input(self.player3, "post_selection",
                            ["Gardens", "Duchy"])

        topdeck1 = self.player3.topdeck()
        topdeck2 = self.player3.topdeck()

        self.assertTrue(topdeck1.title == "Duchy")
        self.assertTrue(topdeck2.title == "Gardens")
Exemplo n.º 10
0
    def test_watchtower_trader(self):
        tu.print_test_header("test Watchtower Trader")
        watchtower = prosperity.Watchtower(self.game, self.player1)
        trader = hl.Trader(self.game, self.player1)
        self.player1.hand.add(watchtower)
        self.player1.hand.add(trader)

        self.player1.spend_all_money()
        yield tu.send_input(self.player1, "buyCard", "Copper")
        self.assertTrue(self.player1.last_mode["mode"] == "select")
        #order reactions, reveal trader then watchtower
        yield tu.send_input(self.player1, "post_selection",
                            ["Watchtower", "Trader"])
        self.assertTrue(self.player1.last_mode["mode"] == "select")
        #reveal trader
        yield tu.send_input(self.player1, "post_selection", ["Reveal"])
        self.assertTrue(self.game.supply.get_count("Copper") == 30)
        #gaining silver now
        yield tu.send_input(self.player1, "post_selection",
                            ["Watchtower", "Trader"])
        # trader's reaction is ignored since its for silver
        # reveal watchtower
        yield tu.send_input(self.player1, "post_selection", ["Reveal"])
        yield tu.send_input(self.player1, "post_selection",
                            ["Put on top of deck"])
        self.assertTrue(self.player1.deck[-1].title == "Silver")

        #watchtower from the copper earlier
        yield tu.send_input(self.player1, "post_selection", ["Reveal"])
        yield tu.send_input(self.player1, "post_selection",
                            ["Put on top of deck"])
        self.assertTrue(self.player1.deck[-1].title == "Silver")
Exemplo n.º 11
0
	def test_Militia(self):
		tu.print_test_header("test Militia")

		player2_discard_future = gen.Future()
		player3_discard_future = gen.Future()
		select_mock2 = unittest.mock.MagicMock(return_value=player2_discard_future)
		select_mock3 = unittest.mock.MagicMock(return_value=player3_discard_future)
		discard_mock2 =unittest.mock.Mock()
		discard_mock3 =unittest.mock.Mock()

		self.player2.select = select_mock2
		self.player3.select = select_mock3
		self.player2.discard = gen.coroutine(discard_mock2)
		self.player3.discard = gen.coroutine(discard_mock3)

		base.Militia(self.game, self.player1).play()
		self.assertTrue(select_mock2.called)
		self.assertTrue(select_mock3.called)
		select_mock2.assert_called_with(unittest.mock.ANY, unittest.mock.ANY, 
			crd.card_list_to_titles(self.player2.hand.card_array()), unittest.mock.ANY)

		player2_selection = crd.card_list_to_titles(self.player2.hand.card_array())[:2]
		player2_discard_future.set_result(player2_selection)
		yield gen.moment
		discard_mock2.assert_called_once_with(player2_selection, self.player2.discard_pile)
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		player3_selection = ["Copper", "Copper"]
		player3_discard_future.set_result(player3_selection)
		yield gen.moment
		discard_mock3.assert_called_once_with(player3_selection, self.player3.discard_pile)
Exemplo n.º 12
0
    def test_Throne_Room_on_Workshop(self):
        tu.print_test_header("test Throne Room workshop")
        throne_room = base.Throne_Room(self.game, self.player1)
        workshop = base.Workshop(self.game, self.player1)
        self.player1.hand.add(workshop)
        self.player1.hand.add(throne_room)

        select_future = gen.Future()
        select_from_supply_future = gen.Future()
        select_from_supply_future2 = gen.Future()
        self.player1.select = unittest.mock.MagicMock(
            return_value=select_future)
        self.player1.select_from_supply = unittest.mock.MagicMock(side_effect=[
            select_from_supply_future, select_from_supply_future2
        ])
        self.player1.gain = unittest.mock.Mock(wraps=self.player1.gain)

        throne_room.play()
        select_future.set_result(["Workshop"])
        yield gen.moment

        select_from_supply_future.set_result(["Silver"])
        yield gen.moment
        self.player1.gain.assert_called_once_with("Silver")

        select_from_supply_future2.set_result(["Estate"])
        yield gen.moment
        self.player1.gain.assert_called_with("Estate")
Exemplo n.º 13
0
	def test_Torturer_Throne_Room(self):
		tu.print_test_header("test Torturer Throne Room")
		throne_room = base.Throne_Room(self.game, self.player1)
		torturer = intrigue.Torturer(self.game, self.player1)
		self.player1.hand.add(torturer)

		throne_room.play()
		#Throne room a torturer
		yield tu.send_input(self.player1, "post_selection", ["Torturer"])
		#Player 2 is choosing, everyone else waits
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue("player2" in self.player1.last_mode["msg"])
		self.assertTrue(self.player3.last_mode["mode"] == "wait")

		yield tu.send_input(self.player2, "post_selection", ["Gain a Curse"])
		#player3's turn to get torturered
		self.assertTrue("player3" in self.player1.last_mode["msg"])
		self.assertTrue(self.player3.last_mode["mode"] != "wait")
		self.assertTrue(self.player2.last_mode["mode"] == "wait")
		self.assertTrue(self.player1.last_mode["mode"] == "wait")

		yield tu.send_input(self.player3, "post_selection", ["Gain a Curse"])
		self.assertTrue("Curse" in self.player3.hand)
		yield gen.sleep(.1)
		#Second torturer
		yield tu.send_input(self.player2, "post_selection", ["Discard 2 cards"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player3.last_mode["mode"] == "wait")
		yield tu.send_input(self.player2, "post_selection", ["Curse", "Copper"])
		self.assertTrue(self.player3.last_mode["mode"] != "wait")
		yield tu.send_input(self.player3, "post_selection", ["Gain a Curse"])
		self.assertTrue(self.player1.last_mode["mode"] != "wait")
Exemplo n.º 14
0
	def test_Baron(self):
		tu.print_test_header("test Baron")
		baron = intrigue.Baron(self.game, self.player1)
		tu.clear_player_hand(self.player1)
		tu.add_many_to_hand(self.player1, baron,3)
		estate = supply_cards.Estate(self.game, self.player1)
		# sadly add an estate to hand since no guarantees -- actually overwrites hand
		self.player1.hand.add(estate)
		self.player1.actions = 3

		# decline Estate discard, gain Estate to discard pile.
		baron.play()
		yield tu.send_input(self.player1, "post_selection", ["No"])
		self.assertTrue(self.player1.buys == 2)
		self.assertTrue(len(self.player1.discard_pile) == 1)

		# accept Estate discard, do not gain Estate to discard pile, gain $4
		baron.play()
		yield tu.send_input(self.player1, "post_selection", ["Yes"])
		self.assertTrue(self.player1.buys == 3)
		self.assertTrue(self.player1.balance == 4)
		self.assertFalse("Estate" in self.player1.hand)

		# Not given option because no Estates in hand.
		baron.play()
		self.assertTrue(self.player1.buys == 4)
Exemplo n.º 15
0
	def test_Forge(self):
		tu.print_test_header("test Forge")
		forge = prosperity.Forge(self.game, self.player1)
		steward = intrigue.Steward(self.game, self.player1)
		minion = intrigue.Minion(self.game, self.player1)
		torturer = intrigue.Torturer(self.game, self.player1)
		secret_chamber = intrigue.Secret_Chamber(self.game, self.player1)
		gold = supply_cards.Gold(self.game, self.player1)

		self.player1.hand.add(steward)
		self.player1.hand.add(minion)
		self.player1.hand.add(torturer)
		self.player1.hand.add(secret_chamber)
		self.player1.hand.add(gold)

		forge.play()
		# trash prices total to 8
		yield tu.send_input(self.player1, "post_selection", ["Steward", "Copper", "Copper", "Minion"])
		self.assertTrue(len(self.game.trash_pile) == 4)
		yield tu.send_input(self.player1, "selectSupply", ["Province"])
		self.assertTrue(self.player1.discard_pile[0].title == "Province")

		forge.play()
		# trash prices total to 13 -- nothing to gain
		yield tu.send_input(self.player1, "post_selection", ["Torturer", "Secret Chamber", "Gold"])
		self.assertTrue(self.player1.cb is None)
Exemplo n.º 16
0
	def test_end_tie(self):
		tu.print_test_header("test end tie")
		self.game.turn = 1
		for i in range(0, 6):
			self.player1.gain("Province")
			self.player2.gain("Province")
		self.assertTrue(self.game.detect_end())
Exemplo n.º 17
0
	def test_remove_from_supply(self):
		tu.print_test_header("test remove from supply")
		self.assertTrue(self.game.supply.get_count("Estate") == 12)
		self.assertTrue(self.game.base_supply.get_count("Estate") == 12)
		self.game.remove_from_supply("Estate")
		self.assertTrue(self.game.supply.get_count("Estate") == 11)
		self.assertTrue(self.game.base_supply.get_count("Estate") == 11)
Exemplo n.º 18
0
	def test_Merchant_Ship(self):
		tu.print_test_header("test Merchant Ship")
		merchant_ship = sea.Merchant_Ship(self.game, self.player1)
		merchant_ship.play()
		self.assertTrue(self.player1.balance == 2)
		merchant_ship.duration()
		self.assertTrue(self.player1.balance == 4)
Exemplo n.º 19
0
    def test_kc_kc_duration(self):
        tu.print_test_header("Test king's court king's court duration")
        kc = prosperity.Kings_Court(self.game, self.player1)
        caravan = sea.Caravan(self.game, self.player1)
        tu.add_many_to_hand(self.player1, kc, 2)
        tu.add_many_to_hand(self.player1, caravan, 3)

        player1_kc_1_select_future = gen.Future()
        player1_kc_2_select_future = gen.Future()
        player1_kc_3_select_future = gen.Future()
        player1_kc_4_select_future = gen.Future()
        self.player1.select = unittest.mock.Mock(side_effect=[
            player1_kc_1_select_future, player1_kc_2_select_future,
            player1_kc_3_select_future, player1_kc_4_select_future
        ])
        kc.play()
        player1_kc_1_select_future.set_result(["King's Court"])
        yield gen.moment
        player1_kc_2_select_future.set_result(["Caravan"])
        yield gen.moment
        player1_kc_3_select_future.set_result(["Caravan"])
        yield gen.moment
        player1_kc_4_select_future.set_result(["Caravan"])
        yield gen.moment
        self.assertTrue(len(self.player1.durations) == 4)
        self.assertTrue(len(self.player1.played_cards) == 1)
        self.assertTrue(len(self.player1.duration_cbs) == 12)
Exemplo n.º 20
0
	def test_Bazaar(self):
		tu.print_test_header("test Bazaar")
		bazaar = sea.Bazaar(self.game, self.player1)
		bazaar.play()
		self.assertTrue(self.player1.actions == 2)
		self.assertTrue(len(self.player1.hand) == 6)
		self.assertTrue(self.player1.balance == 1)
Exemplo n.º 21
0
    def test_Duchess(self):
        tu.print_test_header("Test Duchess")
        duchess = hl.Duchess(self.game, self.player1)
        self.player1.hand.add(duchess)

        player1top = self.player1.deck[-1]
        player2top = self.player2.deck[-1]
        player3top = self.player3.deck[-1]

        tu.send_input(self.player1, "play", "Duchess")
        self.assertTrue(self.player1.balance == 2)
        self.assertTrue(self.player1.last_mode["mode"] == "select")
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        self.assertTrue(self.player3.last_mode["mode"] == "select")
        yield tu.send_input(self.player2, "post_selection", ["Discard"])
        self.assertTrue(self.player1.last_mode["mode"] == "select")
        self.assertTrue(self.player2.discard_pile[-1] == player2top)
        self.assertTrue(self.player2.last_mode["mode"] != "select")
        yield tu.send_input(self.player1, "post_selection", ["Put Back"])
        self.assertTrue(self.player1.deck[-1] == player1top)
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        yield tu.send_input(self.player3, "post_selection", ["Discard"])
        self.assertTrue(self.player1.last_mode["mode"] != "wait")

        self.player1.end_turn()
        self.player2.balance = 5
        yield tu.send_input(self.player2, "buyCard", "Duchy")
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        yield tu.send_input(self.player2, "post_selection", ["Yes"])
        self.assertTrue(self.player2.last_mode["mode"] != "select")
        self.assertTrue(self.player2.discard_pile[-1].title == "Duchess")
Exemplo n.º 22
0
    def test_Fools_Gold(self):
        tu.print_test_header("test Fool's Gold")
        fg = hl.Fools_Gold(self.game, self.player1)
        tu.clear_player_hand(self.player1)
        tu.add_many_to_hand(self.player1, fg, 3)

        fg2 = hl.Fools_Gold(self.game, self.player3)
        tu.add_many_to_hand(self.player3, fg2, 2)

        yield tu.send_input(self.player1, "play", "Fool's Gold")
        yield tu.send_input(self.player1, "play", "Fool's Gold")
        yield tu.send_input(self.player1, "play", "Fool's Gold")
        self.assertTrue(self.player1.balance == 9)

        yield tu.send_input(self.player1, "buyCard", "Province")
        self.assertTrue(self.player3.last_mode["mode"] == "select")
        self.assertTrue(self.game.get_turn_owner() == self.player1)
        # Trash fool's gold
        yield tu.send_input(self.player3, "post_selection", ["Yes"])
        self.assertTrue(len(self.player3.hand) == 6)
        self.assertTrue(self.player3.deck[-1].title == "Gold")
        self.assertTrue(self.game.trash_pile[-1].title == "Fool's Gold")
        self.assertTrue(self.player3.last_mode["mode"] == "select")
        yield tu.send_input(self.player3, "post_selection", ["Yes"])
        self.assertTrue(self.player3.deck[-2].title == "Gold")
Exemplo n.º 23
0
	def test_City(self):
		tu.print_test_header("test City")
		city = prosperity.City(self.game, self.player1)

		cards_in_hand = len(self.player1.hand.card_array())

		city.play()
		self.assertTrue(self.player1.balance == 0)
		self.assertTrue(self.player1.actions == 2)
		self.assertTrue(len(self.player1.hand.card_array()) == cards_in_hand + 1)
		self.assertTrue(self.player1.buys == 1)
		self.assertTrue(self.player1.balance == 0)

		self.game.empty_piles = 1

		city.play()
		self.assertTrue(len(self.player1.hand.card_array()) == cards_in_hand + 3)
		self.assertTrue(self.player1.actions == 3)
		self.assertTrue(self.player1.buys == 1)
		self.assertTrue(self.player1.balance == 0)

		self.game.empty_piles = 2

		city.play()
		self.assertTrue(len(self.player1.hand.card_array()) == cards_in_hand + 5)
		self.assertTrue(self.player1.actions == 4)
		self.assertTrue(self.player1.buys == 2)
		self.assertTrue(self.player1.balance == 1)
Exemplo n.º 24
0
	def test_Rabble(self):
		tu.print_test_header("test Rabble")
		rabble = prosperity.Rabble(self.game, self.player1)
		copper = supply_cards.Copper(self.game, self.player2)
		estate = supply_cards.Estate(self.game, self.player2)

		self.player2.deck.append(estate)
		self.player2.deck.append(copper)
		self.player2.deck.append(estate)

		duchy = supply_cards.Duchy(self.game, self.player3)
		gardens = base.Gardens(self.game, self.player3)
		great_hall = intrigue.Great_Hall(self.game, self.player3)

		self.player3.deck.append(duchy)
		self.player3.deck.append(gardens)
		self.player3.deck.append(great_hall)

		rabble.play()
		topdeck1 = self.player2.topdeck()
		topdeck2 = self.player2.topdeck()
		self.assertTrue(topdeck1.title == "Estate")
		self.assertTrue(topdeck2.title == "Estate")
		yield tu.send_input(self.player3, "post_selection", ["Gardens", "Duchy"])

		topdeck1 = self.player3.topdeck()
		topdeck2 = self.player3.topdeck()

		self.assertTrue(topdeck1.title == "Duchy")
		self.assertTrue(topdeck2.title == "Gardens")
Exemplo n.º 25
0
	def test_Thief_3_players(self):
		tu.print_test_header("test Thief 3 players")
		thief_card = base.Thief(self.game, self.player1)
		self.player1.hand.add(thief_card)

		player2gold = supply_cards.Gold(self.game, self.player2)
		player3copper = supply_cards.Copper(self.game, self.player3)

		self.player2.deck = [supply_cards.Estate(self.game, self.player2), player2gold]
		self.player3.deck = [player3copper, supply_cards.Estate(self.game, self.player3)]
		select_gain_gold_future = gen.Future()
		select_gain_copper_future = gen.Future()
		gain_future = gen.Future()
		self.player1.select = unittest.mock.MagicMock(side_effect=[select_gain_gold_future, select_gain_copper_future])
		self.player1.gain = unittest.mock.Mock(return_value=gain_future)

		thief_card.play()
		self.assertTrue(player2gold in self.game.trash_pile)

		select_gain_gold_future.set_result(["Yes"])
		yield gen.moment
		self.player1.gain.assert_called_with("Gold", False)
		gain_future.set_result("finish gaining gold")
		yield gen.moment
		self.assertTrue(player3copper in self.game.trash_pile)
		select_gain_copper_future.set_result(["Yes"])
		yield gen.moment
		self.player1.gain.assert_called_with("Copper", False)
Exemplo n.º 26
0
	def test_Royal_Seal(self):
		tu.print_test_header("test Royal Seal")
		royal_seal = prosperity.Royal_Seal(self.game, self.player1)
		workers_village = prosperity.Workers_Village(self.game, self.player1)
		copper = supply_cards.Copper(self.game, self.player1)
		self.player1.hand.add(royal_seal)
		self.player1.hand.add(copper)
		tu.add_many_to_hand(self.player1, workers_village, 3)

		workers_village.play()
		workers_village.play()
		workers_village.play()

		royal_seal.play()
		yield tu.send_input(self.player1, "buyCard", "Curse")
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		yield tu.send_input(self.player1, "post_selection", ["Yes"])
		self.assertTrue(self.player1.deck[-1].title == "Curse")
		yield gen.sleep(.2)
		self.assertTrue(self.player1.last_mode["mode"] == "buy")

		yield tu.send_input(self.player1, "buyCard", "Silver")
		self.assertTrue(self.player1.last_mode["mode"] == "select")

		yield tu.send_input(self.player1, "post_selection", ["No"])
		self.assertTrue(self.player1.discard_pile[-1].title == "Silver")
		yield gen.sleep(.2)
		self.assertTrue(self.player1.last_mode["mode"] == "buy")
		yield tu.send_input(self.player1, "buyCard", "Mint")
		self.assertTrue(self.player1.last_mode["mode"] == "buy")
Exemplo n.º 27
0
	def test_Duchess(self):
		tu.print_test_header("Test Duchess")
		duchess = hl.Duchess(self.game, self.player1)
		self.player1.hand.add(duchess)

		player1top = self.player1.deck[-1]
		player2top = self.player2.deck[-1]
		player3top = self.player3.deck[-1]

		tu.send_input(self.player1, "play", "Duchess")
		self.assertTrue(self.player1.balance == 2)
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		self.assertTrue(self.player2.last_mode["mode"] == "select")
		self.assertTrue(self.player3.last_mode["mode"] == "select")
		yield tu.send_input(self.player2, "post_selection", ["Discard"])
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		self.assertTrue(self.player2.discard_pile[-1] == player2top)
		self.assertTrue(self.player2.last_mode["mode"] != "select")
		yield tu.send_input(self.player1, "post_selection", ["Put Back"])
		self.assertTrue(self.player1.deck[-1] == player1top)
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		yield tu.send_input(self.player3, "post_selection", ["Discard"])
		self.assertTrue(self.player1.last_mode["mode"] != "wait")

		self.player1.end_turn()
		self.player2.balance = 5
		yield tu.send_input(self.player2, "buyCard", "Duchy")
		self.assertTrue(self.player2.last_mode["mode"] == "select")
		yield tu.send_input(self.player2, "post_selection", ["Yes"])
		self.assertTrue(self.player2.last_mode["mode"] != "select")
		self.assertTrue(self.player2.discard_pile[-1].title == "Duchess")
Exemplo n.º 28
0
	def test_Throne_Room_on_Workshop(self):
		tu.print_test_header("test Throne Room workshop")
		throne_room = base.Throne_Room(self.game, self.player1)
		workshop = base.Workshop(self.game, self.player1)
		self.player1.hand.add(workshop)
		self.player1.hand.add(throne_room)

		select_future = gen.Future()
		select_from_supply_future = gen.Future()
		select_from_supply_future2 = gen.Future()
		self.player1.select = unittest.mock.MagicMock(return_value=select_future)
		self.player1.select_from_supply = unittest.mock.MagicMock(side_effect=[select_from_supply_future, select_from_supply_future2])
		self.player1.gain = unittest.mock.Mock(wraps=self.player1.gain)

		throne_room.play()
		select_future.set_result(["Workshop"])
		yield gen.moment

		select_from_supply_future.set_result(["Silver"])
		yield gen.moment
		self.player1.gain.assert_called_once_with("Silver")

		select_from_supply_future2.set_result(["Estate"])
		yield gen.moment
		self.player1.gain.assert_called_with("Estate")
Exemplo n.º 29
0
	def test_Scheme(self):
		tu.print_test_header("test Scheme")
		scheme1 = hl.Scheme(self.game, self.player1)
		scheme2 = hl.Scheme(self.game, self.player2)

		tu.add_many_to_hand(self.player1, scheme1, 2)
		self.player2.hand.add(scheme2)

		tu.send_input(self.player1, "play", "Scheme")
		tu.send_input(self.player1, "play", "Scheme")
		self.player1.end_turn()
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		yield tu.send_input(self.player1, "post_selection", ["Scheme", "Scheme"])
		self.assertTrue(self.game.get_turn_owner() == self.player2)
		self.assertTrue(self.player1.hand.get_count("Scheme") == 2)

		tu.send_input(self.player2, "play", "Scheme")

		self.player2.end_turn()
		self.assertTrue(self.player2.last_mode["mode"] == "select")
		self.assertTrue(self.player2.last_mode["max_cards"] == 1)
		yield tu.send_input(self.player2, "post_selection", ["Scheme"])

		self.player3.end_turn()
		self.assertTrue(self.player3.last_mode["mode"] != "select")
Exemplo n.º 30
0
	def test_Fools_Gold(self):
		tu.print_test_header("test Fool's Gold")
		fg = hl.Fools_Gold(self.game, self.player1)
		tu.clear_player_hand(self.player1)
		tu.add_many_to_hand(self.player1, fg, 3)

		fg2 = hl.Fools_Gold(self.game, self.player3)
		tu.add_many_to_hand(self.player3, fg2, 2)

		yield tu.send_input(self.player1, "play", "Fool's Gold")
		yield tu.send_input(self.player1, "play", "Fool's Gold")
		yield tu.send_input(self.player1, "play", "Fool's Gold")
		self.assertTrue(self.player1.balance == 9)

		yield tu.send_input(self.player1, "buyCard", "Province")
		self.assertTrue(self.player3.last_mode["mode"] == "select")
		self.assertTrue(self.game.get_turn_owner() == self.player1)
		# Trash fool's gold
		yield tu.send_input(self.player3, "post_selection", ["Yes"])
		self.assertTrue(len(self.player3.hand) == 6)
		self.assertTrue(self.player3.deck[-1].title == "Gold")
		self.assertTrue(self.game.trash_pile[-1].title == "Fool's Gold")
		self.assertTrue(self.player3.last_mode["mode"] == "select")
		yield tu.send_input(self.player3, "post_selection", ["Yes"])
		self.assertTrue(self.player3.deck[-2].title == "Gold")
Exemplo n.º 31
0
	def test_watchtower_trader(self):
		tu.print_test_header("test Watchtower Trader")
		watchtower = prosperity.Watchtower(self.game, self.player1)
		trader = hl.Trader(self.game, self.player1)
		self.player1.hand.add(watchtower)
		self.player1.hand.add(trader)

		self.player1.spend_all_money()
		yield tu.send_input(self.player1, "buyCard", "Copper")
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		#order reactions, reveal trader then watchtower
		yield tu.send_input(self.player1, "post_selection", ["Watchtower", "Trader"])
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		#reveal trader
		yield tu.send_input(self.player1, "post_selection", ["Reveal"])
		self.assertTrue(self.game.supply.get_count("Copper") == 30)
		#gaining silver now
		yield tu.send_input(self.player1, "post_selection", ["Watchtower", "Trader"])
		# trader's reaction is ignored since its for silver
		# reveal watchtower
		yield tu.send_input(self.player1, "post_selection", ["Reveal"])
		yield tu.send_input(self.player1, "post_selection", ["Put on top of deck"])
		self.assertTrue(self.player1.deck[-1].title == "Silver")

		#watchtower from the copper earlier
		yield tu.send_input(self.player1, "post_selection", ["Reveal"])
		yield tu.send_input(self.player1, "post_selection", ["Put on top of deck"])
		self.assertTrue(self.player1.deck[-1].title == "Silver")
Exemplo n.º 32
0
	def test_Trader(self):
		tu.print_test_header("test Trader")
		witch = base.Witch(self.game, self.player1)
		trader = hl.Trader(self.game, self.player2)
		
		#2 curses left
		for i in range(0, self.game.supply.get_count("Curse")-2):
			self.game.remove_from_supply("Curse")

		self.player1.hand.add(witch)
		self.player2.hand.add(trader)
		#reaction
		tu.send_input(self.player1, "play", "Witch")
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		yield tu.send_input(self.player2, "post_selection", ["Reveal"])
		self.assertTrue(len(self.game.trash_pile) == 0)
		#and gained a silver
		self.assertTrue(self.player2.discard_pile[-1].title == "Silver")
		yield gen.sleep(.1)
		self.assertTrue(self.player1.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.discard_pile[-1].title == "Curse")

		#one curse returned to supply
		self.assertTrue(self.game.supply.get_count("Curse") == 1)
		self.assertTrue(self.game.empty_piles == 0)

		self.player1.end_turn()

		self.player2.hand.add(supply_cards.Estate(self.game, self.player2))
		tu.send_input(self.player2, "play", "Trader")
		yield tu.send_input(self.player2, "post_selection", ["Estate"])
		self.assertTrue(len(self.player2.discard_pile) == 3)
Exemplo n.º 33
0
	def test_Mandarin(self):
		tu.print_test_header("test Mandarin")
		tu.add_many_to_hand(self.player1, supply_cards.Silver(self.game, self.player1), 3)
		tu.add_many_to_hand(self.player1, supply_cards.Gold(self.game, self.player1), 2)

		tu.send_input(self.player1, "play", "Gold")
		tu.send_input(self.player1, "play", "Silver")
		tu.send_input(self.player1, "play", "Silver")

		yield tu.send_input(self.player1, "buyCard", "Mandarin")
		
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		yield tu.send_input(self.player1, "post_selection", ["Silver", "Silver", "Gold"])
		self.assertTrue(len(self.player1.played_cards) == 0)
		self.assertTrue(self.player1.deck[-1].title == "Gold")
		self.assertTrue(self.player1.deck[-2].title == "Silver")
		self.assertTrue(self.player1.deck[-3].title == "Silver")

		self.player1.end_turn()
		self.player2.hand.add(hl.Mandarin(self.game, self.player2))
		self.player2.hand.add(supply_cards.Silver(self.game, self.player2))
		tu.send_input(self.player2, "play", "Mandarin")
		self.assertTrue(self.player2.balance == 3)
		self.assertTrue(self.player2.last_mode["mode"] == "select")
		yield tu.send_input(self.player2, "post_selection", ["Copper"])
		self.assertTrue(self.player2.deck[-1].title == "Copper")
		self.assertTrue(len(self.player2.hand) == 5)
Exemplo n.º 34
0
    def test_Vault(self):
        tu.print_test_header("testing vault")
        vault = prosperity.Vault(self.game, self.player1)
        self.player1.hand.add(vault)

        vault.play()
        yield tu.send_input(self.player1, "post_selection",
                            ["Estate", "Estate"])
        #add two coppers to player2's hand so he can use vault to discard
        tu.add_many_to_hand(self.player2,
                            supply_cards.Copper(self.game, self.player2), 2)
        self.assertTrue(self.player1.balance == 2)
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        #both players should be able to choose to discard at the same time
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        self.assertTrue(self.player3.last_mode["mode"] == "select")
        yield tu.send_input(self.player2, "post_selection", ["Yes"])
        cards_in_hand = len(self.player2.hand.card_array())
        yield tu.send_input(self.player2, "post_selection",
                            ["Copper", "Copper"])
        self.assertTrue(
            len(self.player2.hand.card_array()) == cards_in_hand - 1)

        yield tu.send_input(self.player3, "post_selection", ["No"])
        self.assertTrue(self.player1.last_mode["mode"] == "buy")
Exemplo n.º 35
0
	def test_Trading_Post(self):
		tu.print_test_header("test Trading Post")
		trading_post = intrigue.Trading_Post(self.game, self.player1)
		copper = supply_cards.Copper(self.game, self.player1)
		tu.clear_player_hand(self.player1)
		self.player1.hand.add(copper)
		self.player1.hand.add(trading_post)
		self.player1.actions = 3

		yield tu.send_input(self.player1, "play", "Trading Post")
		self.assertTrue(len(self.player1.hand) == 0)

		tu.clear_player_hand(self.player1)
		self.player1.hand.add(copper)
		self.player1.hand.add(copper)
		self.player1.hand.add(trading_post)

		trading_post.play()
		self.assertTrue(self.player1.hand.get_count("Silver") == 1)

		self.player1.hand.add(trading_post)
		self.player1.hand.add(trading_post)
		self.player1.hand.add(trading_post)
		trading_post.play()
		yield tu.send_input(self.player1, "post_selection", ["Trading Post", "Trading Post"])
		self.assertTrue(self.player1.hand.get_count("Silver") == 2)
Exemplo n.º 36
0
    def test_Thief_3_players(self):
        tu.print_test_header("test Thief 3 players")
        thief_card = base.Thief(self.game, self.player1)
        self.player1.hand.add(thief_card)

        player2gold = supply_cards.Gold(self.game, self.player2)
        player3copper = supply_cards.Copper(self.game, self.player3)

        self.player2.deck = [
            supply_cards.Estate(self.game, self.player2), player2gold
        ]
        self.player3.deck = [
            player3copper,
            supply_cards.Estate(self.game, self.player3)
        ]
        select_gain_gold_future = gen.Future()
        select_gain_copper_future = gen.Future()
        gain_future = gen.Future()
        self.player1.select = unittest.mock.MagicMock(
            side_effect=[select_gain_gold_future, select_gain_copper_future])
        self.player1.gain = unittest.mock.Mock(return_value=gain_future)

        thief_card.play()
        self.assertTrue(player2gold in self.game.trash_pile)

        select_gain_gold_future.set_result(["Yes"])
        yield gen.moment
        self.player1.gain.assert_called_with("Gold", False)
        gain_future.set_result("finish gaining gold")
        yield gen.moment
        self.assertTrue(player3copper in self.game.trash_pile)
        select_gain_copper_future.set_result(["Yes"])
        yield gen.moment
        self.player1.gain.assert_called_with("Copper", False)
Exemplo n.º 37
0
	def test_Masquerade(self):
		tu.print_test_header("test Masquerade")
		masquerade = intrigue.Masquerade(self.game, self.player1)
		curse = supply_cards.Curse(self.game, self.player1)
		baron = intrigue.Baron(self.game, self.player2)
		tribute = intrigue.Tribute(self.game, self.player3)

		self.player1.hand.add(masquerade)
		self.player1.hand.add(curse)
		self.player2.hand.add(baron)
		self.player3.hand.add(tribute)

		masquerade.play()
		self.assertTrue(self.player1.hand.get_count("Curse") == 1)
		yield tu.send_input(self.player1, "post_selection", ["Curse"])
		self.assertTrue(self.player1.hand.get_count("Curse") == 0)

		self.assertTrue(self.player2.hand.get_count("Baron") == 1)
		yield tu.send_input(self.player2, "post_selection", ["Baron"])
		self.assertTrue(self.player2.hand.get_count("Curse") == 1)
		self.assertTrue(self.player2.hand.get_count("Baron") == 0)

		self.assertTrue(self.player3.hand.get_count("Tribute") == 1)
		yield tu.send_input(self.player3, "post_selection", ["Tribute"])
		self.assertTrue(self.player3.hand.get_count("Baron") == 1)
		self.assertTrue(self.player3.hand.get_count("Tribute") == 0)
		self.assertTrue(self.player1.hand.get_count("Tribute") == 1)
		yield tu.send_input(self.player1, "post_selection", ["Tribute"])
		self.assertTrue(self.player1.hand.get_count("Tribute") == 0)
Exemplo n.º 38
0
    def test_Scheme(self):
        tu.print_test_header("test Scheme")
        scheme1 = hl.Scheme(self.game, self.player1)
        scheme2 = hl.Scheme(self.game, self.player2)

        tu.add_many_to_hand(self.player1, scheme1, 2)
        self.player2.hand.add(scheme2)

        tu.send_input(self.player1, "play", "Scheme")
        tu.send_input(self.player1, "play", "Scheme")
        self.player1.end_turn()
        self.assertTrue(self.player1.last_mode["mode"] == "select")
        yield tu.send_input(self.player1, "post_selection",
                            ["Scheme", "Scheme"])
        self.assertTrue(self.game.get_turn_owner() == self.player2)
        self.assertTrue(self.player1.hand.get_count("Scheme") == 2)

        tu.send_input(self.player2, "play", "Scheme")

        self.player2.end_turn()
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        self.assertTrue(self.player2.last_mode["max_cards"] == 1)
        yield tu.send_input(self.player2, "post_selection", ["Scheme"])

        self.player3.end_turn()
        self.assertTrue(self.player3.last_mode["mode"] != "select")
Exemplo n.º 39
0
	def test_throne_room_throne_room(self):
		tu.print_test_header("Test throne room throne room")
		throneroom = base.Throne_Room(self.game, self.player1)
		throneroom2 = base.Throne_Room(self.game, self.player1)
		self.player1.hand.add(throneroom)
		self.player1.hand.add(throneroom2)
		yield tu.send_input(self.player1, "play", "Throne Room")
		yield tu.send_input(self.player1, "post_selection", ["Throne Room"])

		self.player1.end_turn()
		self.player2.end_turn()
		self.player3.end_turn()

		self.player1.hand.add(throneroom)
		self.player1.hand.add(throneroom2)
		self.player1.hand.add(base.Village(self.game, self.player1))
		self.player1.hand.add(base.Village(self.game, self.player1))
		self.player1.hand.add(base.Woodcutter(self.game, self.player1))
		yield tu.send_input(self.player1, "play", "Throne Room")
		yield tu.send_input(self.player1, "post_selection", ["Village"])
		self.assertTrue(self.player1.actions == 4)
		self.assertTrue(self.player1.last_mode["mode"] == "action")

		yield tu.send_input(self.player1, "play", "Throne Room")
		yield tu.send_input(self.player1, "post_selection", ["Woodcutter"])
		self.assertTrue(self.player1.balance == 4)
		self.assertTrue(self.player1.last_mode["mode"] == "action")
Exemplo n.º 40
0
	def test_Border_Village(self):
		tu.print_test_header("test Border Village")
		yield tu.send_input(self.player1, "buyCard", "Border Village")

		yield tu.send_input(self.player1, "selectSupply", ["Duchy"])

		self.assertTrue(len([x for x in self.player1.discard_pile if x.title == "Border Village"]) == 1)
		self.assertTrue(len([x for x in self.player1.discard_pile if x.title == "Duchy"]) == 1)
Exemplo n.º 41
0
	def test_Monument(self):
		tu.print_test_header("test Monument")
		monument = prosperity.Monument(self.game, self.player1)
		monument.play()
		self.assertTrue(self.player1.balance == 2)
		self.assertTrue(self.player1.vp == 1)

		self.assertTrue(self.player1.total_vp() == 4)
Exemplo n.º 42
0
	def test_Forge_nothing(self):
		tu.print_test_header("test Forge nothing")
		forge = prosperity.Forge(self.game, self.player1)
		forge.play()
		yield tu.send_input(self.player1, "post_selection", [])
		self.assertTrue(self.player1.last_mode["mode"] == "selectSupply")
		yield tu.send_input(self.player1, "selectSupply", ["Copper"])
		self.assertTrue(len(self.player1.waiter.waiting_on) == 0)
Exemplo n.º 43
0
 def test_Farmland(self):
     tu.print_test_header("test Farmland")
     yield tu.send_input(self.player1, "buyCard", "Farmland")
     yield tu.send_input(self.player1, "post_selection", ["Copper"])
     yield tu.send_input(self.player1, "selectSupply", ["Estate"])
     self.assertTrue(
         len([x for x in self.player1.discard_pile
              if x.title == "Estate"]) == 1)
Exemplo n.º 44
0
 def test_Forge_nothing(self):
     tu.print_test_header("test Forge nothing")
     forge = prosperity.Forge(self.game, self.player1)
     forge.play()
     yield tu.send_input(self.player1, "post_selection", [])
     self.assertTrue(self.player1.last_mode["mode"] == "selectSupply")
     yield tu.send_input(self.player1, "selectSupply", ["Copper"])
     self.assertTrue(len(self.player1.waiter.waiting_on) == 0)
Exemplo n.º 45
0
    def test_Monument(self):
        tu.print_test_header("test Monument")
        monument = prosperity.Monument(self.game, self.player1)
        monument.play()
        self.assertTrue(self.player1.balance == 2)
        self.assertTrue(self.player1.vp == 1)

        self.assertTrue(self.player1.total_vp() == 4)
Exemplo n.º 46
0
	def test_Great_Hall(self):
		tu.print_test_header("test Great Hall")
		great_hall = intrigue.Great_Hall(self.game, self.player1)
		player1_vp = self.player1.total_vp()
		self.player1.hand.add(great_hall)
		great_hall.play()
		self.assertTrue((self.player1.actions == 1))
		self.assertTrue((self.player1.total_vp()) == player1_vp + 1)
Exemplo n.º 47
0
	def test_Pawn(self):
		tu.print_test_header("test Pawn")
		pawn = intrigue.Pawn(self.game, self.player1)
		self.player1.hand.add(pawn)
		pawn.play()
		yield tu.send_input(self.player1, "post_selection", ["+$1", "+1 Action"])
		self.assertTrue(self.player1.balance == 1)
		self.assertTrue(self.player1.actions == 1)
Exemplo n.º 48
0
	def test_Lighthouse(self):
		tu.print_test_header("test Lighthouse")
		lighthouse = sea.Lighthouse(self.game, self.player1)
		lighthouse.play()
		militia = base.Militia(self.game, self.player2)
		self.assertTrue(militia.is_blocked(self.player1))
		self.assertTrue(militia.is_blocked(self.player1))
		lighthouse.duration()
		self.assertFalse(militia.is_blocked(self.player1))
Exemplo n.º 49
0
	def test_Pearl_Diver(self):
		tu.print_test_header("test Pearl Diver")
		pearl_diver = sea.Pearl_Diver(self.game, self.player1)
		pearl_diver.play()
		self.assertTrue(len(self.player1.hand) == 6)
		self.assertTrue(self.player1.actions == 1)
		bottom_deck = self.player1.deck[0]
		yield tu.send_input(self.player1, "post_selection", ["Yes"])
		self.assertTrue(self.player1.topdeck() == bottom_deck)
Exemplo n.º 50
0
	def test_Salvager(self):
		tu.print_test_header("test Salvager")
		salvager = sea.Salvager(self.game, self.player1)
		province = supply_cards.Province(self.game, self.player1)
		self.player1.hand.add(province)
		salvager.play()
		yield tu.send_input(self.player1, "post_selection", ["Province"])
		self.assertTrue(self.player1.buys == 2)
		self.assertTrue(self.player1.balance == 8)
Exemplo n.º 51
0
	def test_invalid_selection(self):
		tu.print_test_header("test invalid selection")
		selection_future = self.player1.select(1, 1, ["Copper", "Curse"], "Select Copper or Curse")
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		yield tu.send_input(self.player1, "post_selection", ["Province"])
		self.assertTrue(selection_future.running())
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		yield tu.send_input(self.player1, "post_selection", ["Curse"])
		self.assertTrue(selection_future.result() == ["Curse"])
Exemplo n.º 52
0
	def test_Caravan(self):
		tu.print_test_header("test Caravan")
		caravan = sea.Caravan(self.game, self.player1)
		hand_count = len(self.player1.hand)
		caravan.play()
		self.assertTrue(self.player1.actions == 1)
		self.assertTrue(len(self.player1.hand) == hand_count + 1)
		caravan.duration()
		self.assertTrue(len(self.player1.hand) == hand_count + 2)
Exemplo n.º 53
0
	def test_Talisman_Supply(self):
		tu.print_test_header("test Talisman supply")
		talisman = prosperity.Talisman(self.game, self.player1)
		self.player1.hand.add(talisman)

		talisman.play()
		coppers = self.game.supply.get_count("Copper")
		yield tu.send_input(self.player1, "buyCard", "Copper")
		self.assertTrue(self.game.supply.get_count("Copper") == coppers - 2)
Exemplo n.º 54
0
	def test_Bridge(self):
		tu.print_test_header("test Bridge")
		bridge = intrigue.Bridge(self.game, self.player1)
		self.player1.hand.add(bridge)
		bridge.play()
		self.assertTrue(self.player1.balance == 1)
		self.player1.buy_card("Estate")
		self.assertTrue(self.player1.balance == 0)
		self.assertTrue(self.player1.buys == 1)
Exemplo n.º 55
0
	def test_Expand(self):
		tu.print_test_header("testing expand")
		expand = prosperity.Expand(self.game, self.player1)

		expand.play()
		yield tu.send_input(self.player1, "post_selection", ["Copper"])
		yield tu.send_input(self.player1, "post_selection", ["Silver"])

		self.assertTrue(self.player1.discard_pile[0].title == "Silver")
Exemplo n.º 56
0
	def test_Swindler(self):
		tu.print_test_header("test Swindler")
		swindler = intrigue.Swindler(self.game, self.player1)
		self.player2.deck.append(supply_cards.Copper(self.game, self.player2))
		self.player1.hand.add(swindler)

		swindler.play()
		yield tu.send_input(self.player1, "selectSupply", ["Curse"])
		self.assertTrue(self.player2.discard_pile[-1].title == "Curse")
Exemplo n.º 57
0
	def test_quarry_peddler(self):
		tu.print_test_header("test Quarry Peddler")
		village = base.Village(self.game, self.player1)
		quarry = prosperity.Quarry(self.game, self.player1)

		supply_peddler = self.game.supply.get_card("Peddler")
		village.play()
		quarry.play()
		self.assertTrue(supply_peddler.get_price() == 8-2-2)
Exemplo n.º 58
0
	def test_Workers_Village(self):
		tu.print_test_header("test Worker's Village")
		workers_village = prosperity.Workers_Village(self.game, self.player1)

		workers_village.play()

		self.assertTrue(len(self.player1.hand.card_array()) == 6)
		self.assertTrue(self.player1.buys == 2)
		self.assertTrue(self.player1.actions == 2)