Exemplo n.º 1
0
def cg_finish_handler(sock, arg):
    # pop our input handler for finishing character generation
    sock.pop_ih()

    # log that the character created
    mud.log_string("New player: " + sock.ch.name + " has entered the game.")
    
    # register and save him to disk and to an account
    mudsys.do_register(sock.ch)

    # make him exist in the game for functions to look him up
    mudsys.try_enter_game(sock.ch)

    # run the init_player hook
    hooks.run("init_player", hooks.build_info("ch", (sock.ch,)))
    
    # attach him to his account and save the account
    sock.account.add_char(sock.ch)
    mudsys.do_save(sock.account)
    mudsys.do_save(sock.ch)

    # clear their screen
    sock.ch.act("clear")
    
    # send them the motd
    sock.ch.page(mud.get_motd())

    # make him look at the room
    sock.ch.act("look")

    # run our enter hook
    hooks.run("enter", hooks.build_info("ch rm", (sock.ch, sock.ch.room)))
Exemplo n.º 2
0
def try_create_account(sock, name, psswd):
    if mudsys.account_exists(name):
        return False
    elif mudsys.account_creating(name):
        return False
    elif not check_acct_name(name):
        return False
    else:
        # creating a new account
        mud.log_string("Account '" + name + "' is trying to create.")

        # create our new account
        acct = mudsys.create_account(name)
        if acct == None:
            return False
        else:
            mudsys.attach_account_socket(acct, sock)
            mudsys.set_password(acct, psswd)
            sock.pop_ih()
            sock.push_ih(acct_menu_handler, acct_main_menu)

            #sock.push_ih(acct_finish_handler, acct_finish_prompt)

            # log that the account created
            mud.log_string("New account '" + acct.name + "' has created.")

            # register and save the account to disk
            mudsys.do_register(acct)

            return True
    return False
