towngreen.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. look(room, mobile, input) {
  24. switch(input[0]) {
  25. case "grass":
  26. libs.Output.toMobile(mobile.id, "The grass is bright green and full of tiny leaf-like {hint}insects{/hint}, hopping about.");
  27. return true;
  28. case "child":
  29. case "children":
  30. 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.");
  31. return true;
  32. case "insect":
  33. case "grasshopper":
  34. case "insects":
  35. case "grasshoppers":
  36. libs.Output.toMobile(mobile.id, "Tiny and leaf-shaped, the grasshoppers are an important staple of summer.");
  37. return true;
  38. }
  39. }
  40. south(room, mobile, input) {
  41. world.mud_moveMobile(mobile.id, this.id, "PhandalinRoad1");
  42. return true;
  43. }
  44. east(room, mobile, input) {
  45. world.mud_moveMobile(mobile.id, this.id, "PhandalinTownSquare");
  46. return true;
  47. }
  48. catch(room, mobile, input) {
  49. switch(input[0]) {
  50. case "bug":
  51. case "insect":
  52. case "leafhopper":
  53. case "grasshopper":
  54. libs.Output.toMobile(mobile.id, "You spend a little time disturbing the grass with your hands, and manage to grab a leafhopper.");
  55. libs.Output.toRoom(room.id, mobile.name + " flops around in the grass and stands up grinning.", mobile);
  56. var grasshopper = builder.mud_spawnItem("Leafhopper");
  57. grasshopper.heldBy = mobile.id;
  58. world.mud_addItemToMobile(mobile.id, grasshopper.id);
  59. return true;
  60. }
  61. }
  62. };