def build_hero(num_of_weapons=0, num_of_armor=0, num_of_abilities=0):
    heroes = [
        "Athena", "Jodie Foster", "Christina Aguilera", "Gamora", "Supergirl",
        "Wonder Woman", "Batgirl", "Carmen Sandiego", "Okoye",
        "America Chavez", "Cat Woman", "White Canary", "Nakia", "Mera",
        "Iris West", "Quake", "Wasp", "Storm", "Black Widow",
        "San Luis Obispo", "Ted Kennedy", "San Francisco", "Bananas"
    ]

    weapons = []
    armors = []

    for _ in range(num_of_weapons):
        weapons.append(create_weapon())

    for _ in range(num_of_armor):
        armors.append(create_armor())

    for _ in range(num_of_abilities):
        weapons.append(create_ability())

    name = random.choice(heroes)
    hero = Hero(name)

    for item in weapons:
        hero.add_ability(item)

    for armor in armors:
        hero.add_armor(armor)

    return hero
def test_hero_attack():
    flash = Hero("The Flash")
    assert flash.attack() == 0
    pesto = Ability("Pesto Sauce", 8000)
    flash.add_ability(pesto)
    attack = flash.attack()
    assert attack <= 8000 and attack >= 4000
Exemplo 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
Exemplo n.º 4
0
 def create_hero(self):
     # '''Prompt user for Hero information
     #   return Hero with values from user input.
     # '''
     hero_name = input("Hero's name: ")
     hero = Hero(hero_name)
     add_item = None
     while add_item != "4":
         add_item = input(
             "[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: "
         )
         if add_item == "1":
             #TODO add an ability to the hero
             #HINT: First create the ability, then add it to the hero
             ability = self.create_ability()
             hero.add_ability(ability)
         elif add_item == "2":
             #TODO add a weapon to the hero
             #HINT: First create the weapon, then add it to the hero
             weapon = self.create_weapon()
             hero.add_weapon(weapon)
         elif add_item == "3":
             #TODO add an armor to the hero
             #HINT: First create the armor, then add it to the hero
             armor = self.create_armor()
             hero.add_armor(armor)
     return hero
Exemplo n.º 5
0
    def create_hero(self):
        hero_name = input("Hero's name: ")
        hero = Hero(hero_name)
        add_item = None

        while add_item != "4":
            add_item = input(
                "[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: "
            )
            if add_item == "1":
                #TODO add an ability to the hero
                #HINT: First create the ability, then add it to the hero
                ability = self.create_ability()
                hero.add_ability(ability)
            elif add_item == "2":
                #TODO add a weapon to the hero
                #HINT: First create the weapon, then add it to the hero
                weapon = self.create_weapon()
                hero.add_weapon(weapon)
            elif add_item == "3":
                #TODO add an armor to the hero
                #HINT: First create the armor, then add it to the hero
                armor = self.create_armor()
                hero.add_armor = armor

        return hero
Exemplo n.º 6
0
    def create_hero(self):
        """Prompt user for Hero information. It will return Hero with values from user input."""

        hero_name = input("Hero's name: ")
        hero = Hero(hero_name)
        add_item = None

        while add_item != "4":
            add_item = input(
                "[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: "
            )

            if add_item == "1":
                ability = self.create_ability()
                hero.add_ability(ability)

            elif add_item == "2":
                weapon = self.create_weapon()
                hero.add_weapon(weapon)

            elif add_item == "3":
                armor = self.create_armor()
                hero.add_armor(armor)

        return hero
Exemplo n.º 7
0
def test_hero_ability_attack_mean_value():
    athena = Hero("Athena")
    strength = random.randint(10, 30000)
    big_strength = Ability("Overwhelming Strength", strength)
    athena.add_ability(big_strength)
    calculated_mean = strength // 2
    iterations = 6000
    accepted_window = 400

    total_attack = 0

    for _ in range(iterations):
        attack_value = athena.attack()
        assert attack_value >= 0 and attack_value <= strength
        total_attack += attack_value

    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 Distance from Mean: {} | Average distance from mean: {}".
          format(accepted_window, abs(calculated_mean - actual_mean)))
    print("Acceptable min attack: {} | Acceptable max attack: {}".format(
        actual_mean - accepted_window, actual_mean + accepted_window))
    assert actual_mean <= calculated_mean + accepted_window and actual_mean >= calculated_mean - accepted_window
Exemplo n.º 8
0
    def create_hero(self):
        '''Prompt user for Hero information
          return Hero with values from user input.
        '''
        hero_name = input("Hero's name: ")
        hero = Hero(hero_name)
        add_item = None
        while add_item != "4":

            add_item = input(
                "[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: "
            )
            if add_item == "1":

                self.create_ability()
                hero.add_ability(self.create_ability())

            elif add_item == "2":

                self.create_weapon()
                hero.add_weapon(self.create_weapon)

            elif add_item == "3":

                self.create_armor()
                hero.add_armor(self.create_armor)
            elif add_item == "4":
                break

        return hero
