def setup(self, player, request):

        flag = request.flag
        if flag == Flags.SELECT_CAT:
            self.select_cat(player, request)

        elif flag == Flags.READY:

            # Set the player to ready and assign random ability and two random chance cards
            players_ready = self.player_ready(player)

            Ability.random_ability(player)
            Chance.random_chance(player)
            Chance.random_chance(player)

            # If both players are ready proceed to the next phase
            if players_ready:

                # Set and alert players of next phase
                self.next_phase(Phases.PRELUDE)

                # Do not proceed if someone did not select a cat but readied up
                if self.player1.cat is not None and \
                        self.player2.cat is not None:

                    self.post_setup()
                    self.gloria_prelude()

                else:

                    Logger.log(
                        "One of the players did not select a cat - Killing the match"
                    )
                    self.kill_match()
示例#2
0
    def __init__(self, inventory):

        Ability.__init__(self, 'summon', inventory)
        self.not_self = True
        self.not_enemy = True
        self.restrict_terrain = True
        self.target_terrain = {0, 1, 2, 3, 4, 7, 8}
示例#3
0
def test_ability_attack():
    # Test for correct attack value
    test_runs = 400
    big_strength = Ability("Overwhelming Strength", 400)
    for _ in range(0, test_runs):
        attack = big_strength.attack()
        assert attack >= 0 and attack <= 400
示例#4
0
def test_hero_attack_weapon():
    big_strength = Ability("Overwhelming Strength", 200)
    Athena = Hero("Athena")
    Athena.add_ability(big_strength)
    test_runs = 100
    for _ in range(0, test_runs):
        attack = big_strength.attack()
        assert attack <= 200 and attack >= 0
示例#5
0
class EquipmentList():
	equipment_list = [ \
	Equipment("Weapon", "Bare Fists", "Fist", {"Atk": 1.0}, [Ability("Punch", {"Fist"}, {"Atk": 1.0})], 0), \
	Equipment("Weapon", "Wooden Sword", "Sword", {"Atk": 1.9}, [Ability("Slash", {"Sword"}, {"Atk": 1.0})]), \
	Equipment("Weapon", "Wooden Gauntlets", "Fist", {"Armor": 20, "Atk": 1.1}, [Ability("Punch", {"Fist"}, {"Atk": 1.0})]), \
	Equipment("Weapon", "Wooden Bow", "Bow", {"Atk": 2.5}, [Ability("Shoot", {"Bow"}, {"Atk": 1.0})]), \
	Equipment("Chest", "Wooden Breastplate", "medium_armor_type", {"Armor": 50}), \
	Equipment("Chest", "Wooden Tunic", "light_armor_type", {"Armor": 30})]
def test_hero_add_multi_ability():
    big_strength = Ability("Overwhelming Strength", 300)
    speed = Ability("Lightning Speed", 500)
    Athena = Hero("Athena")
    assert len(Athena.abilities) == 0
    Athena.add_ability(big_strength)
    assert len(Athena.abilities) == 1
    Athena.add_ability(speed)
    assert len(Athena.abilities) == 2
    assert "Ability" in str(Athena.abilities[0])
    assert Athena.abilities[0].name == "Overwhelming Strength"
示例#7
0
    def load_abilities(self,files):
        for file_name in files:
            f = open(file_name)
            data = yaml.load(f)
            f.close()
            yamlhelp.merge(data,self.abilities)

        for ability_id in self.abilities:
            ability = self.abilities[ability_id]
            ability = Ability(self, ability_id, **ability)
            self.abilities[ability_id] = ability
            ability.trigger = eval('abilityfunctions.%s'%ability.trigger)
            ability.effect  = eval('abilityfunctions.%s'%ability.effect)
            if ability.color:
                ability.color = yamlhelp.load_color(ability.color)
示例#8
0
    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 test_hero_attack():
    flash = Hero("The Flash")
    assert flash.attack() == 0
    pesto = Ability("Pesto Sauce", 8000)
    flash.add_ability(pesto)
    attack = flash.attack()
    assert attack <= 8000 and attack >= 4000
