shrineluck.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. mud_getName() {
  36. return this.name;
  37. }
  38. mud_getDescription() {
  39. return this.description;
  40. }
  41. look(room, mobile, input) {
  42. switch(input[0]) {
  43. case "debug":
  44. console.log(admin, builder);
  45. return true;
  46. case "door":
  47. 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.");
  48. return true;
  49. case "house":
  50. case "home":
  51. 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}.");
  52. return true;
  53. case "shrine":
  54. case "luck":
  55. 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.");
  56. return true;
  57. case "candle":
  58. case "candles":
  59. libs.Output.toMobile(mobile.id, "The yellow beeswax candles stand tall, having only recently been replaced and lit.");
  60. return true;
  61. case "incense":
  62. libs.Output.toMobile(mobile.id, "Smoke curls upwards from the sticks of incense, their tips glowing orange.");
  63. return true;
  64. case "statue":
  65. case "statuette":
  66. 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.");
  67. return true;
  68. case "stones":
  69. if(!this.stoneIsMissing) {
  70. 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?");
  71. this.stoneIsMissing = true;
  72. } else {
  73. 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}.");
  74. }
  75. return true;
  76. case "hole":
  77. if(this.stoneIsMissing) {
  78. if(!this.keyIsFound) {
  79. libs.Output.toMobile(mobile.id, "Looking in the small hole left by the stone, you find an unassuming key tucked inside.");
  80. world.mud_addItemToRoom("PhandalinShrineLuck", builder.mud_spawnItem("UnassumingKey").id);
  81. this.keyIsFound = true;
  82. } else {
  83. libs.Output.toMobile(mobile.id, "It looks like someone has stolen one of the stones from the edge of the shrine.");
  84. }
  85. return true;
  86. }
  87. }
  88. }
  89. unlock(room, mobile, input) {
  90. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  91. var hasKey = false;
  92. for(var i = 0; i < mobile.items.length; i++) {
  93. if(session.items[mobile.items[i]].constructor.name == "UnassumingKey") {
  94. hasKey = true;
  95. }
  96. }
  97. if(this.homeIsLocked && !this.homeIsOpen && hasKey) {
  98. libs.Output.toMobile(mobile.id, "You unlock the door.");
  99. libs.Output.toRoom(room.id, mobile.name + " unlocks the door.", mobile);
  100. this.homeIsLocked = false;
  101. return true;
  102. } else if(!this.homeIsLocked) {
  103. libs.Output.toMobile(mobile.id, "The door is already unlocked.");
  104. return true;
  105. } else if(!hasKey) {
  106. libs.Output.toMobile(mobile.id, "You don't have a key that fits.");
  107. return true;
  108. }
  109. }
  110. }
  111. open(room, mobile, input) {
  112. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  113. if(!this.homeIsOpen && !this.homeIsLocked) {
  114. libs.Output.toMobile(mobile.id, "You open the door.");
  115. libs.Output.toRoom(room.id, mobile.name + " opens the door.", mobile);
  116. this.homeIsOpen = true;
  117. if(this.roomExits.indexOf("enter") == -1) {
  118. this.roomExits.push("enter");
  119. }
  120. this.description = this.openDoorDescription;
  121. return true;
  122. } else if(!this.homeIsOpen && this.homeIsLocked) {
  123. libs.Output.toMobile(mobile.id, "The door is locked.");
  124. return true;
  125. } else if(this.homeIsOpen) {
  126. libs.Output.toMobile(mobile.id, "The door is already open.");
  127. return true;
  128. }
  129. }
  130. }
  131. lock(room, mobile, input) {
  132. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  133. var hasKey = false;
  134. for(var i = 0; i < mobile.items.length; i++) {
  135. if(session.items[mobile.items[i]].constructor.name == "UnassumingKey") {
  136. hasKey = true;
  137. }
  138. }
  139. if(!this.homeIsLocked && !this.homeIsOpen && hasKey) {
  140. libs.Output.toMobile(mobile.id, "You lock the door.");
  141. libs.Output.toRoom(room.id, mobile.name + " locks the door.", mobile);
  142. this.homeIsLocked = true;
  143. return true;
  144. } else if(!this.homeIsLocked && this.homeIsOpen && hasKey) {
  145. libs.Output.toMobile(mobile.id, "You close and lock the door.");
  146. libs.Output.toRoom(room.id, mobile.name + " closes and locks the door.", mobile);
  147. this.homeIsLocked = true;
  148. this.homeIsOpen = false;
  149. this.roomExits.splice(this.roomExits.indexOf("enter"), 1);
  150. return true;
  151. } else if(this.homeIsLocked && !this.homeIsOpen) {
  152. libs.Output.toMobile(mobile.id, "The door is already locked.");
  153. return true;
  154. } else if(!this.hasKey) {
  155. libs.Output.toMobile(mobile.id, "You don't have the key to this door.");
  156. return true;
  157. }
  158. }
  159. }
  160. close(room, mobile, input) {
  161. if(["door", "home", "north"].indexOf(input[0]) != -1) {
  162. if(this.homeIsOpen) {
  163. libs.Output.toMobile(mobile.id, "You close the door.");
  164. libs.Output.toRoom(room.id, mobile.name + " closes the door.", mobile);
  165. this.homeIsOpen = false;
  166. this.roomExits.splice(this.roomExits.indexOf("enter"), 1);
  167. this.description = this.defaultDescription;
  168. return true;
  169. } else if(!this.homeIsOpen) {
  170. libs.Output.toMobile(mobile.id, "The door is already closed.");
  171. return true;
  172. }
  173. }
  174. }
  175. take(room, mobile, input) {
  176. if(["stone", "flagstone"].indexOf(input[0]) != -1) {
  177. if(!this.stoneIsMissing) {
  178. libs.Output.toMobile(mobile.id, "You find a loose flagstone and steal it!");
  179. libs.Output.toRoom(room.id, mobile.name + " shifts a flagstone loose and steals it.\n", mobile);
  180. this.stoneIsMissing = true;
  181. world.mud_addItemToMobile(mobile.id, builder.mud_spawnItem("RuinFlagstone").id);
  182. return true;
  183. } else {
  184. libs.Output.toMobile(mobile.id, "There are no loose stones.");
  185. return true;
  186. }
  187. }
  188. }
  189. enter(room, mobile, input) {
  190. if(this.homeIsLocked && !this.homeIsOpen) {
  191. libs.Output.toMobile(mobile.id, "The door to the small home is closed and locked.");
  192. libs.Output.toRoom(room.id, mobile.name + " tries to open the door but fails.", mobile);
  193. return true;
  194. } else if(!this.homeIsLocked && !this.homeIsOpen) {
  195. libs.Output.toMobile(mobile.id, "The door is not open.");
  196. return true;
  197. } else if(!this.homeIsLocked && this.homeIsOpen) {
  198. world.mud_moveMobile(mobile.id, this.id, "PhandalinGaraeleHouse", "enters the house", "enters");
  199. return true;
  200. }
  201. }
  202. north(room, mobile, input) {
  203. return this.enter(room, mobile, input);
  204. }
  205. south(room, mobile, input) {
  206. world.mud_moveMobile(mobile.id, this.id, "PhandalinTownSquare", "leaves south", "arrives from the north");
  207. return true;
  208. }
  209. };