示例#1
0
    def func(self):
        from world import archetypes
        # make sure the char has traits - only possible for superuser
        if len(self.caller.traits.all) == 0:
            self.caller.msg("You don't have any traits.")
            return

        table = None
        tr = self.caller.traits
        traits = []
        if self.args.startswith('pri'):
            title = 'Primary Traits'
            traits = archetypes.PRIMARY_TRAITS
        elif self.args.startswith('sav'):
            title = 'Save Rolls'
            traits = archetypes.SAVE_ROLLS
        elif self.args.startswith('com'):
            title = 'Combat Stats'
            traits = archetypes.COMBAT_TRAITS
        elif self.args.startswith('sec'):
            title = 'Secondary Traits'
            data = [[
                "|C{:<29.29}|n : |w{:>4}|n".format(tr[t].name, tr[t].actual)
                for t in ('HP', 'SP')
            ],
                    [
                        "|C{:<28.28}|n : |w{:>4}|n".format(
                            tr[t].name, tr[t].actual) for t in ('BM', 'WM')
                    ]]
            table = EvTable(header=False, table=data)
        elif self.args.startswith('enc') or self.args.startswith('car'):
            title = 'Encumbrance'
            data = [[
                "|C{:<30.30s}|n : |w{:>4}|n / |w{:>5}|n".format(
                    tr.ENC.name, tr.ENC.actual, tr.ENC.max),
                "|C{:30.30s}|n : |w{:>+12}|n".format('Encumbrance Penalty',
                                                     tr.MV.mod),
                "|C{:30.30s}|n : |w{:>12}|n".format(tr.MV.name, tr.MV.actual)
            ]]
            table = EvTable(header=False, table=data)
        else:
            self.caller.msg("Usage: traits <traitgroup>")
            return
        if not table:
            data = []
            for i in xrange(3):
                data.append(
                    [self._format_trait_3col(tr[t]) for t in traits[i::3]])
            table = EvTable(header=False, table=data)

        self.caller.msg("  |Y{}|n".format(title))
        self.caller.msg(unicode(table))
示例#2
0
    def func(self):
        from world import skills
        # make sure the char has skills
        if len(self.caller.skills.all) == 0:
            self.caller.msg("You don't have any skills.")
            return

        sk = self.caller.skills
        sk_list = []

        if len(self.args.strip()) > 0:
            if self.args.lower().startswith('str'):
                title = 'Strength Based Skills'
                sk_list = skills.STR_SKILLS
            elif self.args.lower().startswith('per'):
                title = 'Perception Based Skills'
                sk_list = skills.PER_SKILLS
            elif self.args.lower().startswith('int'):
                title = 'Intelligence Based Skills'
                sk_list = skills.INT_SKILLS
            elif self.args.lower().startswith('dex'):
                title = 'Dexterity Based Skills'
                sk_list = skills.DEX_SKILLS
            elif self.args.lower().startswith('cha'):
                title = 'Charisma Based Skills'
                sk_list = skills.CHA_SKILLS
            else:
                self.msg('Usage: skills [<skillgroup>]')
                return

            table = EvTable(header=False,
                            table=[[self._format_skill_3col(sk[s])]
                                   for s in sk_list])
        else:
            title = 'Skills'
            data = []
            for i in xrange(3):
                data.append([
                    self._format_skill_3col(sk[s])
                    for s in skills.ALL_SKILLS[i::3]
                ])

            table = EvTable(header=False, table=data)

        self.caller.msg("  |Y{}|n".format(title))
        self.caller.msg(unicode(table))
示例#3
0
def pick_race(caller, **kwargs):
    races = [(x.name, x.sdesc) for x in PLAYABLE_RACES]
    text = "Pick a race"
    form = EvForm('resources.chargen_race_form')

    race_info = np.zeros((len(PLAYABLE_RACES), 8), dtype='object')

    for idx in range(len(PLAYABLE_RACES)):

        info = []
        s = PLAYABLE_RACES[idx]
        name = s.name.capitalize()
        for idy in range(8):
            if idy == 0:
                info.append(name)
            else:
                info.append(s.stats[idy - 1].base)

        max = np.max([x for x in info if isinstance(x, int)])
        min = np.min([x for x in info if isinstance(x, int)])

        idx_max = info.index(max)
        idx_min = info.index(min)
        info[idx_max] = f"|g{info[idx_max]}|n"
        info[idx_min] = f"|r{info[idx_min]}|n"

        info = [str(x) for x in info]
        race_info[idx] = info

    race_table = EvTable("Race",
                         "Str",
                         "End",
                         "Agi",
                         "Int",
                         "Wp",
                         "Prc",
                         "Prs",
                         table=race_info.transpose().tolist(),
                         border='incols',
                         height=2)
    form.map(tables={'B': race_table})
    text = str(form) + "\n*base stats"

    options = []
    for name, sdesc in races:
        options.append({
            'key': name.capitalize(),
            'desc': f"|c{sdesc.capitalize()}|n",
            'goto': ("skill_upgrade", {
                'race': name
            })
        })

    return text, tuple(options)