Exemplo n.º 3
0
def cg_finish_handler(sock, arg):
    # pop our input handler for finishing character generation
    sock.pop_ih()

    # log that the character created
    mud.log_string("New player: " + sock.ch.name + " has entered the game.")

    # register and save him to disk and to an account
    mudsys.do_register(sock.ch)

    # make him exist in the game for functions to look him up
    mudsys.try_enter_game(sock.ch)

    # run the init_player hook
    hooks.run("init_player", hooks.build_info("ch", (sock.ch, )))

    # attach him to his account and save the account
    sock.account.add_char(sock.ch)
    mudsys.do_save(sock.account)
    mudsys.do_save(sock.ch)

    # clear their screen
    sock.ch.act("clear")

    # send them the motd
    sock.ch.page(mud.get_motd())

    # make him look at the room
    sock.ch.act("look")

    # run our enter hook
    hooks.run("enter", hooks.build_info("ch rm", (sock.ch, sock.ch.room)))
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
def account_handler_hook(info):
    '''When a socket connects, put them into the account handler menu.'''
    # put a nonfunctional prompt up while waiting for the DNS to resolve
    sock, = hooks.parse_info(info)
    sock.push_ih(login_method_handler, login_method_prompt)
    mud.log_string("new socket, %d, attempting to connect" % sock.uid)
    sock.send(mud.get_greeting())
    sock.send("== Options Are ================================================================")
    sock.send("    Load account   : load   <account> <password>")
    sock.send("    Create account : create <account> <password>")
    sock.send("    Play as guest  : guest")
    sock.send("===============================================================================")
    sock.send("")

    '''
Exemplo n.º 7
0
def list_room_exits(ch, room, filter_compass=False):
    # first, go through our standard exits
    if not filter_compass:
        for dir in compass_dirs:
            ex = room.exit(dir)
            if ex == None:
                continue
            if ex.dest == None:
                mud.log_string("ERROR: room %s headed %s to %s, which does not exist." % room.proto, dir, ex.destproto)
            elif ch.cansee(ex):
                list_one_exit(ch, ex, dir)

    # now do special exits
    for dir in room.exnames:
        if not dir in compass_dirs:
            ex = room.exit(dir)
            if ex.dest == None:
                mud.log_string("ERROR: room %s headed %s to %s, which does not exist." % room.proto, dir, ex.destproto)
            elif ch.cansee(ex):
                list_one_exit(ch, ex, dir)
Exemplo n.º 8
0
def short_room_exits(ch, room, filter_compass=False, split_compass=False):
    exits = []
    output = ""

    switcher = {
        0: "There doesn't seem to be any obvious exits!",
        1: "The only obvious exit is",
        2: "There are two obvious exits:",
        3: "Obvious exits are:"
    }

    if not filter_compass:
        for dir in compass_dirs:
            ex = room.exit(dir)
            if ex == None:
                continue
            if ex.dest == None:
                mud.log_string(
                    "ERROR: room %s headed %s to destination %s " +
                    "which does not exist.", room.proto, dir, ex.destproto)
            elif ch.cansee(ex):
                exits = exits + [dir]

    ex = None
    for dir in room.exnames:
        if not dir in compass_dirs:
            ex = room.exit(dir)
            if ex.dest == None:
                mud.log_string(
                    "ERROR: room %s headed %s to destination %s " +
                    "which does not exist.", room.proto, dir, ex.destproto)
            elif ch.cansee(ex):
                exits = exits + [dir]

    if (len(exits) == 0):
        ch.send(switcher[0])
    else:
        count = 3 if (len(exits) >= 3) else len(exits)
        ch.send("\n    {W%s %s and %s.\n{n" %
                (switcher[count], ", ".join(exits[:-1]), exits[-1]))
Exemplo n.º 9
0
def long_room_exits(ch, room, filter_compass=False):
    # first, go through our standard exits
    if not filter_compass:
        for dir in compass_dirs:
            ex = room.exit(dir)
            if ex == None:
                continue
            if ex.dest == None:
                mud.log_string("ERROR: room %s headed %s to %s, which does not exist."%\
                               room.proto, dir, ex.destproto)
            elif ch.cansee(ex):
                list_one_exit(ch, ex, dir)

    # now do special exits
    for dir in room.exnames:
        if not dir in compass_dirs:
            ex = room.exit(dir)
            if ex.dest == None:
                mud.log_string("ERROR: room %s headed %s to %s, which does not exist." % \
                               room.proto, dir, ex.destproto)
            elif ch.cansee(ex):
                list_one_exit(ch, ex, dir)
Exemplo n.º 10
0
def guest_gen_hook(info):
    sock, = hooks.parse_info(info)
    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")

    # make the guest character
    ch = mudsys.create_player("Guest")

    # oops...
    if ch == None:
        sock.send("Sorry, there were issues creating a guest account.")
        sock.close()

    mudsys.attach_char_socket(ch, sock)
    ch.rdesc = "a guest player is here, exploring the world."
    ch.name = ch.name + str(ch.uid)
    ch.race = "human"

    # log that the character created
    mud.log_string("Guest character created (id %d)." % ch.uid)

    # make him exist in the game for functions to look him up
    mudsys.try_enter_game(ch)

    # run the init_player hook
    hooks.run("init_player", hooks.build_info("ch", (ch, )))

    # clear our screen
    ch.act("clear")

    # send them the motd
    ch.page(mud.get_motd())

    # make him look at the room
    ch.act("look")

    # run our enter hook
    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
Exemplo n.º 11
0
def guest_gen_hook(info):
    sock, = hooks.parse_info(info)
    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")

    # make the guest character
    ch = mudsys.create_player("Guest")

    # oops...
    if ch == None:
        sock.send("Sorry, there were issues creating a guest account.")
        sock.close()

    mudsys.attach_char_socket(ch, sock)
    ch.rdesc = "a guest player is here, exploring the world."
    ch.name  = ch.name + str(ch.uid)
    ch.race  = "human"

    # log that the character created
    mud.log_string("Guest character created (id %d)." % ch.uid)

    # make him exist in the game for functions to look him up
    mudsys.try_enter_game(ch)

    # run the init_player hook
    hooks.run("init_player", hooks.build_info("ch", (ch,)))

    # clear our screen
    ch.act("clear")

    # send them the motd
    ch.page(mud.get_motd())
    
    # make him look at the room
    ch.act("look")

    # run our enter hook
    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
Exemplo n.º 12
0
def cmd_quit(ch, cmd, arg):
    '''Attempts to save and log out of the game.'''
    mud.log_string(ch.name + " has left the game.")
    mudsys.do_save(ch)
    mudsys.do_quit(ch)
Exemplo n.º 13
0
def cmd_quit(ch, cmd, arg):
    """Attempts to save and log out of the game."""
    mud.log_string(ch.name + " has left the game.")
    mudsys.do_save(ch)
    mudsys.do_quit(ch)