Exemple #1
0
class TestOrc(unittest.TestCase):

    def setUp(self):
        self.orc = Orc("Berserk", 100, 2)

    def test_orc_init(self):
        self.assertEqual("Berserk", self.orc.name)
        self.assertEqual(100, self.orc.health)
        self.assertEqual(2, self.orc.berserk_factor)

    def test_berserk_factor_over(self):
        tincho = Orc("Tincho", 200, 5)
        self.assertTrue(tincho.berserk_factor in [1, 2])

    def test_berserk_factor_under(self):
        pencho = Orc("Pencho", 210, 0.5)
        self.assertTrue(pencho.berserk_factor in [1, 2])

    def test_attack_berserk_with_weapon(self):
        weapon = Weapon("Mighty Axe", 25, 0.2)
        self.orc.equip_weapon(weapon)
        self.assertEqual(25 * 2, self.orc.attack())

    def test_attack_berserk_without_weapon(self):
        self.assertEqual(0, self.orc.attack())
Exemple #2
0
 def test_simulate_fight_orc_win(self):
     orc_w = Orc("Winner", 300, 2)
     hero_l = Hero("Loser", 300, "TheLoser")
     wep = Weapon("Ubiec", 15, 0.5)
     orc_w.equip_weapon(wep)
     orc_fight = Fight(hero_l, orc_w)
     self.assertEqual(orc_fight.simulate_fight(), orc_fight._ORC_WINNER)
Exemple #3
0
class FightTest(unittest.TestCase):

    def setUp(self):
        self.hero_one = Hero("Bron", 100, "DragonSlayer")
        self.orc_one = Orc("Orcy", 150, 1.5)
        self.fight_one = fight.Fight(self.hero_one, self.orc_one)
        self.axe = Weapon("Axe", 20, 0.2)
        self.sword = Weapon("Sword", 12, 0.7)
        self.hero_one.weapon = self.sword
        self.orc_one.weapon = self.axe

    def test_init(self):
        self.assertEqual(self.fight_one.hero, self.hero_one)
        self.assertEqual(self.fight_one.orc, self.orc_one)

    def test_fight(self):
        self.fight_one.simulate_battle()
        # if one of them died
        self.assertFalse(self.orc_one.is_alive() and self.hero_one.is_alive())

    def test_fight_no_weapon(self):
        self.orc_one.weapon = None
        self.fight_one.simulate_battle()
        # orc has no weapon => orc dies
        self.assertFalse(self.orc_one.is_alive())

    def test_fight_equal(self):
        hero_one = Hero("Bron", 100, "DragonSlayer")
        orc_one = Orc("Orcy", 150, 1.5)
        hero_one.weapon = Weapon("Axe", 20, 0.5)
        orc_one.weapon = Weapon("Axe", 20, 0.5)
        self.fight_one.simulate_battle()
        # both has the same weapon, but the orc has berserc_factor,\
        # he should be alive at the end
        self.assertTrue(self.orc_one.is_alive())
Exemple #4
0
 def setUp(self):
     weapon = Weapon('Dagger', 10, 0.0)
     hero = Hero('Asd', 100, 'Hero')
     hero.equip_weapon(weapon)
     orc = Orc('Dsa', 1, 1.4)
     orc.equip_weapon(weapon)
     self.fight = fight.Fight(hero, orc)
