예제 #1
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)
예제 #2
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}")
예제 #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 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)
예제 #4
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)
예제 #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, 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)
예제 #6
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)
예제 #7
0
class Arena:
    #Arena class

    def __init__(self):
        #instantiate properties
        self.team_one = Team("One")
        self.team_two = Team("Two")
        self.previous_winner = None

    def create_ability(self):
        #prompty used for ability information
        name = ""
        while len(name) < 1:
            name = input("What is the ability name?  ")
        max_damage = 0
        while max_damage < 1:
            max_damage = input("What is the max damage of the ability?  ")
            try:
                max_damage = int(max_damage)
                print(f"{name} has been added.")
                break
            except (ValueError, TypeError):
                max_damage = 0
                print("Please enter a number.")
        return Ability(name, max_damage)

    def create_armor(self):
        #prompt used for armor information
        name = ""
        while len(name) < 1:
            name = input("What is the armor name?  ")
        max_block = 0
        while max_block < 1:
            max_block = input("What is the max block of the armor?  ")
            try:
                max_block = int(max_block)
                print(f"{name} has been added.")
                break
            except (ValueError, TypeError):
                max_block = 0
                print("Please enter a number.")
        return Armor(name, max_block)

    def create_hero(self):
        #Prompt user for Hero information.
        #Return Hero with values from user input.
        print("\n")
        hero_name = ""
        while len(hero_name) < 1:
            hero_name = input("Hero's name: ")
        hero = Hero(hero_name)
        add_item = None
        while add_item != "4":
            add_item = input(
                "\n[1] Add ability\n[2] Add weapon\n[3] Add armor\n[4] Done adding items\n\nYour choice: "
            )
            if add_item == "1":
                abilty = self.create_ability()
                hero.add_ability(abilty)
            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 user to build team 1
        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)
        return self.team_one

    def build_team_two(self):
        #Prompt user to build team 2
        team_two = Team("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 surviving_heroes(self, team):
        #Return the survival count for a given team
        survival_count = 0
        for hero in team.heroes:
            if hero.is_alive():
                print(f"{hero.name} survived")
                survival_count += 1
        if not survival_count:
            print("no heroes survived")
        return survival_count

    def kd_average(self, team):
        #Prints kill/death average for given 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
        print(f"average K/D: {team_kills/team_deaths}")

    def winning_team(self, team_one, team_one_survival_count, team_two,
                     team_two_survival_count):
        #Prints winning team for two given survival counts
        if team_one_survival_count and team_two_survival_count:
            print("{:=^50}".format("No winner could be declared").upper())
            self.previous_winner = None
        elif team_one_survival_count:
            p = f"{team_one.name} won"
            print("{:=^50}".format(p).upper())
            self.previous_winner = team_one
        else:
            p = f"{team_two.name} won"
            print("{:=^50}".format(p).upper())
            self.previous_winner = team_two

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

    def show_stats(self, team_one, team_two):
        #Print team statistics to terminal
        print("\n")
        print("{:-^50}".format("STATS"))
        print("\n")
        print(f"{team_one.name} statistics: ".upper())
        team_one_survival_count = self.surviving_heroes(team_one)
        self.kd_average(team_one)
        print("\n")
        print(f"{team_two.name} statistics: ".upper())
        team_two_survival_count = self.surviving_heroes(team_two)
        self.kd_average(team_two)
        print("\n")
        self.winning_team(team_one, team_one_survival_count, team_two,
                          team_two_survival_count)
        print("\n")
예제 #8
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!")
예제 #9
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
예제 #10
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!")
예제 #11
0
    def fight(self, opponent):
        ''' Current Hero will take turns fighting the opponent hero passed in.'''
        if len(self.abilities) == 0 and len(opponent.abilities) == 0:
            return print('Draw')
        else:
            while self.is_alive() == True and opponent.is_alive() == True:
                total_damage = self.attack()
                opponent.take_damage(total_damage)
                total_damage2 = opponent.attack()
                self.take_damage(total_damage2)
            if self.is_alive() == False:
                return print(f'{opponent.name} is the winner!')
            elif opponent.is_alive() == False:
                return print(f'{self.name} is the winner!')


if __name__ == "__main__":
    # If you run this file from the terminal
    # this block is executed.
    hero1 = Hero("Athena")
    hero2 = Hero("Batman")
    hero3 = Hero("Supergirl")
    team1 = Team("Best_Team")
    team1.add_hero(hero1)
    team1.add_hero(hero2)
    team1.add_hero(hero3)
    team1.view_all_heroes
    team1.remove_hero(hero1)
    team1.view_all_heroes
    team1.remove_hero(hero1)
예제 #12
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}'
        )
예제 #13
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
예제 #14
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)
예제 #15
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)
예제 #16
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)
예제 #17
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)
예제 #18
0
def test_team_hero():
    team = Team("One")
    jodie = Hero("Jodie Foster")
    team.add_hero(jodie)
    assert len(team.heroes) == 1
    assert team.heroes[0].name == "Jodie Foster"
def test_team_remove_unlisted():
    team = Team("One")
    jodie = Hero("Jodie Foster")
    team.add_hero(jodie)
    code = team.remove_hero("Athena")
    assert code == 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)
예제 #21
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()