Exemple #1
0
def do_hunt(peer, rgs, target, success):
    _.send_to_room_except(peer.account.player.get_name() + " sniffs the air.",
                          peer.account.player.get_room(), [peer])
    myroom = peer.account.player.get_room()
    destroom = target.get_room()
    if myroom == destroom:
        peer.account.player.send(target.get_name() + " is HERE!")
        return
    fringe = []
    for i, j in myroom.exits.items():
        if not j is None:
            fringe.append((get_room_by_vnum(j), i))
    visited = [myroom]

    for room in fringe:
        if room[0] is None:
            #print("NONE")
            pass
        elif room[0] in visited:
            #print("VISITED")
            pass
        elif room[0] is destroom:
            #print("DESTINATION FOUND: ", _.get_dir_string(room[1]))
            peer.account.player.send(target.get_name() + " is " +
                                     _.get_dir_string(room[1]) + " of you.")
            return
        else:
            for i, j in room[0].exits.items():
                if not j is None and not get_room_by_vnum(j) in visited:
                    fringe.append((get_room_by_vnum(j), room[1]))
        visited.append(room[0])
def do_move(char, direction):
    temp_new_room_vnum = char.player.get_room().exits[direction]
    if temp_new_room_vnum is None:
        _.send_to_char(char, "You can't go that way.\n\r")
        return
    elif temp_new_room_vnum not in [x.vnum for x in _.rooms]:
        _.send_to_char(char, "Illegal room. Contact an immortal.\n\r")
        return

    dir_string = _.get_dir_string(direction)

    if "sneak" not in char.player.get_skills():
        _.send_to_room_except(
            "%s leaves %s.\n\r" % (char.player.stats["name"], dir_string),
            char.player.get_room(), [
                char,
            ])
    char.player.stats["room"] = temp_new_room_vnum
    do_look(char, "")
    if "sneak" not in char.player.get_skills():
        _.send_to_room_except(
            "%s has arrived.\n\r" % char.player.stats["name"],
            char.player.get_room(), [
                char,
            ])
    return
def do_look(char, args):
    temp_room = char.player.get_room()

    if not char.player.can_see(None):
        _.send_to_char(char, "You can't see anything!\n\r")
        return

    #  Name and description
    buf = temp_room.get_name() + "\n\r\n\r"\
    + temp_room.get_desc() + "\n\r\n\rExits: [ "

    #  Exits
    noexit = True  # -Rework-
    for d in [x for x in sorted(temp_room.exits) if temp_room.exits[x] is not None]:
        buf += _.get_dir_string(d) + " "
        noexit = False

    if noexit:
        buf += "none "

    buf += "]\n\r\n\r"

    #  Items

    for r in temp_room.items:
        buf += "%s\n\r" % r.get_desc()
    if len(temp_room.items) > 0:
        buf += "\n\r"

    #  Characters

    other_players = [c.player for c in _.peers if c is not char and c.player.get_room() == char.player.get_room()
                                           and not c.linkdead and c.state == _.STATE_ONLINE]
    other_mobs = [m for m in _.mobiles if m.get_peer() is None and m.get_room() == char.player.get_room()]
    others = other_mobs + other_players

    for c in others:
        pos_string = ""
        pos_tag = ""
        if c.get_position() == _.POS_FIGHTING:
            pos_tag = ", fighting %s" % c.fighting.get_name() if c.fighting is not None else "null"
        elif c.get_position() == _.POS_RESTING:
            pos_string = "resting "
        elif c.get_position() == _.POS_SLEEPING:
            pos_string = "sleeping "
        buf += "%s%s is %shere%s.\n\r" % ("<LINKDEAD> " if c.get_peer() is not None and c.get_peer().linkdead else "",
                                          c.stats["name"].capitalize(), pos_string, pos_tag)
    if len(others) > 0:
        buf += "\n\r"

    _.send_to_char(char, buf)
