def init(): from classes import Class new_class = Class(operation, request, 0) rebuild_class = Class(_id=1, **{"name":"Container", "subclasses":{}}) return new_class, rebuild_class
def init(): from items import Item from classes import Class, Subclass from pets import Pet from mounts import Mount weapon_class = Class(operation, request, 2) battle_pet_class = Class(operation, request, 17) misc_class = Class(operation, request, 15) staff_subclass = Subclass(operation, request, 2, 10) pet_subclass = Subclass(operation, request, 17, 0) mount_subclass = Subclass(operation, request, 15, 5) existing_pet = Pet(operation, request, 40) existing_mount = Mount(operation, request, 240) new_item_item = Item(operation, request, 25) new_item_pet = Item(operation, request, 82800, pet_data={"_id":39, "quality":3, "level":1, "breed_id":5}) new_item_mount = Item(operation, request, 34060) new_items = (new_item_item, new_item_pet, new_item_mount) rebuild_item_item = Item(**{"_id":35, "pet":{"_id":0}, "mount":{"_id":0}, "level":1, "name":"Bent Staff", "quality":"Common", "item_class":2, "item_subclass":10, "type":"TWOHWEAPON", "subtype":"Two-Hand", "sold":0, "price":0, "mean_price":0, "Pet":None, "Mount":None, "Class":weapon_class, "Subclass":staff_subclass}) rebuild_item_pet = Item(**{"_id":82800, "pet":{"_id":40}, "mount":{"_id":0},"level":25, "name":"Pet Cage", "quality":"Rare", "item_class":17, "item_subclass":0, "type":"NON_EQUIP", "subtype":"Non-equippable", "sold":0, "price":0, "mean_price":0, "Pet":existing_pet, "Mount":None, "Class":battle_pet_class, "Subclass":pet_subclass}) rebuild_item_mount = Item(**{"_id":41058, "pet":{"_id":0}, "mount":{"_id":240},"level":30, "name":"Mechano-Hog","quality":"Epic", "item_class":15, "item_subclass":5, "type":"NON_EQUIP", "subtype":"Non-equippable", "sold":0, "price":0, "mean_price":0, "Pet":None, "Mount":existing_mount, "Class":misc_class, "Subclass":mount_subclass}) rebuild_items = (rebuild_item_item, rebuild_item_pet, rebuild_item_mount) return new_items, rebuild_items
def parse(f): lines = open(f).read().split('\n') # Remove comments and blank lines: lines = [x.split('#')[0] for x in lines if len(x) > 0 and not x[0] == '#'] name = '' units = [] hours = 0 for line in lines: if not line[0] == '\t': if name: units.append(Unit(name, classes)) hours = 0 name = line.strip() classes = [] else: line = line.strip() if line.split(' ')[-1].startswith('hour'): hours = float(line.split()[0]) else: if hours == 0: error(name, 'Need to specify hours before listing classes.') try: classes += [Class(x, hours) for x in line.split()] except SyntaxError as e: error(name, e.msg) return units
def __init__(self, hp=1, *args, **kwargs): self.hp = hp self.alive = True character_class = kwargs.get('character_class') if character_class: self.character_class = character_class else: self.character_class = Class()
def classes(add, remove, display): if add: class_name = input("Enter the Class Name: ") subject = input("Enter the Class Subject: ") teacher = input("Enter the Teacher's Name: ") cla = Class(class_name, subject, teacher) cla.register_class() elif remove: class_id = input("Enter Class' Id: ") Class.delete_class(class_id) elif display: Class.list_all_classes()
def create_class(): if request.method == "POST": form_class_code = request.form["class_code"] form_class_name = request.form["class_name"] new_class = Class(form_class_name, form_class_code, session['id']) db = current_app.config["db"] if db.check_exists_class_code(form_class_code): error = "The CRN exists ! Enter class code again" return render_template("create_class.html", error=error) class_key = db.add_class(new_class) return redirect(url_for("teacher_main_page", class_key=class_key)) else: return render_template("create_class.html")
def __init__(self): self.name = '' while self.name == '': self.name = console.input("[bold yellow]Character Name: [/]") self.race = iterfzf(racial_stat_bonus) self.stats = { 'Strength': 0, 'Dexterity': 0, 'Constitution': 0, 'Intelligence': 0, 'Wisdom': 0, 'Charisma': 0 } self.stats.update(self.genStats()) self.classes_list_names = iterfzf(class_hitdice, multi=True) self.classes_list = [Class(name) for name in self.classes_list_names] self.proficiency_bonus = 0 self.HP = 0 self.level = 0 self.proficiencies = [] self.expertise = [] self.saves = [] self.armor_proficiencies = [] self.weapon_proficiencies = [] self.tool_proficiencies = [] self.spells = [] self.background = '' self.alignment = '' self.DATA = {} for classitem in self.classes_list: for item in classitem.asi: if classitem.level >= item: self.asi_update() self.level = self.level + classitem.level self.proficiencies.extend(classitem.proficiencies) self.expertise.extend(classitem.expertise) self.saves.extend(classitem.saves) self.armor_proficiencies.extend(classitem.armor_proficiencies) self.weapon_proficiencies.extend(classitem.weapon_proficiencies) self.tool_proficiencies.extend(classitem.tool_proficiencies) self.spells.extend(classitem.spells) self.proficiency_bonus = int((self.level - 1) / 4) + 2 self.proficiencies = list(set(self.proficiencies)) self.expertise = list(set(self.expertise)) self.saves = list(set(self.saves)) self.armor_proficiencies = list(set(classitem.armor_proficiencies)) self.weapon_proficiencies = list(set(classitem.weapon_proficiencies)) self.tool_proficiencies = list(set(classitem.tool_proficiencies)) self.spells = list(set(classitem.spells)) self.background = iterfzf(backgrounds) self.alignment = iterfzf(alignments) ## Select Proficiencies from list of allowable skills self.proficiencies = iterfzf( self.proficiencies, multi=True, prompt="Background (" + self.background + "): " + backgrounds[self.background] + ' ') or [] self.proficiencies.extend( [x.strip() for x in backgrounds[self.background].split(',')]) self.proficiencies = list(set(self.proficiencies)) print("Proficiencies:", self.proficiencies) if any(x in self.classes_list_names for x in ['Rogue', 'Bard']): self.expertise = iterfzf(self.expertise, multi=True, prompt='> Select Expertise: ') or [] print("Expertise:", self.expertise) else: self.expertise = [] print("STATS: ", [self.stats[key] for key in self.stats]) self.mods = {x: modsmap[self.stats[x]] for x in self.stats.keys()} print("MODS: ", [self.mods[key] for key in self.mods]) self.HP = sum([ item.calcHP(self.mods['Constitution']) for item in self.classes_list ]) self.AC = 10 self.weapons = iterfzf( weapons, multi=True, prompt='> ' + ', '.join(self.weapon_proficiencies)) or [] self.armors = iterfzf( armors, prompt='> ' + ', '.join(self.armor_proficiencies)) or [] self.skills = { 'Acrobatics': self.mods['Dexterity'], 'Animal Handling': self.mods['Wisdom'], 'Arcana': self.mods['Intelligence'], 'Athletics': self.mods['Strength'], 'Deception': self.mods['Charisma'], 'History': self.mods['Intelligence'], 'Insight': self.mods['Wisdom'], 'Intimidation': self.mods['Charisma'], 'Investigation': self.mods['Intelligence'], 'Medicine': self.mods['Wisdom'], 'Nature': self.mods['Intelligence'], 'Perception': self.mods['Wisdom'], 'Performance': self.mods['Charisma'], 'Persuasion': self.mods['Charisma'], 'Religion': self.mods['Intelligence'], 'Sleight of Hand': self.mods['Dexterity'], 'Stealth': self.mods['Dexterity'], 'Survival': self.mods['Wisdom'], } self.skills.update({ x: self.skills[x] + self.proficiency_bonus for x in self.skills.keys() if x in self.proficiencies }) self.skills.update({ x: self.skills[x] + self.proficiency_bonus for x in self.skills.keys() if x in self.expertise })
def class_average_test_result(self): if not hasattr(self, '_class_average_test_result'): self._class_average_test_result = dict( [cls.id, self._class_average_result(cls)] for cls in Class.all())
def class_average_test_results(self): return dict([cls.id, self._class_average_result(cls)] for cls in Class.all())
def __init__(self, operation=None, request=None, _id=None, pet_data=None, test=False, **kwargs): """constructor for Item class""" insert_new_item = operation is not None and not kwargs insert_item = operation is not None and kwargs test_item = test rebuild_item = operation is None and kwargs if test_item: self.id = _id self.kwargs = self.setData(operation, request, None, test=True) elif rebuild_item or insert_item: self.pet_id = kwargs["pet"]["_id"] self.mount_id = kwargs["mount"]["_id"] self.name = kwargs["name"] self.level = kwargs["level"] self.quality = kwargs["quality"] self.class_id = kwargs["item_class"] self.subclass_id = kwargs["item_subclass"] self.type = kwargs["type"] self.subtype = kwargs["subtype"] self.sold = kwargs["sold"] self.price = kwargs["price"] self.mean_price = kwargs["mean_price"] if rebuild_item: self.id = _id self.Pet = kwargs["Pet"] self.Mount = kwargs["Mount"] self.Class = kwargs["Class"] self.Subclass = kwargs["Subclass"] elif insert_new_item: self.id = _id self.Pet = None self.Mount = None status, data = self.setData(operation, request, pet_data) if status: new_pet = self.id == 82800 and self.pet_id not in operation.live_data[ "pets"] existing_pet = self.id == 82800 and self.pet_id in operation.live_data[ "pets"] new_class = self.class_id not in operation.live_data["classes"] existing_class = self.class_id in operation.live_data[ "classes"] new_subclass = self.class_id not in operation.live_data[ "classes"] or self.subclass_id not in operation.live_data[ "classes"][self.class_id].subclasses existing_subclass = self.class_id in operation.live_data[ "classes"] and self.subclass_id in operation.live_data[ "classes"][self.class_id].subclasses new_mount = not self.mount_id == 0 and self.mount_id not in operation.live_data[ "mounts"] existing_mount = not self.mount_id == 0 and self.mount_id in operation.live_data[ "mounts"] if new_pet: self.Pet = Pet(operation, request, self.pet_id) operation.live_data["pets"][self.pet_id] = self.Pet elif existing_pet: self.Pet = operation.live_data["pets"][self.pet_id] elif new_mount: self.Mount = Mount(operation, request, self.mount_id) operation.live_data["mounts"][self.mount_id] = self.Mount elif existing_mount: self.Mount = operation.live_data["mounts"][self.mount_id] if new_class: self.Class = Class(operation, request, self.class_id) operation.live_data["classes"][self.class_id] = self.Class elif existing_class: self.Class = operation.live_data["classes"][self.class_id] if new_subclass: self.Subclass = Subclass(operation, request, self.class_id, self.subclass_id) operation.live_data["classes"][self.class_id].subclasses[ self.subclass_id] = self.Subclass elif existing_subclass: self.Subclass = operation.live_data["classes"][ self.class_id].subclasses[self.subclass_id] self.insert(operation) return if status == False: operation.logger.log( True, msg="Encountered an item without data from api") self.id = data["id"] self.pet_id = data["pet_id"] self.mount_id = data["mount_id"] self.name = "" self.level = data["level"] self.quality = "" self.class_id = 0 self.subclass_id = 0 self.type = "" self.subtype = "" self.sold = 0.0 self.price = 0.0 self.mean_price = 0.0 self.insert(operation) return
class_type=Class( name="fighter", desc= "### Fighting Style \n \nYou adopt a particular style of fighting as your specialty. Choose one of the " "following options. You can't take a Fighting Style option more than once, even if you later get to choose " "again. \n \n " "#### Archery \n \n" "You gain a +2 bonus to attack rolls you make with ranged weapons. \n \n" "#### Defense \n \n" "While you are wearing armor, you gain a +1 bonus to AC. \n \n" "#### Dueling \n \n" "When you are wielding a melee weapon in one hand and no other weapons, you gain a +2 bonus to damage rolls with " "that weapon. \n \n " "#### Great Weapon Fighting \n \n" "When you roll a 1 or 2 on a damage die for an attack you make with a melee weapon that you are wielding with two " "hands, you can reroll the die and must use the new roll, even if the new roll is a 1 or a 2. The weapon must " "have the two-handed or versatile property for you to gain this benefit. \n \n " "#### Protection \n \n" "When a creature you can see attacks a target other than you that is within 5 feet of you, you can use your " "reaction to impose disadvantage on the attack roll. You must be wielding a shield. \n \n " "#### Two-Weapon Fighting \n \n" "When you engage in two-weapon fighting, you can add your ability modifier to the damage of the second attack. \n " "\n " "### Second Wind \n \n" "You have a limited well of stamina that you can draw on to protect yourself from harm. On your turn, you can use " "a bonus action to regain hit points equal to 1d10 + your fighter level. Once you use this feature, " "you must finish a short or long rest before you can use it again. \n \n " "### Action Surge \n \n" "Starting at 2nd level, you can push yourself beyond your normal limits for a moment. On your turn, you can take " "one additional action on top of your regular action and a possible bonus action. \n \n " "Once you use this feature, you must finish a short or long rest before you can use it again. Starting at 17th " "level, you can use it twice before a rest, but only once on the same turn. \n \n " "### Martial Archetype \n \n" "At 3rd level, you choose an archetype that you strive to emulate in your combat styles and techniques. Choose " "Champion, Battle Master, or Eldritch Knight, all detailed at the end of the class description. The archetype you " "choose grants you features at 3rd level and again at 7th, 10th, 15th, and 18th level. \n \n " "### Ability Score Improvement \n \n" "When you reach 4th level, and again at 6th, 8th, 12th, 14th, 16th, and 19th level, you can increase one ability " "score of your choice by 2, or you can increase two ability scores of your choice by 1. As normal, " "you can't increase an ability score above 20 using this feature. \n \n " "### Extra Attack \n \n" "Beginning at 5th level, you can attack twice, instead of once, whenever you take the Attack action on your turn. " "\n \n " "The number of attacks increases to three when you reach 11th level in this class and to four when you reach 20th " "level in this class. \n \n " "### Indomitable \n \n" "Beginning at 9th level, you can reroll a saving throw that you fail. If you do so, you must use the new roll, " "and you can't use this feature again until you finish a long rest. \n \n " "You can use this feature twice between long rests starting at 13th level and three times between long rests " "starting at 17th level.\n \n " "### Martial Archetypes \n \n" "Different fighters choose different approaches to perfecting their fighting prowess. The martial archetype you " "choose to emulate reflects your approach.", hit_dice="1d10", prof_armor="All armor, shields", prof_weapons="Simple weapons, martial weapons", prof_tools="None", prof_saving_throws="Strength, Constitution", prof_skills= "Choose two skills from Acrobatics, Animal, Handling, Athletics, History, Insight, Intimidation, " "Perception, and Survival", equipment= "You start with the following equipment, in addition to the equipment granted by your background: \n \n" "* (*a*) chain mail or (*b*) leather armor, longbow, and 20 arrows \n" "* (*a*) a martial weapon and a shield or (*b*) two martial weapons \n" "* (*a*) a light crossbow and 20 bolts or (*b*) two handaxes \n" "* (*a*) a dungeoneer's pack or (*b*) an explorer's pack", table= "| Level | Proficiency Bonus | Features | \n" "|-------|-------------------|---------------------------------------------------| \n" "| 1st | +2 | Fighting Style, Second Wind | \n" "| 2nd | +2 | Action Surge (one use) | \n" "| 3rd | +2 | Martial Archetype | \n" "| 4th | +2 | Ability Score Improvement | \n" "| 5th | +3 | Extra Attack | \n" "| 6th | +3 | Ability Score Improvement | \n" "| 7th | +3 | Martial Archetype Feature | \n" "| 8th | +3 | Ability Score Improvement | \n" "| 9th | +4 | Indomitable (one use) | \n" "| 10th | +4 | Martial Archetype Feature | \n" "| 11th | +4 | Extra Attack (2) | \n" "| 12th | +4 | Ability Score Improvement | \n" "| 13th | +5 | Indomitable (two uses) | \n" "| 14th | +5 | Ability Score Improvement | \n" "| 15th | +5 | Martial Archetype Feature | \n" "| 16th | +5 | Ability Score Improvement | \n" "| 17th | +6 | Action Surge (two uses), Indomitable (three uses) | \n" "| 18th | +6 | Martial Archetype Feature | \n" "| 19th | +6 | Ability Score Improvement | \n" "| 20th | +6 | Extra Attack (3) | ", spellcasting_ability="", subtypes_name="Martial Archetypes", archetypes={ "champion": { "name": "Champion", "slug": "champion", "desc": "The archetypal Champion focuses on the development of raw physical power honed to deadly " "perfection. Those who model themselves on this archetype combine rigorous training with physical " "excellence to deal devastating blows. \n \n " "##### Improved Critical \n \n" "Beginning when you choose this archetype at 3rd level, your weapon attacks score a critical hit " "on a roll of 19 or 20. \n \n " "##### Remarkable Athlete \n \n" "Starting at 7th level, you can add half your proficiency bonus (round up) to any Strength, " "Dexterity, or Constitution check you make that doesn't already use your proficiency bonus. \n \n " "In addition, when you make a running long jump, the distance you can cover increases by a number " "of feet equal to your Strength modifier. \n \n " "##### Additional Fighting Style \n \n" "At 10th level, you can choose a second option from the Fighting Style class feature. \n \n" "##### Superior Critical \n \n" "Starting at 15th level, your weapon attacks score a critical hit on a roll of 18-20. \n \n" "##### Survivor \n \n" "At 18th level, you attain the pinnacle of resilience in battle. At the start of each of your " "turns, you regain hit points equal to 5 + your Constitution modifier if you have no more than " "half of your hit points left. You don't gain this benefit if you have 0 hit points." } }),