Exemplo n.º 9
0
def test_hero_attack_ability():
    big_strength = Ability("Overwhelming Strength", 30000)
    athena = Hero("Athena")
    assert athena.attack() == 0
    athena.add_ability(big_strength)
    attack = athena.attack()
    assert attack <= 30000 and attack >= 0
Exemplo n.º 10
0
def create_hero(max_strength=100, weapons=False, armors=False, health=False):

    heroes = [
        "Athena", "Jodie Foster", "Christina Aguilera", "Gamora", "Supergirl",
        "Wonder Woman", "Batgirl", "Carmen Sandiego", "Okoye",
        "America Chavez", "Cat Woman", "White Canary", "Nakia", "Mera",
        "Iris West", "Quake", "Wasp", "Storm", "Black Widow",
        "San Luis Obispo", "Ted Kennedy", "San Francisco", "Bananas"
    ]
    name = heroes[random.randint(0, len(heroes) - 1)]
    if health:
        power = health
    else:
        power = random.randint(3, 700000)
    hero = Hero(name, power)
    if weapons and armors:
        for weapon in weapons:
            hero.add_ability(weapon)
        for armor in armors:
            hero.add_armor(armor)
    if armors and not weapons:
        for armor in armors:
            hero.add_armor(armor)

    return hero
def test_hero_add_ability():
    big_strength = Ability("Overwhelming Strength", 300)
    Athena = Hero("Athena")
    assert len(Athena.abilities) == 0
    Athena.add_ability(big_strength)
    assert len(Athena.abilities) == 1
    assert "Ability" in str(Athena.abilities[0])
    assert Athena.abilities[0].name == "Overwhelming Strength"
Exemplo n.º 12
0
def test_hero_attack_weapon():
    big_strength = Ability("Overwhelming Strength", 200)
    Athena = Hero("Athena")
    Athena.add_ability(big_strength)
    test_runs = 100
    for _ in range(0, test_runs):
        attack = big_strength.attack()
        assert attack <= 200 and attack >= 0
Exemplo n.º 13
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)
def test_hero_add_multi_ability():
    big_strength = Ability("Overwhelming Strength", 300)
    speed = Ability("Lightning Speed", 500)
    Athena = Hero("Athena")
    assert len(Athena.abilities) == 0
    Athena.add_ability(big_strength)
    assert len(Athena.abilities) == 1
    Athena.add_ability(speed)
    assert len(Athena.abilities) == 2
    assert "Ability" in str(Athena.abilities[0])
    assert Athena.abilities[0].name == "Overwhelming Strength"
Exemplo n.º 15
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
Exemplo n.º 16
0
def test_team_attack_deaths():
    team_one = Team("One")
    jodie = Hero("Jodie Foster")
    aliens = Ability("Alien Friends", 10000)
    jodie.add_ability(aliens)
    team_one.add_hero(jodie)
    team_two = Team("Two")
    athena = Hero("Athena")
    socks = Armor("Socks", 10)
    athena.add_armor(socks)
    team_two.add_hero(athena)
    assert team_two.heroes[0].deaths == 0
    team_one.attack(team_two)
    assert team_two.heroes[0].deaths == 1
Exemplo n.º 17
0
 def create_hero(self):
     """Return Hero with value from user input"""
     hero_name = input("Hero's name: ")
     hero = Hero(hero_name)
     add_item = None
     while add_item != "4":
        add_item = input("[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: ")
        if add_item == "1":
            hero.add_ability(self.create_ability())
        elif add_item == "2":
            hero.add_weapon(self.create_weapon())
        elif add_item == "3":
            hero.add_armor(self.create_armor())
     return hero
Exemplo n.º 18
0
 def create_hero(self):
     hero_name = input("Hero name: ")
     hero_health = int(input("Hero starting health: "))
     new_hero = Hero(hero_name, hero_health)
     num_abilities = int(input("Number of desired abilities to add:"))
     for i in range(0, num_abilities):
         new_hero.add_ability(self.create_ability())
     num_weapons = int(input("Number of desired weapons to add:"))
     for i in range(0, num_weapons):
         new_hero.add_weapon(self.create_weapon())
     num_armor = int(input("Number of desired armors to add:"))
     for i in range(0, num_armor):
         new_hero.add_armor(self.create_armor())
         print(i)
     return new_hero
Exemplo n.º 19
0
 def create_hero(self):
     hero_name = input("What is the character's name?: ")
     hero = Hero(hero_name)
     add_item = None
     while add_item != "4":
        add_item = input("[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: ")
        if add_item == "1":
            ability_input = self.create_ability()
            hero.add_ability(ability_input)
        elif add_item == "2":
            weapon_input = self.create_weapon()
            hero.add_weapon(weapon_input)
        elif add_item == "3":
            armor_input = self.create_armor()
            hero.add_armor(armor_input)
     return hero
