Ejemplo n.º 1
0
def test_hero_multi_weapon_attack():
    strength = Weapon("Overwhelming Strength", 200)
    sword_of_truth = Weapon("Sword of Truth", 700)
    Athena = Hero("Athena")
    Athena.add_ability(strength)
    Athena.add_ability(sword_of_truth)
    assert len(Athena.abilities) == 2

    test_runs = 100
    for _ in range(0, test_runs):
        attack = Athena.attack()
        assert attack <= 900 and attack >= 0
Ejemplo n.º 2
0
 def setUp(self):
     self.w = Weapon(name="The Axe of Destiny", damage=20)
     self.h = Hero(name="Bron",
                   title="Dragonslayer",
                   health=100,
                   mana=100,
                   mana_regeneration_rate=2)
Ejemplo n.º 3
0
def test_hero_weapon_attack_mean_value():
    kkrunch = Hero("Kaptain Krunch")
    strength = random.randint(10, 30000)
    min_attack = strength // 2
    big_strength = Weapon("Sword of Whimsy", strength)
    kkrunch.add_ability(big_strength)
    calculated_mean = (strength - min_attack) // 2 + min_attack
    accepted_window = 400
    iterations = 6000

    sum_of_sqr = 0
    total_attack = 0

    for _ in range(iterations):
        attack_value = kkrunch.attack()
        assert attack_value >= min_attack and attack_value <= strength
        total_attack += attack_value
        deviation = attack_value - calculated_mean
        sum_of_sqr += deviation * deviation

    actual_mean = total_attack / iterations
    print("Max Allowed Damage: {}".format(strength))
    print("Attacks Tested: {}".format(iterations))
    print("Mean -- calculated: {} | actual: {}".format(calculated_mean, actual_mean))
    print("Acceptable Min: {} | Acceptable Max: {}".format(actual_mean - accepted_window, actual_mean + accepted_window))
    print("Tested Result: {}".format(actual_mean))
    assert actual_mean <= calculated_mean + accepted_window
    assert actual_mean >= calculated_mean - accepted_window
Ejemplo n.º 4
0
 def setUp(self):
     self.w = Weapon(name="The Axe of Destiny", damage=20)
     self.h = Hero(name="Bron",
                   title="Dragonslayer",
                   health=100,
                   mana=100,
                   mana_regeneration_rate=2)
     self.s = Spell(name="Fireball", damage=30, mana_cost=50, cast_range=2)
Ejemplo n.º 5
0
def test_hero_weapon_ability_attack():
    quickness = Ability("Quickness", 1300)
    sword_of_truth = Weapon("Sword of Truth", 700)
    Athena = Hero("Athena")
    Athena.add_ability(quickness)
    Athena.add_ability(sword_of_truth)
    assert len(Athena.abilities) == 2
    attack_avg(Athena, 0, 2000)
Ejemplo n.º 6
0
def test_hero_attack_standard_deviation():
    willow_waffle = Hero("Willow Waffle")
    strength = random.randint(400, 30000)
    travel_agent = Weapon("Travel Agents", strength)
    willow_waffle.add_ability(travel_agent)
    attacks = list()
    total_attack = 0
    number_tests = 1000
    for _ in range(number_tests):
        cur_attack = willow_waffle.attack()
        attacks.append(cur_attack)
        total_attack += cur_attack
    mean = total_attack / number_tests

    # Get Square Deviations
    for index, value in enumerate(attacks):
        attacks[index] = math.pow(value - mean, 2)

    standard_dev = math.sqrt(sum(attacks) / len(attacks))
    print("Random values not given. Please make sure you're not returning the same value every time.")
    assert standard_dev != 0.0
Ejemplo n.º 7
0
 def create_weapon(self):
     weapon_name = input("Weapon name: ")
     weapon_damage = int(input("Weapon damage: "))
     return Weapon(weapon_name, weapon_damage)
Ejemplo n.º 8
0
def test_weapon_attack():
    big_stick = Weapon("Overwhelming Stick", 200)
    test_runs = 100
    for _ in range(0, test_runs):
        attack = big_stick.attack()
        assert attack <= 200 and attack >= 100
Ejemplo n.º 9
0
def test_weapon_instance():
    big_stick = Weapon("Overwhelming Stick", 200)
    assert "Weapon" in str(big_stick)
Ejemplo n.º 10
0
def test_hero_weapon_equip():
    sans = Hero("Comic Sans")
    weapon = Weapon("Garlic Hot Sauce", 400)
    sans.add_ability(weapon)
    assert len(sans.abilities) == 1
    assert sans.abilities[0].name == "Garlic Hot Sauce"