Exemplo n.º 1
0
class TestArmorMethods(unittest.TestCase):
    def setUp(self):
        self.armor = Armor('name', 10, [ArmorEffect('frost', 10)])

    def test_get_name(self):
        self.armor = Armor('name')
        print(self.armor, id(self.armor), id(self.armor.effects))
        self.assertEqual(self.armor.name, 'default_armor')

    def test_get_durability(self):
        self.armor = Armor('dur')
        print(self.armor, id(self.armor), id(self.armor.effects))
        self.assertEqual(self.armor.durability, 100)
        print('dur')

    def test_get_effects(self):
        self.armor = Armor('eff')
        print(self.armor, id(self.armor), id(self.armor.effects))
        self.assertEqual(self.armor.effects, [])
        print('get')

    def test_add_effect(self):
        self.armor = Armor('add')
        self.armor.add_effect('new_effect !')
        print(self.armor, id(self.armor), id(self.armor.effects))
        self.assertEqual(self.armor.effects, ['new_effect !'])
        print('add')

    def test_get_attack(self):
        pass
Exemplo n.º 2
0
def test_hero_defend_multi_armor():
    jodie = Hero("Jodie Foster")
    gauntlets = Armor("Gauntlets", 4000)
    science = Armor("Science", 9000)
    jodie.add_armor(gauntlets)
    jodie.add_armor(science)
    defend = jodie.defend()
    assert defend <= 13000 and defend >= 0
Exemplo n.º 3
0
 def __init__(self, args):
     if 'cloak' in args: self._cloak = Armor(args['cloak'])
     else:
         self._cloak = None  # todo: check is this needed/does this do anything in python?
     if 'helmet' in args: self._helmet = Armor(args['helmet'])
     else: self._helmet = None
     if 'torso' in args: self._torso = Armor(args['torso'])
     else: self._torso = None
     if 'bracers' in args: self._bracers = Armor(args['bracers'])
     else: self._bracers = None
     if 'pants' in args: self._pants = Armor(args['pants'])
     else: self._pants = None
Exemplo n.º 4
0
 def __init__(self, name, creature_type, energy, health, attack):
     super().__init__()
     self.name = name
     self.creature_type = CreatureType(creature_type)
     self.energy = energy
     self.base_health = health
     self.base_attack = attack
     self.health = health
     self.attack = attack
     self.weapon = Weapon("", 0, 0)
     self.armor = Armor("", 0, 0, 0)
     self.damage_negation = 0
Exemplo n.º 5
0
 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 maximum amount of block? ")
     return Armor(name, max_block)
Exemplo n.º 6
0
def test_hero_defense_mean_value():
    athena = Hero("Athena")
    strength = random.randint(400, 30000)
    big_strength = Armor("Overwhelming Shield", strength)
    athena.add_armor(big_strength)
    calculated_mean = strength // 2
    iterations = 8000
    total_attack = 0
    accepted_window = 400
    for _ in range(iterations):
        attack_value = athena.defend()
        assert attack_value >= 0 and attack_value <= strength
        total_attack += attack_value

    actual_mean = total_attack / iterations
    print("Max Allowed: {}".format(strength))
    print("Defenses Tested: {}".format(iterations))
    print("Mean -- calculated: {} | actual: {}".format(calculated_mean, actual_mean))
    print(
        "Acceptable deviation from mean: {} | Current deviation from mean: {}".format(
            accepted_window, abs(
                calculated_mean - actual_mean)))
    print(
        "Acceptable Min: {} | Acceptable Max: {}".format(
            actual_mean -
            accepted_window,
            actual_mean +
            accepted_window))
    assert actual_mean <= calculated_mean + \
        accepted_window and actual_mean >= calculated_mean - accepted_window
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
 def load_inventory(self):
     print("Loading Store...")
     if self.shop_type == "Weapon":
         with open("./res/weapon.JSON", "r") as file:
             data = json.load(file)
         for weapon in data['weapons']:
             self.items_for_sale.append(
                 Weapon(weapon['weapon_type'], weapon['name'],
                        weapon['quality'], weapon['damage'],
                        weapon['weight'], weapon['two_handed'],
                        weapon['cost']))
     elif self.shop_type == "Armor":
         with open("./res/armor.JSON", "r") as file:
             data = json.load(file)
         for armor in data['armors']:
             self.items_for_sale.append(
                 Armor(armor['armor_type'], armor['name'], armor['quality'],
                       armor['soak'], armor['weight'],
                       armor['equipment_slot'], armor['cost']))
     elif self.shop_type == "General":
         with open("./res/item.JSON", "r") as file:
             data = json.load(file)
         for item in data['items']:
             self.items_for_sale.append(
                 Item(item['name'], item['weight'], item['cost']))
     else:
         print("Unknown Shop Type")
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
def create_armor():
    print("What armor is he selling?")
    armor_type = input()
    print("What's it's name?")
    armor_name = input()
    new_armor = Armor(armor_name, armor_type)
    return new_armor
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
        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)