示例#4
0
    def func(self):
        "implements the actual functionality"

        skillnames = []
        skilllevels = []
        for key in self.caller.db.skills:
            skillnames.append("|G" + key)
            skilllevels.append("|C" + str(self.caller.db.skills[key]) + "|n")

        skillnames.append("|RSkill Points:")
        skilllevels.append("|C" + str(self.caller.db.stat_skill_points) + "|n")

        table = EvTable("|GSkill|b",
                        "|GLevel|b",
                        table=[skillnames, skilllevels],
                        border="cells")

        t = unicode(table)
        self.caller.msg(t)
示例#5
0
    def func(self):
        """
        Handle displaying status.
        """
        # make sure the char has traits - only possible for superuser
        if len(self.caller.traits.all) == 0:
            return

        form = EvForm('commands.templates.charsheet', align='r')
        tr = self.caller.traits
        fields = {
            'A': self.caller.name,
            'B': self.caller.db.archetype,
            'C': tr.XP.actual,
            'D': tr.XP.level_boundaries[tr.LV.actual],
            'E': tr.LV.actual,
            'F': tr.STR.actual,
            'G': tr.PER.actual,
            'H': tr.INT.actual,
            'I': tr.DEX.actual,
            'J': tr.CHA.actual,
            'K': tr.VIT.actual,
            'L': tr.MAG.actual,
            'M': tr.FORT.actual,
            'N': tr.REFL.actual,
            'O': tr.WILL.actual,
            'P': tr.ATKM.actual,
            'Q': tr.ATKR.actual,
            'R': tr.ATKU.actual,
            'S': tr.DEF.actual,
            'T': "{:+d}".format(tr.PP.actual),
            'U': tr.ENC.actual,
            'V': tr.ENC.max,
            'W': tr.MV.mod,
            'X': tr.MV.actual,
            'Y': self.caller.db.race,
            'Z': self.caller.db.focus,
        }
        form.map({k: self._format_trait_val(v) for k, v in fields.iteritems()})

        gauges = EvTable(
            "|CHP|n",
            "|CSP|n",
            "|CBM|n",
            "|CWM|n",
            table=[[
                "{} / {}".format(self._format_trait_val(tr.HP.actual),
                                 self._format_trait_val(tr.HP.max))
            ],
                   [
                       "{} / {}".format(self._format_trait_val(tr.SP.actual),
                                        self._format_trait_val(tr.SP.max))
                   ],
                   [
                       "{} / {}".format(self._format_trait_val(tr.BM.actual),
                                        self._format_trait_val(tr.BM.max))
                   ],
                   [
                       "{} / {}".format(self._format_trait_val(tr.WM.actual),
                                        self._format_trait_val(tr.WM.max))
                   ]],
            align='c',
            border="incols")
        desc = EvTable(header=False,
                       align='l',
                       table=[[self.caller.db.desc]],
                       border=None)

        form.map(tables={1: gauges, 2: desc})

        self.caller.msg(unicode(form))

        if any(sw.startswith('sk') for sw in self.switches):
            self.caller.execute_cmd('skills')
示例#6
0
    def func(self):
        """check inventory"""

        max_e = calculate_encumbrance_max(self.caller)
        now_e = calculate_encumbrance_now(self.caller)

        enc_string = "|GEncumbrance: %s/%s [%.0f%%]|n" % (now_e, max_e,
                                                          (100 * now_e /
                                                           max_e))

        if not self.caller.contents:
            self.caller.msg("You are not carrying or wearing anything.\n" +
                            enc_string)
            return

        items = self.caller.contents
        if self.caller.db.items_main_hand is not None:
            items.remove(self.caller.db.items_main_hand)
        if self.caller.db.items_off_hand is not None:
            items.remove(self.caller.db.items_off_hand)

        carry_table = EvTable(border="header")
        wear_table = EvTable(border="header")
        for item in items:
            if item.is_typeclass(Clothing, exact=True):
                clothingHelper = ClothingSlots()
                if not clothingHelper.checkwearingit(self.caller, item) == 1:
                    carry_table.add_row("|C  %s|n" % item.name, item.db.desc
                                        or "")
                else:
                    wear_table.add_row(
                        "|C  %s (%s)|n" % (item.name, item.db.worn_slot),
                        item.db.desc or "")
            else:
                carry_table.add_row("|C  %s|n" % item.name, item.db.desc or "")
        if carry_table.nrows == 0:
            carry_table.add_row("|CNothing.|n", "")
        string = "|wYou are carrying:\n%s" % carry_table

        if wear_table.nrows == 0:
            wear_table.add_row("|CNothing.|n", "")
        string += "|/|wYou are wearing:\n%s" % wear_table
        if self.caller.db.items_off_hand is not None or self.caller.db.items_main_hand is not None:
            string += "\n|wYou are holding:"
            if self.caller.db.items_main_hand is not None:
                string += "\n|C  %s (main hand) " % self.caller.db.items_main_hand.name
            if self.caller.db.items_off_hand is not None:
                string += "\n|C  %s (off hand) " % self.caller.db.items_off_hand.name

        string += "\n" + enc_string

        self.caller.msg(string)