class FightTest(unittest.TestCase):

    def setUp(self):
        self.bron_hero = Hero("Bron", 100, "DragonSlayer")
        self.torug_orc = Orc("Torug", 100, 1.2)
        self.new_fight = Fight(self.bron_hero, self.torug_orc)
        self.axe = Weapon("Axe", 20, 0.2)
        self.sword = Weapon("Sword", 12, 0.7)
        self.bron_hero.equip_weapon(self.sword)
        self.torug_orc.equip_weapon(self.axe)

    def test_init(self):
        self.assertEqual(self.new_fight.orc, self.torug_orc)
        self.assertEqual(self.new_fight.hero, self.bron_hero)

    def test_who_is_first(self):
        first_entity = self.new_fight.who_is_first()
        self.assertIn(first_entity, [self.bron_hero, self.torug_orc])

    def test_fight(self):
        self.new_fight.simulate_battle()
        self.assertFalse(self.torug_orc.is_alive() and self.bron_hero.is_alive())

    def test_fight_with_no_weapons(self):
        self.torug_orc.weapon = None
        self.new_fight.simulate_battle()
        self.assertFalse(self.torug_orc.is_alive())
 def test_battle(self):
     orc = Orc("Bron", 100, 1.3)
     hero = Hero("Bron", 100, "DragonSlayer")
     axe = Weapon("Mighty Axe", 25, 0.2)
     orc.weapon = axe
     self.my_map.spawn("player_1", orc)
     self.my_map.spawn("player_2", hero)
     self.my_map.move("player_1", "right")
     self.my_map.move("player_1", "left")
     self.my_map.move("player_1", "right")
     self.my_map.move("player_2", "up")
     self.my_map.move("player_1", "down")
     self.my_map.move("player_1", "down")
     self.my_map.move("player_1", "down")
     for i in range(0, 4):
         self.my_map.move("player_2", "up")
     for i in range(0, 4):
         self.my_map.move("player_2", "left")
     self.my_map.move("player_2", "down")
     self.my_map.move("player_2", "down")
     self.my_map.move("player_2", "down")
     self.my_map.move("player_1", "right")
     self.my_map.move("player_2", "left")
     self.my_map.move("player_2", "left")
     self.my_map.move("player_1", "right")
     self.assertEqual(self.my_map.print_map(), "..##......\n#.##..###.\n#.###.###.\n#..O..###.\n###.#####.\n")
 def setUp(self):
     self.orc = Orc("Berserk", 1000, 2)
     self.hero = Hero("Bron", 1000, "DragonSlayer")
     self.weapon = Weapon("Mighty Axe", 25, 0.3)
     self.orc.equip_weapon(self.weapon)
     self.hero.equip_weapon(self.weapon)
     self.fight = Fight(self.hero, self.orc)
 def test_Orc_attack_with_weapon(self):
     my_weapon = Weapon("Axe", 31, 0.2)
     my_Orc = Orc("Ivan", 100, 1.5)
     my_Orc.equip_weapon(my_weapon)
     attack = my_weapon.damage * (1 + my_weapon.critical_strike_percent) * my_Orc.berserk_factor
     true_attack = my_Orc.attack()
     self.assertEqual(attack, true_attack)
Exemple #9
0
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.thrall = Orc("Thrall", 100, 1.2)

    def test_orc_init(self):
        self.assertEqual(100, self.thrall.health)
        self.assertEqual("Thrall", self.thrall.name)
        self.assertEqual(1.2, self.thrall.berserk_factor)

    def test_berserk_factor_within_bounds(self):
        normal_berserking_orc = Orc("Aaaaaa", 100, 1.89)
        self.assertEqual(1.89, normal_berserking_orc.berserk_factor)

    def test_berserk_factor_out_of_bounds(self):
        berserking_orc = Orc("Gromash", 100, 3)
        self.assertEqual(2, berserking_orc.berserk_factor)

        less_berserking_orc = Orc("Not Gromash", 100, -20)
        self.assertEqual(1, less_berserking_orc.berserk_factor)

    def test_attack_with_berserk_factor(self):
        self.thrall.equip_weapon(Weapon("Pickaxe", 38, 0.6))
        self.assertEqual(
            self.thrall.weapon.damage * self.thrall.berserk_factor,
            self.thrall.attack())
