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)))
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)))
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 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)))