12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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.description = this.defaultDescription + this.lastSentence;
- this.name = this.defaultName;
- 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 = this.defaultDescription;
- 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];
- }
- }
- }
- }
|