예제 #1
0
    def owner_widget(self, name, data):
        if data is None:
            tzid=None
        else:
            tzid=data.tzid

        ps = players.ls()
        ms = mobs.ls()
        cs = ps + ms
        choices = [(c.tzid, '%s (%s)' % (c.name, c.tzid)) for c in cs]
        choices.insert(0, (None, 'None'))
        choices.sort(key=itemgetter(1))
        info = dict(name=name,
                    choices=choices,
                    selected=tzid)

        return self.render_form_select(info)
예제 #2
0
파일: wizard.py 프로젝트: cryptixman/tzmud
def cmd_list(s, r):
    '''list |players|items|rooms|mobs|exits|

    List all objects of the given type.

    '''

    listing = r['type']

    if listing == 'players':
        objs = players.ls()
        classes = []
    elif listing == 'items':
        objs = items.ls()
        classes = items.classes()
    elif listing == 'rooms':
        objs = rooms.ls()
        classes = rooms.classes()
    elif listing == 'mobs':
        objs = mobs.ls()
        classes = mobs.classes()
    elif listing == 'exits':
        objs = exits.ls()
        classes = exits.classes()

    if objs:
        s.message('Existing objects:')
        objs.sort(key=operator.attrgetter('tzid'))
        msgs = []
        for obj in objs:
            tzid = '(%s)' % obj.tzid
            msgs.append('%s %s' % (tzid.rjust(4, ' '), obj))
        s.mlmessage(msgs, indent=4)
    else:
        s.message('No', listing, 'yet.')

    if classes:
        classes = list(classes)
        classes.sort()
        if objs:
            s.message()
        s.message('Cloneable:')
        s.columns_v(classes, color=colors.white)
예제 #3
0
    def create(self, r):
        'Create a new account.'

        try:
            player_name, pwtext = r.split()
        except ValueError:
            self.simessage('Create account with "create <name> <password>"')
        else:
            existing = players.getname(player_name)
            if existing:
                self.simessage('Name already in use.')
            elif player_name=='quit':
                self.simessage('Cannot use the name "quit"')
            else:
                player = players.Player(player_name)
                player.set_password(pwtext)
                if len(players.ls()) == 1:
                    admin.add(player)

                self.simessage('Account created.')
                self.simessage('Log in with "login <name> <password>"')
예제 #4
0
    def purge_all(cls):
        'Disconnect all players.'

        for player in players.ls():
            cls._purge(player)
예제 #5
0
 def data_players(self, ctx, data):
     p = players.ls()
     #p.sort(key=attrgetter('name'))
     return p