playermobile.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. module.exports = class PlayerMobile {
  2. constructor() {
  3. this.id = 0;
  4. this.login = null;
  5. this.name = "";
  6. this.description = "A player.";
  7. this.type = "mobile";
  8. this.roomId = "PhandalinTownGreen";
  9. this.filename = "playermobile.js";
  10. this.keywords = [];
  11. this.items = [];
  12. this.health = 100;
  13. this.maxHealth = 100;
  14. this.roles = [];
  15. this.memory = {};
  16. this.title = "the player";
  17. }
  18. mud_sendMessage(source, message) {
  19. this.login.sendMessage(message);
  20. }
  21. mud_addMemory(section, newMemory) {
  22. if(!this.memory.hasOwnProperty(section)) {
  23. this.memory[section] = [];
  24. }
  25. this.memory[section].push(memory);
  26. }
  27. mud_checkMemory(section, memoryToCheck) {
  28. if(this.memory.hasOwnProperty(section)) {
  29. if(this.memory[section].hasOwnProperty(memory)) {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. mud_tick(time) {
  36. if(this.health != this.maxHealth) {
  37. this.health++;
  38. this.hp();
  39. }
  40. }
  41. hp(room, mobile, input) {
  42. libs.Output.toMobile(mobile.id, "[HP: "+mobile.health+"/" +mobile.maxHealth+"]");
  43. return true;
  44. }
  45. mud_enterRoom(direction) {
  46. if(direction != null) {
  47. return this.name + " " + direction + ".";
  48. }
  49. return this.name + " enters the room.";
  50. }
  51. mud_leaveRoom(direction) {
  52. if(direction != null) {
  53. return this.name + " " + direction + ".";
  54. }
  55. return this.name + " leaves.";
  56. }
  57. quit(room, mobile, input) {
  58. this.login.logout();
  59. return true;
  60. }
  61. save(room, mobile, input) {
  62. libs.Output.toMobile(mobile.id, "Saving player information.");
  63. world.mud_playerSave(this);
  64. libs.Output.toMobile(mobile.id, "Saved successfully.");
  65. return true;
  66. }
  67. hint(room, mobile, input) {
  68. if(["on", "please"].indexOf(input[0]) != -1) {
  69. mobile.hintColor = "FgMagenta";
  70. libs.Output.toMobile(mobile.id, "Enabling hints.");
  71. return true;
  72. }
  73. if (["off"].indexOf(input[0]) != -1) {
  74. mobile.hintColor = "Reset";
  75. libs.Output.toMobile(mobile.id, "Disabling hints.");
  76. return true;
  77. }
  78. }
  79. setting(room, mobile, input) {
  80. }
  81. chpass(room, mobile, input) {
  82. var username = mobile.name.toLowerCase();
  83. mobile.password = world.mud_generateHash(username + input.join(" "));
  84. world.mud_playerSave(mobile);
  85. libs.Output.toMobile(mobile.id, "Password has been updated!");
  86. return true;
  87. }
  88. };