towngreen.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. module.exports = class PhandalinTownGreen {
  2. constructor() {
  3. this.id = this.constructor.name;
  4. this.name = "Phandalin Town Green";
  5. this.description = "A lush green clearing, the {hint}grass{/hint} blowing in the warm summer breeze. The sun shines harshly on this shadeless hill, but the {hint}children{/hint} playing here do not seem to mind.";
  6. this.filename = "phandalin/towngreen.js";
  7. this.type = "room";
  8. this.items = [];
  9. this.mobiles = [];
  10. this.roomExpires = 0;
  11. this.resetDelay = 12000000;
  12. this.roomExits = ["south", "east"];
  13. }
  14. mud_reset(time) {
  15. libs.Output.toRoom(this.id, "A {hint}child{/hint} laughs as she plays with her friends.");
  16. this.roomExpires = time + this.resetDelay;
  17. }
  18. mud_tick(time) {
  19. if(time >= this.roomExpires) {
  20. this.mud_reset(time);
  21. }
  22. }
  23. mud_getName() {
  24. return this.name;
  25. }
  26. mud_getDescription() {
  27. return this.description;
  28. }
  29. look(room, mobile, input) {
  30. switch(input[0]) {
  31. case "grass":
  32. libs.Output.toMobile(mobile.id, "The grass is bright green and full of tiny leaf-like {hint}insects{/hint}, hopping about.");
  33. return true;
  34. case "child":
  35. case "children":
  36. libs.Output.toMobile(mobile.id, "A few children who live in the town play around you. Some are trying to catch {hint}insects{/hint} and others are chasing each other and screaming with joy.");
  37. return true;
  38. case "insect":
  39. case "grasshopper":
  40. case "insects":
  41. case "grasshoppers":
  42. libs.Output.toMobile(mobile.id, "Tiny and leaf-shaped, the grasshoppers are an important staple of summer.");
  43. return true;
  44. }
  45. }
  46. south(room, mobile, input) {
  47. world.mud_moveMobile(mobile.id, this.id, "PhandalinRoad1", "leaves south");
  48. return true;
  49. }
  50. east(room, mobile, input) {
  51. world.mud_moveMobile(mobile.id, this.id, "PhandalinTownSquare", "leaves east");
  52. return true;
  53. }
  54. catch(room, mobile, input) {
  55. switch(input[0]) {
  56. case "bug":
  57. case "insect":
  58. case "leafhopper":
  59. case "grasshopper":
  60. libs.Output.toMobile(mobile.id, "You spend a little time disturbing the grass with your hands, and manage to grab a leafhopper.");
  61. libs.Output.toRoom(room.id, mobile.name + " flops around in the grass and stands up grinning.", mobile);
  62. var grasshopper = builder.mud_spawnItem("Leafhopper");
  63. grasshopper.heldBy = mobile.id;
  64. world.mud_addItemToMobile(mobile.id, grasshopper.id);
  65. return true;
  66. }
  67. }
  68. };