示例#10
0
def test_hero_ability_attack_mean_value():
    athena = Hero("Athena")
    strength = random.randint(10, 30000)
    big_strength = Ability("Overwhelming Strength", strength)
    athena.add_ability(big_strength)
    calculated_mean = strength // 2
    iterations = 6000
    accepted_window = 400

    total_attack = 0

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

    actual_mean = total_attack / iterations
    print("Max Allowed Damage: {}".format(strength))
    print("Attacks Tested: {}".format(iterations))
    print("Mean -- calculated: {} | actual: {}".format(calculated_mean,
                                                       actual_mean))
    print("Acceptable Distance from Mean: {} | Average distance from mean: {}".
          format(accepted_window, abs(calculated_mean - actual_mean)))
    print("Acceptable min attack: {} | Acceptable max attack: {}".format(
        actual_mean - accepted_window, actual_mean + accepted_window))
    assert actual_mean <= calculated_mean + accepted_window and actual_mean >= calculated_mean - accepted_window
示例#11
0
def test_hero_attack_ability():
    big_strength = Ability("Overwhelming Strength", 30000)
    athena = Hero("Athena")
    assert athena.attack() == 0
    athena.add_ability(big_strength)
    attack = athena.attack()
    assert attack <= 30000 and attack >= 0
示例#12
0
 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)
示例#13
0
 def __init__(self, init_rolls=None):
     if not init_rolls:
         init_rolls = [10 for _ in range(6)]
     super().__init__(
         {ability: Ability(name=ability, base=init_rolls[i])
          for i, ability in enumerate(ABILITY)
          })
def test_hero_add_ability():
    big_strength = Ability("Overwhelming Strength", 300)
    Athena = Hero("Athena")
    assert len(Athena.abilities) == 0
    Athena.add_ability(big_strength)
    assert len(Athena.abilities) == 1
    assert "Ability" in str(Athena.abilities[0])
    assert Athena.abilities[0].name == "Overwhelming Strength"
示例#15
0
def test_hero_weapon_ability_attack():
    quickness = Ability("Quickness", 1300)
    sword_of_truth = Weapon("Sword of Truth", 700)
    Athena = Hero("Athena")
    Athena.add_ability(quickness)
    Athena.add_ability(sword_of_truth)
    assert len(Athena.abilities) == 2
    attack_avg(Athena, 0, 2000)
示例#16
0
 def __init__(self, level):
     self.level = level
     self.name = "Monster #" + str(random.randint(1, 10000000))
     self.max_hp = random.randint(40 + level * 4, 60 + level * 6)
     self.curr_hp = self.max_hp
     self.str = random.randint(10 + level * 1, 15 + int(level * 1.5))
     self.gold_reward = int((self.max_hp * self.str) / 100)
     self.abilities = [Ability("Punch", ["Fist"], {"Atk": 1.0})]
示例#17
0
 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_ability():
    abilities = [
        "Alien Attack", "Science", "Star Power", "Immortality",
        "Grandmas Cookies", "Blinding Strength", "Cute Kittens", "Team Morale",
        "Luck", "Obsequious Destruction", "The Kraken",
        "The Fire of A Million Suns", "Team Spirit", "Canada"
    ]
    name = abilities[random.randint(0, len(abilities) - 1)]
    power = random.randint(45, 700000)
    return Ability(name, power)
示例#19
0
    def gloria_postlude(self):

        Logger.log(
            "Postlude phase starting for " + self.p1.username + ", " +
            self.p2.username, LogCodes.Match)

        Ability.use_passive_ability(self.p1, self.p2, self.phase)
        Ability.use_passive_ability(self.p1, self.p2, self.phase,
                                    self.p1.rability)

        Ability.use_passive_ability(self.p2, self.p1, self.phase)
        Ability.use_passive_ability(self.p2, self.p1, self.phase,
                                    self.p2.rability)
    def gloria_postlude(self):

        Logger.log("Postlude phase starting for " + self.player1.username +
                   ", " + self.player2.username)

        Ability.use_passive_ability(self.player1, self.player2, self.phase,
                                    self.player1.cat)
        Ability.use_passive_ability(self.player1, self.player2, self.phase,
                                    self.player1.rability)

        Ability.use_passive_ability(self.player2, self.player1, self.phase,
                                    self.player2.cat)
        Ability.use_passive_ability(self.player2, self.player1, self.phase,
                                    self.player2.rability)
