ruinflagstone.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. module.exports = class RuinFlagstone {
  2. constructor() {
  3. this.id = 0;
  4. this.name = "a large flagstone";
  5. this.description = "A heavy broken brick stone. It was probably previously part of a building that fell into ruin.";
  6. this.type = "item";
  7. this.keywords = ["stone", "flagstone"];
  8. this.resetDelay = 12000000;
  9. this.itemExpires = 0;
  10. this.filename = "ruinflagstone.js";
  11. this.isMarked = false;
  12. this.markText = "";
  13. }
  14. mud_reset(time) {
  15. this.isMarked = false;
  16. this.markText = "";
  17. this.description = this.defaultDescription + this.lastSentence;
  18. this.name = this.defaultName;
  19. this.itemExpires = time + this.resetDelay;
  20. }
  21. mud_tick(time) {
  22. if(time >= this.itemExpires) {
  23. this.mud_reset(time);
  24. }
  25. }
  26. mud_getName() {
  27. if(this.isMarked) {
  28. return "{item}a stone marked with '" + this.markText + "'{/item}";
  29. }
  30. return "{item}a large flagstone{/item}";
  31. }
  32. mud_getDescription() {
  33. var desc = this.defaultDescription;
  34. if(this.isMarked) {
  35. desc += " Someone has drawn '" + this.markText + "' on it.";
  36. } else {
  37. desc += " It's large, flat sides would be perfect for a {hint}mark{/hint} or two.";
  38. }
  39. return desc;
  40. }
  41. mark(room, mobile, input) {
  42. if(input[0] == null) {
  43. return false;
  44. }
  45. var inventoryItem = libs.Utilities.getSpecific(input[0], mobile.items, session.items);
  46. if(inventoryItem != null) {
  47. if(this != inventoryItem) {
  48. return false;
  49. }
  50. var desiredMark = input.slice(1, input.length).join(" ");
  51. if(desiredMark == null || desiredMark == "") {
  52. libs.Output.toMobile(mobile.id, "What mark would you like to put on it?");
  53. return true;
  54. }
  55. var desiredMark = desiredMark.trim();
  56. this.markText = desiredMark.substring(0, 2);
  57. this.isMarked = true;
  58. var output = "You mark the stone with '" + this.markText + "'";
  59. if(desiredMark.length != this.markText.length) {
  60. output += " but can't fit the rest";
  61. }
  62. libs.Output.toMobile(mobile.id, output + ".");
  63. return true;
  64. }
  65. }
  66. mud_saveItem() {
  67. var dataToSave = {};
  68. dataToSave.isMarked = this.isMarked;
  69. dataToSave.markText = this.markText;
  70. dataToSave.itemExpires = this.itemExpires;
  71. return dataToSave;
  72. }
  73. mud_loadItem(itemData) {
  74. for(var dataIndex in itemData) {
  75. if(this.hasOwnProperty(dataIndex)) {
  76. this[dataIndex] = itemData[dataIndex];
  77. }
  78. }
  79. }
  80. }