本文整理汇总了Python中testsSDW.testing_utils.generate_game_for函数的典型用法代码示例。如果您正苦于以下问题:Python generate_game_for函数的具体用法?Python generate_game_for怎么用?Python generate_game_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_game_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Wrath
def test_Wrath(self):
game = generate_game_for(Wrath, StonetuskBoar, EnemyMinionSpellTestingAgent, OneCardPlayingAgent)
game.play_single_turn()
game.play_single_turn()
self.assertEqual(1, len(game.current_player.minions))
game.play_single_turn()
self.assertEqual(0, len(game.other_player.minions))
self.assertEqual(5, len(game.current_player.hand))
random.seed(1857)
game = generate_game_for(Wrath, MogushanWarden, EnemyMinionSpellTestingAgent, OneCardPlayingAgent)
game.players[0].agent.choose_option = lambda options, player: options[1]
for turn in range(0, 8):
game.play_single_turn()
self.assertEqual(1, len(game.current_player.minions))
game.play_single_turn()
self.assertEqual(1, len(game.other_player.minions))
# Two wraths will have been played
self.assertEqual(1, game.other_player.minions[0].health)
示例2: test_IceBarrier
def test_IceBarrier(self):
game = generate_game_for(IceBarrier, StonetuskBoar, CardTestingAgent, PredictableAgent)
for turn in range(0, 5):
game.play_single_turn()
self.assertEqual(1, len(game.current_player.secrets))
self.assertEqual("Ice Barrier", game.current_player.secrets[0].name)
game.play_single_turn()
# only one minion because PredictableAgent will shoot its own minions if there isn't anything else to shoot.
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(7, game.other_player.hero.armor)
# Attacked twice on the first turn, then fireballed before getting the armor up
self.assertEqual(27, game.other_player.hero.health)
# Make sure we can't have two identical secrets at the same time
random.seed(1857)
game = generate_game_for(IceBarrier, StonetuskBoar, CardTestingAgent, DoNothingAgent)
for turn in range(0, 6):
game.play_single_turn()
self.assertEqual(1, len(game.other_player.secrets))
self.assertEqual("Ice Barrier", game.other_player.secrets[0].name)
game.play_single_turn()
self.assertEqual(1, len(game.current_player.secrets))
self.assertEqual("Ice Barrier", game.current_player.secrets[0].name)
示例3: test_Spellbender
def test_Spellbender(self):
game = generate_game_for([Spellbender, Wisp], Moonfire, CardTestingAgent, CardTestingAgent)
for turn in range(0, 6):
game.play_single_turn()
# The moonfire should have been re-directed to the Spellbender, which should have taken one damage
self.assertEqual(2, len(game.other_player.minions))
self.assertEqual(2, game.other_player.minions[1].health)
self.assertEqual(1, game.other_player.minions[1].calculate_attack())
self.assertEqual("Spellbender", game.other_player.minions[1].card.name)
# Now make sure it won't work when the hero is targeted
random.seed(1857)
game = generate_game_for(Spellbender, Moonfire, CardTestingAgent, CardTestingAgent)
for turn in range(0, 6):
game.play_single_turn()
self.assertEqual(0, len(game.other_player.minions))
self.assertEqual(1, len(game.other_player.secrets))
self.assertEqual(23, game.other_player.hero.health)
# Now make sure it doesn't activate when a non-targeted spell is used
random.seed(1857)
game = generate_game_for(Spellbender, ArcaneIntellect, CardTestingAgent, CardTestingAgent)
for turn in range(0, 6):
game.play_single_turn()
# The arcane intellect should not have caused the Spellbender to activate
self.assertEqual(0, len(game.other_player.minions))
self.assertEqual(1, len(game.other_player.secrets))
示例4: test_ExplosiveTrap
def test_ExplosiveTrap(self):
game = generate_game_for(ExplosiveTrap, StonetuskBoar, CardTestingAgent, PlayAndAttackAgent)
for turn in range(0, 3):
game.play_single_turn()
self.assertEqual(1, len(game.current_player.secrets))
self.assertEqual(1, len(game.other_player.minions))
game.play_single_turn()
self.assertEqual(0, len(game.other_player.secrets))
self.assertEqual(0, len(game.current_player.minions))
self.assertEqual(28, game.current_player.hero.health)
self.assertEqual(29, game.other_player.hero.health)
random.seed(1857)
game = generate_game_for(ExplosiveTrap, Frostbolt, CardTestingAgent, CardTestingAgent)
for turn in range(0, 4):
game.play_single_turn()
self.assertEqual(1, len(game.other_player.secrets))
self.assertEqual(30, game.current_player.hero.health)
self.assertEqual(27, game.other_player.hero.health)
示例5: test_DarkWispers
def test_DarkWispers(self):
game = generate_game_for(DarkWispers, SaltyDog, CardTestingAgent, OneCardPlayingAgent)
game.players[0].agent.choose_option = lambda options, player: options[1]
for turn in range(0, 10):
game.play_single_turn()
# 1 Salty Dog on the field
self.assertEqual(0, len(game.players[0].minions))
self.assertEqual(1, len(game.players[1].minions))
self.assertEqual(7, game.players[1].minions[0].calculate_attack())
self.assertEqual(4, game.players[1].minions[0].health)
self.assertFalse(game.players[1].minions[0].taunt)
# Chooses to buff enemy Salty Dog
game.play_single_turn()
self.assertEqual(0, len(game.players[0].minions))
self.assertEqual(1, len(game.players[1].minions))
self.assertEqual(12, game.players[1].minions[0].calculate_attack())
self.assertEqual(9, game.players[1].minions[0].health)
self.assertTrue(game.players[1].minions[0].taunt)
random.seed(1857)
game = generate_game_for(DarkWispers, SaltyDog, CardTestingAgent, OneCardPlayingAgent)
for turn in range(0, 10):
game.play_single_turn()
# 1 Salty Dog on the field
self.assertEqual(0, len(game.players[0].minions))
self.assertEqual(1, len(game.players[1].minions))
# Summons 5 Wisps
game.play_single_turn()
self.assertEqual(5, len(game.players[0].minions))
self.assertEqual(1, len(game.players[1].minions))
self.assertEqual(1, game.players[0].minions[0].calculate_attack())
self.assertEqual(1, game.players[0].minions[0].health)
self.assertEqual("Wisp", game.players[0].minions[0].card.name)
self.assertEqual(1, game.players[0].minions[1].calculate_attack())
self.assertEqual(1, game.players[0].minions[1].health)
self.assertEqual("Wisp", game.players[0].minions[1].card.name)
self.assertEqual(1, game.players[0].minions[2].calculate_attack())
self.assertEqual(1, game.players[0].minions[2].health)
self.assertEqual("Wisp", game.players[0].minions[2].card.name)
self.assertEqual(1, game.players[0].minions[3].calculate_attack())
self.assertEqual(1, game.players[0].minions[3].health)
self.assertEqual("Wisp", game.players[0].minions[3].card.name)
self.assertEqual(1, game.players[0].minions[4].calculate_attack())
self.assertEqual(1, game.players[0].minions[4].health)
self.assertEqual("Wisp", game.players[0].minions[4].card.name)
game.play_single_turn()
game.play_single_turn()
self.assertEqual(7, len(game.players[0].minions))
示例6: test_Snowchugger
def test_Snowchugger(self):
game = generate_game_for(Snowchugger, StonetuskBoar, PredictableAgent, DoNothingAgent)
for turn in range(0, 7):
game.play_single_turn()
self.assertEqual(27, game.other_player.hero.health)
self.assertFalse(game.other_player.hero.frozen)
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(2, game.current_player.minions[0].calculate_attack())
self.assertEqual(3, game.current_player.minions[0].health)
self.assertEqual("Snowchugger", game.current_player.minions[0].card.name)
game.play_single_turn()
game.play_single_turn()
self.assertEqual(25, game.other_player.hero.health)
# Always false after the end of a turn
self.assertTrue(game.other_player.hero.frozen)
# Now make sure that attacking the Snowchugger directly will freeze a character
random.seed(1857)
game = generate_game_for(Snowchugger, IronbarkProtector, OneCardPlayingAgent, PredictableAgent)
for turn in range(0, 4):
game.play_single_turn()
self.assertEqual(1, len(game.other_player.minions))
self.assertEqual(2, game.other_player.minions[0].health)
# The player should be frozen because of weapon attack
self.assertEqual(29, game.current_player.hero.health)
self.assertTrue(game.current_player.hero.frozen)
game.play_single_turn()
game.play_single_turn()
# The player should still be frozen from last turn, and thus shouldn't have attacked
self.assertEqual(29, game.current_player.hero.health)
# If Snowchugger gets 0 attack, and is being attacked so will the minion NOT be frozen since no damage was dealt
game = generate_game_for(Snowchugger, StonetuskBoar, PredictableAgent, PredictableAgent)
for turn in range(0, 2):
game.play_single_turn()
self.assertEqual(1, len(game.players[1].minions))
self.assertEqual("Snowchugger", game.players[1].minions[0].card.name)
# Cheat
game.players[1].minions[0].base_attack = 0
self.assertEqual(0, game.players[1].minions[0].calculate_attack())
self.assertEqual(3, game.players[1].minions[0].health)
# Stonetusk should have attacked the Snowchugger, and will NOT be frozen since they didn't take damage
game.play_single_turn()
self.assertEqual(1, game.players[1].minions[0].health)
self.assertFalse(game.players[0].minions[0].frozen)
示例7: test_KeeperOfTheGrove
def test_KeeperOfTheGrove(self):
# Test Moonfire option
game = generate_game_for(KeeperOfTheGrove, StonetuskBoar, OneCardPlayingAgent, OneCardPlayingAgent)
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(3, len(game.current_player.minions))
game.play_single_turn()
self.assertEqual(2, len(game.other_player.minions))
# Test Dispel option
random.seed(1857)
game = generate_game_for(KeeperOfTheGrove, StonetuskBoar, OneCardPlayingAgent, OneCardPlayingAgent)
game.players[0].agent.choose_option = lambda options, player: options[1]
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertTrue(game.current_player.minions[0].charge())
game.play_single_turn()
self.assertFalse(game.other_player.minions[0].charge())
# Test when there are no targets for the spell
random.seed(1857)
game = generate_game_for(KeeperOfTheGrove, StonetuskBoar, OneCardPlayingAgent, DoNothingAgent)
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual("Keeper of the Grove", game.current_player.minions[0].card.name)
示例8: test_Nourish
def test_Nourish(self):
# Test gaining two mana
game = generate_game_for(Nourish, StonetuskBoar, OneCardPlayingAgent, DoNothingAgent)
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(7, game.current_player.max_mana)
self.assertEqual(7, len(game.current_player.hand))
# Ensure that the case where we would be over 10 mana is handled correctly
game.play_single_turn()
game.play_single_turn()
# Nourish is played. it brings the player to 10
self.assertEqual(10, game.current_player.max_mana)
self.assertEqual(5, game.current_player.mana)
game.play_single_turn()
game.play_single_turn()
# Nourish is played. It doesn't affect the max_mana, but it does fill in two crystals.
# Tested on patch 2.1.0.7785
self.assertEqual(10, game.current_player.max_mana)
self.assertEqual(7, game.current_player.mana)
# Test drawing three cards
random.seed(1857)
game = generate_game_for(Nourish, StonetuskBoar, CardTestingAgent, DoNothingAgent)
game.players[0].agent.choose_option = lambda options, player: options[1]
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(10, len(game.current_player.hand))
self.assertEqual(5, game.current_player.max_mana)
示例9: test_AncientOfLore
def test_AncientOfLore(self):
game = generate_game_for(AncientOfLore, Starfire, OneCardPlayingAgent, EnemySpellTestingAgent)
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(game.other_player.hero.health, 25)
game.play_single_turn()
self.assertEqual(30, game.current_player.hero.health)
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(5, game.current_player.minions[0].health)
self.assertEqual(5, game.current_player.minions[0].calculate_attack())
self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)
random.seed(1857)
game = generate_game_for(AncientOfLore, StonetuskBoar, OneCardPlayingAgent, DoNothingAgent)
game.players[0].agent.choose_option = lambda options, player: options[1]
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(10, len(game.current_player.hand))
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(5, game.current_player.minions[0].health)
self.assertEqual(5, game.current_player.minions[0].calculate_attack())
self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)
示例10: test_SorcerersApprentice
def test_SorcerersApprentice(self):
game = generate_game_for([SorcerersApprentice, ArcaneMissiles, SorcerersApprentice, Frostbolt, Frostbolt,
Frostbolt], StonetuskBoar, CardTestingAgent, DoNothingAgent)
game.play_single_turn()
game.play_single_turn()
game.play_single_turn()
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(3, game.current_player.minions[0].calculate_attack())
self.assertEqual(2, game.current_player.minions[0].health)
self.assertEqual("Sorcerer's Apprentice", game.current_player.minions[0].card.name)
# Arcane missiles should also have been played, since it is now free
self.assertEqual(27, game.other_player.hero.health)
# Make sure the other frostbolts have been properly reduced
self.assertEqual(1, game.current_player.hand[1].mana_cost())
self.assertEqual(1, game.current_player.hand[2].mana_cost())
game.play_single_turn()
game.play_single_turn()
# Both Sorcerer's Apprentices are killed by friendly Frostbolts.
self.assertEqual(0, len(game.current_player.minions))
# Make sure that the cards in hand are no longer reduced
self.assertEqual(2, game.current_player.hand[0].mana_cost())
示例11: test_PatientAssassin
def test_PatientAssassin(self):
game = generate_game_for([PatientAssassin, Shieldbearer, Shieldbearer, Shieldbearer, Shieldbearer, Shieldbearer,
Shieldbearer], [Sunwalker, Malygos], PlayAndAttackAgent,
OneCardPlayingAgent)
for turn in range(0, 12):
game.play_single_turn()
# Lots of turns have passed. The opponent hero shouldn't have died of the poison effect
self.assertEqual(7, len(game.players[0].minions))
self.assertEqual(26, game.players[1].hero.health)
self.assertFalse(game.players[1].hero.dead)
# And Sunwalker should have been played
self.assertEqual(1, len(game.players[1].minions))
self.assertTrue(game.players[1].minions[0].divine_shield)
# Patient Assassin should attack the Sunwalker, but only divine shield should be affected
game.play_single_turn()
self.assertEqual(6, len(game.players[0].minions))
self.assertEqual(1, len(game.players[1].minions))
self.assertFalse(game.players[1].minions[0].divine_shield)
self.assertEqual(5, game.players[1].minions[0].health)
# A new Patient Assassin should be played
game.play_single_turn()
game.play_single_turn()
self.assertEqual(7, len(game.players[0].minions))
# Patient Assassin should attack again, this time killing the Sunwalker since it no longer has divine shield
game.play_single_turn()
game.play_single_turn()
self.assertEqual(6, len(game.players[0].minions))
self.assertEqual(0, len(game.players[1].minions))
示例12: test_TradePrince_Gallywix_and_coin
def test_TradePrince_Gallywix_and_coin(self):
game = generate_game_for(TradePrinceGallywix, Blizzard, OneCardPlayingAgent, OneCardPlayingAgent)
for turn in range(12):
game.play_single_turn()
self.assertEqual("Gallywix's Coin", game.current_player.hand[-1].name)
示例13: test_IronSensei
def test_IronSensei(self):
game = generate_game_for(IronSensei, Mechwarper, OneCardPlayingAgent, OneCardPlayingAgent)
for turn in range(4):
game.play_single_turn()
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(0, len(game.other_player.minions))
game.play_single_turn()
self.assertEqual(1, len(game.current_player.minions))
self.assertEqual(2, game.current_player.minions[0].health)
self.assertEqual(1, len(game.other_player.minions))
self.assertEqual(3, game.other_player.minions[0].health)
game.play_single_turn()
self.assertEqual(2, len(game.current_player.minions))
self.assertEqual(3, game.current_player.minions[0].health)
self.assertEqual(3, game.current_player.minions[1].health)
self.assertEqual(1, len(game.other_player.minions))
self.assertEqual(2, game.other_player.minions[0].health)
game.play_single_turn()
self.assertEqual(2, len(game.current_player.minions))
self.assertEqual(4, game.current_player.minions[0].health)
self.assertEqual(4, game.current_player.minions[0].calculate_attack())
self.assertEqual(4, game.current_player.minions[1].health)
self.assertEqual(4, game.current_player.minions[1].calculate_attack())
self.assertEqual(2, len(game.other_player.minions))
self.assertEqual(3, game.other_player.minions[0].health)
self.assertEqual(3, game.other_player.minions[1].health)
示例14: test_GrommashHellscream
def test_GrommashHellscream(self):
game = generate_game_for(GrommashHellscream, ExplosiveTrap, PlayAndAttackAgent, CardTestingAgent)
for turn in range(0, 14):
game.play_single_turn()
# Hellscream should be played, attacking (charge) and getting 2 damage by trap that will trigger enrage,
# dealing 10 damage as result
game.play_single_turn()
self.assertEqual(1, len(game.players[0].minions))
self.assertEqual(10, game.players[0].minions[0].calculate_attack())
self.assertEqual(7, game.players[0].minions[0].health)
self.assertEqual(20, game.players[1].hero.health)
game.players[0].minions[0].heal(2, None)
self.assertEqual(4, game.players[0].minions[0].calculate_attack())
game.players[0].minions[0].damage(2, None)
self.assertEqual(10, game.players[0].minions[0].calculate_attack())
game.players[0].minions[0].silence()
self.assertEqual(4, game.players[0].minions[0].calculate_attack())
game.players[0].minions[0].heal(2, None)
self.assertEqual(4, game.players[0].minions[0].calculate_attack())
game.players[0].minions[0].damage(2, None)
self.assertEqual(4, game.players[0].minions[0].calculate_attack())
示例15: test_ShamanPower
def test_ShamanPower(self):
game = generate_game_for(AlAkirTheWindlord, MassDispel, PredictableAgent, CardTestingAgent)
for turn in range(0, 3):
game.play_single_turn()
self.assertEqual(1, len(game.players[0].minions))
self.assertEqual("Stoneclaw Totem", game.players[0].minions[0].card.name)
self.assertTrue(game.players[0].minions[0].taunt)
game.play_single_turn()
game.play_single_turn()
self.assertEqual(2, len(game.players[0].minions))
self.assertEqual("Healing Totem", game.players[0].minions[1].card.name)
game.play_single_turn()
game.play_single_turn()
self.assertEqual(3, len(game.players[0].minions))
self.assertEqual("Searing Totem", game.players[0].minions[2].card.name)
game.play_single_turn()
game.play_single_turn()
self.assertEqual(4, len(game.players[0].minions))
self.assertEqual("Wrath of Air Totem", game.players[0].minions[3].card.name)
self.assertEqual(1, game.players[0].spell_damage)
# All Totems are out, nothing should be summoned
game.play_single_turn()
game.play_single_turn()
self.assertEqual(4, len(game.players[0].minions))