コード例 #1
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))
コード例 #2
0
	def test_Secret_Chamber(self):
		tu.print_test_header("test Secret Chamber")
		secret_chamber = intrigue.Secret_Chamber(self.game, self.player1)
		estate = supply_cards.Estate(self.game, self.player1)
		tu.clear_player_hand(self.player1)

		tu.add_many_to_hand(self.player1, estate, 4)
		self.player1.hand.add(secret_chamber)

		secret_chamber.play()
		yield tu.send_input(self.player1, "post_selection", ["Estate", "Estate", "Estate", "Estate"])
		self.assertTrue(self.player1.balance == 4)
		self.player1.end_turn()
		
		tu.clear_player_hand(self.player1)
		tu.add_many_to_hand(self.player1, estate, 4)
		self.player1.hand.add(secret_chamber)
		#clear player3's hand no reaction
		tu.clear_player_hand(self.player3)

		self.player1.deck.append(supply_cards.Copper(self.game, self.player1))
		self.player1.deck.append(supply_cards.Copper(self.game, self.player1))
		self.player2.hand.add(base.Militia(self.game, self.player2))

		self.player2.hand.play("Militia")
		yield tu.send_input(self.player1, "post_selection", ["Reveal"])
		self.assertTrue(self.player2.last_mode["mode"] == "wait")
		#put back on top
		yield tu.send_input(self.player1, "post_selection", ["Estate", "Estate"])
		#second secret chamber
		yield tu.send_input(self.player1, "post_selection", ["Hide"])
		yield gen.sleep(.2)
		#discard
		yield tu.send_input(self.player1, "post_selection", ["Estate", "Estate"])
		self.assertTrue(len(self.player1.hand.card_array()) == 3)
		estates = self.player1.hand.get_count("Estate")
		self.player1.draw(2)
		self.assertTrue(self.player1.hand.get_count("Estate") == estates + 2)
		self.assertTrue(self.player2.last_mode["mode"] != "wait")
コード例 #3
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)
コード例 #4
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")
コード例 #5
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")