1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- module.exports = class Book {
- constructor() {
- this.id = 0;
- this.name = "a leather-bound book";
- this.defaultName = "a leather-bound book";
- this.description = "A beautiful old book bound in aged brown leather.";
- this.defaultDescription = "A beautiful old book bound in aged brown leather.";
- this.type = "item";
- this.keywords = ["book"];
- this.resetDelay = 12000000;
- this.mud_reset(0);
- this.filename = "book.js";
- this.heldBy = 0;
- }
- mud_reset(time) {
- this.itemExpires = time + this.resetDelay;
- }
- mud_tick(time) {
- if(time >= this.itemExpires) {
- this.mud_reset(time);
- }
- }
- read(room, mobile, input) {
- if(this.heldBy == mobile.id) {
- libs.Output.toMobile(mobile.id, "Flipping briefly through the book, you see the pages are all blank.", mobile);
- return true;
- } else if(this.heldBy != mobile.id) {
- libs.Output.toMobile(mobile.id, "You would have to {hint}hold{/hint} it first.", mobile);
- return true;
- }
- }
- drop(room, mobile, input) {
- if(this.keywords.indexOf(input.join(" ")) != -1) {
- this.heldBy = 0;
- this.description = this.defaultDescription;
- this.name = this.defaultName;
- }
- return false;
- }
- hold(room, mobile, input) {
- if(this.keywords.indexOf(input.join(" ")) != -1) {
- libs.Output.toMobile(mobile.id, "You hold "+this.name+" in your hand.", mobile);
- libs.Output.toRoom(mobile.roomId, mobile.name + " holds " + this.name + ".", mobile);
- this.heldBy = mobile.id;
- this.description = this.defaultDescription;
- this.name = this.defaultName + "(held)";
- return true;
- }
- }
- }
|