def login_method_handler(sock, arg):
    args = arg.split()
    if len(args) == 0:
        return
    args[0] = args[0].lower()

    if "create".startswith(args[0]):
        if len(args) != 3:
            return
        elif mudsys.account_exists(args[1]):
            sock.send("{cAn account by that name already exists.{n\r\n")
        elif not check_acct_name(args[1]):
            txt = "{cThat is an invalid account name. Your account name must "\
                  "only consist of characters and numbers, and it must be " \
                  "4 and 12 characters in length. The first character MUST be "\
                  "a letter. Please pick another.{n"
            sock.send(mud.format_string(txt, False))

        elif not try_create_account(sock, args[1], args[2]):
            sock.send("Your account was unable to be created.")

    elif "load".startswith(args[0]):
        if len(args) != 3:
            return
        elif not try_load_account(sock, args[1], args[2]):
            sock.send("{cInvalid account name or password.{n\r\n")
    elif "guest".startswith(args[0]):
        if (mudsys.sys_getval("lockdown") != '' and
            not utils.is_keyword(mudsys.sys_getval("lockdown"), "player")):
            sock.send("{cThe mud is currently locked out to new players.{n\r\n")
        else:
            sock.pop_ih()
            hooks.run("create_guest", hooks.build_info("sk", (sock,)))
Exemple #2
0
def acct_load_char(sock, name):
    '''loads a character attached to the account. Argument supplied must be a
       name of the corresponding character'''
    chars = sock.account.characters()

    if not name.lower() in [n.lower() for n in sock.account.characters()]:
        sock.send("A character by that name does not exist on your account.")
    else:
        # first, try a reconnect
        ch = find_reconnect(name)

        # no reconnect? Try loading our character
        if not ch == None:
            # swap the sockets
            old_sock = ch.sock

            # attach and detach put in mudsys to prevent scripts from
            # messing around with the connections between chars and sockets
            mudsys.detach_char_socket(ch)
            mudsys.attach_char_socket(ch, sock)

            if old_sock != None:
                old_sock.close()
            mud.log_string(ch.name + " has reconnected.")
            # ch.act("clear")
            ch.send("You take over a body already in use.")
            ch.act("look")
            hooks.run("reconnect", hooks.build_info("ch", (ch, )))
            sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt,
                         "playing")

        else:
            # load our character. Put in mudsys to prevent scripts from using it
            ch = mudsys.load_char(name)
            if ch == None:
                sock.send("The player file for " + name + " is missing.")
            elif (mudsys.sys_getval("lockdown") != ''
                  and not ch.isInGroup(mudsys.sys_getval("lockdown"))):
                sock.send("You are currently locked out of the mud.")
                mud.extract(ch)
            else:
                # attach put in mudsys to prevent scripts from messing with
                # character and socket links
                mudsys.attach_char_socket(ch, sock)
                if mudsys.try_enter_game(ch):
                    mud.log_string(ch.name + " has entered the game.")
                    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt,
                                 "playing")
                    # ch.act("clear")
                    ch.page(mud.get_motd())
                    ch.act("look")
                    hooks.run("enter",
                              hooks.build_info("ch rm", (ch, ch.room)))
                else:
                    sock.send("There was a problem entering the game. " + \
                              "try again later.")
                    # detach put in mudsys t prevent scripts from messing with
                    # character and socket links
                    mudsys.detach_char_socket(ch, sock)
                    mud.extract(ch)
def acct_load_char(sock, name):
    '''loads a character attached to the account. Argument supplied must be a
       name of the corresponding character'''
    chars = sock.account.characters()
    
    if not name.lower() in [n.lower() for n in sock.account.characters()]:
        sock.send("A character by that name does not exist on your account.")
    else:
        # first, try a reconnect
        ch = find_reconnect(name)

        # no reconnect? Try loading our character
        if not ch == None:
            # swap the sockets
            old_sock = ch.sock

            # attach and detach put in mudsys to prevent scripts from
            # messing around with the connections between chars and sockets
            mudsys.detach_char_socket(ch)
            mudsys.attach_char_socket(ch, sock)
            
            if old_sock != None:
                old_sock.close()
            mud.log_string(ch.name + " has reconnected.")
            # ch.act("clear")
            ch.send("You take over a body already in use.")
            ch.act("look")
            hooks.run("reconnect", hooks.build_info("ch", (ch,)))
            sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")

        else:
            # load our character. Put in mudsys to prevent scripts from using it
            ch = mudsys.load_char(name)
            if ch == None:
                sock.send("The player file for " + name + " is missing.")
            elif (mudsys.sys_getval("lockdown") != '' and
                  not ch.isInGroup(mudsys.sys_getval("lockdown"))):
                sock.send("You are currently locked out of the mud.")
                mud.extract(ch)
            else:
                # attach put in mudsys to prevent scripts from messing with
                # character and socket links
                mudsys.attach_char_socket(ch, sock)
                if mudsys.try_enter_game(ch):
                    mud.log_string(ch.name + " has entered the game.")
                    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt,
                                 "playing")
                    # ch.act("clear")
                    ch.page(mud.get_motd())
                    ch.act("look")
                    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
                else:
                    sock.send("There was a problem entering the game. " + \
                              "try again later.")
                    # detach put in mudsys t prevent scripts from messing with
                    # character and socket links
                    mudsys.detach_char_socket(ch, sock)
                    mud.extract(ch)
