Ejemplo n.º 1
0
 def match_wc_ring(self, pc, dstore):
     import models
     r = False
     if self.field == '*any': # any ring
         for i in xrange(0, 5):
             ring_id = models.ring_name_from_id(i)
             if self.in_range( pc.get_ring_rank(ring_id) ):
                 pc.set_ring_rank(ring_id, 0)
                 r = True
                 break
     return r
Ejemplo n.º 2
0
    def increase_trait(self, attrib):
        cur_value = self.pc.get_attrib_rank( attrib )
        new_value = cur_value + 1
        ring_id = models.get_ring_id_from_attrib_id(attrib)
        ring_nm = models.ring_name_from_id(ring_id)
        cost = self.pc.get_attrib_cost( attrib ) * new_value
        if self.pc.has_rule('elem_bless_%s' % ring_nm):
            cost -= 1
        text = models.attrib_name_from_id(attrib).capitalize()
        adv = models.AttribAdv(attrib, cost)
        adv.desc = (self.tr('{0}, Rank {1} to {2}. Cost: {3} xp')
                   .format( text, cur_value, new_value, adv.cost ))

        if (adv.cost + self.pc.get_px()) > self.pc.exp_limit:
            return CMErrors.NOT_ENOUGH_XP

        self.pc.add_advancement( adv )
        self.update_from_model()

        return CMErrors.NO_ERROR
