module.exports = class Interaction { help(room, mobile, input) { var topic = input.join(" ").trim(); switch(topic) { case "get": libs.Output.toMobile(mobile.id, "Sometimes you will come across an item you can take for yourself."); libs.Output.toMobile(mobile.id, "* get [item] - if it's possible, you will take that item and store it in your inventory."); libs.Output.toMobile(mobile.id, "In the case where there are multiple of the same item in the room, you can be specific."); libs.Output.toMobile(mobile.id, "* get [number].[item] - if there were 3 sticks in a room and you wanted the 3rd one, you could type get 3.stick"); return true; case "drop": libs.Output.toMobile(mobile.id, "If you are holding an item that you no longer want, you can drop it in the room."); libs.Output.toMobile(mobile.id, "* drop [item] - drop the item in the current room"); libs.Output.toMobile(mobile.id, "In the case where there are multiple of the same item in your inventory, you can be specific."); libs.Output.toMobile(mobile.id, "* drop [number].[item] - if there were 3 sticks in your inventory and you wanted drop drop the 3rd one, you could type drop 3.stick"); return true; case "give": libs.Output.toMobile(mobile.id, "Sometimes you will come across an item you can take for yourself."); libs.Output.toMobile(mobile.id, "* give [item] to [npc/player] - if it's possible, you will take that item and store it in your inventory."); libs.Output.toMobile(mobile.id, "In the case where there are multiple of the same item or NPC, you can be specific."); libs.Output.toMobile(mobile.id, "* give [number].[item] to [number].[npc/player] - To give the second stick to the third goblin, type give 2.stick to 3.goblin"); return true; } } get(room, mobile, input) { var objIndex = 0; var objOffsetCounter = 0; if(input.join(" ").indexOf(".") != -1) { var counterString = input.join(" ").split(".") objIndex = parseInt(counterString[0]) - 1; input = counterString[1].split(" "); } objOffsetCounter = objIndex; var itemKey = input.join(" "); var roomItem = libs.Utilities.getSpecific(itemKey, room.items, session.items); if(roomItem != null) { mobile.items.push(roomItem.id); libs.Output.toMobile(mobile.id, "You pick up " + roomItem.name + "."); libs.Output.toRoom(room.id, mobile.name + " picks up " + roomItem.name + ".", mobile); room.items.splice(room.items.indexOf(roomItem.id), 1); return true; } libs.Output.toMobile(mobile.id, "That is not here."); return true; } drop(room, mobile, input) { var itemKey = input.join(" "); var inventoryItem = libs.Utilities.getSpecific(itemKey, mobile.items, session.items); if(inventoryItem != null) { room.items.push(inventoryItem.id); libs.Output.toMobile(mobile.id, "You drop " + inventoryItem.name + "."); libs.Output.toRoom(room.id, mobile.name + " drops " + inventoryItem.name + ".", mobile); mobile.items.splice(mobile.items.indexOf(inventoryItem.id), 1); return true; } libs.Output.toMobile(mobile.id, "You don't have " + itemKey + "."); return true; } give(room, mobile, input) { var giveString = input.join(" ").split(" to "); var itemKey = giveString[0].trim(); var mobKey = giveString[1].trim(); var itemToGive = null; var inventoryItem = libs.Utilities.getSpecific(itemKey, mobile.items, session.items); if(inventoryItem != null) { itemToGive = inventoryItem; } if(itemToGive == null) { libs.Output.toMobile(mobile.id, "You don't seem to have '"+itemKey+"'."); return true; } var mobileIndex = 0; var mobileOffsetCounter = 0; if(mobKey.indexOf(".") != -1) { var counterString = mobKey.split(".") mobileIndex = parseInt(counterString[0]) - 1; mobKey = counterString[1]; } mobileOffsetCounter = mobileIndex; var mobileToReceive = null; var roomMobile = libs.Utilities.getSpecific(mobKey, room.mobiles, session.mobiles); if(roomMobile != null) { mobileToReceive = roomMobile; } if(mobileToReceive == null) { libs.Output.toMobile(mobile.id, "You cannot give that to '"+mobKey+"'."); return true; } world.mud_removeItemFromMobile(mobile.id, itemToGive.id); world.mud_addItemToMobile(mobileToReceive.id, itemToGive.id); itemToGive.heldBy = mobileToReceive.id; libs.Output.toMobile(mobile.id, "You give " + itemToGive.name + " to " + mobileToReceive.name + "."); libs.Output.toMobile(mobileToReceive.id, mobile.name + " gives you " +itemToGive.name + "."); libs.Output.toRoom(room.id, mobile.name + " gives " + itemToGive.name + " to " + mobileToReceive.name + ".", [mobile, mobileToReceive]); return true; } pray(room, mobile, input) { var prayInput = input.join(" "); var god = null; if(prayInput != null) { prayInput = prayInput.trim().split("to"); if(prayInput[1] != null) { god = prayInput[1].trim(); } else { god = prayInput.join(" ").trim(); } } if(god != null && god != "") { var godName = "an unknown deity"; switch(god) { case "tymora": godName = "Tymora, the goddess of Luck"; break; } libs.Output.toMobile(mobile.id, "You say a quick prayer to "+godName+".", mobile); libs.Output.toRoom(room.id, mobile.name + " whispers a quiet prayer to "+godName+".", mobile); return true; } libs.Output.toMobile(mobile.id, "You say a quick prayer.", mobile); libs.Output.toRoom(room.id, mobile.name + " whispers a quiet prayer.", mobile); return true; } mud_getErrorMessage() { return "Your fingers briefly {error}flicker{/error} out of existance."; } }