shrineluck.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. module.exports = class PhandalinShrineLuck {
  2. constructor() {
  3. this.id = this.constructor.name;
  4. this.name = "The Shrine of Luck";
  5. this.description = "A rough semicircle wall surrounds a {hint}shrine{/hint} to Tymora, the goddess of Luck. The shrine is well-tended, and the {hint}incense{/hint} and {hint}candles{/hint} here appear to have been set recently. There is an unassuming {hint}house{/hint} to the north.";
  6. this.openDoorDescription = "A rough semicircle wall surrounds a {hint}shrine{/hint} to Tymora, the goddess of Luck. The shrine is well-tended, and the {hint}incense{/hint} and {hint}candles{/hint} here appear to have been set recently. There is an unassuming {hint}house{/hint} to the north with the {hint}door{/hint} standing open.";
  7. this.defaultDescription = "A rough semicircle wall surrounds a {hint}shrine{/hint} to Tymora, the goddess of Luck. The shrine is well-tended, and the {hint}incense{/hint} and {hint}candles{/hint} here appear to have been set recently. There is an unassuming {hint}house{/hint} to the north.";
  8. this.filename = "phandalin/shrineluck.js";
  9. this.type = "room";
  10. this.items = [];
  11. this.mobiles = [];
  12. this.roomExpires = 0;
  13. this.resetDelay = 12000000;
  14. this.roomExits = ["south"];
  15. this.homeIsLocked = true;
  16. this.homeIsOpen = false;
  17. this.stoneIsMissing = false;
  18. this.keyIsFound = false;
  19. }
  20. mud_reset(time) {
  21. libs.Output.toRoom(this.id, "A coil of smoke rises from a stick of {hint}incense{/hint}.");
  22. this.roomExpires = time + this.resetDelay;
  23. this.homeIsLocked = true;
  24. this.homeIsOpen = false;
  25. this.stoneIsMissing = false;
  26. this.description = this.defaultDescription;
  27. this.keyIsFound = false;
  28. this.roomExits = ["south"];
  29. }
  30. mud_tick(time) {
  31. if(time >= this.roomExpires) {
  32. this.mud_reset(time);
  33. }
  34. }
  35. look(room, mobile, input) {
  36. switch(input[0]) {
  37. case "debug":
  38. console.log(admin, builder);
  39. return true;
  40. case "door":
  41. libs.Output.toMobile(mobile.id, "The door to the small house is made of strong oak, with a small keyhole and a stylized door knob.");
  42. return true;
  43. case "house":
  44. case "home":
  45. libs.Output.toMobile(mobile.id, "The house is small, but looks cozy and tidy. You wonder if the person who lives there also takes care of the {hint}shrine{/hint}.");
  46. return true;
  47. case "shrine":
  48. case "luck":
  49. libs.Output.toMobile(mobile.id, "A small {hint}statuette{/hint} of Tymora placed on a stone altar is surrounded by lit candles and incense. The altar is protected by a semicircle of {hint}stones{/hint} that look like they were salvaged from the nearby ruins.");
  50. return true;
  51. case "candle":
  52. case "candles":
  53. libs.Output.toMobile(mobile.id, "The yellow beeswax candles stand tall, having only recently been replaced and lit.");
  54. return true;
  55. case "incense":
  56. libs.Output.toMobile(mobile.id, "Smoke curls upwards from the sticks of incense, their tips glowing orange.");
  57. return true;
  58. case "statue":
  59. case "statuette":
  60. libs.Output.toMobile(mobile.id, "The small statue of Tymora stands with her arms outstretched. On her left hand a swallow perches, and a coinpurse is clutched in her right.");
  61. return true;
  62. case "stones":
  63. if(!this.stoneIsMissing) {
  64. libs.Output.toMobile(mobile.id, "The stones are identical to the other broken stones from the ruined buildings just outside of town. One of the flagstones seems to have been moved recently. Perhaps you could {hint}take{/hint} it?");
  65. this.stoneIsMissing = true;
  66. } else {
  67. libs.Output.toMobile(mobile.id, "The stones are identical to the other broken stones from the ruined buildings just outside of town. One of the flagstones is missing, leaving a small {hint}hole{/hint}.");
  68. }
  69. return true;
  70. case "hole":
  71. if(this.stoneIsMissing) {
  72. if(!this.keyIsFound) {
  73. libs.Output.toMobile(mobile.id, "Looking in the small hole left by the stone, you find an unassuming key tucked inside.");
  74. world.mud_addItemToRoom("PhandalinShrineLuck", builder.mud_spawnItem("UnassumingKey").id);
  75. this.keyIsFound = true;
  76. } else {
  77. libs.Output.toMobile(mobile.id, "It looks like someone has stolen one of the stones from the edge of the shrine.");
  78. }
  79. return true;
  80. }
  81. }
  82. }
  83. unlock(room, mobile, input) {
  84. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  85. var hasKey = false;
  86. for(var i = 0; i < mobile.items.length; i++) {
  87. if(session.items[mobile.items[i]].constructor.name == "UnassumingKey") {
  88. hasKey = true;
  89. }
  90. }
  91. if(this.homeIsLocked && !this.homeIsOpen && hasKey) {
  92. libs.Output.toMobile(mobile.id, "You unlock the door.");
  93. libs.Output.toRoom(room.id, mobile.name + " unlocks the door.", mobile);
  94. this.homeIsLocked = false;
  95. return true;
  96. } else if(!this.homeIsLocked) {
  97. libs.Output.toMobile(mobile.id, "The door is already unlocked.");
  98. return true;
  99. } else if(!hasKey) {
  100. libs.Output.toMobile(mobile.id, "You don't have a key that fits.");
  101. return true;
  102. }
  103. }
  104. }
  105. open(room, mobile, input) {
  106. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  107. if(!this.homeIsOpen && !this.homeIsLocked) {
  108. libs.Output.toMobile(mobile.id, "You open the door.");
  109. libs.Output.toRoom(room.id, mobile.name + " opens the door.", mobile);
  110. this.homeIsOpen = true;
  111. if(this.roomExits.indexOf("enter") == -1) {
  112. this.roomExits.push("enter");
  113. }
  114. this.description = this.openDoorDescription;
  115. return true;
  116. } else if(!this.homeIsOpen && this.homeIsLocked) {
  117. libs.Output.toMobile(mobile.id, "The door is locked.");
  118. return true;
  119. } else if(this.homeIsOpen) {
  120. libs.Output.toMobile(mobile.id, "The door is already open.");
  121. return true;
  122. }
  123. }
  124. }
  125. lock(room, mobile, input) {
  126. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  127. var hasKey = false;
  128. for(var i = 0; i < mobile.items.length; i++) {
  129. if(session.items[mobile.items[i]].constructor.name == "UnassumingKey") {
  130. hasKey = true;
  131. }
  132. }
  133. if(!this.homeIsLocked && !this.homeIsOpen && hasKey) {
  134. libs.Output.toMobile(mobile.id, "You lock the door.");
  135. libs.Output.toRoom(room.id, mobile.name + " locks the door.", mobile);
  136. this.homeIsLocked = true;
  137. return true;
  138. } else if(!this.homeIsLocked && this.homeIsOpen && hasKey) {
  139. libs.Output.toMobile(mobile.id, "You close and lock the door.");
  140. libs.Output.toRoom(room.id, mobile.name + " closes and locks the door.", mobile);
  141. this.homeIsLocked = true;
  142. this.homeIsOpen = false;
  143. this.roomExits.splice(this.roomExits.indexOf("enter"), 1);
  144. return true;
  145. } else if(this.homeIsLocked && !this.homeIsOpen) {
  146. libs.Output.toMobile(mobile.id, "The door is already locked.");
  147. return true;
  148. } else if(!this.hasKey) {
  149. libs.Output.toMobile(mobile.id, "You don't have the key to this door.");
  150. return true;
  151. }
  152. }
  153. }
  154. close(room, mobile, input) {
  155. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  156. if(this.homeIsOpen) {
  157. libs.Output.toMobile(mobile.id, "You close the door.");
  158. libs.Output.toRoom(room.id, mobile.name + " closes the door.", mobile);
  159. this.homeIsOpen = false;
  160. this.roomExits.splice(this.roomExits.indexOf("enter"), 1);
  161. this.description = this.defaultDescription;
  162. return true;
  163. } else if(!this.homeIsOpen) {
  164. libs.Output.toMobile(mobile.id, "The door is already closed.");
  165. return true;
  166. }
  167. }
  168. }
  169. take(room, mobile, input) {
  170. if(["stone", "flagstone"].indexOf(input[0]) != -1) {
  171. if(!this.stoneIsMissing) {
  172. libs.Output.toMobile(mobile.id, "You find a loose flagstone and steal it!");
  173. libs.Output.toRoom(room.id, mobile.name + " shifts a flagstone loose and steals it.\n", mobile);
  174. this.stoneIsMissing = true;
  175. world.mud_addItemToMobile(mobile.id, builder.mud_spawnItem("RuinFlagstone").id);
  176. return true;
  177. } else {
  178. libs.Output.toMobile(mobile.id, "There are no loose stones.");
  179. return true;
  180. }
  181. }
  182. }
  183. enter(room, mobile, input) {
  184. if(this.homeIsLocked && !this.homeIsOpen) {
  185. libs.Output.toMobile(mobile.id, "The door to the small home is closed and locked.");
  186. libs.Output.toRoom(room.id, mobile.name + " tries to open the door but fails.", mobile);
  187. return true;
  188. } else if(!this.homeIsLocked && !this.homeIsOpen) {
  189. libs.Output.toMobile(mobile.id, "The door is not open.");
  190. return true;
  191. } else if(!this.homeIsLocked && this.homeIsOpen) {
  192. world.mud_moveMobile(mobile.id, this.id, "PhandalinGaraeleHouse", "enters the house", "walks in");
  193. return true;
  194. }
  195. }
  196. north(room, mobile, input) {
  197. return this.enter(room, mobile, input);
  198. }
  199. south(room, mobile, input) {
  200. world.mud_moveMobile(mobile.id, this.id, "PhandalinTownSquare", "walks away south", "walks in from the north");
  201. return true;
  202. }
  203. };