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 cg_name_handler(sock, arg): if not check_char_name(arg): sock.send("{cIllegal name, please pick another.{n\r\n") elif mudsys.player_exists(arg): sock.send("{cA player with that name already exists.{n\r\n") elif mudsys.player_creating(arg): sock.send("{cA player is already being created with that name.{n\r\n") elif arg.lower().startswith("guest"): sock.send("{cCharacter names cannot begin with 'guest'.{n\r\n") else: name = arg[0].upper() + arg[1:] ch = mudsys.create_player(name) if ch == None: sock.send("{cIllegal name, please pick another.{n\r\n") else: mudsys.attach_char_socket(ch, sock) ch.rdesc = ch.name + " is here." sock.pop_ih()
def cg_name_handler(sock, arg): if not check_char_name(arg): sock.send("{cIllegal name, please pick another.{n\r\n") elif mudsys.player_exists(arg): sock.send("{cA player with that name already exists.{n\r\n") elif mudsys.player_creating(arg): sock.send("{cA player is already being created with that name.{n\r\n") elif arg.lower().startswith("guest"): sock.send("{cCharacter names cannot begin with 'guest'.{n\r\n") else: name = arg[0].upper() + arg[1:] ch = mudsys.create_player(name) if ch == None: sock.send("{cIllegal name, please pick another.{n\r\n") else: mudsys.attach_char_socket(ch, sock) ch.rdesc = ch.name + " is here." ch.desc = "You see a [me.height] [me.sex]. [me.heshe] has \ [me.hair_length] [me.hair_texture] [me.hair_color] hair. \ [me.hisher] [me.nose] nose is set over [me.lips] lips \ and a [me.chin] chin in [me.hisher] [me.face] face." sock.pop_ih()
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)))
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)))