linkpearl.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 = this.name;
  24. if(this.isWorn) {
  25. dispName += " (worn)";
  26. }
  27. return "{item}" + dispName + "{/item}";
  28. }
  29. remove(room, mobile, input) {
  30. if(this.keywords.indexOf(input.join(" ")) != -1) {
  31. libs.Output.toMobile(mobile.id, "You pull the linkpearl out of your ear.", mobile);
  32. libs.Output.toRoom(mobile.roomId, mobile.name + " removes a linkpearl from their ear.", mobile);
  33. this.isWorn = false;
  34. return true;
  35. }
  36. }
  37. wear(room, mobile, input) {
  38. if(this.keywords.indexOf(input.join(" ")) != -1) {
  39. libs.Output.toMobile(mobile.id, "You slip the linkpearl into your ear.", mobile);
  40. libs.Output.toRoom(mobile.roomId, mobile.name + " puts a linkpearl in their ear.", mobile);
  41. this.isWorn = true;
  42. return true;
  43. }
  44. }
  45. mud_saveItem() {
  46. var dataToSave = {};
  47. dataToSave.belongsTo = this.belongsTo;
  48. return dataToSave;
  49. }
  50. mud_loadItem(itemData) {
  51. for(var dataIndex in itemData) {
  52. if(this.hasOwnProperty(dataIndex)) {
  53. this[dataIndex] = itemData[dataIndex];
  54. }
  55. }
  56. }
  57. }