Esempio n. 1
0
	def test_Conspirator_Throne_Room(self):
		tu.print_test_header("test Conspirator Throne Room")
		conspirator = intrigue.Conspirator(self.game, self.player1)
		throne_room = base.Throne_Room(self.game, self.player1)
		tu.set_player_hand(self.player1, [conspirator, throne_room])
		throne_room.play()
		handsize = len(self.player1.hand)
		yield tu.send_input(self.player1, "post_selection", ["Conspirator"])
		self.assertTrue(self.player1.actions == 1)
		self.assertTrue(self.player1.balance == 4)
		#discard conspirator, draw 1 card should have same handsize
		self.assertTrue(handsize == len(self.player1.hand))
Esempio n. 2
0
	def test_Tactician(self):
		tu.print_test_header("test Tactician")
		tactician = sea.Tactician(self.game, self.player1)
		tactician.play()
		self.assertTrue(len(self.player1.hand) == 0)

		tactician.duration()
		self.assertTrue(self.player1.actions == 1)
		self.assertTrue(self.player1.buys == 2)
		self.assertTrue(len(self.player1.hand) == 5)

		tu.set_player_hand(self.player1, [tactician])
		tactician.play()
Esempio n. 3
0
	def test_Embassy(self):
		tu.print_test_header("test Embassy")
		self.player1.balance = 5
		yield tu.send_input(self.player1, "buyCard", "Embassy")
		self.assertTrue(self.player2.discard_pile[-1].title == "Silver")
		self.assertTrue(self.player3.discard_pile[-1].title == "Silver")
		embassy = hl.Embassy(self.game, self.player2)
		copper = supply_cards.Copper(self.game, self.player2)
		tu.set_player_hand(self.player2, [embassy])
		tu.add_many_to_hand(self.player2, copper, 4)
		embassy.play()
		yield tu.send_input(self.player2, "post_selection", ["Copper", "Copper", "Copper"])
		self.assertTrue(len(self.player2.hand) == 6)
Esempio n. 4
0
	def test_Watchtower_play(self):
		tu.print_test_header("testing Watchtower play action")
		watchtower = prosperity.Watchtower(self.game, self.player1)
		watchtower2 = prosperity.Watchtower(self.game, self.player1)
		estate = supply_cards.Estate(self.game, self.player1)
		tu.set_player_hand(self.player1, [watchtower, estate, watchtower2])
		self.player1.actions = 2
		watchtower.play()
		#3 cards in hand
		self.assertTrue(len(self.player1.hand) == 6)
		#7 cards in hand
		tu.set_player_hand(self.player1, [estate, estate, watchtower2, estate, estate, estate, estate])
		watchtower2.play()
		self.assertTrue(len(self.player1.hand) == 6)
Esempio n. 5
0
	def test_Kings_Court(self):
		tu.print_test_header("testing King's Court")
		conspirator = intrigue.Conspirator(self.game, self.player1)
		kings_court = prosperity.Kings_Court(self.game, self.player1)
		tu.set_player_hand(self.player1, [conspirator, kings_court])
		kings_court.play()
		yield tu.send_input(self.player1, "post_selection", ["Conspirator"])
		self.assertTrue(self.player1.actions == 2)
		self.assertTrue(self.player1.balance == 6)
		#conspirator should be triggered twice, we drew 2 cards
		self.assertTrue(len(self.player1.hand) == 2)
		self.player1.end_turn()
		conspirators_in_deck = [x for x in self.player1.all_cards() if x.title == "Conspirator"]
		self.assertTrue(len(conspirators_in_deck) == 1)
Esempio n. 6
0
 def test_Embassy(self):
     tu.print_test_header("test Embassy")
     self.player1.balance = 5
     yield tu.send_input(self.player1, "buyCard", "Embassy")
     self.assertTrue(self.player2.discard_pile[-1].title == "Silver")
     self.assertTrue(self.player3.discard_pile[-1].title == "Silver")
     embassy = hl.Embassy(self.game, self.player2)
     copper = supply_cards.Copper(self.game, self.player2)
     tu.set_player_hand(self.player2, [embassy])
     tu.add_many_to_hand(self.player2, copper, 4)
     embassy.play()
     yield tu.send_input(self.player2, "post_selection",
                         ["Copper", "Copper", "Copper"])
     self.assertTrue(len(self.player2.hand) == 6)