Ejemplo n.º 3
0
    def export_body(self, io):
        m = self.model
        f = self.form

        fields = {
            'NAME': m.name,
            'CLAN': self.get_clan_name(),
            'RANK': api.character.insight_rank(),
            'FAMILY': self.get_family_name(),
            'SCHOOL': self.get_school_name(),
            'EXP': self.get_exp(),
            'INSIGHT': api.character.insight()
        }

        # TRAITS AND RINGS
        for i in range(0, 8):
            trait_nm = models.attrib_name_from_id(i)
            fields[trait_nm.upper()] = api.character.modified_trait_rank(
                trait_nm)
        for i in range(0, 5):
            ring_nm = models.ring_name_from_id(i)
            fields[ring_nm.upper()] = api.character.ring_rank(ring_nm)

        # HONOR, GLORY, STATUS, TAINT
        hvalue, hdots = api.rules.split_decimal(api.character.honor())
        gvalue, gdots = api.rules.split_decimal(api.character.glory())
        svalue, sdots = api.rules.split_decimal(api.character.status())
        tvalue, tdots = api.rules.split_decimal(api.character.taint())

        fields['HONOR'] = hvalue
        fields['GLORY'] = gvalue
        fields['STATUS'] = svalue
        fields['TAINT'] = tvalue

        for i in range(1, hdots * 10 + 1):
            fields['HONOR_DOT.%d' % i] = True

        for i in range(1, gdots * 10 + 1):
            fields['GLORY_DOT.%d' % i] = True

        for i in range(1, sdots * 10 + 1):
            fields['STATUS_DOT.%d' % i] = True

        for i in range(1, tdots * 10 + 1):
            fields['TAINT_DOT.%d' % i] = True

        # INITIATIVE
        fields['INITIATIVE_BASE'] = f.tx_base_init.text()
        fields['INITIATIVE_MOD'] = f.tx_mod_init.text()
        fields['INITIATIVE_CUR'] = f.tx_cur_init.text()

        # TN / RD
        fields['TN_BASE'] = api.character.get_base_tn()
        fields['TN_CUR'] = api.character.get_full_tn()
        fields['BASE_RD'] = api.character.get_base_rd()
        fields['CUR_RD'] = api.character.get_full_rd()

        # ARMOR
        fields['ARMOR_TYPE'] = api.character.get_armor_name()
        fields['ARMOR_TN'] = api.character.get_armor_tn()
        fields['ARMOR_RD'] = api.character.get_armor_rd()
        fields['ARMOR_NOTES'] = api.character.get_armor_desc()

        # WOUNDS
        w_labels = [
            'HEALTHY', 'NICKED', 'GRAZED', 'HURT', 'INJURED', 'CRIPPLED',
            'DOWN', 'OUT'
        ]
        method = QSettings().value('health_method', 'wounds')
        wounds_table = api.rules.get_wounds_table()
        for i, (i_inc, i_total, i_stacked, _inc_wounds, _total_wounds,
                _stacked_wounds) in enumerate(wounds_table):
            if method == 'default':
                value = i_inc
            elif method == 'wounds':
                value = i_stacked
            else:
                value = i_total
            fields[w_labels[i]] = str(value) if value else ''

        fields['WOUND_HEAL_BASE'] = api.rules.get_wound_heal_rate()
        fields['WOUND_HEAL_CUR'] = fields['WOUND_HEAL_BASE']

        # MERITS AND FLAWS
        merits = f.merits_view_model.items
        flaws = f.flaws_view_model.items

        count = min(17, len(merits))
        for i in range(1, count + 1):
            merit = merits[i - 1]
            fields['ADVANTAGE_NM.%d' % i] = merit.name
            fields['ADVANTAGE_PT.%d' % i] = abs(merit.cost)

        count = min(17, len(flaws))
        for i in range(1, count + 1):
            flaw = flaws[i - 1]
            fields['DISADVANTAGE_NM.%d' % i] = flaw.name
            fields['DISADVANTAGE_PT.%d' % i] = abs(flaw.cost)

        # WEAPONS
        melee_weapons = f.melee_view_model.items
        range_weapons = [
            x for x in f.ranged_view_model.items if 'melee' not in x.tags
        ]
        wl = zigzag(melee_weapons, range_weapons)

        count = min(2, len(wl))
        for i in range(1, count + 1):
            weap = wl[i - 1]
            fields['WEAP_TYPE.%d' % i] = weap.name
            if weap.base_atk != weap.max_atk:
                fields['WEAP_ATK.%d' % i] = weap.base_atk + "/" + weap.max_atk
            else:
                fields['WEAP_ATK.%d' % i] = weap.base_atk
            if weap.base_dmg != weap.max_dmg:
                fields['WEAP_DMG.%d' % i] = weap.base_dmg + "/" + weap.max_dmg
            else:
                fields['WEAP_DMG.%d' % i] = weap.base_dmg
            fields['WEAP_NOTES.%d' % i] = weap.desc

        # ARROWS
        arrows = f.arrow_view_model.items
        count = min(5, len(arrows))
        for i in range(1, count + 1):
            ar = arrows[i - 1]
            fields['ARROW_TYPE.%d' % i] = ar.name.replace('Arrow', '')
            fields['ARROW_DMG.%d' % i] = ar.dr
            fields['ARROW_QTY.%d' % i] = ar.qty

        # PERSONAL INFORMATIONS
        fields['GENDER'] = m.get_property('sex')
        fields['AGE'] = m.get_property('age')
        fields['HEIGHT'] = m.get_property('height')
        fields['WEIGHT'] = m.get_property('weight')
        fields['HAIR'] = m.get_property('hair')
        fields['EYES'] = m.get_property('eyes')
        fields['FATHER'] = m.get_property('father')
        fields['MOTHER'] = m.get_property('mother')
        fields['BROTHERS'] = m.get_property('brothers')
        fields['SISTERS'] = m.get_property('sisters')
        fields['MARITAL STATUS'] = m.get_property('marsta')
        fields['SPOUSE'] = m.get_property('spouse')

        if m.get_property('childr'):
            chrows = m.get_property('childr').split('\n\r')
            for i in range(0, len(chrows)):
                fields['CHILDREN.%d' % (i + 1)] = chrows[i]

        # EQUIPMENT
        starting_outfit_ = []
        first_rank_ = api.character.rankadv.get_first()
        if first_rank_:
            starting_outfit_ = first_rank_.outfit

        equip_list = starting_outfit_ + m.get_property('equip', [])
        equip_num = min(50, len(equip_list))
        equip_cols = [18, 18, 15]
        c = 0
        for i in range(0, len(equip_cols)):
            for j in range(0, equip_cols[i]):
                if c < equip_num:
                    fields['EQUIP_LINE.{0}.{1}'.format(j, i)] = equip_list[c]
                    c += 1

        # MONEY
        money = api.character.get_money()
        if money and len(money) == 3:
            fields['KOKU'] = str(money[0])
            fields['BU'] = str(money[1])
            fields['ZENI'] = str(money[2])

        # MISC
        misc = f.tx_pc_notes.get_plain_text()
        fields['MISCELLANEOUS'] = misc

        # EXPORT FIELDS
        for k in fields.iterkeys():
            self.export_field(k, fields[k], io)
    def export_body(self, io):
        m = self.model
        f = self.form

        fields = {}
        fields['NAME'   ] = m.name
        fields['CLAN'   ] = self.get_clan_name   ()
        fields['RANK'   ] = m.get_insight_rank   ()
        fields['FAMILY' ] = self.get_family_name ()
        fields['SCHOOL' ] = self.get_school_name ()
        fields['EXP'    ] = self.get_exp         ()
        fields['INSIGHT'] = m.get_insight        ()

        # TRAITS AND RINGS
        for i in xrange(0, 8):
            fields[models.attrib_name_from_id(i).upper()] = m.get_mod_attrib_rank(i)
        for i in xrange(0, 5):
            fields[models.ring_name_from_id(i).upper()] = m.get_ring_rank(i)

        # HONOR, GLORY, STATUS, TAINT
        hvalue, hdots = rules.split_decimal(m.get_honor ())
        gvalue, gdots = rules.split_decimal(m.get_glory ())
        svalue, sdots = rules.split_decimal(m.get_status())
        tvalue, tdots = rules.split_decimal(m.get_taint ())

        fields['HONOR' ] = hvalue
        fields['GLORY' ] = gvalue
        fields['STATUS'] = svalue
        fields['TAINT' ] = tvalue

        for i in xrange(1, hdots*10+1):
            fields['HONOR_DOT.%d' % i ]  = True

        for i in xrange(1, gdots*10+1):
            fields['GLORY_DOT.%d' % i ]  = True

        for i in xrange(1, sdots*10+1):
            fields['STATUS_DOT.%d' % i]  = True

        for i in xrange(1, tdots*10+1):
            fields['TAINT_DOT.%d' % i ]  = True

        # INITIATIVE
        fields['INITIATIVE_BASE'] = f.tx_base_init.text()
        fields['INITIATIVE_MOD' ] = f.tx_mod_init .text()
        fields['INITIATIVE_CUR' ] = f.tx_cur_init .text()

        # TN / RD
        fields['TN_BASE'] = m.get_base_tn ()
        fields['TN_CUR' ] = m.get_cur_tn  ()
        fields['BASE_RD'] = m.get_base_rd ()
        fields['CUR_RD' ] = m.get_full_rd ()

        # ARMOR
        fields['ARMOR_TYPE' ] = m.get_armor_name   ()
        fields['ARMOR_TN'   ] = m.get_armor_tn     ()
        fields['ARMOR_RD'   ] = m.get_armor_rd     ()
        fields['ARMOR_NOTES'] = m.get_armor_desc   ()

        # WOUNDS
        w_labels = ['HEALTHY', 'NICKED', 'GRAZED',
                    'HURT', 'INJURED', 'CRIPPLED',
                    'DOWN', 'OUT']
        for i in xrange(0, len(w_labels)):
            fields[w_labels[i]] = str(f.get_health_rank(i))

        fields['WOUND_HEAL_BASE'] = (m.get_mod_attrib_rank(models.ATTRIBS.STAMINA)*2
                                     + m.get_insight_rank())
        fields['WOUND_HEAL_CUR' ] = fields['WOUND_HEAL_BASE']

        # SKILLS
        sorted_skills = sorted( f.sk_view_model.items, key = lambda x: (not x.is_school, -x.rank, x.name) )
        for i, sk in enumerate(sorted_skills):
            j = i+1
            if i >= 23: break

            fields['SKILL_IS_SCHOOL.%d' % j] = sk.is_school
            fields['SKILL_NAME.%d'    % j  ] = sk.name
            fields['SKILL_RANK.%d'    % j  ] = sk.rank
            fields['SKILL_TRAIT.%d'   % j  ] = (dal.query.get_trait(f.dstore, sk.trait) or
                                                dal.query.get_ring (f.dstore, sk.trait))
            fields['SKILL_EMPH_MA.%d' % j  ] = ', '.join(sk.emph)

        # MERITS AND FLAWS
        merits = f.merits_view_model.items
        flaws  = f.flaws_view_model .items

        count = min(17, len(merits))
        for i in xrange(1, count+1):
            merit = merits[i-1]
            fields['ADVANTAGE_NM.%d' % i] = merit.name
            fields['ADVANTAGE_PT.%d' % i] = abs(merit.cost)

        count = min(17, len(flaws))
        for i in xrange(1, count+1):
            flaw = flaws[i-1]
            fields['DISADVANTAGE_NM.%d' % i] = flaw.name
            fields['DISADVANTAGE_PT.%d' % i] = abs(flaw.cost)

        # WEAPONS
        melee_weapons = f.melee_view_model .items
        range_weapons = [x for x in f.ranged_view_model.items if 'melee' not in x.tags]
        wl = zigzag(melee_weapons, range_weapons)

        count = min(2, len(wl))
        for i in xrange(1, count+1):
            weap = wl[i-1]
            fields['WEAP_TYPE.%d'  % i] = weap.name
            if weap.base_atk != weap.max_atk:
                fields['WEAP_ATK.%d'   % i] = weap.base_atk + "/" + weap.max_atk
            else:
                fields['WEAP_ATK.%d'   % i] = weap.base_atk
            if weap.base_dmg != weap.max_dmg:
                fields['WEAP_DMG.%d'   % i] = weap.base_dmg + "/" + weap.max_dmg
            else:
                fields['WEAP_DMG.%d'   % i] = weap.base_dmg
            fields['WEAP_NOTES.%d' % i] = weap.desc

        # ARROWS
        arrows        = f.arrow_view_model .items
        count = min(5, len(arrows))
        for i in xrange(1, count+1):
            ar = arrows[i-1]
            fields['ARROW_TYPE.%d'  % i] = ar.name.replace('Arrow', '')
            fields['ARROW_DMG.%d'   % i] = ar.dr
            fields['ARROW_QTY.%d'   % i] = ar.qty

        # PERSONAL INFORMATIONS
        fields['GENDER']         = m.get_property('sex')
        fields['AGE']            = m.get_property('age')
        fields['HEIGHT']         = m.get_property('height')
        fields['WEIGHT']         = m.get_property('weight')
        fields['HAIR']           = m.get_property('hair')
        fields['EYES']           = m.get_property('eyes')
        fields['FATHER']         = m.get_property('father')
        fields['MOTHER']         = m.get_property('mother')
        fields['BROTHERS']       = m.get_property('brothers')
        fields['SISTERS']        = m.get_property('sisters')
        fields['MARITAL STATUS'] = m.get_property('marsta')
        fields['SPOUSE']         = m.get_property('spouse')

        if m.get_property('childr'):
            chrows = m.get_property('childr').split('\n\r')
            for i in xrange(0, len(chrows)):
                fields['CHILDREN.%d' % (i+1)] = chrows[i]

        # EQUIPMENT
        equip_list = m.get_school_outfit() + m.get_property('equip', [])
        equip_num  = min(50, len(equip_list))
        equip_cols = [18, 18, 15]
        c          = 0
        for i in xrange(0, len(equip_cols)):
            for j in xrange(0, equip_cols[i]):
                if c < equip_num:
                    fields['EQUIP_LINE.{0}.{1}'.format(j, i)] = equip_list[c]
                    c += 1

        # MONEY
        money = m.get_property('money')
        if money and len(money) == 3:
            fields['KOKU'] = str( money[0] )
            fields['BU'  ] = str( money[1] )
            fields['ZENI'] = str( money[2] )

        # MISC
        misc = f.tx_pc_notes.get_plain_text()
        fields['MISCELLANEOUS'] = misc

        # EXPORT FIELDS
        for k in fields.iterkeys():
            self.export_field(k, fields[k], io)