linkpearl.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. module.exports = class Linkpearl {
  2. constructor() {
  3. this.id = 0;
  4. this.name = "a small pearl";
  5. this.description = "A small opalescent pearl.";
  6. this.type = "item";
  7. this.keywords = ["pearl", "linkpearl"];
  8. this.resetDelay = 12000000;
  9. this.itemExpires = 0;
  10. this.filename = "linkpearl.js";
  11. this.isWorn = false;
  12. this.belongsTo = 0;
  13. }
  14. mud_reset(time) {
  15. this.itemExpires = time + this.resetDelay;
  16. }
  17. mud_tick(time) {
  18. if(time >= this.itemExpires) {
  19. this.mud_reset(time);
  20. }
  21. }
  22. mud_getName() {
  23. var dispName = "{item}" + this.name + "{/item}";
  24. if(this.isWorn) {
  25. dispName += " (worn)";
  26. }
  27. return dispName;
  28. }
  29. mud_getDescription() {
  30. return this.description;
  31. }
  32. remove(room, mobile, input) {
  33. if(this.keywords.indexOf(input.join(" ")) != -1) {
  34. libs.Output.toMobile(mobile.id, "You pull the linkpearl out of your ear.", mobile);
  35. libs.Output.toRoom(mobile.roomId, mobile.name + " removes a linkpearl from their ear.", mobile);
  36. this.isWorn = false;
  37. return true;
  38. }
  39. }
  40. wear(room, mobile, input) {
  41. if(this.keywords.indexOf(input.join(" ")) != -1) {
  42. libs.Output.toMobile(mobile.id, "You slip the linkpearl into your ear.", mobile);
  43. libs.Output.toRoom(mobile.roomId, mobile.name + " puts a linkpearl in their ear.", mobile);
  44. this.isWorn = true;
  45. return true;
  46. }
  47. }
  48. mud_saveItem() {
  49. var dataToSave = {};
  50. dataToSave.belongsTo = this.belongsTo;
  51. return dataToSave;
  52. }
  53. mud_loadItem(itemData) {
  54. for(var dataIndex in itemData) {
  55. if(this.hasOwnProperty(dataIndex)) {
  56. this[dataIndex] = itemData[dataIndex];
  57. }
  58. }
  59. }
  60. }