1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- module.exports = class RuinFlagstone {
- constructor() {
- this.id = 0;
- this.name = "a large flagstone";
- this.description = "A heavy broken brick stone. It was probably previously part of a building that fell into ruin.";
- this.type = "item";
- this.keywords = ["stone", "flagstone"];
- this.resetDelay = 12000000;
- this.itemExpires = 0;
- this.filename = "ruinflagstone.js";
- this.isMarked = false;
- this.markText = "";
- }
- mud_reset(time) {
- this.isMarked = false;
- this.markText = "";
- this.itemExpires = time + this.resetDelay;
- }
- mud_tick(time) {
- if(time >= this.itemExpires) {
- this.mud_reset(time);
- }
- }
- mud_getName() {
- if(this.isMarked) {
- return "{item}a stone marked with '" + this.markText + "'{/item}";
- }
- return "{item}a large flagstone{/item}";
- }
- mud_getDescription() {
- var desc = "A heavy broken brick stone. It was probably previously part of a building that fell into ruin.";
- if(this.isMarked) {
- desc += " Someone has drawn '" + this.markText + "' on it.";
- } else {
- desc += " It's large, flat sides would be perfect for a {hint}mark{/hint} or two.";
- }
- return desc;
- }
- mark(room, mobile, input) {
- if(input[0] == null) {
- return false;
- }
- var inventoryItem = libs.Utilities.getSpecific(input[0], mobile.items, session.items);
- if(inventoryItem != null) {
- if(this != inventoryItem) {
- return false;
- }
- var desiredMark = input.slice(1, input.length).join(" ");
- if(desiredMark == null || desiredMark == "") {
- libs.Output.toMobile(mobile.id, "What mark would you like to put on it?");
- return true;
- }
- var desiredMark = desiredMark.trim();
- this.markText = desiredMark.substring(0, 2);
- this.isMarked = true;
- var output = "You mark the stone with '" + this.markText + "'";
- if(desiredMark.length != this.markText.length) {
- output += " but can't fit the rest";
- }
- libs.Output.toMobile(mobile.id, output + ".");
- return true;
- }
- }
- mud_saveItem() {
- var dataToSave = {};
- dataToSave.isMarked = this.isMarked;
- dataToSave.markText = this.markText;
- dataToSave.itemExpires = this.itemExpires;
- return dataToSave;
- }
- mud_loadItem(itemData) {
- for(var dataIndex in itemData) {
- if(this.hasOwnProperty(dataIndex)) {
- this[dataIndex] = itemData[dataIndex];
- }
- }
- }
- }
|