module.exports = class Observation { help(room, mobile, input) { var topic = input.join(" ").trim(); switch(topic) { case "look": libs.Output.toMobile(mobile.id, "Look is the most important command in a MUD. It is the first thing you should do when trying to learn about something."); libs.Output.toMobile(mobile.id, "* look - shows you the name and description of the room you are in."); libs.Output.toMobile(mobile.id, "* look at [something] - can give you detailed descriptions of item in the room, other players or NPCs, and even descriptive elements around you."); libs.Output.toMobile(mobile.id, "In the case where there are multiple of the same item or NPC in the room, you can be specific."); libs.Output.toMobile(mobile.id, "* look at [number].[something] - for example, to look at the 3rd goblin in the room, you can type look 3.goblin"); return true; case "inventory": libs.Output.toMobile(mobile.id, "As you collect items, you will need a way to check what you're carrying."); libs.Output.toMobile(mobile.id, "* inventory - Display a list of all the items you are currently holding."); libs.Output.toMobile(mobile.id, "aliases: i, inv"); return true; case "who": libs.Output.toMobile(mobile.id, "To see a list of all the players currently logged in."); libs.Output.toMobile(mobile.id, "* who - Display a list of all the active players."); return true; } } look(room, mobile, input) { if (input[0] == "at") { input.shift(); } if(this.mud_lookAt(room, mobile, input)) { return true; } if(input.length == 0) { return this.mud_lookRoom(room, mobile, input); } libs.Output.toMobile(mobile.id, "There isn't anything to see."); return true; } examine(room, mobile, input) { return this.look(room, mobile, input); } mud_lookRoom(room, mobile, input) { libs.Output.toMobile(mobile.id, room.mud_getName()); libs.Output.toMobile(mobile.id, room.mud_getDescription()); this.exits(room, mobile, input); room.mobiles.forEach(function(mobileId, index, array) { var otherMobile = session.mobiles[mobileId]; if(mobile.id != otherMobile.id) { libs.Output.toMobile(mobile.id, otherMobile.mud_getName()); } }); room.items.forEach(function(itemId, index, array) { var otherItem = session.items[itemId]; libs.Output.toMobile(mobile.id, otherItem.mud_getName()); }); return true; } mud_lookAt(room, mobile, input) { var inventoryItem = libs.Utilities.getSpecific(input.join(" "), mobile.items, session.items); if(inventoryItem != null) { libs.Output.toMobile(mobile.id, inventoryItem.mud_getDescription()); return true; } var roomMobile = libs.Utilities.getSpecific(input.join(" "), room.mobiles, session.mobiles); if(roomMobile != null) { libs.Output.toMobile(mobile.id, roomMobile.mud_getDescription()); if(roomMobile.itemSlots != null) { for(var index in roomMobile.itemSlots) { var item = world.mud_getItem(roomMobile.itemSlots[index]); if(item != null) { libs.Output.toMobile(mobile.id, item.mud_getName()); } } } return true; } var roomItem = libs.Utilities.getSpecific(input.join(" "), room.items, session.items); if(roomItem != null) { libs.Output.toMobile(mobile.id, roomItem.mud_getDescription()); return true; } } exits(room, mobile, input) { if(typeof room.exits == 'function') { return room.exits(room, mobile, input); } if(room.roomExits.length == 0) { libs.Output.toMobile(mobile.id, "There are no visible exits."); return true; } libs.Output.toMobile(mobile.id, "Visible exits are " + room.roomExits.join(", ")); return true; } who(room, mobile, input) { var count = 0; for(var playerId in session.players) { count++; } var message = "There "; message += count > 1 ? "are" : "is"; message += " " + count + " "; message += count > 1 ? "players" : "player"; message += " currently online."; libs.Output.toMobile(mobile.id, message); for(var playerId in session.players) { var player = session.players[playerId]; libs.Output.toMobile(mobile.id, "{"+player.type+"}"+ player.name + "{/"+player.type+"} " + player.title); } return true; } inventory(room, mobile, input) { if(mobile.account <= 0) { libs.Output.toMobile(mobile.id, "You don't have any money."); } else { libs.Output.toMobile(mobile.id, "You have "+mobile.account+" coins."); } if(mobile.items.length <= 0) { libs.Output.toMobile(mobile.id, "You are not carrying anything."); return true; } for(var index in mobile.items) { var otherItem = world.mud_getItem(mobile.items[index]); libs.Output.toMobile(mobile.id, otherItem.mud_getName()); } return true; } i(room, mobile, input) { return this.inventory(room, mobile, input); } mud_getErrorMessage() { return "You blink as things seem {error}fuzzy{/error} for a split-second."; } }