Exemplo n.º 1
0
    def team_battle(self):
        '''Battle team_one and team_two together.'''
        # TODO: This method should battle the teams together.
        # Call the attack method that exists in your team objects
        # for that battle functionality.

        Team.attack(self.team_one, self.team_two)
Exemplo n.º 2
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.º 3
0
class Arena:
    def __init__(self):
        '''Instantiate properties
            team_one: None
            team_two: None
        '''
        self.team_one = Team("Team One")
        self.team_two = Team("Team Two")

    def team_battle(self):
        '''Battle team_one and team_two together.'''
        # TODO: This method should battle the teams together.
        # Call the attack method that exists in your team objects
        # for that battle functionality.
        self.team_one.attack(self.team_two)

    def create_ability(self):
        '''Prompt for Ability information.
            return Ability with values from user Input
        '''
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")

        return Ability(name, max_damage)

    def create_weapon(self):
        '''Prompt user for Weapon information
            return Weapon with values from user input.
        '''
        # TODO: This method will allow a user to create a weapon.
        # Prompt the user for the necessary information to create a new weapon object.
        # return the new weapon object.
        print(
            "In order to create a weapon you need to add a name and a max_damage"
        )
        name = input("What is your weapon name?  ")
        max_damage = input("What is the max damage of your weapon?  ")

        return Weapon(name, max_damage)

    def create_armor(self):
        '''Prompt user for Armor information
          return Armor with values from user input.
        '''
        # TODO:This method will allow a user to create a piece of armor.
        #  Prompt the user for the necessary information to create a new armor object.
        #  return the new armor object with values set by user.
        print(
            "To create an armor you need to provide a name and a max block value"
        )
        name = input("What is your armor name?  ")
        max_block = input("What is the max block of your armor?  ")

        return Armor(name, max_block)

    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
                ability = self.create_ability()
                hero.add_ability(ability)
                #HINT: First create the ability, then add it to the hero
            elif add_item == "2":
                #TODO add a weapon to the hero
                weapon = self.create_weapon()
                hero.add_weapon(weapon)
                #HINT: First create the weapon, then add it to the hero
            elif add_item == "3":
                #TODO add an armor to the hero
                armor = self.create_armor()
                hero.add_armor(armor)
                #HINT: First create the armor, then add it to the hero
        return hero

    def build_team_one(self):
        '''Prompt the user to build team_one '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero1 = self.create_hero()
            self.team_one.add_hero(hero1)

    # Now implement build_team_two
    #HINT: If you get stuck, look at how build_team_one is implemented
    def build_team_two(self):
        '''Prompt the user to build team_two'''
        # TODO: This method should allow a user to create team two.
        # This method should allow a user to create team two.
        # Prompt the user for the number of Heroes on team two
        # call self.create_hero() for every hero that the user wants to add to team two.
        # Add the created hero to team two.
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def show_stats(self):
        '''Prints team statistics to terminal.'''
        # TODO: This method should print out battle statistics
        # including each team's average kill/death ratio.
        # Required Stats:
        #     Show surviving heroes.
        #     Declare winning team
        #     Show both teams average kill/death ratio.
        print("Team One:")
        alive_heroes = 0
        for i in self.team_one.heroes:
            if i.is_alive():
                alive_heroes += 1
            print(f"{i.get_name()} is alive: {i.is_alive()}")
            print(self.team_one.stats())

        print("\n")

        print("Team two:")
        alive_opponents = 0
        for i in self.team_two.heroes:

            if i.is_alive():
                alive_opponents += 1
            print(f"{i.get_name()} is alive: {i.is_alive()}")
            print(self.team_two.stats())

        if alive_heroes > alive_opponents:
            print("Team one wins!")
        else:
            print("Team two wins!")
Exemplo n.º 4
0
class Arena:
    def __init__(self):
        # instance variables named team_one and team_two hold teams.
        self.team_one = Team("One")
        self.team_two = Team("Two")

    def create_ability(self):
        # prompts for the info to make an ability + max_damage
        name = input("What is the ability name?")
        max_damage = input("What is the max damage of the ability?")
        return Ability(name, max_damage)

    def create_weapon(self):
        # prompts for the info to make a weapon + max_damage
        name = input("What is the weapon name?")
        max_damage = input("What is the max damage of the weapon?")
        return Weapon(name, max_damage)

    def create_armor(self):
        # prompts for the info to make add armor + max_block
        name = input("What is the armor name?")
        max_block = input("What is the max the armor blocks?")
        return Armor(name, max_block)

    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

    def build_team_one(self):
        '''Prompt the user to build team_one '''
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for _ in range(numOfTeamMembers):
            # call self.create_hero() for every hero that the user wants to add to team one.
            hero = self.create_hero()
            # Add the created hero to team one.
            self.team_one.add_hero(hero)

    def build_team_two(self):
        '''Prompt the user to build team_two'''
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for _ in range(numOfTeamMembers):
            # call self.create_hero() for every hero that the user wants to add to team one.
            hero = self.create_hero()
            # Add the created hero to team one.
            self.team_two.add_hero(hero)

    def team_battle(self):
        '''Battle team_one and team_two together.'''
        self.team_one.attack(self.team_two)

    # and use the is_alive() method to check for alive heroes,
    # printing their names and increasing the count if they're alive.

    # TODO: based off of your count of alive heroes,

    # you can see which team has more alive heroes, and therefore,
    # declare which team is the winning team
    #

    # TODO for each team, calculate the total kills and deaths for each hero,
    # find the average kills and deaths by dividing the totals by the number of heroes.
    # finally, divide the average number of kills by the average number of deaths for each team

    def show_stats(self):
        '''Prints team statistics to terminal.'''
        # self.alive_heroes = 0
        # self.dead_heroes = 0

        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # Team 1 Stats
        team1_kills = 0
        team1_deaths = 0
        for hero in self.team_one.heroes:
            team1_kills += hero.kills
            team1_deaths += hero.deaths
        if team1_deaths == 0:
            team1_deaths = 1
            print(self.team_one.name + " average K/D was: " +
                  str(team1_kills / team1_deaths))

        # Team 2 Stats
        team2_kills = 0
        team2_deaths = 0
        for hero in self.team_one.heroes:
            team2_kills += hero.kills
            team2_deaths += hero.deaths
        if team2_deaths == 0:
            team2_deaths = 1
            print(self.team_two.name + " average K/D was: " +
                  str(team2_kills / team2_deaths))

        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 5
0
class Arena:
    def __init__(self):
        '''Instantiate properties
            team_one: None
            team_two: None
        '''
        # TODO: create instance variables named team_one and team_two that
        # will hold our teams.
        self.team_one = Team("Team One")
        self.team_two = Team("Team Two")

    def create_ability(self):
        '''Prompt for Ability information.
            return Ability with values from user Input
        '''
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")

        return Ability(name, int(max_damage))

    def create_weapon(self):
        weapon = input("What is the weapon name?  ")
        max_damage = input("What is the max damage of the weapon?  ")
        return Weapon(weapon, int(max_damage))

    def create_armor(self):
        armor = input("What is the armor name?  ")
        max_block = input("What is the max block of the armor?  ")
        return Armor(armor, int(max_block))

    def create_hero(self):
        hero_name = input("What is the 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

    def build_team_one(self):
        '''Prompt the user to build team_one '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        self.team_one.attack(self.team_two)

    def show_stats(self):
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " +
              str(team_kills / team_deaths))

        team_kills = 0
        team_deaths = 0
        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_two.name + " average K/D was: " +
              str(team_kills / team_deaths))

        # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 6
