本文整理汇总了Python中tests.testing_utils.generate_game_for函数的典型用法代码示例。如果您正苦于以下问题:Python generate_game_for函数的具体用法?Python generate_game_for怎么用?Python generate_game_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_game_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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))
示例2: test_Wrath
def test_Wrath(self):
game = generate_game_for(Wrath, StonetuskBoar, EnemyMinionSpellTestingAgent, MinionPlayingAgent)
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, MinionPlayingAgent)
game.players[0].agent.choose_option = Mock(side_effect=lambda one, three: three)
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].defense)
示例3: 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)
示例4: 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)
示例5: test_ExplosiveTrap
def test_ExplosiveTrap(self):
game = generate_game_for(ExplosiveTrap, StonetuskBoar, SpellTestingAgent, 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, SpellTestingAgent, SpellTestingAgent)
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)
示例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_this_turn)
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.assertFalse(game.other_player.hero.frozen_this_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_this_turn)
self.assertFalse(game.players[0].minions[0].frozen)
示例7: 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))
示例8: 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)
示例9: 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)
示例10: 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)
示例11: test_AncientOfLore
def test_AncientOfLore(self):
game = generate_game_for(AncientOfLore, Starfire, MinionPlayingAgent, 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.health, 25)
game.play_single_turn()
self.assertEqual(30, game.current_player.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].attack_power)
self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)
random.seed(1857)
game = generate_game_for(AncientOfLore, StonetuskBoar, MinionPlayingAgent, DoNothingBot)
game.players[0].agent.choose_option = Mock(side_effect=lambda heal, draw: draw)
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].attack_power)
self.assertEqual("Ancient of Lore", game.current_player.minions[0].card.name)
示例12: test_AncestralSpirit
def test_AncestralSpirit(self):
game = generate_game_for([ArgentCommander, AncestralSpirit], StonetuskBoar, MinionPlayingAgent, DoNothingBot)
for turn in range(0, 11):
game.play_single_turn()
self.assertEqual(1, len(game.players[0].minions))
self.assertEqual("Argent Commander", game.players[0].minions[0].card.name)
self.assertEqual(2, game.players[0].minions[0].health)
self.assertTrue(game.players[0].minions[0].divine_shield)
game.play_single_turn()
# Ancestral Spirit should be played on the Argent Commander
game.play_single_turn()
self.assertEqual(1, len(game.players[0].minions))
game.players[0].minions[0].health = 1
game.players[0].minions[0].divine_shield = False
# Let the minion die in order to test Ancestral Spirit
commander = game.players[0].minions[0]
commander.die(None)
commander.activate_delayed()
self.assertEqual(1, len(game.players[0].minions))
self.assertEqual("Argent Commander", game.players[0].minions[0].card.name)
self.assertEqual(2, game.players[0].minions[0].health)
self.assertTrue(game.players[0].minions[0].divine_shield)
示例13: test_FrostShock
def test_FrostShock(self):
game = generate_game_for(FrostShock, StonetuskBoar, SpellTestingAgent, DoNothingBot)
# Frost Shock should be played
game.play_single_turn()
self.assertEqual(29, game.players[1].hero.health)
self.assertTrue(game.players[1].hero.frozen)
示例14: test_BestialWrath
def test_BestialWrath(self):
def verify_bwrath():
self.assertEqual(3, game.other_player.minions[0].calculate_attack())
self.assertTrue(game.other_player.minions[0].immune)
def verify_silence():
self.assertFalse(game.other_player.minions[0].immune)
self.assertEqual(1, game.other_player.minions[0].calculate_attack())
game = generate_game_for(StonetuskBoar, [BestialWrath, BestialWrath, BestialWrath, Silence, BoulderfistOgre],
OneCardPlayingAgent, EnemyMinionSpellTestingAgent)
game.play_single_turn()
game.other_player.bind_once("turn_ended", verify_bwrath)
game.play_single_turn()
self.assertEqual(1, len(game.other_player.minions))
self.assertFalse(game.other_player.minions[0].immune)
self.assertEqual(1, game.other_player.minions[0].calculate_attack())
game.play_single_turn()
game.other_player.bind_once("turn_ended", verify_silence)
game.play_single_turn()
self.assertEqual(2, len(game.other_player.minions))
self.assertFalse(game.other_player.minions[0].immune)
self.assertEqual(1, game.other_player.minions[0].calculate_attack())
self.assertEqual(2, len(game.players[1].hand))
示例15: test_UnboundElemental
def test_UnboundElemental(self):
game = generate_game_for([UnboundElemental, DustDevil, DustDevil], StonetuskBoar, MinionPlayingAgent,
DoNothingBot)
for turn in range(0, 6):
game.play_single_turn()
self.assertEqual(1, len(game.players[0].minions))
self.assertEqual("Unbound Elemental", game.players[0].minions[0].card.name)
self.assertEqual(2, game.players[0].minions[0].calculate_attack())
self.assertEqual(4, game.players[0].minions[0].calculate_max_health())
# One Dust Devil should be played, giving the Unbound Elemental +1/+1
game.play_single_turn()
self.assertEqual(2, len(game.players[0].minions))
self.assertEqual(3, game.players[0].minions[-1].calculate_attack())
self.assertEqual(5, game.players[0].minions[-1].calculate_max_health())
# Test the silence
game.players[0].minions[-1].silence()
self.assertEqual(2, game.players[0].minions[-1].calculate_attack())
self.assertEqual(4, game.players[0].minions[-1].calculate_max_health())
# Another Dust Devil, nothing should happen because of silence
game.play_single_turn()
game.play_single_turn()
self.assertEqual(3, len(game.players[0].minions))
self.assertEqual(2, game.players[0].minions[-1].calculate_attack())
self.assertEqual(4, game.players[0].minions[-1].calculate_max_health())