module.exports = class FriendlyMobile { constructor() { this.id = 1; this.name = "A friendly mobile"; this.description = "An exceedingly average, incredibly friendly mobile. Why not say hi?"; this.type = "mobile"; this.roomId = 1; this.idleDelay = 30000; this.filename = "friendlymobile.js"; this.lastIdle = 0; this.keywords = ["mobile", "friendly mobile"]; this.items = []; this.commandQueue = []; this.memory = {}; } mud_init() { world.mud_addMobileToRoom("PhandalinTownGreen", this.id); } mud_sendMessage(source, message) { message = message.replace(/\{.*?\}/g, ""); var cleanMessage = message.trim(); console.log(this.name + " sees '" + cleanMessage + "'"); if(source == this) { return; } if(cleanMessage.indexOf("shout") != -1) { return; } if(libs.Conversation.basicDecency(source, cleanMessage, this)) { return; } if(cleanMessage.indexOf("banana") != -1) { this.mud_addCommand(this, "say I'm sorry, I don't have any bananas."); return; } if(libs.Conversation.followsOrders(source, cleanMessage, this)) { return; } } mud_addMemory(section, newMemory) { if(!this.memory.hasOwnProperty(section)) { this.memory[section] = []; } this.memory[section].push(memory); } mud_checkMemory(section, memoryToCheck) { if(this.memory.hasOwnProperty(section)) { if(this.memory[section].hasOwnProperty(memory)) { return true; } } return false; } mud_addCommand(source, message) { this.commandQueue.push(message); } mud_tick(time) { if(time >= this.lastIdle) { var idleMessages = ["emote grins at nothing in particular.", "emote looks around, beaming at everyone.", "emote smiles.", "emote looks at you and nods knowingly."]; var randomIdle = idleMessages[parseInt(Math.random() * idleMessages.length)]; this.mud_addCommand(this, randomIdle); this.lastIdle = time + this.idleDelay; } if(this.commandQueue.length > 0 ) { world.mud_handleInput(this.roomId, this.id, this.commandQueue.shift().split(" ")); this.lastIdle = time + this.idleDelay; } } mud_enterRoom(direction) { if(direction != null) { return this.name + " " + direction + "."; } return this.name + " enters the room."; } mud_leaveRoom(direction) { if(direction != null) { return this.name + " " + direction + "."; } return this.name + " leaves."; } };