Exemple #10
0
class TestFight(unittest.TestCase):
    def setUp(self):
        self.my_hero = Hero("Hero", 100, "Hero")
        self.my_orc = Orc("Orc", 100, 1.5)
        self.the_fight = Fight(self.my_hero, self.my_orc)

    def test_init(self):
        self.assertEqual(self.my_hero.name, "Hero")
        self.assertEqual(self.my_hero.health, 100)
        self.assertEqual(self.my_hero.nickname, "Hero")
        self.assertEqual(self.my_orc.name, "Orc")
        self.assertEqual(self.my_orc.health, 100)
        self.assertEqual(self.my_orc.berserk_factor, 1.5)

    def test_attacks_first(self):
        my_arr = []
        for i in range(0, 100):
            if self.the_fight.attacks_first() == True:
                my_arr.append(1)
            my_arr.append(0)
        self.assertIn(1, my_arr)
        self.assertIn(0, my_arr)

    def test_simulate_fight(self):
        proba1 = Weapon("axe", 1, 0.1)
        proba2 = Weapon("sword", 40, 0.9)
        self.my_hero.equip_weapon(proba1)
        self.my_orc.equip_weapon(proba2)
        the_fight = Fight(self.my_hero, self.my_orc)
        self.assertFalse(the_fight.simulate_fight())
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.grom_orc = Orc("Grom", 100, 1.5)

    def test_orc_init(self):
        self.assertEqual("Grom", self.grom_orc.name)
        self.assertEqual(100, self.grom_orc.health)
        self.assertEqual(1.5, self.grom_orc.berserk_factor)

    def test_orc_berserk_factor_init(self):
        self.orc = Orc("Orc", 100, 0.2)
        self.assertEqual(self.orc.berserk_factor, 1)
        self.orc2 = Orc("test", 100, 2.6)
        self.assertEqual(self.orc2.berserk_factor, 2)

    def test_orc_attack(self):
        weapon = Weapon("Axe", 30, 0.2)
        self.grom_orc.equip(weapon)
        crit = False
        not_crit = False
        for i in range(100):
            if self.grom_orc.attack() == 90:
                crit = True
            elif self.grom_orc.attack() == 45:
                not_crit = True
        self.assertTrue(crit and not_crit)
Exemple #12
0
class Tests(unittest.TestCase):
    def setUp(self):
        self.test_hero = Hero("Bron", 100, "DragonSlayer")
        self.test_ork = Orc("Vilasteros", 100, 1.34)
        self.bow = Weapon("Mighty Bow", 13, 0.17)
        self.axe = Weapon("Thunder Axe", 19, 0.25)
        self.test_ork.equip_weapon(self.bow)
        self.test_hero.equip_weapon(self.axe)
        self.battle = Fight(self.test_hero, self.test_ork)

    def test_init(self):
        self.assertEqual(self.battle.attaker, self.test_hero)
        self.assertEqual(self.battle.orc, self.test_ork)

    def test_simulate_fight(self):
        self.battle.simulate_fight()
        self.assertTrue(self.test_hero.is_alive() ^ self.test_ork.is_alive())

    def test_fight_with_no_weapons_orc(self):
        self.test_ork.equipped_weapon = None
        self.battle.simulate_fight()
        self.assertTrue(self.test_hero.is_alive())

    def test_fight_with_no_weapons_hero(self):
        self.test_hero.equipped_weapon = None
        self.battle.simulate_fight()
        self.assertTrue(self.test_ork.is_alive())
Exemple #13
0
def main():
    map = Dungeon("dungeon_map")
    goshko = Hero("Hero", 100, "Hero")
    Orko = Orc("Orko", 100, 1.5)
    Orko2 = Orc("Orko2", 100, 1.4)
    Orko3 = Orc("Orko3", 100, 1.4)
    map.spawn("Goshko", goshko)
    map.spawn("Orko", Orko)
    map.spawn("Orko2", Orko2)
    map.spawn("Orko3", Orko3)
    map.move("Goshko", "right")
    map.move("Goshko", "down")
    map.move("Goshko", "down")
    map.move("Goshko", "down")
    map.move("Goshko", "right")
    map.move("Goshko", "right")
    map.move("Goshko", "right")
    map.move("Goshko", "right")
    map.move("Goshko", "up")
    map.move("Goshko", "up")
    map.move("Goshko", "up")
    map.move("Goshko", "up")
    map.move("Goshko", "right")
    map.move("Goshko", "right")
    map.move("Goshko", "right")
    map.move("Goshko", "right")
    map.move("Goshko", "down")
    map.move("Goshko", "down")
    map.move("Goshko", "down")
    map.print_map()
    print(map.players["Goshko"].i_coord, map.players["Goshko"].j_coord)
    map.move("Orko", "up")
    map.print_map()