示例#21
0
    def loadFromPkmnXML(name):
        """ Load an ability with the given name from an XML file """
        # Get Ability XML
        tree = AbilityFactory.getAbilitydexTree()
        tree = AbilityFactory.getAbilityXML(tree, name)

        # Build the Ability
        if tree == None:
            print "Could not find ability:", name
            ability = Ability(name)
        else:
            ability = AbilityFactory.buildAbilityFromXML(tree)
        return ability
    def select_ability(self, player, request):

        ability_id = -1
        if request.body:
            ability_id = int(request.body)

        opponent = self.get_opponent(player.username)
        ability_used = Ability.use_active_ability(player, opponent, self.phase,
                                                  ability_id)

        response = Network.generate_responseb(Flags.USE_ABILITY,
                                              Flags.ONE_BYTE,
                                              int(ability_used))
        Network.send_data(player.username, player.connection, response)
示例#23
0
 def __str__(self):
     output = ("{}\n"
               "HP Total: {}\n"
               "{}\n"
               "{}\n"
               "Ability: {}\n"
               "	{}\n"
               "Base Stats{}\n"
               "	HP: {}\n"
               "	Atk: {}\n"
               "	Def: {}\n"
               "	SpAtk: {}\n"
               "	SpDef: {}\n"
               "	Speed: {}\n"
               "Current Stats {}\n"
               "	HP: {}\n"
               "	Atk: {}\n"
               "	Def: {}\n"
               "	SpAtk: {}\n"
               "	SpDef: {}\n"
               "	Speed: {}\n"
               "Type: {}/{}\n"
               "WeightClass: {}\n"
               "Size: {}\n"
               "Sex: {}\n"
               "Capture Rate: {}\n"
               "Exp Drop: {}\n"
               "Capabilities: {}\n"
               "	Int: {}\n"
               "	Power: {}\n"
               "	Overland: {}\n"
               "	Surface: {}\n"
               "	Underwater: {}\n"
               "	Sky: {}\n"
               "	Burrow: {}\n"
               "	Jump: {}\n"
               "	Capability Name: {}\n"
               "	{}\n")
     return output.format(self.name, self.finalHPtotal, self.shiny,
                          Nature(self.nature), "",
                          Ability((self.ability_id, )), "", self.HP,
                          self.Atk, self.Def, self.SpAtk, self.SpDef,
                          self.Speed, "", self.finalHP, self.finalAtk,
                          self.finalDef, self.finalSpAtk, self.finalSpDef,
                          self.finalSpeed, self.Type1, self.Type2,
                          self.WeightClass, self.Size, self.Sex(),
                          self.caprate, self.exp * self.level, "", self.Int,
                          self.Power, self.Overland, self.Surface,
                          self.Underwater, self.Sky, self.Burrow, self.Jump,
                          self.capability_name, self.capability_desc)
示例#24
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
示例#25
0
 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)
示例#26
0
    def add_ability(self, ability: Ability) -> None:
        """
        Add ability to ability inventory.
        Using this function is recommended instead of using .append()
        """
        # Prevent duplicates
        if ability in self.abilities:
            return None

        ability.parent = self
        self.abilities.append(ability)

        # give alphabet key
        for key, value in self.ability_hotkeys.items():
            if value == None:
                self.ability_hotkeys[key] = ability
                break
示例#27
0
def test_hero_ability_attack_standard_deviation():
    willow_waffle = Hero("Willow Waffle")
    strength = random.randint(400, 30000)
    willow = Ability("Willowness", strength)
    willow_waffle.add_ability(willow)
    attacks = list()
    total_attack = 0
    number_tests = 1000
    for _ in range(number_tests):
        cur_attack = willow_waffle.attack()
        attacks.append(cur_attack)
        total_attack += cur_attack
    mean = total_attack / number_tests

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

    standard_dev = math.sqrt(sum(attacks) / len(attacks))
    print("Standard Deviation Cannot be 0.\nRandom Numbers not generated for attack.")
    assert standard_dev != 0.0
示例#28
0
            if not self.is_alive():
                print(f"\n{self.name} has been defeated by {opponent.name}\n".
                      upper())
            elif not opponent.is_alive():
                print(f"\n{opponent.name} has been defeated by {self.name}\n".
                      upper())
        else:
            print("Draw!")
        #print(f'{random.choice(hero_choice)} wins!')

    def is_alive(self):
        #checks to see if the hero is still alive
        if self.current_health <= 0:
            return False
        else:
            return True


