def test_mage(game): game = player.apply(player.Default, game, None, "mage", "ooze") assert game.party.mage == 1 assert game.dungeon.ooze == 0 game = player.apply(player.Default, game, None, "mage", "goblin") assert game.party.mage == 0 assert game.dungeon.goblin == 1
def test_elixir(game, randrange): game = game._replace(treasure=game.treasure._replace(elixir=1)) game = player.apply(player.Default, game, randrange, "elixir", "cleric") assert game.party.cleric == 1 assert game.treasure.elixir == 0 with pytest.raises(error.DrollError): player.apply(player.Default, game, randrange, "elixir", "mage")
def test_scroll_quaff(game): with pytest.raises(error.DrollError): player.apply(player.Default, game, None, "scroll", "potion", "fighter", "fighter") # Too soon game = __remove_monsters(game) # Required for drinking potions game = player.apply(player.Default, game, None, "scroll", "potion", "fighter", "fighter") # Duplicate assert game.party.scroll == 1 assert game.dungeon.potion == 0 assert game.party.fighter == 4
def test_fighter(game): game = player.apply(player.Default, game, None, "fighter", "goblin") assert game.party.fighter == 1 assert game.dungeon.goblin == 0 game = player.apply(player.Default, game, None, "fighter", "ooze") assert game.party.fighter == 0 assert game.dungeon.ooze == 1 with pytest.raises(error.DrollError): player.apply(player.Default, game, None, "fighter", "ooze")
def test_only_heroes_accepted(game, randrange): with pytest.raises(error.DrollError): player.apply( player.Default, game, randrange, "fighter", "dragon", "cleric", "foo", )
def test_bait(game, randrange): game = game._replace(treasure=game.treasure._replace(bait=2)) game = player.apply(player.Default, game, randrange, "bait", "dragon") assert game.treasure.bait == 1 assert game.dungeon.goblin == 0 assert game.dungeon.skeleton == 0 assert game.dungeon.ooze == 0 assert game.dungeon.dragon == 8 with pytest.raises(error.DrollError): player.apply(player.Default, game, randrange, "bait")
def test_champion(game): game = player.apply(player.Default, game, None, "champion", "goblin") assert game.party.champion == 1 assert game.dungeon.goblin == 0 game = __remove_monsters(game) # Required for drinking potion game = player.apply(player.Default, game, None, "champion", "potion", "cleric", "mage") # Different assert game.party.champion == 0 assert game.dungeon.potion == 0 assert game.party.cleric == 3 assert game.party.mage == 3
def test_monsters_remain(game, randrange): game = game._replace(dungeon=game.dungeon._replace(goblin=1)) with pytest.raises(error.DrollError): player.apply( player.Default, game, randrange, "fighter", "dragon", "cleric", "mage", )
def test_cleric(game, randrange): with pytest.raises(error.DrollError): player.apply(player.Default, game, None, "cleric", "dragon") game = player.apply(player.Default, game, None, "cleric", "skeleton") assert game.party.cleric == 1 assert game.dungeon.skeleton == 0 game = __remove_monsters(game) # Required for opening chest game = player.apply(player.Default, game, randrange, "cleric", "chest") assert game.party.cleric == 0 assert game.dungeon.chest == 1 assert sum(game.treasure) == 1
def test_thief(game, randrange): game = player.apply(player.Default, game, None, "thief", "ooze") assert game.party.thief == 1 assert game.dungeon.ooze == 1 game = __remove_monsters(game) # Required for opening chest game = player.apply(player.Default, game, randrange, "thief", "chest") assert game.party.thief == 0 assert game.dungeon.chest == 0 assert sum(game.treasure) == 2 game = game._replace(party=game.party._replace(thief=1)) # Add one with pytest.raises(error.DrollError): player.apply(player.Default, game, None, "thief", "chest")
def helper_sword(identifier, game): """Test sword when referred to via identifier (e.g. 'sword', 'fighter'.""" game = game._replace(treasure=game.treasure._replace(sword=2)) game = player.apply(player.Default, game, None, identifier, "goblin") assert game.treasure.sword == 1 assert game.party.fighter == 0 assert game.dungeon.goblin == 0 game = player.apply(player.Default, game, None, identifier, "ooze") assert game.treasure.sword == 0 assert game.party.fighter == 0 assert game.dungeon.ooze == 1 with pytest.raises(error.DrollError): player.apply(player.Default, game, None, identifier, "ooze")
def test_one_scroll(game, randrange): with pytest.raises(error.DrollError): player.apply( player.Default, game, randrange, "fighter", "dragon", "cleric", "scroll", ) # Dragon Slayer requires only two with pytest.raises(error.DrollError): player.apply(heroes.DragonSlayer, game, randrange, "fighter", "dragon", "scroll")
def test_successful(game, randrange): game = player.apply(player.Default, game, randrange, "fighter", "dragon", "cleric", "mage") assert game.party.fighter == 1 assert game.party.cleric == 1 assert game.party.mage == 1 assert game.dungeon.dragon == 0 assert game.experience == 1 assert sum(game.treasure) == 1
def test_too_many_specified(game, randrange): with pytest.raises(error.DrollError): player.apply( player.Default, game, randrange, "fighter", "dragon", "cleric", "mage", "thief", ) # Dragon Slayer requires only two with pytest.raises(error.DrollError): player.apply( heroes.DragonSlayer, game, randrange, "fighter", "dragon", "cleric", "mage", )
def test_treasure_slot2(game, randrange): game = game._replace(treasure=game.treasure._replace(sceptre=7)) game = game._replace(party=game.party._replace(mage=0)) game = player.apply( player.Default, game, randrange, # Notice talisman! "fighter", "dragon", "cleric", "mage", ) assert game.treasure.sceptre == 6 assert game.party.fighter == 1 assert game.party.cleric == 1 assert game.party.mage == 0 assert game.dungeon.dragon == 0 assert game.experience == 1 assert sum(game.treasure) == 7
def test_scroll_reroll(game): # Consumed by canned_sequence just below sequence = [0, 1, 2] def canned_sequence(start, stop): return start + sequence.pop(0) # Notice scroll causes chests to be re-rolled game = player.apply( player.Default, game, canned_sequence, "scroll", "chest", "ooze", "chest", ) assert game.party.scroll == 1 assert game.dungeon == struct.Dungeon(goblin=3, skeleton=3, ooze=2, chest=0, potion=2, dragon=2)
def test_not_enough_distinct(game, randrange): with pytest.raises(error.DrollError): player.apply(player.Default, game, randrange, "fighter", "dragon", "mage", "mage")