0
class Arena:
    def __init__(self):
        self.team_one = Team("team_one")
        self.team_two = Team("team_two")

    def create_ability(self):
        name = input("What is the ability name?   ")
        max_damage = int(input("What is the max damage of the ability?   "))
        return Ability(name, max_damage)

    def create_weapon(self):
        name = input("What is the weapon name?  ")
        max_damage = int(input("What si the max damage of the weapon?   "))
        return Weapon(name, max_damage)

    def create_armor(self):
        name = input("What is the name of your armor?   ")
        max_block = int(
            input("What is the max blocking power of your armor?   "))
        return Armor(name, max_block)

    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
                hero.add_ability(self.create_ability())
            elif add_item == "2":
                #TODO add a weapon to the hero
                hero.add_weapon(self.create_weapon())
            elif add_item == "3":
                #TODO add an armor to the hero
                hero.add_armor(self.create_armor())
        return hero

    def build_team_one(self):
        '''Prompt the user to build team_one '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)
            print(f"Hero {i} created")

    def build_team_two(self):

        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)
            print(f"Hero {i} created")

    def team_battle(self):
        self.team_one.attack(self.team_two)

    def show_stats(self):
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " +
              str(team_kills / team_deaths))

        team_kills = 0
        team_deaths = 0
        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(
            f"{self.team_two.name} average K/D was: {team_kills/team_deaths}")

        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print(f"survived from {self.team_two.name}: {hero.name}")
Exemplo n.º 7
0
class Arena:
    def __init__(self):
        '''
        Instance properies:
            team_one: None
            team_two: None
        '''
        self.team_one = None
        self.team_two = None

    def create_ability(self):
        '''
        Prompt user for Ability information.
        return
        ------
        Ability with values from user input.
        '''
        name = input("What is the ability name? ")
        max_damage = input("What is the max damage of the ability? ")
        return Ability(name, max_damage)

    def create_weapon(self):
        '''
        Prompt user for Weapon information.
        return
        ------
        Weapon with values from user input.
        '''
        name = input("What is the weapon name? ")
        max_damage = input("What is the max damage of the weapon? ")
        return Weapon(name, max_damage)

    def create_armor(self):
        '''
        Prompt user for Armor information.
        return
        ------
        Armor with values from user input.
        '''
        name = input("What is the armor name? ")
        max_block = input("What is the max block of the armor? ")
        return Armor(name, max_block)

    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

    # build_team_one is provided to you
    def build_team_one(self):
        '''
        Prompt the user to build team_one.
        '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(input("How many members would you like on Team One?\n"))
        name = input("Team 1 Name: ")
        self.team_one = Team(name)

        for hero in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        '''
        Prompt the user to build team_two.
        '''
        numOfTeamMembers = int(input("How many members would you like on Team Two?\n"))
        name = input("Team 2 Name: ")
        self.team_two = Team(name)

        for hero in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        '''
        Battle team_one and team_two together.
        '''
        self.team_one.attack(self.team_two)

    def show_stats(self):
        '''
        Prints team statistics to terminal.
        '''
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " + str(team_kills/team_deaths))

        # This is how to calculate the average K/D for Team Two
        team_kills = 0
        team_deaths = 0
        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_two.name + " average K/D was: " + str(team_kills/team_deaths))

        # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("Survived from " + self.team_one.name + ": " + hero.name)

        # Here is a way to list the heroes from Team Two that survived
        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("Survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 8
0
class Arena:
    def __init__(self):
        self.team_one = None
        self.team_two = None

    def create_ability(self):
        '''Prompt for Ability information.
            return Ability with values from user Input
        '''
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")

        return Ability(name, max_damage)

    def create_weapon(self):
        '''Prompt user for Weapon information
            return Weapon with values from user input.
        '''

        weapon = input("What is the name of your weapon? ")
        max_damage = input("How hard does it hit? ")

        return Weapon(weapon, max_damage)

    def create_armor(self):
        '''Prompt user for Armor information
          return Armor with values from user input.
        '''

        armor_name = input("What type of armor do you have? ")
        block_value = input("How much does it block? ")

        return Armor(armor_name, block_value)

    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

    def build_team_one(self):
        '''Prompt the user to build team_one '''

        team_name = input("What is the team name for first team? ")
        self.team_one = Team(team_name)

        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        '''Prompt the user to build team_two'''
        team_name = input("What is the team name for second team? ")
        self.team_two = Team(team_name)

        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        '''Battle team_one and team_two together.'''

        self.team_one.attack(self.team_two)

    def show_stats(self):
        '''Prints team statistics to terminal.'''
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " +
              str(team_kills / team_deaths))
        team_kills = 0
        team_deaths = 0
        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_two.name + " average K/D was: " +
              str(team_kills / team_deaths))

        # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 9