if __name__ == "__main__":
    my_hero = Hero('Grace Hopper', 200)
    hero1 = Hero('Dumbledore', 200)
    ability = Ability("Shmoove", 25)
    ability2 = Ability("Ice", 15)
    ability3 = Ability("Laugh", 30)
    shield = Armor("Shield", 50)
    my_hero.add_ability(ability)
    hero1.add_ability(ability2)
    my_hero.add_ability(ability3)
    my_hero.add_armor(shield)
    my_hero.fight(hero1)
    #hero1.fight(hero2)
示例#29
0
        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_name = input("what is the name of your weapon")
        weapon_description = input("What does this weapon do?")
        return Weapon(weapon_name, weapon_description)

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

          armor_name = input("what piesce of armor do you want")
          armor_specs = input("what materails do you need")
          return Armor(armor,armor_specs)

        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.create_ability()
               
           elif add_item == "2":
               weapon = self.create_weapon()
               hero.create_weapon()
           elif add_item == "3":
               armor = self.create_armor()
               hero.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'''
        numOfTeamMembers2 = int(input("How many members would you like on Team two?\n"))
        for i in range(numOfTeamMembers2):
            hero = self.create_hero()
            self.team_two.add_hero(hero)
  
    def team_battle(self):
        '''Battle team_one and team_two together.'''
        team_one.attack(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))

    # 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)

    
    #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)


    if __name__ == "__main__":
    game_is_running = True

    # Instantiate Game Arena
    arena = Arena()

    #Build Teams
    arena.build_team_one()
    arena.build_team_two()

    while game_is_running:

        arena.team_battle()
        arena.show_stats()
        play_again = input("Play Again? Y or N: ")

        #Check for Player Input
        if play_again.lower() == "n":
            game_is_running = False

        else:
            #Revive heroes to play again
            arena.team_one.revive_heroes()
            arena.team_two.revive_heroes()git 
示例#30
0
文件: switch.py 项目: 450W16/MODACT
 def __init__(self):
     Ability.__init__(self, "switch", pygame.K_f)
示例#31
0
文件: ladder.py 项目: 450W16/MODACT
	def __init__(self):
		Ability.__init__(self, "ladder", pygame.K_l)
 def __init__(self, name):
     """ Builds the Confuse """
     Ability.__init__(self, name)
示例#33
0
文件: climb.py 项目: 450W16/MODACT
	def __init__(self):
		Ability.__init__(self, "climbDown", pygame.K_DOWN)
示例#34
0
文件: climb.py 项目: 450W16/MODACT
	def __init__(self):
		Ability.__init__(self, "climbUp", pygame.K_UP)
示例#35
0
文件: bridge.py 项目: 450W16/MODACT
	def __init__(self):
		Ability.__init__(self, "bridge", pygame.K_b)
示例#36
0
文件: wall.py 项目: 450W16/MODACT
	def __init__(self):
		Ability.__init__(self, "wall", pygame.K_w)
示例#37
0
文件: revert.py 项目: 450W16/MODACT
	def __init__(self):
		Ability.__init__(self, "revert", pygame.K_r)
示例#38
0
    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)
示例#39
0
        """docstring for resilience_defense"""
        return 10 + self.ability.bonus(self.ability.constitution) #+ misc

    def movemnet_speed(self):
        """docstring for movemnet_speed"""
        return 5 + self.ability.modifier(self.ability.dexterity) #+ misc


if __name__ == '__main__':
    from level import Level
    from ability import Ability
    from class_ import Class
    from race import Race
    level = Level()
    race = Race()
    ability = Ability(level)
    ability.generate()
    ability.wisdom = 22
    class_ = Class()
    statistics = Statistics(ability, level, class_)
    def yell():
        """docstring for debug"""
        print "hp:%s ap:%s mb:%s rb:%s mab:%s ad:%s ed:%s md:%s rd:%s spd:%s at level: %s" % (
            statistics.max_health_points(),
            statistics.max_anima_points(),
            statistics.melee_bonus(),
            statistics.ranged_bonus(),
            statistics.magic_bonus(),
            statistics.armor_defense(10),
            statistics.evasion_defense(),
            statistics.magic_defense(),
示例#40
0
    def __init__(self, manager):

        Ability.__init__(self, manager)
 def __init__(self, name, effects):
     """ Builds the Ability """
     Ability.__init__(self, name)
     self.effects = effects