Exemple #14
0
class TestFight(unittest.TestCase):

    def setUp(self):
        self.my_hero = Hero("Hero",  100, "Hero")
        self.my_orc = Orc("Orc", 100, 1.5)
        self.the_fight = Fight(self.my_hero, self.my_orc)

    def test_init(self):
        self.assertEqual(self.my_hero.name, "Hero")
        self.assertEqual(self.my_hero.health, 100)
        self.assertEqual(self.my_hero.nickname, "Hero")
        self.assertEqual(self.my_orc.name, "Orc")
        self.assertEqual(self.my_orc.health, 100)
        self.assertEqual(self.my_orc.berserk_factor, 1.5)

    def test_attacks_first(self):
        my_arr = []
        for i in range(0, 100):
            if self.the_fight.attacks_first() == True:
                my_arr.append(1)
            my_arr.append(0)
        self.assertIn(1, my_arr)
        self.assertIn(0, my_arr)

    def test_simulate_fight(self):
        proba1 = Weapon("axe", 1, 0.1)
        proba2 = Weapon("sword", 40, 0.9)
        self.my_hero.equip_weapon(proba1)
        self.my_orc.equip_weapon(proba2)
        the_fight = Fight(self.my_hero, self.my_orc)
        self.assertFalse(the_fight.simulate_fight())
Exemple #15
0
 def test_battle(self):
     orc = Orc("Bron", 100, 1.3)
     hero = Hero("Bron", 100, "DragonSlayer")
     axe = Weapon("Mighty Axe", 25, 0.2)
     orc.weapon = axe
     self.my_map.spawn("player_1", orc)
     self.my_map.spawn("player_2", hero)
     self.my_map.move("player_1", "right")
     self.my_map.move("player_1", "left")
     self.my_map.move("player_1", "right")
     self.my_map.move("player_2", "up")
     self.my_map.move("player_1", "down")
     self.my_map.move("player_1", "down")
     self.my_map.move("player_1", "down")
     for i in range(0, 4):
         self.my_map.move("player_2", "up")
     for i in range(0, 4):
         self.my_map.move("player_2", "left")
     self.my_map.move("player_2", "down")
     self.my_map.move("player_2", "down")
     self.my_map.move("player_2", "down")
     self.my_map.move("player_1", "right")
     self.my_map.move("player_2", "left")
     self.my_map.move("player_2", "left")
     self.my_map.move("player_1", "right")
     self.assertEqual(
         self.my_map.print_map(),
         "..##......\n#.##..###.\n#.###.###.\n#..O..###.\n###.#####.\n")
Exemple #16
0
 def setUp(self):
     weapon = Weapon('Dagger', 10, 0.0)
     hero = Hero('Asd', 100, 'Hero')
     hero.equip_weapon(weapon)
     orc = Orc('Dsa', 1, 1.4)
     orc.equip_weapon(weapon)
     self.fight = fight.Fight(hero, orc)
Exemple #17
0
 def setUp(self):
     self.hero = Hero("Bron", 100, "DragonSlayer")
     self.orc = Orc("Shapeshifter", 100, 1.5)
     sword = Weapon("Sword", 10, 0.2)
     axe = Weapon("Axe", 10, 0.2)
     self.hero.equip_weapon(sword)
     self.orc.equip_weapon(axe)
     self.battle = Fight(self.hero, self.orc)
