def export_npc(self, index, pc, fields): api.character.set_model(pc) def _af(key, value, idx=index): fields['{}{}'.format(key, idx)] = str(value) clan_obj = api.data.clans.get(api.character.get_clan()) if clan_obj: _af("Clan", clan_obj.name) name = "" family_obj = api.data.families.get(api.character.get_family()) if family_obj: name = "{} {}".format(family_obj.name, pc.name) else: name = pc.name _af("Name", name) sobj = api.data.schools.get(api.character.schools.get_current()) if sobj: _af("School", sobj.name) _af("Rank", api.character.insight_rank()) _af("Insight", api.character.insight()) _af("XP", api.character.xp()) # rings _af("Earth", api.character.ring_rank('earth')) _af("Air", api.character.ring_rank('air')) _af("Water", api.character.ring_rank('water')) _af("Fire", api.character.ring_rank('fire')) _af("Void", api.character.ring_rank('void')) # traits _af("Stamina", api.character.trait_rank('stamina')) _af("Willpower", api.character.trait_rank('willpower')) _af("Reflexes", api.character.trait_rank('reflexes')) _af("Awareness", api.character.trait_rank('awareness')) _af("Strength", api.character.trait_rank('strength')) _af("Perception", api.character.trait_rank('perception')) _af("Agility", api.character.trait_rank('agility')) _af("Intelligence", api.character.trait_rank('intelligence')) _af("Initiative", api.rules.format_rtk_t(api.rules.get_tot_initiative())) _af("Armor", api.character.get_full_tn()) _af("Reduction", api.character.get_full_rd()) # HEALTH w_labels = ['Healthy', 'Nicked', 'Grazed', 'Hurt', 'Injured', 'Crippled', 'Down', 'Out'] hl = [0] * 8 for i in range(0, 8): if i == 0: hl[i] = api.rules.get_health_rank(i) else: hl[i] = api.rules.get_health_rank(i) + hl[i - 1] _af(w_labels[i], hl[i]) # WEAPONS melee_weapons = [x for x in pc.get_weapons() if 'melee' in x.tags] range_weapons = [ x for x in pc.get_weapons() if 'ranged' in x.tags and 'melee' not in x.tags] wl = zigzag(melee_weapons, range_weapons) for i, weapon in enumerate(wl): if i >= 2: break j = (index - 1) * 2 + i + 1 _af("Type", weapon.name, j) atk_roll = api.rules.format_rtk_t( api.rules.calculate_mod_attack_roll(pc, weapon)) _af("Attack", atk_roll, j) dmg_roll = api.rules.format_rtk_t( api.rules.calculate_mod_damage_roll(pc, weapon)) _af("Damage", atk_roll, j) _af("Notes", weapon.desc, j) # OTHER TRAITS _af("Status", api.character.status()) _af("Honor", api.character.honor()) _af("Glory", api.character.glory()) _af("GloryTN", int(50 - api.character.glory() * 5)) # SKILLS skills = self.get_skills_sorted(pc, lambda x: x['rank']) # divide in 5 lists skill_per_line = max(5, len(skills) / 5) # offset off = 0 for i in range(0, 5): sks = [] if i == 4: sks = skills[off:] else: sks = skills[off:off + skill_per_line] if len(sks) == 0: break skill_line = ', '.join([self.fmt_skill_line(x) for x in sks]) fn = "Skill Rank Emphases {}".format(i + 1) if index > 1: fn += "_2" fields[fn] = skill_line off += skill_per_line
def export_npc(self, index, pc, fields): api.character.set_model(pc) def _af(key, value, idx=index): fields['{}{}'.format(key, idx)] = str(value) clan_obj = api.data.clans.get(api.character.get_clan()) if clan_obj: _af("Clan", clan_obj.name) name = "" family_obj = api.data.families.get(api.character.get_family()) if family_obj: name = "{} {}".format(family_obj.name, pc.name) else: name = pc.name _af("Name", name) sobj = api.data.schools.get(api.character.schools.get_current()) if sobj: _af("School", sobj.name) _af("Rank", api.character.insight_rank()) _af("Insight", api.character.insight()) _af("XP", api.character.xp()) # rings _af("Earth", api.character.ring_rank('earth')) _af("Air", api.character.ring_rank('air')) _af("Water", api.character.ring_rank('water')) _af("Fire", api.character.ring_rank('fire')) _af("Void", api.character.ring_rank('void')) # traits _af("Stamina", api.character.trait_rank('stamina')) _af("Willpower", api.character.trait_rank('willpower')) _af("Reflexes", api.character.trait_rank('reflexes')) _af("Awareness", api.character.trait_rank('awareness')) _af("Strength", api.character.trait_rank('strength')) _af("Perception", api.character.trait_rank('perception')) _af("Agility", api.character.trait_rank('agility')) _af("Intelligence", api.character.trait_rank('intelligence')) _af("Initiative", api.rules.format_rtk_t(api.rules.get_tot_initiative())) _af("Armor", api.character.get_full_tn()) _af("Reduction", api.character.get_full_rd()) # HEALTH w_labels = [ 'Healthy', 'Nicked', 'Grazed', 'Hurt', 'Injured', 'Crippled', 'Down', 'Out' ] hl = [0] * 8 for i in range(0, 8): if i == 0: hl[i] = api.rules.get_health_rank(i) else: hl[i] = api.rules.get_health_rank(i) + hl[i - 1] _af(w_labels[i], hl[i]) # WEAPONS melee_weapons = [x for x in pc.get_weapons() if 'melee' in x.tags] range_weapons = [ x for x in pc.get_weapons() if 'ranged' in x.tags and 'melee' not in x.tags ] wl = zigzag(melee_weapons, range_weapons) for i, weapon in enumerate(wl): if i >= 2: break j = (index - 1) * 2 + i + 1 _af("Type", weapon.name, j) atk_roll = api.rules.format_rtk_t( api.rules.calculate_mod_attack_roll(pc, weapon)) _af("Attack", atk_roll, j) dmg_roll = api.rules.format_rtk_t( api.rules.calculate_mod_damage_roll(pc, weapon)) _af("Damage", atk_roll, j) _af("Notes", weapon.desc, j) # OTHER TRAITS _af("Status", api.character.status()) _af("Honor", api.character.honor()) _af("Glory", api.character.glory()) _af("GloryTN", int(50 - api.character.glory() * 5)) # SKILLS skills = self.get_skills_sorted(pc, lambda x: x['rank']) # divide in 5 lists skill_per_line = max(5, len(skills) / 5) # offset off = 0 for i in range(0, 5): sks = [] if i == 4: sks = skills[off:] else: sks = skills[off:off + skill_per_line] if len(sks) == 0: break skill_line = ', '.join([self.fmt_skill_line(x) for x in sks]) fn = "Skill Rank Emphases {}".format(i + 1) if index > 1: fn += "_2" fields[fn] = skill_line off += skill_per_line
def export_npc(self, index, pc, fields ): def _af( name, value, idx = index ): fields['{}{}'.format(name, idx)] = str(value) clan_obj = dal.query.get_clan( self.dstore, pc.clan ) if clan_obj: _af( "Clan", clan_obj.name ) name = "" family_obj = dal.query.get_family( self.dstore, pc.family ) if family_obj: name = "{} {}".format( family_obj.name, pc.name ) else: name = pc.name _af( "Name", name ) sobj = dal.query.get_school( self.dstore, pc.get_school_id() ) if sobj: _af("School", sobj.name) _af("Rank", pc.get_insight_rank()) _af("Insight", pc.get_insight()) _af("XP", pc.get_px()) # rings _af("Earth", pc.get_ring_rank( models.RINGS.EARTH ) ) _af("Air" , pc.get_ring_rank( models.RINGS.AIR ) ) _af("Water", pc.get_ring_rank( models.RINGS.WATER ) ) _af("Fire" , pc.get_ring_rank( models.RINGS.FIRE ) ) _af("Void" , pc.get_ring_rank( models.RINGS.VOID ) ) # traits _af("Stamina" , pc.get_attrib_rank( models.ATTRIBS.STAMINA ) ) _af("Willpower" , pc.get_attrib_rank( models.ATTRIBS.WILLPOWER ) ) _af("Reflexes" , pc.get_attrib_rank( models.ATTRIBS.REFLEXES ) ) _af("Awareness" , pc.get_attrib_rank( models.ATTRIBS.AWARENESS ) ) _af("Strength" , pc.get_attrib_rank( models.ATTRIBS.STRENGTH ) ) _af("Perception" , pc.get_attrib_rank( models.ATTRIBS.PERCEPTION ) ) _af("Agility" , pc.get_attrib_rank( models.ATTRIBS.AGILITY ) ) _af("Intelligence", pc.get_attrib_rank( models.ATTRIBS.INTELLIGENCE ) ) _af("Initiative", rules.format_rtk_t(pc.get_tot_initiative()) ) _af("Armor" , pc.get_cur_tn () ) _af("Reduction" , pc.get_full_rd() ) # HEALTH w_labels = ['Healthy', 'Nicked', 'Grazed', 'Hurt', 'Injured', 'Crippled', 'Down', 'Out'] hl = [0]*8 for i in range(0, 8): if i == 0: hl[i] = pc.get_health_rank(i) else: hl[i] = pc.get_health_rank(i) + hl[i-1] _af( w_labels[i], hl[i] ) # WEAPONS melee_weapons = [ x for x in pc.get_weapons() if 'melee' in x.tags ] range_weapons = [ x for x in pc.get_weapons() if 'ranged' in x.tags and 'melee' not in x.tags ] wl = zigzag(melee_weapons, range_weapons) for i, weapon in enumerate( wl ): if i >= 2: break j = (index-1)*2 + i + 1 _af( "Type" , weapon.name, j ) atk_roll = rules.format_rtk_t(rules.calculate_mod_attack_roll (pc, weapon)) _af( "Attack", atk_roll, j ) dmg_roll = rules.format_rtk_t(rules.calculate_mod_damage_roll (pc, weapon)) _af( "Damage", atk_roll, j ) _af( "Notes", weapon.desc, j ) # OTHER TRAITS _af("Status" , pc.get_status() ) _af("Honor" , pc.get_honor () ) _af("Glory" , pc.get_glory () ) _af("GloryTN", int(50 - pc.get_glory() * 5) ) # SKILLS skills = self.get_skills_sorted( pc, lambda x: x['rank'] ) # divide in 5 lists skill_per_line = max( 5, len(skills) / 5 ) # offset off = 0 for i in range(0, 5): sks = [] if i == 4: sks = skills[ off: ] else: sks = skills[ off:off+skill_per_line ] if len( sks ) == 0: break skill_line = ', '.join( [ self.fmt_skill_line(x) for x in sks ] ) fn = "Skill Rank Emphases {}".format(i+1) if index > 1: fn += "_2" fields[fn] = skill_line off += skill_per_line