コード例 #1
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)
コード例 #2
0
ファイル: currency.py プロジェクト: KaSt/nereamud
def give_currency_hook(info):
    """Turns a currency object into actual currency when received.
    """
    ch, recv, obj = hooks.parse_info(info)
    # if obj.hasBit("currency"):
    if utils.is_keyword(obj.bits, "currency"):
        recv.worth += obj.worth
        mud.extract(obj)
コード例 #3
0
ファイル: currency.py プロジェクト: KaSt/nereamud
def get_currency_hook(info):
    """Turns a currency object into actual currency when taken.
    """
    ch, obj = hooks.parse_info(info)
    # if obj.hasBit("currency"):
    if utils.is_keyword(obj.bits, "currency"):
        ch.worth += obj.worth
        mud.extract(obj)
コード例 #4
0
ファイル: currency.py プロジェクト: KaSt/nereamud
def give_currency_hook(info):
    """Turns a currency object into actual currency when received.
    """
    ch, recv, obj = hooks.parse_info(info)
    # if obj.hasBit("currency"):
    if utils.is_keyword(obj.bits, "currency"):
        recv.worth += obj.worth
        mud.extract(obj)
コード例 #5
0
ファイル: currency.py プロジェクト: KaSt/nereamud
def get_currency_hook(info):
    """Turns a currency object into actual currency when taken.
    """
    ch, obj = hooks.parse_info(info)
    # if obj.hasBit("currency"):
    if utils.is_keyword(obj.bits, "currency"):
        ch.worth += obj.worth
        mud.extract(obj)
コード例 #6
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)