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 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 spawnPlayer( player ): """ Spawn the player in the map. """ room = random.sample(world.maps.World.roomsList, 1)[0] # Uncomment below to force spawn in a certain room room = "544" player.room = room world.maps.World.mapGrid[room].players[player.name] = player player.status = PLAYING sendToRoomNotPlayer( player, "{0}{1} appears in a flash!{2}".format(BLUE, player, WHITE) ) tellWorld( player, None, "{0} has entered the arena!".format(player.name) ) displayRoom(player, player.room)
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)