123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- module.exports = class PhandalinGaraeleHouse {
- constructor() {
- this.id = this.constructor.name;
- this.name = "Sister Garaele's Home";
- this.description = "This small home is decorated with many trinkets of Tymora. There is a door to the south with a small {hint}table{/hint} next to it.";
- this.filename = "phandalin/garaelehouse.js";
- this.type = "room";
- this.items = [];
- this.mobiles = [];
- this.roomExits = [];
- this.roomExpires = 0;
- this.resetDelay = 12000000;
- this.roomExits = ["leave"];
- this.homeIsOpen = true;
- this.homeIsLocked = false;
- }
- mud_reset(time) {
- libs.Output.toRoom(this.id, "The house creaks.");
- this.roomExpires = time + this.resetDelay;
- }
- mud_tick(time) {
- if(time >= this.roomExpires) {
- this.mud_reset(time);
- }
- }
- look(room, mobile, input) {
- switch(input[0]) {
- case "table":
- libs.Output.toMobile(mobile.id, "The small table has a few things on it but nothing of interest.");
- return true;
- }
- }
- leave(room, mobile, input) {
- if(this.homeIsLocked && !this.homeIsOpen) {
- libs.Output.toMobile(mobile.id, "The door out is closed and locked.");
- libs.Output.toRoom(room.id, mobile.name + " tries to open the door but fails.", mobile);
- return true;
- } else if(!this.homeIsLocked && !this.homeIsOpen) {
- libs.Output.toMobile(mobile.id, "The door is not open.");
- return true;
- } else if(!this.homeIsLocked && this.homeIsOpen) {
- world.mud_moveMobile(mobile.id, this.id, "PhandalinShrineLuck", "leaves", "leaves the house");
- return true;
- }
- }
- south(room, mobile, input) {
- return this.leave(room, mobile, input);
- }
- unlock(room, mobile, input) {
- if(["door", "south"].indexOf(input[0]) != -1) {
- var hasKey = false;
- for(var i = 0; i < mobile.items.length; i++) {
- if(session.items[mobile.items[i]].constructor.name == "UnassumingKey") {
- hasKey = true;
- }
- }
- if(this.homeIsLocked && !this.homeIsOpen && hasKey) {
- libs.Output.toMobile(mobile.id, "You unlock the door.");
- libs.Output.toRoom(room.id, mobile.name + " unlocks the door.", mobile);
- this.homeIsLocked = false;
- return true;
- } else if(!this.homeIsLocked) {
- libs.Output.toMobile(mobile.id, "The door is already unlocked.");
- return true;
- } else if(!hasKey) {
- libs.Output.toMobile(mobile.id, "You don't have a key that fits.");
- return true;
- }
- }
- }
- open(room, mobile, input) {
- if(["door", "south"].indexOf(input[0]) != -1) {
- if(!this.homeIsOpen && !this.homeIsLocked) {
- libs.Output.toMobile(mobile.id, "You open the door.");
- libs.Output.toRoom(room.id, mobile.name + " opens the door.", mobile);
- this.homeIsOpen = true;
- this.roomExits.push("leave");
- return true;
- } else if(!this.homeIsOpen && this.homeIsLocked) {
- libs.Output.toMobile(mobile.id, "The door is locked.");
- return true;
- } else if(this.homeIsOpen) {
- libs.Output.toMobile(mobile.id, "The door is already open.");
- return true;
- }
- }
- }
- lock(room, mobile, input) {
- if(["door", "south"].indexOf(input[0]) != -1) {
- var hasKey = false;
- for(var i = 0; i < mobile.items.length; i++) {
- if(session.items[mobile.items[i]].constructor.name == "UnassumingKey") {
- hasKey = true;
- }
- }
- if(!this.homeIsLocked && !this.homeIsOpen && hasKey) {
- libs.Output.toMobile(mobile.id, "You lock the door.");
- libs.Output.toRoom(room.id, mobile.name + " locks the door.", mobile);
- this.homeIsLocked = true;
- return true;
- } else if(!this.homeIsLocked && this.homeIsOpen && hasKey) {
- libs.Output.toMobile(mobile.id, "You close and lock the door.");
- libs.Output.toRoom(room.id, mobile.name + " closes and locks the door.", mobile);
- this.homeIsLocked = true;
- this.homeIsOpen = false;
- this.roomExits.splice(this.roomExits.indexOf("leave"), 1);
- return true;
- } else if(this.homeIsLocked && !this.homeIsOpen) {
- libs.Output.toMobile(mobile.id, "The door is already locked.");
- return true;
- } else if(!this.hasKey) {
- libs.Output.toMobile(mobile.id, "You don't have the key to this door.");
- return true;
- }
- }
- }
- close(room, mobile, input) {
- if(["door", "south"].indexOf(input[0]) != -1) {
- if(this.homeIsOpen) {
- libs.Output.toMobile(mobile.id, "You close the door.");
- libs.Output.toRoom(room.id, mobile.name + " closes the door.", mobile);
- this.homeIsOpen = false;
- this.roomExits.splice(this.roomExits.indexOf("leave"), 1);
- return true;
- } else if(!this.homeIsOpen) {
- libs.Output.toMobile(mobile.id, "The door is already closed.");
- return true;
- }
- }
- }
- };
|