crunch
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

436 строки
8.8 KiB

  1. "use strict";
  2. /*jshint browser: true*/
  3. /*jshint devel: true*/
  4. let NORTH = 0;
  5. let NORTH_EAST = 1;
  6. let EAST = 2;
  7. let SOUTH_EAST = 3;
  8. let SOUTH = 4;
  9. let SOUTH_WEST = 5;
  10. let WEST = 6;
  11. let NORTH_WEST = 7;
  12. let locations = {};
  13. let locationsSrc = [
  14. {
  15. "name": "Bedroom",
  16. "desc": "A bedroom. It has a bed in it.",
  17. "conn": [
  18. {
  19. "name": "Bathroom",
  20. "dir": EAST,
  21. "desc": "You step into your bathroom."
  22. },
  23. {
  24. "name": "Living Room",
  25. "dir": NORTH,
  26. "desc": "You walk into the living room."
  27. }
  28. ],
  29. "objs": [
  30. Bed,
  31. Journal,
  32. AnacondaTest,
  33. PowerUp
  34. ],
  35. },
  36. {
  37. "name": "Bathroom",
  38. "desc": "Your modest bathroom.",
  39. "conn": [
  40. {
  41. "name": "Bedroom",
  42. "dir": WEST,
  43. "desc": "You walk back into your bedroom."
  44. }
  45. ],
  46. "objs": [
  47. Toilet
  48. ]
  49. },
  50. {
  51. "name": "Living Room",
  52. "desc": "A bare living room",
  53. "conn": [
  54. {
  55. "name": "Lobby",
  56. "dir": NORTH,
  57. "desc": "You leave your apartment and head to the lobby."
  58. },
  59. {
  60. "name": "Bedroom",
  61. "dir": SOUTH,
  62. "desc": "You walk into your bedroom."
  63. }
  64. ],
  65. "objs": [
  66. TV,
  67. Phone
  68. ]
  69. },
  70. {
  71. "name": "North Street",
  72. "desc": "It's a street",
  73. "conn": [
  74. {
  75. "name": "Alley",
  76. "dir": WEST,
  77. "desc": "You wander into the dark alley"
  78. },
  79. {
  80. "name": "Lobby",
  81. "dir": EAST,
  82. "desc": "You step into your apartment's lobby"
  83. },
  84. {
  85. "name": "Crossroads",
  86. "dir": SOUTH,
  87. "desc": "You walk south"
  88. },
  89. {
  90. "name": "DANGER ZONE",
  91. "dir": NORTH,
  92. "desc": "You walk into the DANGER ZONE"
  93. }
  94. ],
  95. "objs": [
  96. Nerd
  97. ]
  98. },
  99. {
  100. "name": "Lobby",
  101. "desc": "The modest lobby of your modest apartment complex",
  102. "conn": [
  103. {
  104. "name": "North Street",
  105. "dir": WEST,
  106. "desc": "You walk out into the street"
  107. },
  108. {
  109. "name": "Living Room",
  110. "dir": SOUTH,
  111. "desc": "You walk back into your apartment"
  112. }
  113. ],
  114. "objs": [
  115. VendingMachine
  116. ]
  117. },
  118. {
  119. "name": "Alley",
  120. "desc": "A suspicious alley",
  121. "conn": [
  122. {
  123. "name": "North Street",
  124. "dir": EAST,
  125. "desc": "You hurry back into the open street."
  126. },
  127. {
  128. "name": "Seedy Bar",
  129. "dir": NORTH,
  130. "desc": "You step into the bar."
  131. },
  132. {
  133. "name": "Dark Alley",
  134. "dir": WEST,
  135. "desc": "You step into the darkness..."
  136. }
  137. ]
  138. },
  139. {
  140. "name": "Dark Alley",
  141. "desc": "A dark, claustrophobic alley",
  142. "conn": [
  143. {
  144. "name": "Alley",
  145. "dir": EAST,
  146. "desc": "You emerge from the darkness"
  147. }
  148. ],
  149. "hooks": [
  150. function() {
  151. if (player.prefs.prey && (player.prefs.vore.oral > 0 || player.prefs.vore.anal > 0))
  152. startCombat(new KuroLuxray());
  153. }
  154. ]
  155. },
  156. {
  157. "name": "Seedy Bar",
  158. "desc": "God this place is seedy",
  159. "conn": [
  160. {
  161. "name": "Alley",
  162. "dir": SOUTH,
  163. "desc": "You step out of the bar"
  164. }
  165. ],
  166. "objs": [
  167. PoojawaEncounter
  168. ]
  169. },
  170. {
  171. "name": "Crossroads",
  172. "desc": "Where the roads cross",
  173. "conn": [
  174. {
  175. "name": "North Street",
  176. "dir": NORTH,
  177. "desc": "You walk north"
  178. },
  179. {
  180. "name": "East Street",
  181. "dir": EAST,
  182. "desc": "You walk east"
  183. },
  184. {
  185. "name": "South Street",
  186. "dir": SOUTH,
  187. "desc": "You walk south"
  188. },
  189. {
  190. "name": "Corner Mart",
  191. "dir": SOUTH_EAST,
  192. "desc": "You walk into the convenience store"
  193. }
  194. ]
  195. },
  196. {
  197. "name": "East Street",
  198. "desc": "This street is in the east",
  199. "conn": [
  200. {
  201. "name": "Crossroads",
  202. "dir": WEST,
  203. "desc": "You walk to the crossroads"
  204. },
  205. {
  206. "name": "East Trail",
  207. "dir": EAST,
  208. "desc": "You head out on the road."
  209. }
  210. ]
  211. },
  212. {
  213. "name": "East Trail",
  214. "desc": "A trail from your hometown to lands beyond",
  215. "conn": [
  216. {
  217. "name": "East Street",
  218. "dir": WEST,
  219. "desc": "You walk back into town"
  220. },
  221. {
  222. "name": "Woods",
  223. "dir": NORTH,
  224. "desc": "You wander into the woods."
  225. },
  226. {
  227. "name": "Mountains",
  228. "dir": EAST,
  229. "desc": "You head up into the mountains, passing by a...noticeably stained sign reading \"WATCH OUT FOR HORNY DRAGONS\". Weird. You see a cave off in the distance, as well as some jagged cliffs and plateaus to explore."
  230. },
  231. {
  232. "name": "Woods",
  233. "dir": SOUTH,
  234. "desc": "You wander into the woods."
  235. },
  236. ]
  237. },
  238. {
  239. "name": "Woods",
  240. "desc": "A thick forest. It's easy to get lost here, but it's not too dangerous, at least.",
  241. "conn": [
  242. ],
  243. "objs": [
  244. ForestExplore,
  245. ],
  246. "hooks": [
  247. function() {
  248. currentRoom.flags.exit = false;
  249. }
  250. ]
  251. },
  252. {
  253. "name": "South Street",
  254. "desc": "This street is in the south",
  255. "conn": [
  256. {
  257. "name": "Crossroads",
  258. "dir": NORTH,
  259. "desc": "You walk to the crossroads"
  260. },
  261. {
  262. "name": "Nature Trail",
  263. "dir": SOUTH,
  264. "desc": "You head out into the woods"
  265. }
  266. ]
  267. },
  268. {
  269. "name": "Nature Trail",
  270. "desc": "A winding train cutting through a thick forest",
  271. "conn": [
  272. {
  273. "name": "South Street",
  274. "dir": NORTH,
  275. "desc": "You return to town."
  276. },
  277. {
  278. "name": "Wilderness",
  279. "dir": SOUTH,
  280. "desc": "You wander into the wilderness...and immediately get lost."
  281. }
  282. ],
  283. "objs": [
  284. NatureTrailExercise,
  285. GetaObj
  286. ]
  287. },
  288. {
  289. "name": "Wilderness",
  290. "desc": "Pretty spooky",
  291. "conn": [
  292. ],
  293. "objs": [
  294. WildernessExplore
  295. ]
  296. },
  297. {
  298. "name": "DANGER ZONE",
  299. "desc": "THE DANGER ZONE",
  300. "conn": [
  301. {
  302. "name": "North Street",
  303. "dir": SOUTH,
  304. "desc": "You walk out of the DANGER ZONE"
  305. },
  306. {
  307. "name": "SUPER DANGER ZONE",
  308. "dir": NORTH,
  309. "desc": "Getting eaten is fun!",
  310. }
  311. ],
  312. "hooks": [
  313. function() {
  314. startCombat(new Anthro());
  315. }
  316. ]
  317. },
  318. {
  319. "name": "SUPER DANGER ZONE",
  320. "desc": "Very dangerous",
  321. "conn": [
  322. {
  323. "name": "DANGER ZONE",
  324. "dir": SOUTH,
  325. "desc": "You hurriedly leave the SUPER DANGER ZONE"
  326. }
  327. ],
  328. "hooks": [
  329. function() {
  330. startCombat(new Fen());
  331. }
  332. ]
  333. },
  334. {
  335. "name": "Corner Mart",
  336. "desc": "A convenience store with a variety of snacks and supplies",
  337. "conn": [
  338. {
  339. "name": "Crossroads",
  340. "dir": NORTH_WEST,
  341. "desc": "You leave the store."
  342. }
  343. ]
  344. },
  345. {
  346. "name": "Mountains",
  347. "desc": "Steep, chilly slopes.",
  348. "conn": [
  349. {
  350. "name": "East Trail",
  351. "dir": WEST,
  352. "desc": "You clamber down from the mountains."
  353. }
  354. ],
  355. "objs": [
  356. MountainExplore
  357. ]
  358. }
  359. ];
  360. function Location(name="Nowhere",desc="Nada") {
  361. this.name = name;
  362. this.description = desc;
  363. this.exits = [null,null,null,null,null,null,null,null];
  364. this.exitDescs = [null,null,null,null,null,null,null,null];
  365. this.objects = [];
  366. this.hooks = [];
  367. this.conditions = [];
  368. this.flags = [];
  369. this.visit = function() {
  370. this.hooks.forEach(function (x) {
  371. x();
  372. });
  373. };
  374. }
  375. function opposite(direction) {
  376. return (direction + 4) % 8;
  377. }
  378. function connectLocations(loc1,loc2,dir,desc) {
  379. if (loc1.exits[dir] != null) {
  380. alert(loc1.name + " is already connected to " + loc1.exits[dir].name);
  381. return;
  382. } else {
  383. if (dir >= 0 && dir <= 7) {
  384. loc1.exits[dir] = loc2;
  385. loc1.exitDescs[dir] = desc;
  386. } else {
  387. alert("Invalid direction given when linking " + loc1.name + " and " + loc2.name + ": " + dir);
  388. }
  389. }
  390. }
  391. function createWorld() {
  392. for (let i = 0; i < locationsSrc.length; i++) {
  393. let src = locationsSrc[i];
  394. let location = new Location(src.name,src.desc);
  395. locations[src.name] = location;
  396. if (src.objs != undefined) {
  397. src.objs.forEach(function (obj) {
  398. location.objects.push(new obj());
  399. });
  400. }
  401. if (src.hooks != undefined) {
  402. src.hooks.forEach(function (hook) {
  403. location.hooks.push(hook);
  404. });
  405. }
  406. if (src.conditions != undefined) {
  407. src.conditions.forEach(function (cond) {
  408. location.conditions.push(cond);
  409. });
  410. }
  411. }
  412. for (let i = 0; i < locationsSrc.length; i++) {
  413. let src = locationsSrc[i];
  414. let from = locations[src.name];
  415. for (let j = 0; j < src.conn.length; j++) {
  416. let to = locations[src.conn[j].name];
  417. connectLocations(from, to, src.conn[j].dir, src.conn[j].desc);
  418. }
  419. }
  420. return locations;
  421. }