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 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
Exemplo n.º 3
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.º 4
0
def test_hero_defense_mean_value():
    athena = Hero("Athena")
    strength = random.randint(400, 30000)
    big_strength = Armor("Overwhelming Shield", strength)
    athena.add_armor(big_strength)
    calculated_mean = strength // 2
    iterations = 8000
    total_attack = 0
    accepted_window = 400
    for _ in range(iterations):
        attack_value = athena.defend()
        assert attack_value >= 0 and attack_value <= strength
        total_attack += attack_value

    actual_mean = total_attack / iterations
    print("Max Allowed: {}".format(strength))
    print("Defenses Tested: {}".format(iterations))
    print("Mean -- calculated: {} | actual: {}".format(calculated_mean, actual_mean))
    print(
        "Acceptable deviation from mean: {} | Current deviation from mean: {}".format(
            accepted_window, abs(
                calculated_mean - actual_mean)))
    print(
        "Acceptable Min: {} | Acceptable Max: {}".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.º 5
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.º 6
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.º 7
0
def test_hero_defend_multi_armor():
    jodie = Hero("Jodie Foster")
    gauntlets = Armor("Gauntlets", 4000)
    science = Armor("Science", 9000)
    jodie.add_armor(gauntlets)
    jodie.add_armor(science)
    defend = jodie.defend()
    assert defend <= 13000 and defend >= 0
Exemplo n.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
0
def test_hero_defense_standard_deviation():
    willow_waffle = Hero("Willow Waffle")
    strength = random.randint(400, 30000)
    willow = Armor("Willowness", strength)
    willow_waffle.add_armor(willow)
    defenses = list()
    total_defend = 0
    number_tests = 100
    for _ in range(number_tests):
        defense = willow_waffle.defend()
        defenses.append(defense)
        total_defend += defense
    mean = total_defend / number_tests

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

    standard_dev = math.sqrt(sum(defenses) / len(defenses))
    print("Hero Armor must block with random value.")
    print("Standard Deviation Cannot be 0.")
    assert standard_dev != 0.0
Exemplo n.º 16
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.º 17
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.º 18
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.º 19
0
def test_hero_equip_armor():
    jodie = Hero("Jodie Foster")
    gauntlets = Armor("Gauntlets", 30)
    jodie.add_armor(gauntlets)
    assert len(jodie.armors) == 1
    assert jodie.armors[0].name == "Gauntlets"
Exemplo n.º 20
0
def test_hero_defense():
    jodie = Hero("Jodie Foster")
    gauntlets = Armor("Gauntlets", 30)
    jodie.add_armor(gauntlets)
    defense = jodie.defend()
    assert defense >= 0 and defense <= 30