Exemplo n.º 13
0
    def toObject(self):
        output = self.info
        for i in self.get("equipped armors").keys():
            print(type(output["equipped armors"][i]))
            if (type(output["equipped armors"][i]).__name__ == "instance"):
                continue
            arminfo = output["equipped armors"][i]
            output["equipped armors"][i] = Armor()
            output["equipped armors"][i].serialize(arminfo)

        for i in self.get("equipped").keys():
            print(type(output["equipped"][i]))
            if (type(output["equipped"][i]).__name__ == "instance"):
                continue
            arminfo = output["equipped"][i]
            output["equipped"][i] = Armor()
            output["equipped"][i].serialize(arminfo)
Exemplo n.º 14
0
    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 damage the armor can take?  ")

        return Armor(name, max_block)
Exemplo n.º 15
0
 def create_armor(self):
     '''
         Prompt user for Armor information
         return Armor with values from user input.
     '''
     name = input("What is the name of your armor? ")
     damage_reduction = int(
         input("What is the max damage reduction of your armor? "))
     return Armor(name, damage_reduction)
Exemplo n.º 16
0
 def create_armor(self):
     """Return armor with values from user input."""
     name = input('What is the armor name? ')
     try:
         max_block_strength = int(input('What is the max block strength? '))
     except ValueError:
         print("Please enter a number.")
         max_block_strength = int(input('What is the max block strength? '))
     return Armor(name, max_block_strength)
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
 def __init__(
         self,
         name="",
         des="",
         lvl=1,
         mhp=0,
         mmp=0,
         atk=0,
         pdef=0,
         spd=0,
         crit=0,
         equipped={
             "weapon": Weapons(),
             "talisman": Item(),
             "bracelet": Item(),
             "ring": Item()
         },
         eqarmors={
             "left": Armor(),
             "right": Armor(),
             "head": Armor(),
             "body": Armor()
         },
         drop={
             "items": [],
             "xp": 0
         }):
     self.info = {
         "name": name,
         "description": des,
         "level": lvl,
         "mhp": mhp,
         "mmp": mmp,
         "hp": mhp,
         "mp": mmp,
         "atk": atk,
         "def": pdef,
         "spd": spd,
         "crit": crit,
         "equipped": equipped,
         "equipped armors": eqarmors,
         "drop": drop
     }
Exemplo n.º 19
0
    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)
Exemplo n.º 20
0
 def create_armor(self):
     '''Prompt user for Armor information
       return Armor with values from user input.
     '''
     # 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 = input("What's the shield's name soldier?\n")
     max_block = input("What's the max block, big shot?\n")
     return Armor(name, max_block)
Exemplo n.º 21
0
def create_armor():
    armors = [
        "Calculator", "Laser Shield", "Invisibility", "SFPD Strike Force",
        "Social Workers", "Face Paint", "Damaskus Shield", "Bamboo Wall",
        "Forced Projection", "Thick Fog", "Wall of Will", "Wall of Walls",
        "Obamacare", "Thick Goo"
    ]
    name = armors[random.randint(0, len(armors) - 1)]
    power = random.randint(23, 700000)
    return Armor(name, power)
Exemplo n.º 22
0
    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 = input("What is the armor's's name?  ")
        max_block = input("What is the max defense of the armor?  ")

        return Armor(name, max_block)
Exemplo n.º 23
0
    def completed_attack(self):
        """Returns all cards that have to be discarded and sent to unused"""
        to_discard = []
        to_unused = []

        if self.armor.is_destroyed():
            to_discard.append(self.armor)
            self.armor = Armor("", 0, 0, 0)

        if self.weapon.is_destroyed():
            to_discard.append(self.weapon)
            self.weapon = Weapon("", 0, 0)

        if self.is_dead():
            to_discard.append(self)
            if self.armor:
                to_unused.append(self.armor)
            if self.weapon:
                to_unused.append(self.weapon)

        return to_discard, to_unused
Exemplo n.º 24
0
    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)
Exemplo n.º 25
0
def test_team_attack_deaths():
    team_one = Team("One")
    jodie = Hero("Jodie Foster")
    aliens = Ability("Alien Friends", 10000)
    jodie.add_ability(aliens)
    team_one.add_hero(jodie)
    team_two = Team("Two")
    athena = Hero("Athena")
    socks = Armor("Socks", 10)
    athena.add_armor(socks)
    team_two.add_hero(athena)
    assert team_two.heroes[0].deaths == 0
    team_one.attack(team_two)
    assert team_two.heroes[0].deaths == 1
Exemplo n.º 26
0
 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)