Esempio n. 7
0
	def test_Watchtower_react(self):
		tu.print_test_header("testing Watchtower reaction")
		watchtower = prosperity.Watchtower(self.game, self.player1)
		tu.set_player_hand(self.player1, [watchtower])
		self.player1.buy_card("Silver")
		#0 buys should end turn normally but we have a reaction so should still be player1's turn
		self.assertTrue(self.game.get_turn_owner().name == self.player1.name)
		#shouldn't trigger reaction wait for opponents
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		yield tu.send_input(self.player1, "post_selection", ["Reveal"])
		yield tu.send_input(self.player1, "post_selection", ["Put on top of deck"])
		self.assertTrue(len(self.player1.discard_pile) == 0)
		self.assertTrue(self.player1.deck[-1].title == "Silver")
Esempio n. 8
0
 def test_Kings_Court(self):
     tu.print_test_header("testing King's Court")
     conspirator = intrigue.Conspirator(self.game, self.player1)
     kings_court = prosperity.Kings_Court(self.game, self.player1)
     tu.set_player_hand(self.player1, [conspirator, kings_court])
     kings_court.play()
     yield tu.send_input(self.player1, "post_selection", ["Conspirator"])
     self.assertTrue(self.player1.actions == 2)
     self.assertTrue(self.player1.balance == 6)
     #conspirator should be triggered twice, we drew 2 cards
     self.assertTrue(len(self.player1.hand) == 2)
     self.player1.end_turn()
     conspirators_in_deck = [
         x for x in self.player1.all_cards() if x.title == "Conspirator"
     ]
     self.assertTrue(len(conspirators_in_deck) == 1)
Esempio n. 9
0
 def test_Watchtower_play(self):
     tu.print_test_header("testing Watchtower play action")
     watchtower = prosperity.Watchtower(self.game, self.player1)
     watchtower2 = prosperity.Watchtower(self.game, self.player1)
     estate = supply_cards.Estate(self.game, self.player1)
     tu.set_player_hand(self.player1, [watchtower, estate, watchtower2])
     self.player1.actions = 2
     watchtower.play()
     #3 cards in hand
     self.assertTrue(len(self.player1.hand) == 6)
     #7 cards in hand
     tu.set_player_hand(
         self.player1,
         [estate, estate, watchtower2, estate, estate, estate, estate])
     watchtower2.play()
     self.assertTrue(len(self.player1.hand) == 6)
Esempio n. 10
0
    def test_Watchtower_react(self):
        tu.print_test_header("testing Watchtower reaction")
        watchtower = prosperity.Watchtower(self.game, self.player1)
        tu.set_player_hand(self.player1, [watchtower])
        self.player1.buy_card("Silver")
        #0 buys should end turn normally but we have a reaction so should still be player1's turn
        self.assertTrue(self.game.get_turn_owner().name == self.player1.name)
        #shouldn't trigger reaction wait for opponents
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        yield tu.send_input(self.player1, "post_selection", ["Reveal"])
        yield tu.send_input(self.player1, "post_selection",
                            ["Put on top of deck"])
        self.assertTrue(len(self.player1.discard_pile) == 0)
        self.assertTrue(self.player1.deck[-1].title == "Silver")
Esempio n. 11
0
	def test_Kings_Court_duration(self):
		tu.print_test_header("testing King's Court Duration end effect")
		lighthouse = sea.Lighthouse(self.game, self.player1)
		kings_court = prosperity.Kings_Court(self.game, self.player1)
		tu.set_player_hand(self.player1, [lighthouse, kings_court])
		kings_court.play()
		yield tu.send_input(self.player1, "post_selection", ["Lighthouse"])
		self.assertTrue(self.player1.actions == 3)
		self.assertTrue(self.player1.balance == 3)
		self.player1.end_turn()
		self.player2.end_turn()
		self.player3.end_turn()
		self.assertTrue(kings_court not in self.player1.durations)
		self.assertTrue(lighthouse not in self.player1.durations)
		self.assertTrue(kings_court in self.player1.played_cards)
		self.assertTrue(lighthouse in self.player1.played_cards)
		self.assertTrue(self.player1.balance == 3)