Exemple #18
0
 def setUp(self):
     self.test_hero = Hero("Bron", 100, "DragonSlayer")
     self.test_ork = Orc("Vilasteros", 100, 1.34)
     self.bow = Weapon("Mighty Bow", 13, 0.17)
     self.axe = Weapon("Thunder Axe", 19, 0.25)
     self.test_ork.equip_weapon(self.bow)
     self.test_hero.equip_weapon(self.axe)
     self.battle = Fight(self.test_hero, self.test_ork)
 def test_Orc_attack_with_weapon(self):
     my_weapon = Weapon("Axe", 31, 0.2)
     my_Orc = Orc("Ivan", 100, 1.5)
     my_Orc.equip_weapon(my_weapon)
     attack = my_weapon.damage * (
         1 + my_weapon.critical_strike_percent) * my_Orc.berserk_factor
     true_attack = my_Orc.attack()
     self.assertEqual(attack, true_attack)
Exemple #20
0
    def setUp(self):
        self.varyan = Hero("Varyan Wrynn", 100, "King")
        self.garrosh = Orc("Garrosh Hellscream", 100, 7)

        self.weak_weapon = Weapon("Noob Weapon", 10, 0.1)
        self.strong_weapon = Weapon("Woo Weapon", 20, 0.7)

        self.fight = Fight(self.varyan, self.garrosh)
Exemple #21
0
 def setUp(self):
     self.bron_hero = Hero("Bron", 100, "DragonSlayer")
     self.axe = Weapon("Mighty Axe", 25, 0.2)
     self.sword = Weapon("Mighty Sword", 12, 0.7)
     self.bron_orc = Orc("Bron", 100, 1.3)
     self.my_fight = Fight(self.bron_hero, self.bron_orc)
     self.bron_hero.weapon = self.sword
     self.bron_orc.weapon = self.axe
Exemple #22
0
 def test_fight1(self):
     new_hero = Hero("Jack", 100, "Ripper")
     new_orc = Orc("Gruumsh", 40, 1.2)
     hero_weapon = Weapon("The Sting", 8, 0.33)
     orc_weapon = Weapon("The Pacifier", 12, 1)
     new_hero.equip_weapon(hero_weapon)
     new_orc.equip_weapon(orc_weapon)
     Fight(new_hero, new_orc)
Exemple #23
0
 def test_fight1(self):
     new_hero = Hero("Jack", 100, "Ripper")
     new_orc = Orc("Gruumsh", 40, 1.2)
     hero_weapon = Weapon("The Sting", 8, 0.33)
     orc_weapon = Weapon("The Pacifier", 12, 1)
     new_hero.equip_weapon(hero_weapon)
     new_orc.equip_weapon(orc_weapon)
     Fight(new_hero, new_orc)
Exemple #24
0
 def setUp(self):
     self.orc_goshe = Orc("Georgi", 100, 1.2)
     self.hero_slayer = Hero("DragonSlayer", 100, "Killer")
     self.axe = Weapon("Axe", 10, 0.2)
     self.sword = Weapon("Sword", 12, 0.5)
     self.orc_goshe.weapon = self.axe
     self.hero_slayer.weapon = self.sword
     self.battle_one = Fight(self.orc_goshe, self.hero_slayer)
Exemple #25
0
 def test_fight_equal(self):
     hero_one = Hero("Bron", 100, "DragonSlayer")
     orc_one = Orc("Orcy", 150, 1.5)
     hero_one.weapon = Weapon("Axe", 20, 0.5)
     orc_one.weapon = Weapon("Axe", 20, 0.5)
     self.fight_one.simulate_battle()
     # both has the same weapon, but the orc has berserc_factor,\
     # he should be alive at the end
     self.assertTrue(self.orc_one.is_alive())
