def roll_skill(skill): """ Rolls an arbitrary skill for the entire party. Different from roll_att. Accepts a string. Returns: {'charname':[result,bonus],...} """ rolls = {} # Represent roll per character. Use human-readable strings. for chtr in character_list: # Character dict holds character # object strings. charname = chtr.name # Get the key as the character name # Skills for the character. c_skills = chtr.SKILLS # Skills you care about. If the skill is known by the # character, just access the correct skill, which is stored as # a value in a dictionary. Otherwise, use the generalized # skill map which includes ALL skills. if skill in list(c_skills.keys()): c_skill = c_skills[skill] else: c_skill = chtr.map(skill_map[skill]) # Make the roll rolls[charname] = [dice.roll_1dx(20) + c_skill, c_skill] return rolls # Return the dictionary.
def roll_att(self,attribute): rolls = {} for i in self.members: charname = i.name c_attribute = i.map(attribute) rolls[charname] = [dice.roll_1dx(20) + c_attribute,c_attribute] return rolls
def roll_att(self, attribute): rolls = {} for i in self.members: charname = i.name c_attribute = i.map(attribute) rolls[charname] = [dice.roll_1dx(20) + c_attribute, c_attribute] return rolls
def make_attack(self): # Some namespace simplifications damage = self.damage crit_range = self.crit_range crit_multiplier = self.crit_multiplier bonus = self.bonus # Roll to hit attack_roll = [dice.roll_1dx(20) + i for i in bonus] # Roll damage. Even if you miss, damage is rolled. Be careful! attack_damage = [ dice.sum_ndm(damage[0], damage[1]) + damage[2] for i in bonus ] # Check for crits and multiply by appropriate values. for i in range(len(attack_roll)): if attack_roll[i] >= self.crit_range: # Nice message: print("CRITICAL HIT, BITCHES") # TODO: make it roll for multiplier attack_damage[i] += sum([ dice.sum_ndm(damage[0], damage[1]) + damage[2] for i in range(self.crit_multiplier - 1) ]) # Return roll resuts return [attack_roll, attack_damage]
def roll_att(self,attribute_name): """Rolls an attribute for a single character. Works only for attributes, not skills! Returns: [result,bonus]""" attribute = self.map(attribute_name) return [dice.roll_1dx(20) + attribute,attribute]
def roll_att(self, attribute_name): """Rolls an attribute for a single character. Works only for attributes, not skills! Returns: [result,bonus]""" attribute = self.map(attribute_name) return [dice.roll_1dx(20) + attribute, attribute]
def roll_skill(self, skill): rolls = {} for i in self.members: charname = i.name c_skills = i.SKILLS if skill in c_skills.keys(): c_skill = c_skills[skill] else: c_skill = i.map(skill_map[skill]) rolls[charname] = [dice.roll_1dx(20) + c_skill, c_skill] return rolls
def roll_skill(self,skill): rolls = {} for i in self.members: charname = i.name c_skills = i.SKILLS if skill in c_skills.keys(): c_skill = c_skills[skill] else: c_skill = i.map(skill_map[skill]) rolls[charname] = [dice.roll_1dx(20) + c_skill, c_skill] return rolls
def initiative(charlist=[]): """ Roll initiative for the party. If arguments given, do it for the character list. """ if len(charlist) == 0: initiatives = roll_att('INITIATIVE') print_dic(initiatives) return initiatives else: rolls = {} for i in charlist: rolls[i.name] = [dice.roll_1dx(20) + i.INITIATIVE, i.INITIATIVE] print_dic(rolls) return rolls
def initiative(charlist = []): """ Roll initiative for the party. If arguments given, do it for the character list. """ if len(charlist) == 0: initiatives = roll_att('INITIATIVE') print_dic(initiatives) return initiatives else: rolls = {} for i in charlist: rolls[i.name] = [dice.roll_1dx(20) + i.INITIATIVE, i.INITIATIVE] print_dic(rolls) return rolls
def roll_skill(self,skill_name): """Rolls a skill for a single character. Accepts a string. Returns: [result,bonus] """ # If the skill is something the character has trained in, it's # in the dictionary defined by the self.SKILLS attribute. Just # use it. if skill_name in self.SKILLS.keys(): skill = self.SKILLS[skill_name] # If the character is not trained in the skill, then assume # it's the character's ability modifier. else: skill = self.map(skill_map[skill_name]) return [dice.roll_1dx(20) + skill, skill]
def roll_skill(self, skill_name): """Rolls a skill for a single character. Accepts a string. Returns: [result,bonus] """ # If the skill is something the character has trained in, it's # in the dictionary defined by the self.SKILLS attribute. Just # use it. if skill_name in self.SKILLS.keys(): skill = self.SKILLS[skill_name] # If the character is not trained in the skill, then assume # it's the character's ability modifier. else: skill = self.map(skill_map[skill_name]) return [dice.roll_1dx(20) + skill, skill]
def roll_att(attribute): """Rolls an arbitrary attribute for the entire party. Different from roll_skill. Accepts a string. Returns: {'charname':[result,bonus],...} """ rolls = {} # Represent roll per character. Use human-readable strings. for i in character_list: # Character dict holds character # object strings. charname = i.name # Get the key as the character name # Attribute you care about. References a dictionary inside # character class. That dictionary transforms a human-readable # string to an attribute of a character. c_attribute = i.map(attribute) # Add the roll to the dictionary with the character name as the key. rolls[charname] = [dice.roll_1dx(20) + c_attribute,c_attribute] return rolls # Return the dictionary.
def roll_att(attribute): """Rolls an arbitrary attribute for the entire party. Different from roll_skill. Accepts a string. Returns: {'charname':[result,bonus],...} """ rolls = {} # Represent roll per character. Use human-readable strings. for i in character_list: # Character dict holds character # object strings. charname = i.name # Get the key as the character name # Attribute you care about. References a dictionary inside # character class. That dictionary transforms a human-readable # string to an attribute of a character. c_attribute = i.map(attribute) # Add the roll to the dictionary with the character name as the key. rolls[charname] = [dice.roll_1dx(20) + c_attribute, c_attribute] return rolls # Return the dictionary.
def make_attack(self): # Some namespace simplifications damage = self.damage crit_range = self.crit_range crit_multiplier = self.crit_multiplier bonus = self.bonus # Roll to hit attack_roll = [dice.roll_1dx(20)+i for i in bonus] # Roll damage. Even if you miss, damage is rolled. Be careful! attack_damage = [dice.sum_ndm(damage[0], damage[1])+damage[2] for i in bonus] # Check for crits and multiply by appropriate values. for i in range(len(attack_roll)): if attack_roll[i] >= self.crit_range: # Nice message: print("CRITICAL HIT, BITCHES") # TODO: make it roll for multiplier attack_damage[i] += sum([dice.sum_ndm(damage[0],damage[1])+damage[2] for i in range(self.crit_multiplier-1)]) # Return roll resuts return [attack_roll,attack_damage]
def roll(): return dice.roll_1dx(20)