module.exports = class MidasBot { constructor() { this.id = 1; this.name = "Midas"; this.description = "The immortal Midas."; this.type = "mobile"; this.roomId = "Void1"; this.idleDelay = 30000; this.filename = "midasbot.js"; this.lastIdle = 0; this.keywords = ["midas"]; this.items = []; this.commandQueue = []; this.waitTime = 0; this.query = ""; } mud_sendMessage(source, message) { var cleanMessage = message.trim(); if(source != this && source != null) { if(libs.Conversation.basicDecency(source, cleanMessage, this)) { return; } if(cleanMessage.indexOf("yes") != -1) { if(this.query == "follow") { this.addCommand(this, "say Yea, ok."); this.addCommand(this, "follow " + source.name); } this.query = ""; return; } if(cleanMessage.indexOf("no") != -1) { //this.addCommand(this, "say You want me to follow you?"); this.query = ""; return; } if(cleanMessage.indexOf("follow") != -1) { this.addCommand(this, "say You want me to follow you?"); this.query = "follow"; return; } } /*if(libs.conversation.followsOrders(source, cleanMessage, this)) { return; }*/ } mud_addCommand(source, message) { this.commandQueue.push(message); } mud_tick(time) { if(time >= this.lastIdle) { var idleMessages = [ "emote wonders about a programming problem.", "" ]; var randomIdle = idleMessages[parseInt(Math.random() * idleMessages.length)]; this.mud_addCommand(this, randomIdle); this.lastIdle = time + this.idleDelay; } if(this.waitTime > 0) { this.waitTime--; } if(this.commandQueue.length > 0 && this.waitTime <= 0) { world.mud_handleInput(this.roomId, this.id, this.commandQueue.shift().split(" ")); this.lastIdle = time + this.idleDelay; this.waitTime = 0; } } wait(room, mobile, input) { this.waitTime = parseInt(input.join(" ")); return true; } follow(room, mobile, input) { this.followTarget = input.join(" "); } 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."; } };