Esempio n. 12
0
 def test_Kings_Court_duration(self):
     tu.print_test_header("testing King's Court Duration end effect")
     lighthouse = sea.Lighthouse(self.game, self.player1)
     kings_court = prosperity.Kings_Court(self.game, self.player1)
     tu.set_player_hand(self.player1, [lighthouse, kings_court])
     kings_court.play()
     yield tu.send_input(self.player1, "post_selection", ["Lighthouse"])
     self.assertTrue(self.player1.actions == 3)
     self.assertTrue(self.player1.balance == 3)
     self.player1.end_turn()
     self.player2.end_turn()
     self.player3.end_turn()
     self.assertTrue(kings_court not in self.player1.durations)
     self.assertTrue(lighthouse not in self.player1.durations)
     self.assertTrue(kings_court in self.player1.played_cards)
     self.assertTrue(lighthouse in self.player1.played_cards)
     self.assertTrue(self.player1.balance == 3)
Esempio n. 13
0
	def test_Margrave(self):
		tu.print_test_header("test Margrave")
		margrave = hl.Margrave(self.game, self.player1)
		tu.set_player_hand(self.player1, [margrave])
		margrave.play()
		
		self.assertTrue(len(self.player1.hand)==3)
		self.assertTrue(len(self.player2.hand)==6)
		self.assertTrue(len(self.player3.hand)==6)

		yield tu.send_input(self.player2, "post_selection", ["Copper", "Copper", "Copper"])
		yield tu.send_input(self.player3, "post_selection", ["Copper", "Copper", "Copper"])

		self.assertTrue(len(self.player2.hand)==3)
		self.assertTrue(len(self.player2.discard_pile)==3)
		self.assertTrue(len(self.player3.hand)==3)
		self.assertTrue(len(self.player3.discard_pile)==3)