def acct_menu_handler(sock, arg):
    '''parses account commands (new character, enter game, quit, etc)'''
    if len(arg) == 0:
        return

    args = arg.split()
    args[0] = args[0].upper()
    
    if args[0].isdigit():
        opts = sock.account.characters()
        arg  = int(args[0])
        if arg < 0 or arg >= len(opts):
            sock.send("Invalid choice!")
        else:
            acct_load_char(sock, opts[arg])
    elif args[0] == 'L':
        if len(args) == 1:
            sock.send("Which character would you like to load?")
        else:
            acct_load_char(sock, args[1])
    elif args[0] == 'Q' or "QUIT".startswith(args[0]):
        sock.send("Come back soon!")
        mudsys.do_save(sock.account)
        sock.close()
    elif args[0] == 'P':
        # sock.push_ih(acct_confirm_password_handler,acct_confirm_password_prompt)
        sock.push_ih(acct_new_password_handler, acct_new_password_prompt)
        sock.push_ih(acct_password_handler, acct_password_prompt)
    elif args[0] == 'N':
        if "player" in [x.strip() for x in mudsys.sys_getval("lockdown").split(",")]:
            sock.send("New characters are not allowed to be created at this time.")
        else:
            hooks.run("create_character", hooks.build_info("sk", (sock,)))
    else:
        sock.send("Invalid choice!")
Exemple #5
0
def cmd_lockdown(ch, cmd, arg):
    '''Usage: lockdown [allowed groups | off]

       Locks the game for anyone not a member of one of the user groups
       specified. No argument will list all the user groups locked out of the
       mud. The off argument will remove all lockdowns.'''
    if arg == '':
        lockdown = mudsys.sys_getval("lockdown")
        if lockdown == '':
            ch.send("Lockdown is currently off.")
        else:
            ch.send("Lockdown is currently to members not of: " + lockdown)
            ch.send("To turn off lockdown, use {clockdown off{n")

    elif arg.lower() == "off":
        ch.send("Lockdown disabled.")
        mudsys.sys_setval("lockdown", "")

    # make sure we're not locking ourself out
    elif not ch.isInGroup(arg):
        ch.send("You cannot lock yourself out!")

    else:
        ch.send("MUD locked down to everyone not in groups: " + arg)
        mudsys.sys_setval("lockdown", arg)

        # kick out everyone who we've just locked out
        for ch in mudchar.char_list():
            if ch.is_pc and not ch.isInGroup(arg):
                ch.send("The mud has just been locked down to you.")
                mudsys.do_save(ch)
                mudsys.do_disconnect(ch)
                extract(ch)
Exemple #6
0
def cmd_lockdown(ch, cmd, arg):
    '''Usage: lockdown [allowed groups | off]

       Locks the game for anyone not a member of one of the user groups
       specified. No argument will list all the user groups locked out of the
       mud. The off argument will remove all lockdowns.'''
    if arg == '':
        lockdown = mudsys.sys_getval("lockdown")
        if lockdown == '':
            ch.send("Lockdown is currently off.")
        else:
            ch.send("Lockdown is currently to members not of: " + lockdown)
            ch.send("To turn off lockdown, use {clockdown off{n")

    elif arg.lower() == "off":
        ch.send("Lockdown disabled.")
        mudsys.sys_setval("lockdown", "")

    # make sure we're not locking ourself out
    elif not ch.isInGroup(arg):
        ch.send("You cannot lock yourself out!")

    else:
        ch.send("MUD locked down to everyone not in groups: " + arg)
        mudsys.sys_setval("lockdown", arg)

        # kick out everyone who we've just locked out
        for ch in mudchar.char_list():
            if ch.is_pc and not ch.isInGroup(arg):
                ch.send("The mud has just been locked down to you.")
                mudsys.do_save(ch)
                mudsys.do_disconnect(ch)
                extract(ch)
Exemple #7
0
def cmd_pulserate(ch, cmd, arg):
    '''Usage: pulserate <pulses>
    
      Changes the number of pulses the mud experiences each second. The mud
      makes one loop through the main game handler each pulse.
      '''
    if arg == '':
        ch.send("The mud currently has " +
                mudsys.sys_getval("pulses_per_second") + "pulses per second.")
    else:
        pulserate = string.atoi(arg)
        if pulserate == 0 or 1000 % pulse != 0:
            ch.send("The number of pulses per second must divide 1000.")
        else:
            mudsys.sys_setval("pulses_per_second", str(pulserate))
            ch.send("The mud's new pulse rate is %d pulses per second." %
                    pulserate)
Exemple #8
0
def cmd_pulserate(ch, cmd, arg):
    '''Usage: pulserate <pulses>
    
      Changes the number of pulses the mud experiences each second. The mud
      makes one loop through the main game handler each pulse.
      '''
    if arg == '':
        ch.send("The mud currently has "+mudsys.sys_getval("pulses_per_second")+
                "pulses per second.")
    else:
        pulserate = string.atoi(arg)
        if pulserate == 0 or 1000 % pulse != 0:
            ch.send("The number of pulses per second must divide 1000.")
        else:
            mudsys.sys_setval("pulses_per_second", str(pulserate))
            ch.send("The mud's new pulse rate is %d pulses per second." %
                    pulserate)