123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- module.exports = class MidasBot {
- constructor() {
- this.id = 1;
- this.name = "MidasBot";
- this.description = "The immortal Midas.";
- this.type = "mobile";
- this.roomId = "Void1";
- this.idleDelay = 30000;
- this.filename = "midasbot.js";
- this.lastIdle = 0;
- this.keywords = ["midas", "midasbot"];
- 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_reset(time) {
- 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;
- }
- mud_tick(time) {
- if(time >= this.lastIdle) {
- this.mud_reset(time);
- }
- 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;
- }
- }
- mud_addMemory(section, newMemory) {
- if(!this.memory.hasOwnProperty(section)) {
- this.memory[section] = [];
- }
- if(!this.mud_checkMemory(section, newMemory)) {
- this.memory[section].push(newMemory);
- }
- }
- mud_checkMemory(section, memoryToCheck) {
- if(this.memory.hasOwnProperty(section)) {
- if(this.memory[section].indexOf(memoryToCheck) != -1) {
- return true;
- }
- }
- return false;
- }
- mud_getName() {
- return "{mobile}" + this.name + "{/mobile}";
- }
- mud_getDescription() {
- return this.description;
- }
- wait(room, mobile, input) {
- this.waitTime = parseInt(input.join(" "));
- return true;
- }
- follow(room, mobile, input) {
- this.followTarget = input.join(" ");
- }
- };
|