# if obj.hasBit("currency"): if utils.is_keyword(obj.bits, "currency"): recv.worth += obj.worth mud.extract(obj) ################################################################################ # initialization ################################################################################ # install currency aux data and item types auxiliary.install("currency_data", CurrencyAuxData, "character, object") # add hooks hooks.add("get", get_currency_hook) hooks.add("give", give_currency_hook) # add our character and object properties mudsys.add_char_method("worth", property(__getWorth__, __setWorth__, doc="The character's accumulated wealth")) mudsys.add_obj_method("worth", property(__getWorth__, __setWorth__, doc="The object's value")) # items that have the currency bit will be transformed into worth when received mudsys.create_bit("obj_bits", "currency") # register default currency and denominations ## register_denomination("copper", "money", 1, shorthand="cp")
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("") ''' sock.push_ih(acct_wait_dns_handler, acct_wait_dns_prompt) sock.send("================================================================================") event.start_event(None, 0.2, dns_check_event, None, info) ''' def copyover_complete_hook(info): sock, = hooks.parse_info(info) sock.push_ih(acct_menu_handler, acct_main_menu) sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing") ################################################################################ # loading and unloading the module ################################################################################ hooks.add("receive_connection", account_handler_hook) hooks.add("copyover_complete", copyover_complete_hook) def __unload__(): '''removes the hooks for account handling''' hooks.remove("receive_connection", account_handler_hook) hooks.remove("copyover_complete", copyover_complete_hook)
# if it's a valid colour code, build it if base_colours.has_key(char.lower()): newbuf.append(colour_start + shade + ';' + \ base_colours[char.lower()] + 'm') # if it was an invalid code, ignore it else: newbuf.append(base_colour_marker) if not char == base_colour_marker: i = i - 1 else: newbuf.append(buf[i]) i = i + 1 # replace our outbound buffer with the processed text sock.outbound_text = ''.join(newbuf) ################################################################################ # initializing and unloading our hooks ################################################################################ hooks.add("process_outbound_text", process_colour_hook) hooks.add("process_outbound_prompt", process_colour_hook) def __unload__(): '''detaches our colour module from the game''' hooks.remove("process_outbound_text", process_colour_hook) hooks.remove("process_outbound_prompt", process_colour_hook)
# 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))) ################################################################################ # loading and unloading the module ################################################################################ hooks.add("create_character", char_gen_hook) hooks.add("create_guest", guest_gen_hook) def __unload__(): '''removes the hooks for character generation''' hooks.remove("create_character", char_gen_hook) hooks.remove("create_guest", guest_gen_hook)
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))) ################################################################################ # loading and unloading the module ################################################################################ hooks.add("create_character", char_gen_hook) hooks.add("create_guest", guest_gen_hook) def __unload__(): '''removes the hooks for character generation''' hooks.remove("create_character", char_gen_hook) hooks.remove("create_guest", guest_gen_hook)
def room_look_hook(info): """diplays info about the room contents""" room, ch = hooks.parse_info(info) list_room_exits(ch, room) list_room_contents(ch, room) def exit_look_hook(info): ex, ch = hooks.parse_info(info) if not ex.is_closed and ch.cansee(ex) and ex.dest != None: list_room_contents(ch, ex.dest) ################################################################################ # add our hooks ################################################################################ hooks.add("look_at_char", equipment_look_hook) hooks.add("look_at_room", room_look_hook) hooks.add("look_at_exit", exit_look_hook) ################################################################################ # unload procedure ################################################################################ def __unload__(): """things that need to be detached when the module is un/reloaded""" hooks.remove("look_at_char", equipment_look_hook) hooks.remove("look_at_room", room_look_hook) hooks.remove("look_at_exit", exit_look_hook)
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) ################################################################################ # initialization ################################################################################ # install currency aux data and item types auxiliary.install("currency_data", CurrencyAuxData, "character, object") # add hooks hooks.add("get", get_currency_hook) hooks.add("give", give_currency_hook) # add our character and object properties mudsys.add_char_method( "worth", property(__getWorth__, __setWorth__, doc="The character's accumulated wealth")) mudsys.add_obj_method( "worth", property(__getWorth__, __setWorth__, doc="The object's value")) # items that have the currency bit will be transformed into worth when received mudsys.create_bit("obj_bits", "currency") # register default currency and denominations
def room_look_hook(info): '''diplays info about the room contents''' room, ch = hooks.parse_info(info) list_room_exits(ch, room) list_room_contents(ch, room) def exit_look_hook(info): ex, ch = hooks.parse_info(info) if not ex.is_closed and ch.cansee(ex) and ex.dest != None: list_room_contents(ch, ex.dest) ################################################################################ # add our hooks ################################################################################ hooks.add("look_at_char", equipment_look_hook) hooks.add("look_at_room", room_look_hook) hooks.add("look_at_exit", exit_look_hook) ################################################################################ # unload procedure ################################################################################ def __unload__(): '''things that need to be detached when the module is un/reloaded''' hooks.remove("look_at_char", equipment_look_hook) hooks.remove("look_at_room", room_look_hook) hooks.remove("look_at_exit", exit_look_hook)