def export_body(self, io): m = self.model f = self.form fields = {} # WEAPONS count = min(10, len(m.get_weapons())) j = 0 for weap in m.get_weapons()[0:count]: weap.base_atk = rules.format_rtk_t(rules.calculate_base_attack_roll(m, weap)) weap.max_atk = rules.format_rtk_t(rules.calculate_mod_attack_roll (m, weap)) weap.base_dmg = rules.format_rtk_t(rules.calculate_base_damage_roll(m, weap)) weap.max_dmg = rules.format_rtk_t(rules.calculate_mod_damage_roll (m, weap)) fields['WEAPON.TYPE.%d' % j] = weap.name if weap.base_atk != weap.max_atk: fields['WEAPON.ATK.%d' % j] = weap.base_atk + "/" + weap.max_atk else: fields['WEAPON.ATK.%d' % j] = weap.base_atk if weap.base_dmg != weap.max_dmg: fields['WEAPON.DMG.%d' % j] = weap.base_dmg + "/" + weap.max_dmg else: fields['WEAPON.DMG.%d' % j] = weap.base_dmg fields['WEAPON.NOTES.%d' % j] = weap.desc j+=1 # EXPORT FIELDS for k in fields.iterkeys(): self.export_field(k, fields[k], io)
def update_from_model(self, model): self.clean() for w in model.weapons: if self.type in w.tags: # calculate weapon atk w.base_atk = rules.format_rtk_t(rules.calculate_base_attack_roll(model, w)) w.max_atk = rules.format_rtk_t(rules.calculate_mod_attack_roll (model, w)) w.base_dmg = rules.format_rtk_t(rules.calculate_base_damage_roll(model, w)) w.max_dmg = rules.format_rtk_t(rules.calculate_mod_damage_roll (model, w)) self.add_item(w)