Exemplo n.º 27
0
def import_data(data_dir):
    """Loads all csv files of cards"""
    creature_cards = {}
    with open(os.path.join(data_dir, "creatures.csv"), "r") as in_file:
        csv_reader = csv.DictReader(in_file, quoting=csv.QUOTE_NONNUMERIC)
        unnamed_count = 0
        for row in csv_reader:
            # Creature(name, creature_type, energy, health, attack)
            name = row["name"]
            if name is None or name == "":
                name = "Creature{}".format(unnamed_count)
                unnamed_count += 1
            creature_cards[name] = Creature(name, row["type"], row["energy"],
                                            row["health"], row["attack"])

    armor_cards = {}
    with open(os.path.join(data_dir, "armors.csv"), "r") as in_file:
        csv_reader = csv.DictReader(in_file, quoting=csv.QUOTE_NONNUMERIC)
        for row in csv_reader:
            # Armor(name, attack, damage_negation_per_combat, max_damage_negation)
            if row["name"] is None or row["name"] == "":
                continue
            armor_cards[row["name"]] = Armor(row["name"], row["attack"],
                                             row["damage_negation_per_combat"],
                                             row["max_damage_negation"])

    weapon_cards = {}
    with open(os.path.join(data_dir, "weapons.csv"), "r") as in_file:
        csv_reader = csv.DictReader(in_file, quoting=csv.QUOTE_NONNUMERIC)
        for row in csv_reader:
            # Weapon(name, attack, max_uses)
            if row["name"] is None or row["name"] == "":
                continue
            weapon_cards[row["name"]] = Weapon(row["name"], row["attack"],
                                               row["max_uses"])

    upgrade_cards = {}
    with open(os.path.join(data_dir, "upgrades.csv"), "r") as in_file:
        csv_reader = csv.DictReader(in_file, quoting=csv.QUOTE_NONNUMERIC)
        for row in csv_reader:
            # Upgrade(name, upgrades)
            if row["name"] is None or row["name"] == "":
                continue
            upgrade_cards[row["name"]] = Upgrade(row["name"],
                                                 literal_eval(row["upgrades"]))

    return creature_cards, armor_cards, weapon_cards, upgrade_cards
Exemplo n.º 28
0
def load_armor():

    armor = []
    filepath = None

    armor_dir = "../out/armor"
    for filename in os.listdir(armor_dir):
        if not filename.endswith(".json"):
            continue

        filepath = os.path.join(armor_dir, filename)

        with open(filepath, 'r') as f:
            for json_obj in json.load(f):
                armor.append(Armor(filepath, json_obj))

    convert_armor(armor)
Exemplo n.º 29
0
def init_game():
    for y, row in enumerate(settings.field):
        for x, column in enumerate(row):
            if column == 1:
                settings.grass.append(
                    Grass(settings.main_surf, settings.field_size,
                          settings.cells_size, (x, y)))
            elif column == 2:
                settings.armor.append(
                    Armor(settings.main_surf, settings.field_size,
                          settings.cells_size, (x, y)))
            elif type(column) is list:

                for add_nums in column:
                    if add_nums[0] == 0:
                        if add_nums[1] % 2 == 0:
                            ind = 0
                        else:
                            ind = 3
                    else:
                        if add_nums[1] % 2 == 0:
                            ind = 2
                        else:
                            ind = 1

                    settings.bricks.append(
                        Brick(settings.main_surf, settings.field_size,
                              settings.cells_size,
                              (50 + settings.cells_size * x +
                               add_nums[0] * settings.cells_size // 2,
                               50 + settings.cells_size * y +
                               add_nums[1] * settings.cells_size // 4), ind))
            elif column == 4:
                settings.fin.append(
                    Fin(settings.main_surf, settings.field_size,
                        settings.cells_size, (x, y)))
                settings.fin_pos.append([x, y])

            elif column == 5:
                settings.spawns.append([x, y])
            elif column == 6:
                settings.bots_spawn.append([x, y])
            elif column == 7:
                settings.water.append(
                    Water(settings.main_surf, settings.field_size,
                          settings.cells_size, (x, y)))
Exemplo n.º 30
0
def test_hero_defense_standard_deviation():
    willow_waffle = Hero("Willow Waffle")
    strength = random.randint(400, 30000)
    willow = Armor("Willowness", strength)
    willow_waffle.add_armor(willow)
    defenses = list()
    total_defend = 0
    number_tests = 100
    for _ in range(number_tests):
        defense = willow_waffle.defend()
        defenses.append(defense)
        total_defend += defense
    mean = total_defend / number_tests

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

    standard_dev = math.sqrt(sum(defenses) / len(defenses))
    print("Hero Armor must block with random value.")
    print("Standard Deviation Cannot be 0.")
    assert standard_dev != 0.0