def test_weapon_has_finesse(self): # execution weapon = Weapon(self.json_data) # conditions weapon.properties = ["Finesse"] # expected self.assertTrue(weapon.has_finesse())
def test_weapon_has_thrown(self): # execution weapon = Weapon(self.json_data) # conditions weapon.properties = ["Thrown"] # expected self.assertTrue(weapon.has_thrown())
def test_weapon_has_no_special_attributes(self): # execution weapon = Weapon(self.json_data) # conditions weapon.properties = [] # expected self.assertFalse(weapon.has_finesse()) self.assertFalse(weapon.has_thrown())
def test_weapon_without_properties(self): # conditions del self.json_data['definition']['properties'] # execution weapon = Weapon(self.json_data) # expected self.assertEqual(0, len(weapon.properties))
def set_weapon(): weapon_type = request.form['weapon_type'] weapon_name = request.form['weapon_name'] weapon_rarity = request.form['weapon_rarity'] weapon_raw_damage = request.form['weapon_raw_damage'] weapon_true_damage = request.form['weapon_true_damage'] weapon_elemental_damage = request.form['weapon_elemental_damage'] weapon_status_damage = request.form['weapon_status_damage'] weapon_damage_type = request.form['weapon_damage_type'] weapon_sharpness = request.form['weapon_sharpness'] weapon_awakened = request.form['weapon_awakened'] weapon_affinity = request.form['weapon_affinity'] weapon_defense = request.form['weapon_defense'] weapon_slot = request.form['weapon_slot'] weapon_weapon_id = request.form['weapon_weapon_id'] weapon = Weapon(weapon_type, weapon_name, weapon_rarity, weapon_raw_damage, weapon_true_damage, weapon_elemental_damage, weapon_status_damage, weapon_damage_type, weapon_sharpness, weapon_awakened, weapon_affinity, weapon_defense, weapon_slot, weapon_weapon_id) Weapon.register(weapon) return weapon.name
def __init__(self, name: str, location: List[int] = [56, 10], gold: int = 0, items: List[Item] = []): """Initialize an instance of the playable character.""" player_weapon: Weapon = Weapon(weapon_type=WeaponType.FISTS, prefix=self.get_random_fists_prefix()) player_armor: Armor = Armor(armor_type=ArmorType.RAGS, prefix=self.get_random_rags_prefix()) player_stats: Stats = Stats(level=1, health=100, speed=1) self.fighter = Fighter(name=name, weapon=player_weapon, armor=player_armor, stats=player_stats) self.location = location self.gold = gold self.items = items self.game_state = GameState.WORLDMAP
def query_weapons(criteria): element = None weapon = None skill = None ability = None rarity = None lookback = None if "element" in criteria: element = criteria["element"] if "weapon" in criteria: weapon = criteria["weapon"] if "skill" in criteria: skill = criteria["skill"] if "ability" in criteria: ability = criteria["ability"] if "rarity" in criteria: rarity = criteria["rarity"] if "lookback" in criteria: lookback = datetime.today() - timedelta(days=int(criteria["lookback"])) if (element is None and skill is None and weapon is None and ability is None and rarity is None and lookback is None): return [] return Weapon.find_weapons(element, weapon, skill, ability, rarity, lookback)
def process_weapon(name, level=None): if name is None or name == "": raise KeyError("Name not specified") return Weapon(name, level or 2)
from models.item import Item from models.inventory import BaseInventory, EntityInventory from models.weapon import Weapon from models.player import Player from models.actions import Test if __name__ == '__main__': gold = Item("gold", "a single gold piece", 1) gold._max = 6 my_inv = EntityInventory(5) print(my_inv.inv_items('add', gold, 4)) print("THIS", my_inv) print(my_inv.inv_items('add', gold, 3)) print("SHOULD BE 7") print(my_inv) sword = Weapon("sword", "a sword", 1, 9) sword._max = 2 sword.type = 'attack' gun = Weapon("gun", "a gun", 21, 6) gun._max = 1 gun.type = 'attack' print(gun.to_json()) print(my_inv.inv_items('add', sword, 2)) print(my_inv.inv_items('add', gun, 5)) print("SHOULD BE 2") print(my_inv) print(my_inv.drop_random()) print(my_inv._viable_equipment("attack", type_array=['attack'])) print("NEW PLAYER") barnstorm = Player("Barnstorm", "A new Player", 50, 3) barnstorm.table()
from models.player import Player from models.weapon import Weapon player1 = Player("Ziffuge", 20, 2) player2 = Player("GobUlysse", 15, 6) knife = Weapon("Couteau", 5) player1.attack_player(player2) print(player1.get_pseudo(), "attaque", player2.get_pseudo()) print(player2.get_pseudo(), "a encore", player2.get_health(), "points de vie") player1.set_weapon(knife) player1.attack_player(player2) print(player1.get_pseudo(), "attaque", player2.get_pseudo()) print(player2.get_pseudo(), "a encore", player2.get_health(), "points de vie")
def get_weapon(name): weapon = Weapon.find_by_name(name) return json.dumps(weapon.json())
def get_all_weapons(): weapons = Weapon.find_all() return json.dumps(weapons)
def __init__(self, json_data, race_data, by_id): character = json_data if by_id else json_data['character'] self.id = character['id'] self.beyond_url = character['readonlyUrl'] self.name = character['name'] self.level = int(character['classes'][0]['level']) self.race = character['race']['baseName'] self._class = character['classes'][0]['definition']['name'] self.str = int(character['stats'][0]['value']) + int( race_data['ability_bonuses'][0]) self.dex = int(character['stats'][1]['value']) + int( race_data['ability_bonuses'][1]) self.con = int(character['stats'][2]['value']) + int( race_data['ability_bonuses'][2]) self.int = int(character['stats'][3]['value']) + int( race_data['ability_bonuses'][3]) self.wis = int(character['stats'][4]['value']) + int( race_data['ability_bonuses'][4]) self.cha = int(character['stats'][5]['value']) + int( race_data['ability_bonuses'][5]) self.str_mod = math.floor((self.str - 10) / 2) self.dex_mod = math.floor((self.dex - 10) / 2) self.con_mod = math.floor((self.con - 10) / 2) self.int_mod = math.floor((self.int - 10) / 2) self.wis_mod = math.floor((self.wis - 10) / 2) self.cha_mod = math.floor((self.cha - 10) / 2) self.walking_speed = int( character['race']['weightSpeeds']['normal']['walk']) self.max_hit_points = int(character['baseHitPoints']) + self.con_mod self.removed_hit_points = int(character['removedHitPoints']) self.current_hit_points = self.max_hit_points - self.removed_hit_points self.hit_dice = int(character['classes'][0]['definition']['hitDice']) self.hit_dice_used = int(character['classes'][0]['hitDiceUsed']) self.current_experience = int(character['currentXp']) self.initiative = self.dex_mod self.weapons = [ Weapon(x) for x in character['inventory'] if x['definition']['filterType'] == "Weapon" ] self.armor = [ Armor(x) for x in character['inventory'] if x['definition']['filterType'] == "Armor" ] self.proficiencies = self.__extract_proficiencies(character) self.size = character['race']['size'] self.proficiency = math.floor((self.level + 7) / 4) self.spells = [] self.mods = self.__calculate_modifiers() # Define spellcasting stuff if character['classes'][0]['definition']['canCastSpells'] is True: spellcasting_ability_id = int(character['classes'][0]['definition'] ['spellCastingAbilityId']) - 1 self.spellcasting_ability_mod = self.mods[ ABILITIES_INDEX[spellcasting_ability_id]] + self.proficiency # Load spells from feat if 'spells' in character: if 'feat' in character['spells']: for x in character['spells']['feat']: if "Damage" in x['definition']['tags']: self.spells.append(Spell(x)) # Load spells from class spells for x in character['classSpells']: if 'spells' in x: for y in x['spells']: if "Damage" in y['definition']['tags']: self.spells.append(Spell(y))
from models.player import Player from models.weapon import Weapon player1 = Player("Oracions", 100, 4) #player1.attack = 143 #print(player1.attack) #player1.damege(3) #print(player1.health) # Combat player2 = Player("MonkeyD", 100, 2) couteau = Weapon("Couteau", 10) player2.set_weapon(couteau) print(player1.get_pseudo(), " / Points de vie ", player1.get_health(), "/ attack ", player1.get_attack()) print(player2.get_pseudo(), " / Points de vie ", player2.get_health(), "/ attack ", player2.get_attack()) player1.attack_player(player2) print(player1.get_pseudo(), " attaque ", player2.get_pseudo()) print(player1.get_pseudo(), " / Points de vie ", player1.get_health()) print(player2.get_pseudo(), " / Points de vie ", player2.get_health()) player2.attack_player(player1) print(player2.get_pseudo(), " attaque ", player1.get_pseudo()) print(player1.get_pseudo(), " / Points de vie ", player1.get_health()) print(player2.get_pseudo(), " / Points de vie ", player2.get_health())