0
class Arena:
    """Define class Arena."""

    def __init__(self):
        """Initialize properties for our Arena."""
        self.team_one = Team("Team One")
        self.team_two = Team("Team Two")

    def create_ability(self):
        """Return ability with values from user input."""
        name = input('What is the ability name? ')
        try:
            max_damage = int(input('What is the max damage? '))
        except ValueError:
            print("Please enter a number.")
            max_damage = int(input('What is the max damage? '))
        return Ability(name, max_damage)

    def create_weapon(self, drop_weapon=None):
        """Return weapon with values from user input."""
        if drop_weapon:
            possible_weapons = ["Bad Joke", "BO", "Party Crasher", "The DEA"]
            bonus_weapon = choice(possible_weapons)
            name = input(f"[1] Laser Beam\n[2] MGK\n[3] Guy Who Talks Too Much\n[4] Banana\n[5] {bonus_weapon}\n\nYour choice: ")
        else:
            name = input("[1] Laser Beam\n[2] MGK\n[3] Guy Who Talks Too Much\n[4] Banana\n\nYour Choice: ")
        try:
            max_damage = int(input('What is the max damage? '))
            if not max_damage % 2 == 0:
                max_damage -= 1
        except ValueError:
            print("Please enter a number.")
            max_damage = int(input('What is the max damage? '))
        return Weapon(name, max_damage)

    def create_armor(self):
        """Return armor with values from user input."""
        name = input('What is the armor name? ')
        try:
            max_block_strength = int(input('What is the max block strength? '))
        except ValueError:
            print("Please enter a number.")
            max_block_strength = int(input('What is the max block strength? '))
        return Armor(name, max_block_strength)

    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

    def build_team_one(self):
        """Prompt the user to buid team one"""
        try:
            numOfTeamMembers = int(input("How many members would you like on Team One?\n"))
        except ValueError:
            print("Please enter a number.")
            numOfTeamMembers = int(input("How many members would you like on Team One?\n"))

        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        """Prompt the user to build team two"""
        numOfTeamMembers = int(input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        """Battle team_one and team_two together."""
        winner = self.team_one.attack(self.team_two)
        drop_weapon = False
        for hero in self.team_one.heroes:
            if winner == hero.name:
                print("{:-^50}".format("Congratulations - You get a new weapon!"))
                drop_weapon =  True
                return drop_weapon
        for hero in self.team_two.heroes:
            if winner == hero.name:
                print("{:-^50}".format("Congratulations - You get a new weapon!"))
                drop_weapon = True
                return drop_weapon

    def kill_death_stats(self):
        """Calculate the average K/D for team one and two."""
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(f"{self.team_one.name} average K/D was: {str(team_kills/team_deaths)}")
        print(f"{self.team_two.name} average K/D was: {str(team_kills/team_deaths)}")

    def surviving_heroes(self):
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print(f"Survived from {self.team_one.name}: {hero.name}")
        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print(f"Survived from {self.team_two.name}: {hero.name}")

    def show_stats(self):
        """Print battle stats to terminal."""
        self.kill_death_stats()
        self.surviving_heroes()

    def edit_team(self, play_again):
        """Allow user to edit team after first playthrough."""
        if play_again.lower() == "y":
            edit_team = input("Would you like to edit your team first? Y or N: ")
            if edit_team.lower() == "y":
                pick_team = input("[1] Edit Team One\n[2] Edit Team Two\n ")
                if pick_team == "1":
                    self.build_team_one()
                elif pick_team == "2":
                    self.build_team_two()
                else:
                    print("Invalid response - please try again.")
                    pick_team = input("[1] Edit Team One\n[2] Edit Team Two\n ")
Exemplo n.º 10
0
class Arena:
    def __init__(self):
        self.team_one = Team("Team 1")
        self.team_two = Team("Team 2")

    def create_ability(self):
        name = input("What is the ability name?  ")
        max_damage = int(input("What is the max damage of the ability?  "))

        return Ability(name, max_damage)

    def create_weapon(self):
        name = input("What is the weapons name?  ")
        max_damage = int(input("What is the max damage of the weapon?  "))

        return Weapon(name, max_damage)

    def create_armor(self):
        name = input("What is the armors name?  ")
        max_block = input("What is the max health of the armor?  ")

        return Weapon(name, max_block)

    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
                weapons = self.create_weapon()
                hero.add_weapon(weapons)
            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

    def build_team_one(self):
        numOfTeamMembers = int(input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        numOfTeamMembers = int(input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        self.team_one.attack(self.team_two)

    def show_stats(self):
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " + str(team_kills/team_deaths))

    # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        team2_kills = 0
        team2_deaths = 0
        for hero in self.team_two.heroes:
            team2_kills += hero.kills
            team2_deaths += hero.deaths
        if team2_deaths == 0:
            team2_deaths = 1
        print(self.team_two.name + " average K/D was: " + str(team2_kills/team2_deaths))

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 11
0
class Arena:
    def __init__(self):
        '''Instantiate properties
            team_one: None
            team_two: None
        '''
        self.team_one = Team('Team One')
        self.team_two = Team('Team Two')
        # will hold our teams.

    def create_ability(self):
        '''Prompt for Ability information.
            return Ability with values from user Input
        '''
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")

        return Ability(name, max_damage)

    def create_weapon(self):
        '''Prompt user for Weapon information
            return Weapon with values from user input.
        '''
        # Prompt the user for the necessary information to create a new weapon object.
        # return the new weapon object.
        name = input("What is the weapon name?  ")
        max_damage = input("What is the max damage of the weapon?  ")

        return Weapon(name, max_damage)

    def create_armor(self):
        '''Prompt user for Armor information
          return Armor with values from user input.
        '''
        #  Prompt the user for the necessary information to create a new armor object.
        #  return the new armor object with values set by user.
        name = input("What is the armor name?  ")
        max_block = input("What is the max block of the armor?  ")

        return Armor(name, max_block)

    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":
                hero.add_ability(self.create_ability())
                #HINT: First create the ability, then add it to the hero
            elif add_item == "2":
                hero.add_weapon(self.create_weapon())
                #HINT: First create the weapon, then add it to the hero
            elif add_item == "3":
                hero.add_armor(self.create_armor())
                #HINT: First create the armor, then add it to the hero
        return hero

    # build_team_one is provided to you
    def build_team_one(self):
        '''Prompt the user to build team_one '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    # Now implement build_team_two
    #HINT: If you get stuck, look at how build_team_one is implemented
    def build_team_two(self):
        '''Prompt the user to build team_two'''
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        '''Battle team_one and team_two together.'''
        self.team_one.attack(self.team_two)
        # Call the attack method that exists in your team objects
        # for that battle functionality.

    def show_stats(self):
        '''Prints team statistics to terminal.'''
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        print(self.team_one.name + " average K/D was: " +
              self.team_one.kd_stat())

        print(self.team_two.name + " average K/D was: " +
              self.team_two.kd_stat())

        # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 12
0
class Arena:
    def __init__(self, team_one=None, team_two=None):
        '''Instantiate properties
            team_one: None
            team_two: None
        '''
        self.team_one = Team(team_one)
        self.team_two = Team(team_two)

    def create_ability(self):
        '''Prompt for Ability information.
            return Ability with values from user Input
        '''
        name = input("What is the ability name?  ")
        max_damage = input(
            "What is the max damage of the ability?  ")

        return Ability(name, max_damage)

    def create_weapon(self):
        '''Prompt user for Weapon information
            return Weapon with values from user input.
        '''
        name = input("What is the weapon name?  ")
        max_damage = input(
            "What is the max damage of the weapon?  ")

        return Weapon(name, max_damage)

    def create_armor(self):
        '''Prompt user for Armor information
          return Armor with values from user input.
        '''
        name = input("What is the armor name?  ")
        max_block = input(
            "What is the max block of the armor?  ")

        return Armor(name, max_block)

    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":
               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

    def build_team_one(self):
        '''Prompt the user to build team_one '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        '''Prompt the user to build team_two'''
        numOfTeamMembers = int(input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        '''Battle team_one and team_two together.'''
        self.team_one.attack(self.team_two)

    def show_stats(self):
        '''Prints team statistics to terminal.'''
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        team_one_kills = 0
        team_one_deaths = 0
        for hero in self.team_one.heroes:
            team_one_kills += hero.kills
            team_one_deaths += hero.deaths
        if team_one_deaths == 0:
            team_one_deaths = 1
        print(self.team_one.name + " average K/D was: " + str(team_one_kills/team_one_deaths))

        team_two_kills = 0
        team_two_deaths = 0
        for hero in self.team_two.heroes:
            team_two_kills += hero.kills
            team_two_deaths += hero.deaths
        if team_two_deaths == 0:
            team_two_deaths = 1
        print(self.team_two.name + " average K/D was: " + str(team_two_kills/team_two_deaths))

        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)

        t1_alive_heroes = len(self.team_one.heroes) - team_two_kills
        
        if t1_alive_heroes > 0:
            print(f"{self.team_one.name} won!")
        else:
            print(f"{self.team_two.name} won!")
Exemplo n.º 13
0
class Arena:
    def __init__(self):
        self.team_one = Team("Team1")
        self.team_two = Team("Team2")

    def create_ability(self):
        # prompt for the ability
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")
        return Ability(name, max_damage)

    def create_weapon(self):
        # prompt for the weapon
        name = input("What is the weapon's name?  ")
        max_damage = input("What is the max damage of the weapon?  ")
        return Weapon(name, max_damage)

    def create_armor(self):
        # prompt for armor
        name = input("What is the armor's name?")
        max_block = input("What is the armor's max defense?")
        return Armor(name, max_block)

    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

    def build_team_one(self):
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        # TODO: This method should battle the teams together.
        # Call the attack method that exists in your team objects
        # for that battle functionality.
        self.team_one.attack(self.team_two)

    def show_stats(self):
        """Prints team statistics to terminal."""
        print("\n")

        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        self.getTeamKD(self.team_one)
        self.getTeamKD(self.team_two)

        team_one_survivor_count = self.getSurvivingHeroes(self.team_one)
        team_two_survivor_count = self.getSurvivingHeroes(self.team_two)

        if team_one_survivor_count > team_two_survivor_count:
            print("Team one is the winner!")
        elif team_two_survivor_count > team_one_survivor_count:
            print("Team two is the winner!")
        else:
            print("It was a draw!")

    def getTeamKD(self, team):
        team_kills = 0
        team_deaths = 0
        for hero in team.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1

        KD = str(team_kills / team_deaths)
        print(team.name + " average K/D was: " + KD)

    def getSurvivingHeroes(self, team):
        survivorCount = 0
        for hero in team.heroes:
            if hero.deaths == 0:
                survivorCount += 1
                print("survived from " + team.name + ": " + hero.name)
        return survivorCount
Exemplo n.º 14
0
class Arena:
    def __init__(self):
        """ Instantiate properties: team_one to None and team_two to None"""

        self.team_one = Team('Team One')
        self.team_two = Team('Team Two')

    def create_ability(self):
        """Promp for Ability information. It will return Ability with values from user input"""

        name = input('What is the ability name? ')
        max_damage = input('What is the max damage of the ability? ')

        return Ability(name, max_damage)

    def create_weapon(self):
        """Promp user for Weapon information. It will return Weapon with values from user input."""

        name = input('What is the weapon name? ')
        max_damage = input('What is the max damage of the weapon? ')

        return Weapon(name, max_damage)

    def create_armor(self):
        """Prompt user for Armor information. It will return Armor with values from user input."""

        name = input('What is the armor name? ')
        max_block = input('What is the max blocking value of the ability? ')

        return Armor(name, max_block)

    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

    def build_team_one(self):
        """Prompt the user to built team_one"""

        num_of_team_members = int(
            input("How many members would you like on Team One?\n"))
        for i in range(num_of_team_members):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        """Prompt the user to built team_two"""

        num_of_team_members = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(num_of_team_members):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        """Battle team_one and team_two together."""

        self.team_one.attack(self.team_two)

    def show_stats(self):
        """Prints team statistics to terminal"""

        # Surviving heroes ---------------------------------
        hero_team_one_alive = 0
        hero_team_two_alive = 0

        # cheking for surviving heroes on team 1
        for hero in self.team_one.heroes:
            if hero.is_alive():
                print(f'{hero.name} is alive.')
                hero_team_one_alive += 1

        # cheking for surviving heroes on team 2
        for hero in self.team_two.heroes:
            if hero.is_alive():
                print(f'{hero.name} is alive.')
                hero_team_two_alive += 1

        # Deciding which team won --------------------------
        if hero_team_one_alive > hero_team_two_alive:
            print(f'Team one won!')
        elif hero_team_one_alive < hero_team_two_alive:
            print(f'Team two won!')
        elif hero_team_one_alive == hero_team_two_alive:
            print(f'There was a draw!')

        # Calculating K/D for each team ---------------------
        team_one_kills = 0
        team_two_kills = 0
        team_one_deaths = 0
        team_two_deaths = 0

        # calculating K/D for team one
        for hero in self.team_one.heroes:  # para mi que el .heroes no va
            team_one_kills += hero.kills
            team_one_deaths += hero.deaths
        if team_one_deaths == 0:
            team_one_deaths = 1
        print(
            f'{self.team_one.name} average K/D was: {team_one_kills/team_one_deaths}'
        )

        # calculating K/D for team two
        for hero in self.team_two.heroes:  # para mi que el .heroes no va
            team_two_kills += hero.kills
            team_two_deaths += hero.deaths
        if team_two_deaths == 0:
            team_two_deaths = 1
        print(
            f'{self.team_two.name} average K/D was: {team_two_kills/team_two_deaths}'
        )
Exemplo n.º 15
0
class Arena:
    def __init__(self):
        self.team_one = Team("Team1")
        self.team_two = Team("Team2")

    def create_ability(self):
        """Prompt for Ability information.
        return Ability with values from user Input
        """
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")

        return Ability(name, max_damage)

    def create_weapon(self):
        """Prompt user for Weapon information
        return Weapon with values from user input.
        """
        name = input("What is the weapon's name?  ")
        max_damage = input("What is the max damage of the weapon?  ")

        return Weapon(name, max_damage)

    def create_armor(self):
        """Prompt user for Armor information
        return Armor with values from user input.
        """
        name = input("What is the armor's name?")
        max_block = input("What is the armor's max defense?")
        return Armor(name, max_block)

    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":
                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

    # build_team_one is provided to you
    def build_team_one(self):
        """Prompt the user to build team_one """
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    # Now implement build_team_two
    # HINT: If you get stuck, look at how build_team_one is implemented
    def build_team_two(self):
        """Prompt the user to build team_two"""
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        """Battle team_one and team_two together."""
        self.team_one.attack(self.team_two)

    def show_stats(self):
        """Prints team statistics to terminal."""
        print("\n")

        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        self.getTeamKD(self.team_one)
        self.getTeamKD(self.team_two)

        team_one_survivor_count = self.getSurvivingHeroes(self.team_one)
        team_two_survivor_count = self.getSurvivingHeroes(self.team_two)

        if team_one_survivor_count > team_two_survivor_count:
            print("Team one is the winner!")
        elif team_two_survivor_count > team_one_survivor_count:
            print("Team two is the winner!")
        else:
            print("It was a draw!")

    def getTeamKD(self, team):
        team_kills = 0
        team_deaths = 0
        for hero in team.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1

        KD = str(team_kills / team_deaths)
        print(team.name + " average K/D was: " + KD)

    def getSurvivingHeroes(self, team):
        survivorCount = 0
        for hero in team.heroes:
            if hero.deaths == 0:
                survivorCount += 1
                print("survived from " + team.name + ": " + hero.name)
        return survivorCount
Exemplo n.º 16
0
class Arena:
    def __init__(self):
        '''Instantiate properties
            team_one: None
            team_two: None
        '''
        # TODO: create instance variables named team_one and team_two that
        # will hold our teams.
        self.team_one = Team("Team One")
        self.team_two = Team("Team Two")

    def create_ability(self):
        # '''Prompt for Ability information.
        #     return Ability with values from user Input
        # '''
        name = input("What is the ability name?")
        max_damage = input("What is the max damage of the ability?")

        return Ability(name, max_damage)

    def create_weapon(self):
        # '''Prompt user for Weapon information
        #     return Weapon with values from user input.
        # '''
        # TODO: This method will allow a user to create a weapon.
        # Prompt the user for the necessary information to create a new weapon object.
        # return the new weapon object.
        name_of_weapon = input("What is this weapons name?")
        damage_of_weapon = input("What is the weapons max damage ?")
        return Weapon(name_of_weapon, damage_of_weapon)

    def create_armor(self):
        # '''Prompt user for Armor information
        #   return Armor with values from user input.
        # '''
        # TODO:This method will allow a user to create a piece of armor.
        #  Prompt the user for the necessary information to create a new armor object.
        #  return the new armor object with values set by user.
        name_of_armor = input("What is this armors name ?")
        max_health = input("What is the armors max health?")
        return Weapon(name_of_armor, max_health)

    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

        # build_team_one is provided to you
    def build_team_one(self):
        '''Prompt the user to build team_one '''
        # This method should allow a user to create team one.
        # Prompt the user for the number of Heroes on team one
        # call self.create_hero() for every hero that the user wants to add to team one.
        # Add the created hero to team one.
        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    # Now implement build_team_two
    #HINT: If you get stuck, look at how build_team_one is implemented
    def build_team_two(self):
        '''Prompt the user to build team_two'''
        # TODO: This method should allow a user to create team two.
        # This method should allow a user to create team two.
        # Prompt the user for the number of Heroes on team two
        # call self.create_hero() for every hero that the user wants to add to team two.
        # Add the created hero to team two.
        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        # '''Battle team_one and team_two together.'''
        # TODO: This method should battle the teams together.
        # Call the attack method that exists in your team objects
        # for that battle functionality.
        self.team_one.attack(self.team_two)

    def show_stats(self):

        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " +
              str(team_kills / team_deaths))

        # TODO: Now display the average K/D for Team Two
        team_kills = 0
        team_deaths = 0
        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_two.name + " average K/D was: " +
              str(team_kills / team_deaths))

        # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

    #TODO: Now list the heroes from Team Two that survived
        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 17
0
class Arena:
    def __init__(self):
        self.team_one = Team(team_one)
        self.team_two = Team(team_two)

    def create_ability(self):
        name = input("What is the ability name? ")
        max_damage = input("What is the max damage of the ability? ")

        return Ability(name, max_damage)

    def create_weapon(self):
        weapon_name = input("What is the weapon's name? ")
        weapon_damage = input("What is the max damage of the weapon? ")

        return Weapon(weapon, weapon_damage)

    def create_armor(self):
        armor_name = input("What is the name of the armor? ")
        max_defense = input("What is the max defense of the armor? ")

        return Armor(armor_name, max_defense)

    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":
                self.create_ability()
            elif add_item == "2":
                self.create_weapon()
            elif add_item == "3":
                self.create_armor()

    def build_team_one(self):
        numOfTeamMembers = int(
            input("How many members would you like on team one?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        numOfTeamMembers = int(
            input("How many members would you like on team two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        self.team_one.attack(self.team_two)

    def show_stats(self):
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()

        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " +
              str(team_kills / team_deaths))

        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        for hero in self.team_two.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_two.name + " average K/D was: " +
              str(team_kills / team_deaths))

        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 18
0
class Arena:
    def __init__(self):
        ''' Instantiate properties
            team_one: None
            team_two: None
        '''
        self.team_one = Team("team_one")
        self.team_two = Team("team_two")

    def create_ability(self):
        ''' Prompt for Ability information.
            return Ability with values from user Input
        '''
        name = input("What is the ability name? ")
        max_damage = int(input("What is the max damage of the ability? "))

        return Ability(name, max_damage)

    def create_weapon(self):
        ''' Prompt user for Weapon information.
            return Weapon with values from user input
        '''
        name = input("What is the weapon name? ")
        max_damage = int(input("What is the weapon's max damage? "))

        return Weapon(name, max_damage)

    def create_armor(self):
        '''Prompt user for Armor information
          return Armor with values from user input.
        '''
        name = input("What is the armor name? ")
        max_block = int(input("What is the max block of the piece of armor? "))

        return Armor(name, max_block)

    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":
               hero.add_ability(self.create_ability())
           elif add_item == "2":
               hero.add_weapon(self.create_weapon())
           elif add_item == "3":
               hero.add_armors(self.create_armor())
        return hero

    def build_team_one(self):
        '''Prompt the user to build team_one '''
        numOfTeamMembers = int(input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        '''Prompt the user to build team_two'''
        numOfTeamMembers = int(input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        '''Battle team_one and team_two together.'''
        self.team_one.attack(self.team_two)

    def show_stats(self):
        ''' Prints team statistics to terminal. '''
        print("\n")
        print(self.team_one.name + " statistics: ")
        self.team_one.stats()
        print("\n")
        print(self.team_two.name + " statistics: ")
        self.team_two.stats()
        print("\n")

        # This is how to calculate the average K/D for Team One
        team_kills = 0
        team_deaths = 0
        for hero in self.team_one.heroes:
            team_kills += hero.kills
            team_deaths += hero.deaths
        if team_deaths == 0:
            team_deaths = 1
        print(self.team_one.name + " average K/D was: " + str(team_kills/team_deaths))

        # TODO: Now display the average K/D for Team Two
        team_two_kills = 0
        team_two_deaths = 0
        for hero in self.team_two.heroes:
            team_two_kills += hero.kills
            team_two_deaths += hero.deaths
        if team_two_deaths == 0:
            team_two_deaths = 1
        print(self.team_two.name + " average K/D was:" + str(team_two_kills/team_two_deaths))

        # Here is a way to list the heroes from Team One that survived
        for hero in self.team_one.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_one.name + ": " + hero.name)

        #TODO: Now list the heroes from Team Two that survived
        for hero in self.team_two.heroes:
            if hero.deaths == 0:
                print("survived from " + self.team_two.name + ": " + hero.name)
Exemplo n.º 19
0
class Arena:
    def __init__(self):
        self.team_one = None  #Team("Team Iron Man")
        self.team_two = None  #Team("Team Captain America")

    def create_ability(self):
        name = input("What is the ability name?  ")
        max_damage = input("What is the max damage of the ability?  ")
        return Ability(name, max_damage)

    def create_weapon(self):
        name = input("What is the name of your weapon?   ")
        max_damage = input("What is the max damage of the weapon?  ")

        return Weapon(name, int(max_damage))

    def create_armor(self):
        name = input("What is the name of your armor?   ")
        max_block = input("What is the max block power of the armor?  ")
        return Armor(name, max_block)

    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

    def build_team_one(self):
        team_name = input("What's your team name?   ")
        self.team_one = Team(team_name)

        numOfTeamMembers = int(
            input("How many members would you like on Team One?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        team_name = input("What's your team name?   ")
        self.team_two = Team(team_name)

        numOfTeamMembers = int(
            input("How many members would you like on Team Two?\n"))
        for i in range(numOfTeamMembers):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    # ERROR:  TypeError: can only concatenate str (not "int") to str
    def team_battle(self):
        self.team_one.attack(self.team_two)
Exemplo n.º 20
0
class Arena:
    """Arena class for heroes' battleground."""
    def __init__(self):
        """Constructor for arena."""
        self.team_one = None
        self.team_two = None

    def create_ability(self):
        """Prompt for Ability information."""
        name = input("Ability name?: ")
        max_damage = int(input("Max damage?: "))
        return Ability(name, max_damage)

    def create_weapon(self):
        """Prompt for Weapon information."""
        name = input("Weapon name?: ")
        max_damage = int(input("Max damage?: "))
        return Weapon(name, max_damage)

    def create_armor(self):
        """Prompt for Armor information."""
        name = input("Armor name?: ")
        max_block = int(input("Max block?: "))
        return Armor(name, max_block)

    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

    def build_team_one(self):
        """Prompt for team one."""
        team_name = input("Team one name?: ")
        num_heroes = int(input(f"How many heroes on team \"{team_name}\"?: "))
        self.team_one = Team(team_name)
        for _ in range(num_heroes):
            hero = self.create_hero()
            self.team_one.add_hero(hero)

    def build_team_two(self):
        """Prompt for team two."""
        team_name = input("Team two name?: ")
        num_heroes = int(input(f"How many heroes on team \"{team_name}\"?: "))
        self.team_two = Team(team_name)
        for _ in range(num_heroes):
            hero = self.create_hero()
            self.team_two.add_hero(hero)

    def team_battle(self):
        """Duels hero teams (team_one and team_two)."""
        self.team_one.attack(self.team_two)

        # Error trap method 1:
        # assert isinstance(self.team_one, Team)
        # assert isinstance(self.team_two, Team)
        # self.team_one.attack(self.team_two)

        # Error trap method 2:
        # try:
        #     self.team_one.attack(self.team_two)
        # except:
        #     print("Build both teams first!")

    def show_stats(self):
        """Show team statistics."""
        print(f"\nTeam \"{self.team_one.name}\" statistics:")
        self.team_one.stats()

        print(f"\nTeam \"{self.team_two.name}\" statistics:")
        self.team_two.stats()

        print()
        team_kdr(self.team_one)
        team_kdr(self.team_two)

        print()
        print("Survivors:")
        survivors(self.team_one)
        survivors(self.team_two)
        print()