Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def char_gen_hook(info):
    '''Put a socket into the character generation menu when character generation
       hooks are called.
    '''
    sock, = hooks.parse_info(info)
    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")
    sock.push_ih(cg_finish_handler, cg_finish_prompt)
    sock.push_ih(cg_race_handler, cg_race_prompt)
    sock.push_ih(cg_sex_handler, cg_sex_prompt)
    sock.push_ih(cg_name_handler, cg_name_prompt)
Ejemplo n.º 6
0
def char_gen_hook(info):
    '''Put a socket into the character generation menu when character generation
       hooks are called.
    '''
    sock, = hooks.parse_info(info)
    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")
    sock.push_ih(cg_finish_handler, cg_finish_prompt)
    sock.push_ih(cg_race_handler, cg_race_prompt)
    sock.push_ih(cg_sex_handler, cg_sex_prompt)
    sock.push_ih(cg_name_handler, cg_name_prompt)
Ejemplo n.º 7
0
def equipment_look_hook(info):
    """displays a character\'s equipment when looked at"""
    tgt, ch = hooks.parse_info(info)

    if ch != tgt:
        gndr = tgt.heshe
        act = "is"
    else:
        gndr = "You"
        act = "are"

    if len(tgt.eq) > 0:
        ch.send("\n" + gndr + " " + act + " wearing:")
        show_equipment(ch, tgt)
Ejemplo n.º 8
0
def dns_check_event(owner, void, info):
    '''After a socket connects, monitor their hostname until dns lookup is
       complete. Then, put the socket into the account handler.
    '''
    sock, = hooks.parse_info(info)
    if sock != None and sock.can_use:
        sock.send(" Lookup complete.")
        sock.send("================================================================================")
        sock.send(mud.get_greeting())
        sock.pop_ih()
        sock.bust_prompt()
        # mud.log_string("new connection from " + sock.hostname)
    else:
        event.start_event(None, 0.2, dns_check_event, None, info)
Ejemplo n.º 9
0
def equipment_look_hook(info):
    '''displays a character\'s equipment when looked at'''
    tgt, ch = hooks.parse_info(info)

    if ch != tgt:
        gndr = tgt.heshe
        act = "is"
    else:
        gndr = "You"
        act = "are"

    if len(tgt.eq) > 0:
        ch.send("\n" + gndr + " " + act + " wearing:")
        show_equipment(ch, tgt)
Ejemplo n.º 10
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("")

    '''
Ejemplo n.º 11
0
def char_gen_hook(info):
    '''Put a socket into the character generation menu when character generation
       hooks are called.
    '''
    sock, = hooks.parse_info(info)
    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")
    sock.push_ih(cg_finish_handler, cg_finish_prompt)
    sock.push_ih(cg_height_handler, cg_height_prompt)
    sock.push_ih(cg_chin_handler, cg_chin_prompt)
    sock.push_ih(cg_lips_handler, cg_lips_prompt)
    sock.push_ih(cg_nose_handler, cg_nose_prompt)
    sock.push_ih(cg_face_handler, cg_face_prompt)
    sock.push_ih(cg_hair_texture_handler, cg_hair_texture_prompt)
    sock.push_ih(cg_hair_length_handler, cg_hair_length_prompt)
    sock.push_ih(cg_hair_color_handler, cg_hair_color_prompt)
    sock.push_ih(cg_eye_color_handler, cg_eye_color_prompt)
    sock.push_ih(cg_complexion_handler, cg_complexion_prompt)
    sock.push_ih(cg_body_handler, cg_body_prompt)
    sock.push_ih(cg_race_handler, cg_race_prompt)
    sock.push_ih(cg_sex_handler, cg_sex_prompt)
    sock.push_ih(cg_name_handler, cg_name_prompt)
Ejemplo n.º 12
0
def char_gen_hook(info):
    '''Put a socket into the character generation menu when character generation
       hooks are called.
    '''
    sock, = hooks.parse_info(info)
    sock.push_ih(mudsys.handle_cmd_input, mudsys.show_prompt, "playing")
    sock.push_ih(cg_finish_handler, cg_finish_prompt)
    sock.push_ih(cg_height_handler, cg_height_prompt)
    sock.push_ih(cg_chin_handler, cg_chin_prompt)
    sock.push_ih(cg_lips_handler, cg_lips_prompt)
    sock.push_ih(cg_nose_handler, cg_nose_prompt)
    sock.push_ih(cg_face_handler, cg_face_prompt)
    sock.push_ih(cg_hair_texture_handler, cg_hair_texture_prompt)
    sock.push_ih(cg_hair_length_handler, cg_hair_length_prompt)
    sock.push_ih(cg_hair_color_handler, cg_hair_color_prompt)
    sock.push_ih(cg_eye_color_handler, cg_eye_color_prompt)
    sock.push_ih(cg_complexion_handler, cg_complexion_prompt)
    sock.push_ih(cg_body_handler, cg_body_prompt)
    sock.push_ih(cg_race_handler, cg_race_prompt)
    sock.push_ih(cg_sex_handler, cg_sex_prompt)
    sock.push_ih(cg_name_handler, cg_name_prompt)
Ejemplo n.º 13
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)))
Ejemplo n.º 14
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)))
Ejemplo n.º 15
0
def process_colour_hook(info):
    """When outbound text is being processed, find colour codes and replace them
       by the proper colour escape sequences."""
    sock,  = hooks.parse_info(info)
    buf    = sock.outbound_text
    newbuf = []

    # go through our outbound text and process all of the colour codes
    i = 0
    while i < len(buf):
        if buf[i] == base_colour_marker and i + 1 < len(buf):
            i = i + 1
            char  = buf[i]

            # upper case is bright, lower case is dark
            shade = cLIGHT
            if char == char.lower():
                shade = cDARK

            # 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)
Ejemplo n.º 16
0
def process_colour_hook(info):
    """When outbound text is being processed, find colour codes and replace them
       by the proper colour escape sequences."""
    sock, = hooks.parse_info(info)
    buf = sock.outbound_text
    newbuf = []

    # go through our outbound text and process all of the colour codes
    i = 0
    while i < len(buf):
        if buf[i] == base_colour_marker and i + 1 < len(buf):
            i = i + 1
            char = buf[i]

            # upper case is bright, lower case is dark
            shade = cLIGHT
            if char == char.lower():
                shade = cDARK

            # 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)
Ejemplo n.º 17
0
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")
Ejemplo n.º 18
0
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)
Ejemplo n.º 19
0
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)
Ejemplo n.º 20
0
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)
Ejemplo n.º 21
0
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)