Esempio n. 14
0
	def test_Masquerade_with_no_cards(self):
		tu.print_test_header("test Masquerade with no cards")
		masquerade = intrigue.Masquerade(self.game, self.player1)
		tu.set_player_hand(self.player1, [masquerade])
		self.player1.deck = []
		self.player1.discard_pile = []
		self.player2.hand.add(supply_cards.Estate(self.game, self.player2))
		self.player3.hand.add(supply_cards.Estate(self.game, self.player2))

		masquerade.play()
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		yield tu.send_input(self.player2, "post_selection", ["Estate"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		yield tu.send_input(self.player3, "post_selection", ["Estate"])
		self.assertTrue(self.player1.last_mode["mode"] == "select")
		yield tu.send_input(self.player1, "post_selection", ["Estate"])
		self.assertTrue(len(self.player1.hand) == 0)
Esempio n. 15
0
    def test_Margrave(self):
        tu.print_test_header("test Margrave")
        margrave = hl.Margrave(self.game, self.player1)
        tu.set_player_hand(self.player1, [margrave])
        margrave.play()

        self.assertTrue(len(self.player1.hand) == 3)
        self.assertTrue(len(self.player2.hand) == 6)
        self.assertTrue(len(self.player3.hand) == 6)

        yield tu.send_input(self.player2, "post_selection",
                            ["Copper", "Copper", "Copper"])
        yield tu.send_input(self.player3, "post_selection",
                            ["Copper", "Copper", "Copper"])

        self.assertTrue(len(self.player2.hand) == 3)
        self.assertTrue(len(self.player2.discard_pile) == 3)
        self.assertTrue(len(self.player3.hand) == 3)
        self.assertTrue(len(self.player3.discard_pile) == 3)
Esempio n. 16
0
	def test_Torturer(self):
		tu.print_test_header("test Torturer")
		torturer = intrigue.Torturer(self.game, self.player1)
		tu.add_many_to_hand(self.player1, torturer, 2)
		copper = supply_cards.Copper(self.game, self.player2)
		estate = supply_cards.Estate(self.game, self.player2)
		tu.set_player_hand(self.player2, [copper, copper, copper, estate, estate])
		self.player1.actions = 2
		tu.send_input(self.player1, "play", "Torturer")
		# choosing to discard 2
		yield tu.send_input(self.player2, "post_selection", ["Discard 2 cards"])
		yield tu.send_input(self.player2, "post_selection", ["Copper", "Copper"])
		yield tu.send_input(self.player3, "post_selection", ["Gain a Curse"])
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")
		self.assertTrue(len(self.player2.hand) == 3)

		tu.send_input(self.player1, "play", "Torturer")
		yield tu.send_input(self.player2, "post_selection", ["Gain a Curse"])
		yield tu.send_input(self.player3, "post_selection", ["Gain a Curse"])
		self.assertTrue(self.player2.hand.get_count('Curse') == 1)
Esempio n. 17
0
	def test_Trade_Route(self):
		tu.print_test_header("test Trade Route")
		trade_route = prosperity.Trade_Route(self.game, self.player1)
		copper = supply_cards.Copper(self.game, self.player1)
		tu.set_player_hand(self.player1, [trade_route, copper, copper, copper, copper])
		trade_route2 = prosperity.Trade_Route(self.game, self.player2)
		self.player2.hand.add(trade_route2)

		self.assertTrue(self.player1.buys == 1)
		trade_route.play()
		self.assertTrue(self.player1.buys == 2)
		self.assertTrue(self.player1.balance == 0)
		yield tu.send_input(self.player1, "post_selection", ["Copper"])
		self.player1.spend_all_money()
		#buy 2 estates
		tu.send_input(self.player1, "buyCard", "Estate")
		tu.send_input(self.player1, "buyCard", "Estate")
		self.player1.end_turn()

		trade_route2.play()
		yield tu.send_input(self.player2, "post_selection", ["Copper"])
		self.assertTrue(self.player2.balance == 1)
		self.assertTrue(self.player2.buys == 2)
Esempio n. 18
0
    def test_Trade_Route(self):
        tu.print_test_header("test Trade Route")
        trade_route = prosperity.Trade_Route(self.game, self.player1)
        copper = supply_cards.Copper(self.game, self.player1)
        tu.set_player_hand(self.player1,
                           [trade_route, copper, copper, copper, copper])
        trade_route2 = prosperity.Trade_Route(self.game, self.player2)
        self.player2.hand.add(trade_route2)

        self.assertTrue(self.player1.buys == 1)
        trade_route.play()
        self.assertTrue(self.player1.buys == 2)
        self.assertTrue(self.player1.balance == 0)
        yield tu.send_input(self.player1, "post_selection", ["Copper"])
        self.player1.spend_all_money()
        #buy 2 estates
        tu.send_input(self.player1, "buyCard", "Estate")
        tu.send_input(self.player1, "buyCard", "Estate")
        self.player1.end_turn()

        trade_route2.play()
        yield tu.send_input(self.player2, "post_selection", ["Copper"])
        self.assertTrue(self.player2.balance == 1)
        self.assertTrue(self.player2.buys == 2)
Esempio n. 19
0
    def test_2_reaction_waits(self):
        tu.print_test_header("test 2 reaction waits")
        militia = base.Militia(self.game, self.player1)
        moat = base.Moat(self.game, self.player2)
        secret_chamber = intrigue.Secret_Chamber(self.game, self.player2)
        self.player2.hand.add(moat)
        self.player2.hand.add(secret_chamber)
        self.player2.deck.append(supply_cards.Estate(self.game, self.player2))
        self.player2.deck.append(supply_cards.Estate(self.game, self.player2))

        moat3 = base.Moat(self.game, self.player3)
        secret_chamber3 = intrigue.Secret_Chamber(self.game, self.player3)
        silver = supply_cards.Silver(self.game, self.player3)
        tu.set_player_hand(self.player3,
                           [silver, silver, silver, moat3, secret_chamber3])

        militia.play()
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 choose order, moat then secret chamber
        yield tu.send_input(self.player2, "post_selection",
                            ["Secret Chamber", "Moat"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 reveals moat
        yield tu.send_input(self.player2, "post_selection", ["Reveal"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 3 chooses same order, moat then secret chamber
        yield tu.send_input(self.player3, "post_selection",
                            ["Secret Chamber", "Moat"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 reveals secret chamber
        yield tu.send_input(self.player2, "post_selection", ["Reveal"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 draws 2 estates, puts back 1 and a copper
        yield tu.send_input(self.player2, "post_selection",
                            ["Estate", "Copper"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 3 reveals moat
        yield tu.send_input(self.player3, "post_selection", ["Reveal"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 3 hides secret chamber
        yield tu.send_input(self.player3, "post_selection", ["Hide"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 drew cards so is reprompted and chooses order again
        yield tu.send_input(self.player2, "post_selection",
                            ["Secret Chamber", "Moat"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 hides moat
        yield tu.send_input(self.player2, "post_selection", ["Hide"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] != "wait")
        self.assertTrue(self.player3.last_mode["mode"] != "wait")

        #player 2 hides secret chamber
        yield tu.send_input(self.player2, "post_selection", ["Hide"])
        yield gen.sleep(.1)
        self.assertTrue(self.player1.last_mode["mode"] != "wait")
Esempio n. 20
0
    def test_2_Reactions(self):
        tu.print_test_header("test 2 reaction secret chamber moat")
        militia = base.Militia(self.game, self.player1)
        moat = base.Moat(self.game, self.player2)
        secret_chamber = intrigue.Secret_Chamber(self.game, self.player2)
        estate = supply_cards.Estate(self.game, self.player2)
        self.player2.hand.add(moat)
        self.player2.hand.add(secret_chamber)
        self.player2.deck.append(estate)
        self.player2.deck.append(estate)
        moat3 = base.Moat(self.game, self.player3)
        secret_chamber3 = intrigue.Secret_Chamber(self.game, self.player3)
        silver = supply_cards.Silver(self.game, self.player3)
        tu.set_player_hand(self.player3,
                           [silver, silver, silver, moat3, secret_chamber3])

        militia.play()
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        self.assertTrue(
            "Secret Chamber" in self.player2.last_mode["select_from"])
        self.assertTrue("Moat" in self.player2.last_mode["select_from"])
        yield tu.send_input(self.player2, "post_selection",
                            ["Secret Chamber", "Moat"])
        #moat trigger first
        self.assertTrue("Moat" in self.player2.last_mode["msg"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")

        #while player2 is deciding to reveal moat or not,
        #player3 chose order Secret chamber first
        self.assertTrue(self.player3.last_mode["mode"] == "select")

        yield tu.send_input(self.player3, "post_selection",
                            ["Moat", "Secret Chamber"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")

        #player3 reveals secret chamber
        self.assertTrue("Secret Chamber" in self.player3.last_mode["msg"])
        yield tu.send_input(self.player3, "post_selection", ["Reveal"])

        #player3 chooses to put back secret chamber and moat in secret chamber reaction
        yield tu.send_input(self.player3, "post_selection",
                            ["Secret Chamber", "Moat"])
        self.assertTrue(self.player3.deck[-1].title == "Moat")
        self.assertTrue(self.player3.deck[-2].title == "Secret Chamber")
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        #player2 reveals moat
        self.assertTrue(self.player2.last_mode["mode"] == "select")
        yield tu.send_input(self.player2, "post_selection", ["Reveal"])
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        #player2 reveals secret chamber
        yield tu.send_input(self.player2, "post_selection", ["Reveal"])
        #player2 puts back Estate, moat
        self.assertTrue(self.player2.protection == 1)
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        yield tu.send_input(self.player2, "post_selection", ["Moat", "Estate"])
        self.assertTrue(self.player2.deck[-1].title == "Estate")
        self.assertTrue(self.player2.deck[-2].title == "Moat")
        #workaround to allow ioloop to process nested yields in time
        yield gen.sleep(.2)
        self.assertTrue(self.player1.last_mode["mode"] == "wait")
        #player3 discards 2 silver
        yield tu.send_input(self.player3, "post_selection",
                            ["Silver", "Silver"])
        self.assertTrue(len(self.player3.hand) == 3)
        #player1 resumes
        self.assertTrue(self.player1.last_mode["mode"] == "buy")
Esempio n. 21
0
	def test_2_reaction_waits(self):
		tu.print_test_header("test 2 reaction waits")
		militia = base.Militia(self.game, self.player1)
		moat = base.Moat(self.game, self.player2)
		secret_chamber = intrigue.Secret_Chamber(self.game, self.player2)
		self.player2.hand.add(moat)
		self.player2.hand.add(secret_chamber)
		self.player2.deck.append(supply_cards.Estate(self.game, self.player2))
		self.player2.deck.append(supply_cards.Estate(self.game, self.player2))

		moat3 = base.Moat(self.game, self.player3)
		secret_chamber3 = intrigue.Secret_Chamber(self.game, self.player3)
		silver = supply_cards.Silver(self.game, self.player3)
		tu.set_player_hand(self.player3, [silver, silver, silver, moat3, secret_chamber3])

		militia.play()
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 choose order, moat then secret chamber
		yield tu.send_input(self.player2, "post_selection", ["Secret Chamber", "Moat"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 reveals moat
		yield tu.send_input(self.player2, "post_selection", ["Reveal"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 3 chooses same order, moat then secret chamber
		yield tu.send_input(self.player3, "post_selection", ["Secret Chamber", "Moat"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 reveals secret chamber
		yield tu.send_input(self.player2, "post_selection", ["Reveal"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 draws 2 estates, puts back 1 and a copper
		yield tu.send_input(self.player2, "post_selection", ["Estate", "Copper"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 3 reveals moat
		yield tu.send_input(self.player3, "post_selection", ["Reveal"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 3 hides secret chamber
		yield tu.send_input(self.player3, "post_selection", ["Hide"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 drew cards so is reprompted and chooses order again
		yield tu.send_input(self.player2, "post_selection", ["Secret Chamber", "Moat"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 hides moat
		yield tu.send_input(self.player2, "post_selection", ["Hide"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
		self.assertTrue(self.player3.last_mode["mode"] != "wait")

		#player 2 hides secret chamber
		yield tu.send_input(self.player2, "post_selection", ["Hide"])
		yield gen.sleep(.1)
		self.assertTrue(self.player1.last_mode["mode"] != "wait")
Esempio n. 22
0
	def test_2_Reactions(self):
		tu.print_test_header("test 2 reaction secret chamber moat")
		militia = base.Militia(self.game, self.player1)
		moat = base.Moat(self.game, self.player2)
		secret_chamber = intrigue.Secret_Chamber(self.game, self.player2)
		estate = supply_cards.Estate(self.game, self.player2)
		self.player2.hand.add(moat)
		self.player2.hand.add(secret_chamber)
		self.player2.deck.append(estate)
		self.player2.deck.append(estate)
		moat3 = base.Moat(self.game, self.player3)
		secret_chamber3 = intrigue.Secret_Chamber(self.game, self.player3)
		silver = supply_cards.Silver(self.game, self.player3)
		tu.set_player_hand(self.player3, [silver, silver, silver, moat3, secret_chamber3])

		militia.play()
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		self.assertTrue(self.player2.last_mode["mode"] == "select")
		self.assertTrue("Secret Chamber" in self.player2.last_mode["select_from"])		
		self.assertTrue("Moat" in self.player2.last_mode["select_from"])
		yield tu.send_input(self.player2, "post_selection", ["Secret Chamber", "Moat"])
		#moat trigger first
		self.assertTrue("Moat" in self.player2.last_mode["msg"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")

		#while player2 is deciding to reveal moat or not,
		#player3 chose order Secret chamber first
		self.assertTrue(self.player3.last_mode["mode"] == "select")

		yield tu.send_input(self.player3, "post_selection", ["Moat", "Secret Chamber"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")

		#player3 reveals secret chamber
		self.assertTrue("Secret Chamber" in self.player3.last_mode["msg"])
		yield tu.send_input(self.player3, "post_selection", ["Reveal"])

		#player3 chooses to put back secret chamber and moat in secret chamber reaction
		yield tu.send_input(self.player3, "post_selection", ["Secret Chamber", "Moat"])
		self.assertTrue(self.player3.deck[-1].title == "Moat")
		self.assertTrue(self.player3.deck[-2].title == "Secret Chamber")
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		#player2 reveals moat
		self.assertTrue(self.player2.last_mode["mode"] == "select")
		yield tu.send_input(self.player2, "post_selection", ["Reveal"])
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		#player2 reveals secret chamber
		yield tu.send_input(self.player2, "post_selection", ["Reveal"])
		#player2 puts back Estate, moat
		self.assertTrue(self.player2.protection == 1)
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		yield tu.send_input(self.player2, "post_selection", ["Moat", "Estate"])
		self.assertTrue(self.player2.deck[-1].title == "Estate")
		self.assertTrue(self.player2.deck[-2].title == "Moat")
		#workaround to allow ioloop to process nested yields in time
		yield gen.sleep(.2)
		self.assertTrue(self.player1.last_mode["mode"] == "wait")
		#player3 discards 2 silver
		yield tu.send_input(self.player3, "post_selection", ["Silver", "Silver"])
		self.assertTrue(len(self.player3.hand)==3)
		#player1 resumes
		self.assertTrue(self.player1.last_mode["mode"] == "buy")