ruinflagstone.js 2.2 KB

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