Пример #1
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
Пример #2
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
Пример #3
0
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
    # Check for correct type
    assert "Ability" in str(Athena.abilities[0])
    assert Athena.abilities[0].name == "Overwhelming Strength"
Пример #4
0
 def __init__(self, owner, name, power=0, turns=1, mp_cost=0, aspect=None,
              desc="", effect_verb=None, target_type=None, max_range=None,
              use_classes=None):
     self.power = power  # used as base strength
     self.mp_cost = mp_cost
     self.aspect = aspect
     verb = "casts"
     noun = name
     #self.info_to_display = ["Base power: " + str(self.power),
     #                        "MP cost: " + str(self.mp_cost)]
     Ability.__init__(self, owner=owner, strength=power, turns=turns,
                      name=name, verb=verb, noun=noun,
                      effect_verb=effect_verb, target_type=target_type,
                      max_range=max_range, use_classes=use_classes)
Пример #5
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
Пример #6
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
Пример #7
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)
Пример #8
0
 def get_abilities_for_level(self):
     ability_list = self.profession_component[4]
     abilities = []
     for index, ability in enumerate(ability_list):
         if int(index) <= self.owner.level:
             abilities.append(
                 Ability(*ability_data.get_ability_data(ability)))
     self.owner.abilities = abilities
Пример #9
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)
Пример #10
0
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
    # Check for correct type
    assert "Ability" in str(Athena.abilities[0])
    assert Athena.abilities[0].name == "Overwhelming Strength"
Пример #11
0
 def __init__(self, model, scale, pos, render, animations, base, path,
              health, name):
     self.startPos = pos
     self.actor = Actor(model, animations)
     self.actor.setScale(scale)
     self.actor.setPos(pos)
     self.actor.reparentTo(render)
     self.render = render
     self.base = base
     self.y, self.z, self.up = 0, 0, 0
     self.path = path
     self.life = health
     self.currLife = health
     self.fired = False
     self.fireOnCooldown = False
     self.fireCooldown = 2
     self.fireCooldownStart = 42
     bounds = self.actor.getChild(0).getBounds()
     c = bounds.getCenter()
     r = bounds.getRadius() * 1.005
     self.colS = CollisionSphere(c, r)
     self.colN = CollisionNode(name)
     self.colN.addSolid(self.colS)
     self.pColN = self.actor.attachNewNode(self.colN)
     self.colHand = CollisionHandlerQueue()
     self.base.cTrav.addCollider(self.pColN, self.colHand)
     self.base.taskMgr.add(self.move, "Move")
     self.base.taskMgr.add(self.update, "upd")
     self.projList = []
     self.roundSyms = dict()
     self.rounds = 0
     self.lost = False
     self.win = False
     self.abilities = []
     self.healUp = Ability("j", 4, "heal()", self.base, self)
     self.ultAbil = Ability("k", 15, "ult()", self.base, self)
     self.abilities.append(self.ultAbil)
     self.abilities.append(self.healUp)
Пример #12
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
Пример #13
0
 def __init__(self, owner, name, desc, use_msg, target_type, max_range,
              use_classes):
     Ability.__init__(self, owner=owner, name=name, desc=desc,
                      use_msg=use_msg, target_type=target_type,
                      max_range=max_range, use_classes=use_classes)
Пример #14
0
 def __init__(self):
     Ability.__init__(self, "Error", [])
Пример #15
0
 def __init__(self):
     Ability.__init__(self, "Coerce", ["coerce","co"])
Пример #16
0
 def __init__(self):
     Ability.__init__(self, "Hack", ["hack", "hk"])
Пример #17
0
# coding: utf-8
from Ability import Ability, _abilities

def get_ability(ability : str) -> Ability:
    return _abilities[ability]

Ability("Alive", "Able to sustain life")

Ability("Dead", "Too injured to sustain life")

Ability("Undead", "Animated by necromancy")

Ability("Target Attack (Piercing)", "", True,
        target_health_point='target_piercing')

Ability("Target Attack (Normal)", "", True,
        target_health_point='target_normal')

Ability("Attack", "", True,
        list_attack_modes='register_weapon',
        prepare_attack='prepare_attack',
        execute_attack='execute_attack',)

Ability("Normal Attack", "Performs a normal attack",
        base_attack=[
            'base_attack_abilities_default',
            'add_attack_point_normal'])

Ability("Piercing Attack", "Performs a piercing attack",
        base_attack=[
Пример #18
0
 def __init__(self):
     Ability.__init__(self, "Abilities", ["abilities","ab"])
Пример #19
0
 def use(self):
     return Ability.use(self)
Пример #20
0
 def __init__(self):
     Ability.__init__(self, "Save", ["save","sa"])
Пример #21
0
 def __init__(self):
     Ability.__init__(self, "Kill", ["kill","k"])
     self.activeKills = {}
Пример #22
0
 def __init__(self):
     Ability.__init__(self, "Truthtell", ["truthtell","tt"])
Пример #23
0
def test_ability_instance():
    # Test instantiation without error
    big_strength = Ability("Overwhelming Strength", 300)
    assert big_strength
Пример #24
0
 def __init__(self):
     Ability.__init__(self, LimitedUseString("Steal",2), ["steal","st"])
Пример #25
0
def test_ability_name():
    # Test for Correct Name
    big_strength = Ability("Overwhelming Strength", 300)
    assert big_strength.name == "Overwhelming Strength"
Пример #26
0
 def use(self):
     self.strength = self.calc_power()
     return Ability.use(self)
Пример #27
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)