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)
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")
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")
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)
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)
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")
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")
def test_Treasure_Map(self): tu.print_test_header("test Treasure Map") treasure_map = sea.Treasure_Map(self.game, self.player1) tu.add_many_to_hand(self.player1, treasure_map, 2) treasure_map.play() yield tu.send_input(self.player1, "post_selection", ["Yes"]) for i in range (0, 4): self.assertTrue(self.player1.deck.pop().title == 'Gold') self.assertTrue(self.player1.hand.get_count('Treasure Map') == 0)
def test_has_selectable(self): tu.print_test_header("test has selectable") #2 Remodels in hand tu.add_many_to_hand(self.player1, base.Remodel(self.game, self.player1), 2) #nothing in supply except remodel and gold both at 0 left self.game.supply.data = {"Remodel": [base.Remodel(self.game, None), 0], "Gold": [supply_cards.Gold(self.game, None), 0]} #try to remodel another remodel tu.send_input(self.player1, "play", "Remodel") self.assertTrue(self.player1.last_mode["mode"] == "select") yield tu.send_input(self.player1, "post_selection", ["Remodel"]) self.assertTrue(self.player1.last_mode["mode"] != "selectSupply")
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)
def test_Develop(self): tu.print_test_header("Test Develop") develop = hl.Develop(self.game, self.player1) tu.add_many_to_hand(self.player1, develop, 2) self.player1.hand.add(supply_cards.Copper(self.game, self.player1)) self.player1.hand.add(supply_cards.Estate(self.game, self.player1)) develop.play() yield tu.send_input(self.player1, "post_selection", ["Copper"]) develop.play() yield tu.send_input(self.player1, "post_selection", ["Estate"]) yield tu.send_input(self.player1, "selectSupply", ["Silver"]) self.assertTrue("Silver" == self.player1.discard_pile[-1].title)
def test_Upgrade(self): tu.print_test_header("test Upgrade") upgrade = intrigue.Upgrade(self.game, self.player1) tu.add_many_to_hand(self.player1, upgrade, 2) self.player1.hand.add(supply_cards.Copper(self.game, self.player1)) self.player1.hand.add(supply_cards.Estate(self.game, self.player1)) upgrade.play() yield tu.send_input(self.player1, "post_selection", ["Copper"]) upgrade.play() yield tu.send_input(self.player1, "post_selection", ["Estate"]) yield tu.send_input(self.player1, "selectSupply", ["Silver"]) self.assertTrue("Silver" == self.player1.discard_pile[-1].title)
def test_Nobles(self): tu.print_test_header("test Nobles") nobles = intrigue.Nobles(self.game, self.player1) tu.add_many_to_hand(self.player1, nobles, 2) nobles.play() yield tu.send_input(self.player1, "post_selection", ["+2 Actions"]) self.assertTrue(self.player1.actions == 2) cards_in_hand = len(self.player1.hand) nobles.play() yield tu.send_input(self.player1, "post_selection", ["+3 Cards"]) self.assertTrue(len(self.player1.hand) == cards_in_hand + 2)
def test_Shanty_Town(self): tu.print_test_header("test Shanty Town") shanty_town = intrigue.Shanty_Town(self.game, self.player1) tu.add_many_to_hand(self.player1, shanty_town,2) # First Play: has an action, should not draw cards. cards_in_hand = len(self.player1.hand) shanty_town.play() self.assertTrue(self.player1.actions == 2) self.assertTrue(len(self.player1.hand) == cards_in_hand - 1) # Second Play: has no other action cards in hand, should draw cards. shanty_town.play() self.assertTrue(self.player1.actions == 3) self.assertTrue(len(self.player1.hand) == cards_in_hand)
def test_Wishing_Well(self): tu.print_test_header("test Wishing Well") wishing_well = intrigue.Wishing_Well(self.game, self.player1) tu.add_many_to_hand(self.player1, wishing_well, 2) province = supply_cards.Province(self.game, self.player1) self.player1.deck.append(province) self.player1.deck.append(supply_cards.Silver(self.game, self.player1)) self.player1.deck.append(province) wishing_well.play() yield tu.send_input(self.player1, "selectSupply", ["Curse"]) self.assertTrue(self.player1.hand.get_count('Province') == 1) wishing_well.play() yield tu.send_input(self.player1, "selectSupply", ["Province"]) self.assertTrue(self.player1.hand.get_count('Province') == 2)
def test_Highway(self): tu.print_test_header("test Highway") highway = hl.Highway(self.game, self.player1) workshop = base.Workshop(self.game, self.player1) tu.add_many_to_hand(self.player1, highway, 4) self.player1.hand.add(workshop) tu.send_input(self.player1, "play", "Highway") tu.send_input(self.player1, "play", "Highway") tu.send_input(self.player1, "play", "Workshop") # Gold should cost 4 and should be workshoppable yield tu.send_input(self.player1, "selectSupply", ["Gold"]) self.assertTrue(len([x for x in self.player1.discard_pile if x.title == "Gold"]) == 1)
def test_Peddler(self): tu.print_test_header("test Peddler") village = base.Village(self.game, self.player1) copper = supply_cards.Copper(self.game, self.player1) self.player1.hand.add(copper) tu.add_many_to_hand(self.player1, village, 5) village.play() self.assertTrue(self.game.price_modifier["Peddler"] == 0) village.play() village.play() village.play() village.play() copper.play() self.assertTrue(self.game.price_modifier["Peddler"] == -10) self.assertTrue(self.game.card_from_title("Peddler").get_price() == 0)
def test_Conspirator(self): tu.print_test_header("test Conspirator") conspirator = intrigue.Conspirator(self.game, self.player1) tu.add_many_to_hand(self.player1, conspirator,2) village = base.Village(self.game, self.player1) self.player1.hand.add(village) village.play() conspirator.play() self.assertTrue(self.player1.actions == 1) self.assertTrue(self.player1.balance == 2) cards_in_hand = len(self.player1.hand) conspirator.play() self.assertTrue(self.player1.actions == 1) self.assertTrue(len(self.player1.hand) == cards_in_hand)
def test_Highway(self): tu.print_test_header("test Highway") highway = hl.Highway(self.game, self.player1) workshop = base.Workshop(self.game, self.player1) tu.add_many_to_hand(self.player1, highway, 4) self.player1.hand.add(workshop) tu.send_input(self.player1, "play", "Highway") tu.send_input(self.player1, "play", "Highway") tu.send_input(self.player1, "play", "Workshop") # Gold should cost 4 and should be workshoppable yield tu.send_input(self.player1, "selectSupply", ["Gold"]) self.assertTrue( len([x for x in self.player1.discard_pile if x.title == "Gold"]) == 1)
def test_Crossroads(self): tu.print_test_header("test Crossroads") crossroads = hl.Crossroads(self.game, self.player1) tu.add_many_to_hand(self.player1, crossroads, 2) base_hand_size = len(self.player1.hand) num_victory_cards = len(self.player1.hand.get_cards_by_type("Victory")) tu.send_input(self.player1, "play", "Crossroads") num_actions = self.player1.actions self.assertTrue(num_actions == 3) self.assertTrue(len(self.player1.hand ) == num_victory_cards + base_hand_size - 1) base_hand_size = len(self.player1.hand) num_victory_cards = len(self.player1.hand.get_cards_by_type("Victory")) deck_size = len(self.player1.deck) tu.send_input(self.player1, "play", "Crossroads") self.assertTrue(self.player1.actions == num_actions - 1) expected_drawn = min(deck_size, num_victory_cards) self.assertTrue(len(self.player1.hand) == expected_drawn + base_hand_size - 1)
def test_Tribute(self): tu.print_test_header("test Tribute") tribute = intrigue.Tribute(self.game, self.player1) tu.add_many_to_hand(self.player1, tribute, 2) copper = supply_cards.Copper(self.game, self.player2) great_hall = intrigue.Great_Hall(self.game, self.player2) swindler = intrigue.Swindler(self.game, self.player2) self.player2.deck.append(copper) self.player2.deck.append(copper) self.player2.deck.append(great_hall) self.player2.deck.append(swindler) cards_in_hand = len(self.player1.hand.card_array()) tribute.play() self.assertTrue(self.player1.actions == 4) self.assertTrue(len(self.player2.discard_pile) == 2) tribute.play() self.assertTrue(self.player1.balance == 2)
def test_Ironworks(self): tu.print_test_header("test Ironworks") ironworks = intrigue.Ironworks(self.game, self.player1) tu.add_many_to_hand(self.player1, ironworks, 4) self.player1.actions = 2 tu.send_input(self.player1, "play", "Ironworks") yield tu.send_input(self.player1, "selectSupply", ["Steward"]) self.assertTrue(self.player1.actions == 2) tu.send_input(self.player1, "play", "Ironworks") yield tu.send_input(self.player1, "selectSupply", ["Silver"]) self.assertTrue(self.player1.balance == 1) self.assertTrue(self.player1.actions == 1) tu.send_input(self.player1, "play", "Ironworks") cards_in_hand = len(self.player1.hand.card_array()) yield tu.send_input(self.player1, "selectSupply", ["Great Hall"]) self.assertTrue(self.player1.actions == 1) self.assertTrue(self.player1.hand, cards_in_hand + 1)
def test_quarry(self): tu.print_test_header("test Quarry") quarry = prosperity.Quarry(self.game, self.player1) bridge = intrigue.Bridge(self.game, self.player1) self.player1.hand.add(bridge) tu.add_many_to_hand(self.player1, quarry, 2) bridge.play() quarry.play() self.assertTrue(self.game.card_from_title("Estate").get_price() == 1) self.assertTrue(self.game.card_from_title("Village").get_price() == 0) self.assertTrue(self.game.card_from_title("Laboratory").get_price() == 2) quarry.play() self.assertTrue(self.game.card_from_title("Laboratory").get_price() == 0) self.assertTrue(self.player1.balance == 3) self.assertTrue(self.player1.last_mode["mode"] == "buy") tu.send_input(self.player1, "buyCard", "Laboratory") self.assertTrue(self.player1.balance == 3) self.player1.end_turn() self.assertTrue(self.game.card_from_title("Laboratory").get_price() == 5)
def test_tr_tr_duration(self): tu.print_test_header("Test throne room throne room duration") tr = base.Throne_Room(self.game, self.player1) caravan = sea.Caravan(self.game, self.player1) tu.add_many_to_hand(self.player1, tr, 2) tu.add_many_to_hand(self.player1, caravan, 2) player1_tr_1_select_future = gen.Future() player1_tr_2_select_future = gen.Future() player1_tr_3_select_future = gen.Future() self.player1.select = unittest.mock.Mock(side_effect=[player1_tr_1_select_future, player1_tr_2_select_future, player1_tr_3_select_future]) tr.play() player1_tr_1_select_future.set_result(["Throne Room"]) yield gen.moment player1_tr_2_select_future.set_result(["Caravan"]) yield gen.moment player1_tr_3_select_future.set_result(["Caravan"]) yield gen.moment self.assertTrue(len(self.player1.durations) == 3) self.assertTrue(len(self.player1.played_cards) == 1) self.assertTrue(len(self.player1.duration_cbs) == 6)
def test_Crossroads(self): tu.print_test_header("test Crossroads") crossroads = hl.Crossroads(self.game, self.player1) tu.add_many_to_hand(self.player1, crossroads, 2) base_hand_size = len(self.player1.hand) num_victory_cards = len(self.player1.hand.get_cards_by_type("Victory")) tu.send_input(self.player1, "play", "Crossroads") num_actions = self.player1.actions self.assertTrue(num_actions == 3) self.assertTrue( len(self.player1.hand) == num_victory_cards + base_hand_size - 1) base_hand_size = len(self.player1.hand) num_victory_cards = len(self.player1.hand.get_cards_by_type("Victory")) deck_size = len(self.player1.deck) tu.send_input(self.player1, "play", "Crossroads") self.assertTrue(self.player1.actions == num_actions - 1) expected_drawn = min(deck_size, num_victory_cards) self.assertTrue( len(self.player1.hand) == expected_drawn + base_hand_size - 1)
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")
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)
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")
def test_quarry(self): tu.print_test_header("test Quarry") quarry = prosperity.Quarry(self.game, self.player1) bridge = intrigue.Bridge(self.game, self.player1) self.player1.hand.add(bridge) tu.add_many_to_hand(self.player1, quarry, 2) bridge.play() quarry.play() self.assertTrue(self.game.card_from_title("Estate").get_price() == 1) self.assertTrue(self.game.card_from_title("Village").get_price() == 0) self.assertTrue( self.game.card_from_title("Laboratory").get_price() == 2) quarry.play() self.assertTrue( self.game.card_from_title("Laboratory").get_price() == 0) self.assertTrue(self.player1.balance == 3) self.assertTrue(self.player1.last_mode["mode"] == "buy") tu.send_input(self.player1, "buyCard", "Laboratory") self.assertTrue(self.player1.balance == 3) self.player1.end_turn() self.assertTrue( self.game.card_from_title("Laboratory").get_price() == 5)
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)
def test_tr_tr_duration(self): tu.print_test_header("Test throne room throne room duration") tr = base.Throne_Room(self.game, self.player1) caravan = sea.Caravan(self.game, self.player1) tu.add_many_to_hand(self.player1, tr, 2) tu.add_many_to_hand(self.player1, caravan, 2) player1_tr_1_select_future = gen.Future() player1_tr_2_select_future = gen.Future() player1_tr_3_select_future = gen.Future() self.player1.select = unittest.mock.Mock(side_effect=[ player1_tr_1_select_future, player1_tr_2_select_future, player1_tr_3_select_future ]) tr.play() player1_tr_1_select_future.set_result(["Throne Room"]) yield gen.moment player1_tr_2_select_future.set_result(["Caravan"]) yield gen.moment player1_tr_3_select_future.set_result(["Caravan"]) yield gen.moment self.assertTrue(len(self.player1.durations) == 3) self.assertTrue(len(self.player1.played_cards) == 1) self.assertTrue(len(self.player1.duration_cbs) == 6)
def test_Steward(self): tu.print_test_header("test Steward") steward = intrigue.Steward(self.game, self.player1) steward2 = intrigue.Steward(self.game, self.player1) steward3 = intrigue.Steward(self.game, self.player1) copper = supply_cards.Copper(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, steward, 3) tu.add_many_to_hand(self.player1, copper, 3) tu.add_many_to_hand(self.player1, estate, 2) self.player1.actions = 5 # +$2 steward.play() yield tu.send_input(self.player1, "post_selection", ["+$2"]) self.assertTrue(self.player1.balance == 2) # Trash 2 with more than 2 in hand steward2.play() trash_size = len(self.game.trash_pile) yield tu.send_input(self.player1, "post_selection", ["Trash 2 cards from hand"]) yield tu.send_input(self.player1, "post_selection", ["Estate", "Estate"]) self.assertTrue(len(self.game.trash_pile) == trash_size + 2) # Trash 2 with homogeneous hand steward3.play() yield tu.send_input(self.player1, "post_selection", ["Trash 2 cards from hand"]) self.assertTrue(self.player1.hand.get_count("Copper") == 1) self.player1.hand.add(steward) # Trash 2 with 1 in hand self.player1.hand.data["Steward"] = [intrigue.Steward(self.game, self.player1)] steward.play() yield tu.send_input(self.player1, "post_selection", ["Trash 2 cards from hand"]) self.assertTrue(len(self.player1.hand) == 0)