def move(player, direction): """ Moves the character from one room to the next. """ curRoom = world.maps.World.mapGrid[player.room] door = curRoom.dirs[direction] roomid = world.maps.World.doors[door].getExitRoom(curRoom.id) newRoom = world.maps.World.mapGrid[roomid] brokesneak = False if player.getAttr(SNEAKING) and not utils.gameutils.stealthRoll(player): player.setAttr(SNEAKING, False) sendToRoomNotPlayer(player, "{0}You notice {1} sneaking out to the {2}.".format(LRED, player, DIRS[direction])) sendToPlayer(player, "{0}You make a sound".format(LRED)) brokesneak = True elif not player.getAttr(SNEAKING): sendToRoomNotPlayer( player, "{0} left to the {1}.".format(player, DIRS[direction])) del curRoom.players[player.name] newRoom.players[player.name] = player player.room = newRoom.id if brokesneak: sendToRoomNotPlayer(player, "{0}You notice {1} sneaking into the room from the {2}.".format(LRED, player, DIRS[OPPOSITEDIRS[direction]])) elif not player.getAttr(SNEAKING): sendToRoomNotPlayer(player, "{0} entered from the {1}.".format(player, DIRS[OPPOSITEDIRS[direction]])) displayRoom(player, player.room) player.stats[MOVING] = False
def rest(player): """ Set player in resting state. """ combat.functions.endCombat(player) sendToPlayer( player, "You stop to rest." ) sendToRoomNotPlayer( player, "{0} stops to rest.".format(player.name) ) player.stats[RESTING] = True player.statLine()
def adminDisplayRoom(player, room): """ Displays helpful info about rooms and doors for correcting mistakes in maps """ curRoom = world.maps.World.mapGrid[room] exitstr = '' sendToPlayer( player, "{0}{1} - (Room #: {2})".format(LCYAN, curRoom.name, room) ) items = curRoom.getItems() if items: sendToPlayer( player, "{0}You notice: {1}".format(LMAGENTA, items) ) playersinroom = curRoom.whosInRoom(player) if playersinroom is not None: sendToPlayer( player, "{0}Also here:{1} {2}".format(GREEN, LMAGENTA, playersinroom) ) for x in range(NORTH, DOWN + 1): if curRoom.dirs[x]: if exitstr == '': exitstr += DIRS[x] + '(' + str(curRoom.dirs[x]) + ')' else: exitstr += ", {0}({1})".format(DIRS[x], curRoom.dirs[x]) if exitstr == "": exitstr = "NONE." else: exitstr += "." sendToPlayer( player, "{0}Obvious exits: {1}{2}".format(GREEN, exitstr, WHITE) )
def movePlayer(player, direction): """ Moves player from one room to another. """ # If player died before the move occured, do nothing if player.status == PURGATORY: return player.stats[RESTING]= False if player.stats[MOVING] is True: sendToPlayer( player, "You are already moving, slow down!" ) return if player.stats[HELD]: player.stats[MOVING] = False sendToPlayer( player, "You cannot move!" ) curRoom = world.maps.World.mapGrid[player.room] # Run into the wall/ceiling/floor, if no door if not curRoom.dirs[direction]: if direction is DOWN: sendToPlayer(player, "You run into the floor!" ) sendToRoomNotPlayer(player, "{0} ran into the floor!".format(player)) elif direction is UP: sendToPlayer( player, "You run into the ceiling!" ) sendToRoomNotPlayer(player, "{0} ran into the ceiling!".format(player)) else: sendToPlayer(player, "You run into the {0} wall!".format(DIRS[direction])) sendToRoomNotPlayer(player, "{0} ran into the {1} wall!".format(player, DIRS[direction])) else: if player.getAttr(SLOWED): moverate = SLOWMOVERATE else: moverate = MOVERATE player.stats[MOVING] = True if player.getAttr(SNEAKING): sendToPlayer(player, "Sneaking...") reactor.callLater(moverate, move, player, direction) return player.setAttr(SNEAKING, False)
def displayRoom(player, room): """ Display the room """ if player.getAttr(ADMIN) is True: adminDisplayRoom(player, room) return curRoom = world.maps.World.mapGrid[room] if player.stats[BLIND]: sendToPlayer( player, "{0}You are blind.".format(WHITE) ) return if player.stats[VISION] < curRoom.light: sendToPlayer( player, "{0}You cannot see anything, it's too dark.".format(WHITE) ) return sendToPlayer( player, "{0}{1}".format(LCYAN, curRoom.name) ) items = curRoom.getItems() if items: sendToPlayer( player, "{0}You notice: {1}".format(LMAGENTA, items) ) playersinroom = curRoom.whosInRoom(player) if playersinroom is not None: sendToPlayer( player, "{0}Also here:{1} {2}".format(GREEN, LMAGENTA, playersinroom) ) sendToPlayer( player, "{0}Obvious exits: {1}{2}".format(GREEN, curRoom.getExits(), WHITE) )