class TestDungeon(unittest.TestCase):

    def setUp(self):

        self.without_weapon = Weapon("With bare hands", 0, 0)
        self.thanes_hummer = Weapon("Thanes hummer", 15, 0.4)
        self.yurnero_blade = Weapon("Yurneros blade", 10, 0.35)
        self.the_hero = Hero("Thanes", 150, 150, "Mountain King")
        self.the_orc = Orc("Yurnero the Blademaster", 150, 150, 1.3)
        self.the_chen = Orc("Chen", 150, 150, 1.3)
        self.small_potion = Potion("Small potion", 15)
        self.midium_potion = Potion("Midium potion", 25)
        self.the_hero.equip_weapon(self.thanes_hummer)
        self.the_orc.equip_weapon(self.yurnero_blade)
        self.map = Dungeon("map.txt")
        self.map.read_map()
        self.map.dict_of_items[self.yurnero_blade] = []
        self.map.dict_of_items[self.thanes_hummer] = []
        self.map.dict_of_items[self.small_potion] = []
        self.map.dict_of_items[self.midium_potion] = []
        self.map.dict_of_herous[self.the_orc] = []
        self.map.dict_of_herous[self.the_hero] = []
        self.map.spawn_player("shosho", self.the_hero)
        #self.map.spawn_player("kosho", self.the_orc)
        #self.map.dict_champion_name[self.the_hero] = "shosho"
        self.map.dict_champion_name[self.the_orc] = "kosho"



    #def test_validate_player(self):
    #    self.assertEqual(self.the_hero, self.map.validate_player_name("hero"))
    def test_spawn_player(self):
        #self.assertFalse(self.map.spawn_player("shosho", self.the_hero))
        self.assertTrue(self.map.spawn_player("kosho", self.the_orc))
        self.assertFalse(self.map.spawn_player("kosho", self.the_chen))

    def test_can_move(self):
        #print("{}\n{}".format(self.map.number_of_rows, self.map.number_of_chars))
        #print((self.map.number_of_rows))
        self.current_user = self.the_orc
        self.map.print_map()

        self.assertFalse(self.map.can_move_up(-1, 0))
        self.assertFalse(self.map.can_move_down(1, 0))
        self.assertTrue(self.map.can_move_right(0, 1))
        self.map.validate_player_name("orc")
        print("{}     {}".format(self.map.current_x, self.map.current_y))
        self.assertFalse(self.map.can_move_up(-1, 0))
        self.assertFalse(self.map.can_move_down(1, 0))
        self.assertTrue(self.map.can_move_right(0, 1))
        self.assertFalse(self.map.can_move_left(0, -1))

    def test_validate_player_name(self):

        self.map.spawn_player("kosho", self.the_orc)
        self.assertEqual(self.map.validate_player_name("kosho"), self.the_orc)
        self.map.print_map()
Exemple #27
0
 def setUp(self):
     self.hero = Hero('Stoyan', 200, 'DeathBringer')
     self.hero.equip_weapon(Weapon('Sword', 20, 0.5))
     self.orc = Orc('Beginner Orc', 100, 1.5)
     self.orc.equip_weapon(Weapon('Stick', 10, 0.1))
     self.legendary_orc = Orc('Broksiguar', 200, 2)
     self.legendary_orc.equip_weapon(Weapon('Frostmourne', 80, 0.9))
     self.fight_hero_vs_orc = Fight(self.hero, self.orc)
     self.fight_hero_vs_legendary_orc = Fight(self.hero, self.legendary_orc)
Exemple #28
0
    def setUp(self):
        self.sniper = Weaphon("Gun", 85, 0.10)
        self.hammer = Weaphon("One-Hand", 30, 0)

        self.bron_orc = Orc("Pesho", 100, 1.50)
        self.bron_hero = Hero("Ivan", 100, "Magician")

        self.bron_orc.equip_weapon(self.hammer)
        self.bron_hero.equip_weapon(self.sniper)
        self.magura = Dungeon("/home/biser/TDD/simple_dungeon.txt")
Exemple #29
0
 def test_start_fight_both_alive(self):
     fight_map = Dungeon("fight_map.txt")
     blademaster = Orc("Yurnero", 120, 1.2)
     fight_map.spawn("player_1", self.paladin)
     fight_map.spawn("player_2", blademaster)
     fight_map.move("player_1", "right")
     fight_map.move("player_2", "left")
     fight_map.move("player_1", "right")
     self.assertTrue(self.paladin.is_alive())
     self.assertTrue(blademaster.is_alive())
