ruinflagstone.js 2.2 KB

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