Exemple #4
0
    def display(self, peer):
        
        #  Name and description
        buf = self.get_name() + "\n\r\n\r"\
        + self.get_desc() + "\n\r\n\rExits: [ "
        
        #  Exits
        noexit = True  # -Rework- (should do_peer see exits?)
        for d in [x for x in sorted(self.exits) if self.exits[x] is not None]:
            buf += _.get_dir_string(d) + " "
            noexit = False

        if noexit:
            buf += "none "

        buf += "]\n\r\n\r"

        #  Items

        for r in self.items:
            buf += "%s\n\r" % r.get_desc()
        if len(self.items) > 0:
            buf += "\n\r"

        #  Characters

        other_players = [c.account.player for c in _.peers if c is not peer and c.account.player.get_room() == self
                                               and not c.linkdead and c.game_state == _.STATE_ONLINE]
        other_mobs = [m for m in _.mobiles if m.peer is None and m.get_room() == self]
        others = other_mobs + other_players

        for c in others:
            pos_string = ""
            pos_tag = ""
            if c.get_position() == _.POS_FIGHTING:
                pos_tag = ", fighting %s" % c.fighting.get_name() if c.fighting is not None else "null"
            elif c.get_position() == _.POS_RESTING:
                pos_string = "resting "
            elif c.get_position() == _.POS_SLEEPING:
                pos_string = "sleeping "
            buf += "%s%s is %shere%s.\n\r" % ("<LINKDEAD> " if c.peer is not None and c.peer.linkdead else "",
                                              c.stats["name"].capitalize(), pos_string, pos_tag)
        if len(others) > 0:
            buf += "\n\r"

        return buf
def do_move(char, direction):
    temp_new_room_vnum = char.player.get_room().exits[direction]
    if temp_new_room_vnum is None:
        _.send_to_char(char, "You can't go that way.\n\r")
        return
    elif temp_new_room_vnum not in [x.vnum for x in _.rooms]:
        _.send_to_char(char, "Illegal room. Contact an immortal.\n\r")
        return

    dir_string = _.get_dir_string(direction)

    if "sneak" not in char.player.get_skills():
        _.send_to_room_except("%s leaves %s.\n\r" % (char.player.stats["name"], dir_string), char.player.get_room(), [char,])
    char.player.stats["room"] = temp_new_room_vnum
    do_look(char, "")
    if "sneak" not in char.player.get_skills():
        _.send_to_room_except("%s has arrived.\n\r" % char.player.stats["name"], char.player.get_room(), [char,])
    return
def do_look(char, args):
    temp_room = char.player.get_room()

    if not char.player.can_see(None):
        _.send_to_char(char, "You can't see anything!\n\r")
        return

    #  Name and description
    buf = temp_room.get_name() + "\n\r\n\r"\
    + temp_room.get_desc() + "\n\r\n\rExits: [ "

    #  Exits
    noexit = True  # -Rework-
    for d in [
            x for x in sorted(temp_room.exits)
            if temp_room.exits[x] is not None
    ]:
        buf += _.get_dir_string(d) + " "
        noexit = False

    if noexit:
        buf += "none "

    buf += "]\n\r\n\r"

    #  Items

    for r in temp_room.items:
        buf += "%s\n\r" % r.get_desc()
    if len(temp_room.items) > 0:
        buf += "\n\r"

    #  Characters

    other_players = [
        c.player for c in _.peers
        if c is not char and c.player.get_room() == char.player.get_room()
        and not c.linkdead and c.state == _.STATE_ONLINE
    ]
    other_mobs = [
        m for m in _.mobiles
        if m.get_peer() is None and m.get_room() == char.player.get_room()
    ]
    others = other_mobs + other_players

    for c in others:
        pos_string = ""
        pos_tag = ""
        if c.get_position() == _.POS_FIGHTING:
            pos_tag = ", fighting %s" % c.fighting.get_name(
            ) if c.fighting is not None else "null"
        elif c.get_position() == _.POS_RESTING:
            pos_string = "resting "
        elif c.get_position() == _.POS_SLEEPING:
            pos_string = "sleeping "
        buf += "%s%s is %shere%s.\n\r" % (
            "<LINKDEAD> " if c.get_peer() is not None and c.get_peer().linkdead
            else "", c.stats["name"].capitalize(), pos_string, pos_tag)
    if len(others) > 0:
        buf += "\n\r"

    _.send_to_char(char, buf)