Exemple #30
0
 def test_fight(self):
     my_Hero = Hero("Ivan", 100, "bad ass")
     my_Orc = Orc("Boko", 100, 1.5)
     my_weapon1 = Weapon("Axe1", 31, 0.2)
     my_weapon2 = Weapon("Axe2", 31, 0.2)
     my_Hero.equip_weapon(my_weapon1)
     my_Orc.equip_weapon(my_weapon2)
     fight1 = Fight(my_Hero, my_Orc)
     fight1.simulate_fight()
     self.assertFalse(my_Orc.is_alive() and my_Hero.is_alive())
class OrcTests(unittest.TestCase):

    def setUp(self):
        self.the_orc = Orc("Oplik", 122, 1.42)

    def test_orc_init(self):
        self.assertEqual(1.42, self.the_orc.berserk_factor)

    def test_set_berserk_factor(self):
        self.the_orc.set_berserk_factor(2.55)
        self.assertEqual(2, self.the_orc.berserk_factor)
        self.the_orc.set_berserk_factor(0.55)
        self.assertEqual(1, self.the_orc.berserk_factor)

    def test_orc_attack_no_weapon(self):
        self.assertEqual(0, self.the_orc.attack())

    # that's a stupid test, fix it later!
    def test_orc_attack(self):
        weapon = Weapon("spoon", 2, 0.7)
        self.the_orc.equip_weapon(weapon)
        critical = False
        normal = False
        critical_num = 4 * self.the_orc.berserk_factor
        normal_num = 2 * self.the_orc.berserk_factor
        for i in range(0, 1000):
            critical = critical or (critical_num == self.the_orc.attack())
            normal = normal or (normal_num == self.the_orc.attack())
        self.assertTrue(critical)
        self.assertTrue(normal)
Exemple #32
0
class TestOrc(unittest.TestCase):
    def setUp(self):
        self.gad_orc = Orc("Gad", 100, 1.5)

    def test_orc_init(self):
        self.assertEqual(self.gad_orc.berserk_factor, 1.5)

    def test_attack(self):
        weapon = Weapon("tree", 10, 0.5)
        self.gad_orc.equip_weapon(weapon)
        self.assertEqual(self.gad_orc.attack(), 15)
class TestFight(unittest.TestCase):
    def setUp(self):
        self.orc = Orc("Berserk", 1000, 2)
        self.hero = Hero("Bron", 1000, "DragonSlayer")
        self.weapon = Weapon("Mighty Axe", 25, 0.3)
        self.orc.equip_weapon(self.weapon)
        self.hero.equip_weapon(self.weapon)
        self.fight = Fight(self.hero, self.orc)

    def test_simulate_fight(self):
        self.fight.simulate_fight()
        self.assertTrue(not self.orc.is_alive() or not self.hero.is_alive())
Exemple #34
0
 def test__fail_move_on_map(self):
     bron_orc = Orc("Bron", 100, 1.3)
     bron_hero = Hero("Bron", 100, "DragonSlayer")
     axe = Weapon("Mighty Axe", 25, 0.2)
     bron_orc.weapon = axe
     self.my_map.spawn("player_1", bron_orc)
     self.my_map.spawn("player_2", bron_hero)
     self.assertFalse(self.my_map.move("player_1", "left"))
     self.assertTrue(self.my_map.move("player_1", "right"))
     self.assertFalse(self.my_map.move("player_1", "up"))
     self.assertFalse(self.my_map.move("player_1", "right"))
     self.assertFalse(self.my_map.move("player_2", "down"))
 def test_move_and_fight(self):
     boromir = Hero("Boromir", 100, "OneDoesNotSimply")
     gollum = Orc("Gollum", 100, 1.5)
     axe = Weapon("Mighty Axe", 25, 0.2)
     sword = Weapon("Sword", 25, 0.2)
     boromir.equip_weapon(sword)
     gollum.equip_weapon(axe)
     self.dungeon.spawn("player_1", boromir)
     self.dungeon.spawn("player_2", gollum)
     self.dungeon.spawned["player_2"][1] = 12
     self.dungeon.move("player_1", "right")
     been_fight = self.dungeon.spawned["player_1"][0].is_alive() and self.dungeon.spawned["player_2"][0].is_alive()
     self.assertFalse(been_fight)