Exemplo n.º 20
0
def create_hero(self):
      hero_name = input("Hero's name: ")
      hero = Hero(hero_name)
      add_item = None
      while add_item != "4":
         add_item = input("[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: ")
         if add_item == "1":
             ability = self.create_ability()
             hero.add_ability(ability)
         elif add_item == "2":
             weapon = self.create_weapon()
             hero.add_weapon(weapon)
         elif add_item == "3":
             armor self.create_armor()
             hero.add_armor(armor)
         return hero
Exemplo n.º 21
0
 def create_hero(self):
     hero_name = input("Hero's name:\n")
     hero_health = int(input(f"How much health does {hero_name} have?\n"))
     hero = Hero(hero_name, hero_health)
     add_item = None
     while add_item != "4":
         add_item = input(
             "[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice:\n"
         )
         if add_item == "1":
             ability = self.create_ability()
             hero.add_ability(ability)
         elif add_item == "2":
             weapon = self.create_weapon()
             hero.add_weapon(weapon)
         elif add_item == "3":
             armor = self.create_armor()
             hero.add_armor(armor)
     return hero
Exemplo n.º 22
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
Exemplo n.º 23
0
def test_hero_ability_attack_standard_deviation():
    willow_waffle = Hero("Willow Waffle")
    strength = random.randint(400, 30000)
    willow = Ability("Willowness", strength)
    willow_waffle.add_ability(willow)
    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("Standard Deviation Cannot be 0.\nRandom Numbers not generated for attack.")
    assert standard_dev != 0.0
Exemplo n.º 24
0
    def create_hero(self):
        """Prompt for Hero information."""

        hero_name = input("Hero name?: ")
        hero = Hero(hero_name)

        equip_menu = None
        while equip_menu != "4":
            equip_menu = input("\n[1] Add ability\n"
                               "[2] Add weapon\n"
                               "[3] Add armor\n"
                               "[4] Done adding equips\n\n"
                               "Your choice: ")
            print()

            if equip_menu == "1":
                hero.add_ability(self.create_ability())
            elif equip_menu == "2":
                hero.add_weapon(self.create_weapon())
            elif equip_menu == "3":
                hero.add_armor(self.create_armor())

        return hero
Exemplo n.º 25
0
 def create_hero(self):
     '''Prompt user for Hero information
       return Hero with values from user input.
     '''
     hero_name = input("Hero's name: ")
     hero = Hero(hero_name)
     add_item = None
     while add_item != "4":
         print("[1] Add ability\n[2] Add weapon\n[3] Add armor")
         add_item = input("[4] Done adding items\n\nYour choice: ")
         if add_item == "1":
             # add an ability to the hero
             added_ability = self.create_ability()
             hero.add_ability(added_ability)
             # print(f"_ ability added")
         elif add_item == "2":
             # add a weapon to the hero
             added_weapon = self.create_weapon()
             hero.add_weapon(added_weapon)
         elif add_item == "3":
             # add an armor to the hero
             added_armor = self.create_armor()
             hero.add_armor(added_armor)
     return hero
Exemplo n.º 26
0
 def create_hero(self):
     '''
     Prompt user for Hero information.
     return
     ------
     Hero with values from user input.
     '''
     hero_name = input("Hero's name: ")
     hero = Hero(hero_name)
     add_item = None
     while add_item != "4":
         add_item = input("[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: ")
         if add_item == "1":
             new_ability = self.create_ability()
             hero.add_ability(new_ability)
         elif add_item == "2":
             new_weapon = self.create_weapon()
             hero.add_weapon(new_weapon)
         elif add_item == "3":
             new_armor = self.create_armor()
             hero.add_armor(new_armor)
         elif add_item == '4':
             print('Finished creating ' + hero.name)
     return hero
Exemplo n.º 27
0
 def create_hero(self):
     '''input from user and prompt return.
     '''
     hero_name = input("Hero's name: ")
     hero = Hero(hero_name)
     add_item = None
     while add_item != "4":
         add_item = input(
             "[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: "
         )
         if add_item == "1":
             # add an ability to the hero
             self.create_ability()
             hero.add_ability(self.create_ability)
         elif add_item == "2":
             # add a weapon to the hero
             self.create_weapon()
             hero.add_ability(self.create_weapon)
         elif add_item == "3":
             # add an armor to the hero
             self.create_armor()
             hero.add_ability(self.create_armor)
     return hero
Exemplo n.º 28
0
def test_dead_hero_defense():
    hero = Hero("Vlaad", 0)
    defense_amount = 30000
    garlic = Armor("Garlic", defense_amount)
    hero.add_ability(garlic)
    assert hero.defend() == 0
Exemplo n.º 29
0
def test_dead_hero_defense():
    hero = Hero("Vlaad", 0)
    garlic = Armor("Garlic", 30000)
    hero.add_ability(garlic)
    assert hero.defend() == 0
Exemplo n.º 30
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"