Exemple #36
0
class TestFight(unittest.TestCase):
    def setUp(self):
        self.varyan = Hero("Varyan Wrynn", 100, "King")
        self.garrosh = Orc("Garrosh Hellscream", 100, 7)

        self.weak_weapon = Weapon("Noob Weapon", 10, 0.1)
        self.strong_weapon = Weapon("Woo Weapon", 20, 0.7)

        self.fight = Fight(self.varyan, self.garrosh)

    def test_simulate_fight_win(self):
        self.varyan.equip_weapon(self.strong_weapon)
        self.garrosh.equip_weapon(self.weak_weapon)
        self.assertIsNotNone(self.fight.simulate_fight())
Exemple #37
0
    def setUp(self):
        path = open("path.txt", "w")
        self.dung_map = """S.##......
#.##..###
#.###.###.
#.....###
###.####S"""
        path.write(self.dung_map)
        path.close()
        self.dungeon = Dungeon("path.txt")
        self.bron = Hero("Bron", 100, "DragonSlayer")
        self.orc = Orc("orc", 90, 1.4)
        self.bron.equip_weapon(Weapon("Mighty Axe", 25, 0.2))
        self.orc.equip_weapon(Weapon("basher", 16, 0.75))
Exemple #38
0
 def setUp(self):
     self.start_map_content = 'S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S'
     with open('basic_dungeon.txt', 'w') as map_file:
         map_file.write(self.start_map_content)
     self.map = Dungeon('basic_dungeon.txt')
     self.hero_player = Hero('Stoyan', 100, 'DeathBringer')
     self.hero_player.equip_weapon(Weapon('Sword', 20, 0.5))
     self.orc_player = Orc('Broks', 100, 1.5)
     self.orc_player.equip_weapon(Weapon('Stick', 10, 0.1))
     self.battle_map_content = 'S.#\n#S#'
     with open('battle_map.txt', 'w') as map_file:
         map_file.write(self.battle_map_content)
     self.battle_map = Dungeon('battle_map.txt')
     self.battle_map.spawn('human', self.hero_player)
     self.battle_map.spawn('orc', self.orc_player)
Exemple #39
0
 def test_start_fight_paladin_dead(self):
     axe = Weapon("axe", 10, 0.5)
     blademaster = Orc("Yurnero", 120, 1.2)
     blademaster.equip_weapon(axe)
     fight_map = Dungeon("fight_map.txt")
     fight_map.spawn("player_1", self.paladin)
     fight_map.spawn("player_2", blademaster)
     fight_map.move("player_1", "right")
     fight_map.move("player_2", "left")
     fight_map.move("player_1", "right")
     expected_arr = [['.', '.', 'O', '.']]
     self.assertFalse(self.paladin.is_alive())
     self.assertTrue(blademaster.is_alive())
     #testing _make_changes_after_fight
     self.assertEqual(fight_map.map_array, expected_arr)
Exemple #40
0
class TestOrc(unittest.TestCase):

    def setUp(self):
        self.orc = Orc('Broks', 100, 1.5)

    def test_orc_init_berserk(self):
        self.assertEqual(self.orc.berserk_factor, 1.5)

    def test_orc_attack_without_weapon(self):
        self.assertEqual(self.orc.attack(), 0)

    def test_orc_attack_with_weapon(self):
        axe = Weapon('Axe', 25, 0.5)
        self.orc.equip_weapon(axe)
        self.assertEqual(self.orc.attack(), 25*1.5)