crunch
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

983 linhas
28 KiB

  1. let world = null;
  2. let currentRoom = null;
  3. let currentDialog = null;
  4. let currentFoe = null;
  5. let dirButtons = [];
  6. let mode = "explore";
  7. let actions = [];
  8. let time = 9*60*60;
  9. let date = 1;
  10. let newline = " ";
  11. let player = new Player();
  12. let playerAttacks = [];
  13. let struggles = [];
  14. let killingBlow = null;
  15. let deaths = [];
  16. let respawnRoom;
  17. let noLog = false;
  18. let logPadLine = undefined;
  19. let MIDNIGHT = 0;
  20. let MORNING = 21600;
  21. let NOON = 43200;
  22. let EVENING = 64800;
  23. function toggleLog() {
  24. noLog = !noLog;
  25. if (noLog) {
  26. document.getElementById("log-button").innerHTML = "Log: Disabled";
  27. } else {
  28. document.getElementById("log-button").innerHTML = "Log: Enabled";
  29. }
  30. }
  31. function join(things) {
  32. if (things.length == 1) {
  33. return things[0].description("a");
  34. } else if (things.length == 2) {
  35. return things[0].description("a") + " and " + things[1].description("a");
  36. } else {
  37. let line = "";
  38. line = things.slice(0,-1).reduce((line, prey) => line + prey.description("a") + ", ", line);
  39. line += " and " + things[things.length-1].description("a");
  40. return line;
  41. }
  42. }
  43. function pickRandom(list) {
  44. return list[Math.floor(Math.random() * list.length)];
  45. }
  46. function pick(list, attacker, defender) {
  47. if (list.length == 0)
  48. return null;
  49. else {
  50. let sum = list.reduce((sum, choice) => choice.weight == undefined ? sum + 1 : sum + choice.weight(attacker, defender), 0);
  51. let target = Math.random() * sum;
  52. for (let i = 0; i < list.length; i++) {
  53. sum -= list[i].weight == undefined ? 1 : list[i].weight(attacker, defender);
  54. if (sum <= target) {
  55. return list[i];
  56. }
  57. }
  58. return list[list.length-1];
  59. }
  60. }
  61. function filterValid(options, attacker, defender) {
  62. let filtered = options.filter(option => option.conditions == undefined || option.conditions.reduce((result, test) => result && test(attacker, defender), true));
  63. return filtered.filter(option => option.requirements == undefined || option.requirements.reduce((result, test) => result && test(attacker, defender), true));
  64. }
  65. function filterPriority(options) {
  66. let max = options.reduce((max, option) => option.priority > max ? option.priority : max, -1000);
  67. return options.filter(option => option.priority == max);
  68. }
  69. function round(number, digits) {
  70. return Math.round(number * Math.pow(10,digits)) / Math.pow(10,digits);
  71. }
  72. function updateExploreCompass() {
  73. for (let i = 0; i < dirButtons.length; i++) {
  74. let button = dirButtons[i];
  75. button.classList.remove("active-button");
  76. button.classList.remove("inactive-button");
  77. button.classList.remove("disabled-button");
  78. if (currentRoom.exits[i] == null) {
  79. button.disabled = true;
  80. button.classList.add("inactive-button");
  81. button.innerHTML = "";
  82. } else {
  83. if (currentRoom.exits[i].conditions.reduce((result, test) => result && test(player.prefs), true)) {
  84. button.disabled = false;
  85. button.classList.add("active-button");
  86. button.innerHTML = currentRoom.exits[i].name;
  87. } else {
  88. button.disabled = true;
  89. button.classList.add("disabled-button");
  90. button.innerHTML = currentRoom.exits[i].name;
  91. }
  92. }
  93. }
  94. }
  95. function updateExploreActions() {
  96. updateActions();
  97. let actionButtons = document.querySelector("#actions");
  98. actionButtons.innerHTML = "";
  99. for (let i = 0; i < actions.length; i++) {
  100. let button = document.createElement("button");
  101. button.innerHTML = actions[i].name;
  102. button.classList.add("active-button");
  103. button.classList.add("action-button");
  104. button.addEventListener("click", function() { actions[i].action(); });
  105. actionButtons.appendChild(button);
  106. }
  107. }
  108. function updateExplore() {
  109. updateExploreCompass();
  110. updateExploreActions();
  111. }
  112. function updateEaten() {
  113. let list = document.getElementById("eaten");
  114. while(list.firstChild) {
  115. list.removeChild(list.firstChild);
  116. }
  117. if (player.health > 0)
  118. struggles = filterValid(currentFoe.struggles, currentFoe, player);
  119. else
  120. struggles = [submit(currentFoe)];
  121. for (let i = 0; i < struggles.length; i++) {
  122. let li = document.createElement("li");
  123. let button = document.createElement("button");
  124. button.classList.add("eaten-button");
  125. button.innerHTML = struggles[i].name;
  126. button.addEventListener("click", function() { struggleClicked(i); } );
  127. button.addEventListener("mouseover", function() { struggleHovered(i); } );
  128. button.addEventListener("mouseout", function() { document.getElementById("eaten-desc").innerHTML = ""; } );
  129. li.appendChild(button);
  130. list.appendChild(li);
  131. }
  132. }
  133. function updateCombat() {
  134. let list = document.getElementById("combat");
  135. while(list.firstChild) {
  136. list.removeChild(list.firstChild);
  137. }
  138. if (player.health > 0)
  139. if (currentFoe.playerAttacks == undefined)
  140. playerAttacks = filterValid(player.attacks, player, currentFoe);
  141. else
  142. playerAttacks = filterValid(currentFoe.playerAttacks.map(attack => attack(player)), player, currentFoe);
  143. else
  144. playerAttacks = [pass(player)];
  145. if (playerAttacks.length == 0)
  146. playerAttacks = [player.backupAttack];
  147. for (let i = 0; i < playerAttacks.length; i++) {
  148. let li = document.createElement("li");
  149. let button = document.createElement("button");
  150. button.classList.add("combat-button");
  151. button.innerHTML = playerAttacks[i].name;
  152. button.addEventListener("click", function() { attackClicked(i); } );
  153. button.addEventListener("mouseover", function() { attackHovered(i); } );
  154. button.addEventListener("mouseout", function() { document.getElementById("combat-desc").innerHTML = ""; } );
  155. li.appendChild(button);
  156. list.appendChild(li);
  157. }
  158. document.getElementById("stat-foe-name").innerHTML = "Name: " + currentFoe.name;
  159. document.getElementById("stat-foe-health").innerHTML = "Health: " + currentFoe.health + "/" + currentFoe.maxHealth;
  160. document.getElementById("stat-foe-stamina").innerHTML = "Stamina: " + currentFoe.stamina + "/" + currentFoe.maxStamina;
  161. document.getElementById("stat-foe-str").innerHTML = "Str: " + currentFoe.str;
  162. document.getElementById("stat-foe-dex").innerHTML = "Dex: " + currentFoe.dex;
  163. document.getElementById("stat-foe-con").innerHTML = "Con: " + currentFoe.con;
  164. }
  165. function updateDialog() {
  166. let list = document.getElementById("dialog");
  167. while(list.firstChild) {
  168. list.removeChild(list.firstChild);
  169. }
  170. for (let i = 0; i < currentDialog.choices.length; i++) {
  171. let activated = currentDialog.choices[i].node.requirements == undefined || currentDialog.choices[i].node.requirements.reduce((result, test) => result && test(player, currentFoe), true);
  172. let li = document.createElement("li");
  173. let button = document.createElement("button");
  174. button.classList.add("dialog-button");
  175. button.innerHTML = currentDialog.choices[i].text;
  176. button.addEventListener("click", function() { dialogClicked(i); });
  177. if (!activated) {
  178. button.classList.add("disabled-button");
  179. button.disabled = true;
  180. }
  181. li.appendChild(button);
  182. list.appendChild(li);
  183. }
  184. }
  185. function updateDisplay() {
  186. document.querySelectorAll(".selector").forEach(function (x) {
  187. x.style.display = "none";
  188. });
  189. switch(mode) {
  190. case "explore":
  191. document.getElementById("selector-explore").style.display = "flex";
  192. updateExplore();
  193. break;
  194. case "combat":
  195. document.getElementById("selector-combat").style.display = "flex";
  196. updateCombat();
  197. break;
  198. case "dialog":
  199. document.getElementById("selector-dialog").style.display = "flex";
  200. updateDialog();
  201. break;
  202. case "eaten":
  203. document.getElementById("selector-eaten").style.display = "flex";
  204. updateEaten();
  205. break;
  206. }
  207. document.getElementById("time").innerHTML = "Time: " + renderTime(time);
  208. document.getElementById("date").innerHTML = "Day " + date;
  209. document.getElementById("stat-name").innerHTML = "Name: " + player.name;
  210. document.getElementById("stat-health").innerHTML = "Health: " + round(player.health,0) + "/" + round(player.maxHealth,0);
  211. document.getElementById("stat-cash").innerHTML = "Cash: $" + round(player.cash,0);
  212. document.getElementById("stat-stamina").innerHTML = "Stamina: " + round(player.stamina,0) + "/" + round(player.maxStamina,0);
  213. document.getElementById("stat-str").innerHTML = "Str: " + player.str;
  214. document.getElementById("stat-dex").innerHTML = "Dex: " + player.dex;
  215. document.getElementById("stat-con").innerHTML = "Con: " + player.con;
  216. document.getElementById("stat-arousal").innerHTML = "Arousal: " + round(player.arousal,0) + "/" + round(player.arousalLimit(),0);
  217. document.getElementById("stat-stomach").innerHTML = "Stomach: " + round(player.stomach.fullness(),0) + "/" + player.stomach.capacity;
  218. if (player.prefs.pred.anal || player.prefs.scat)
  219. document.getElementById("stat-bowels").innerHTML = "Bowels: " + round(player.bowels.fullness(),0) + "/" + player.bowels.capacity;
  220. else
  221. document.getElementById("stat-bowels").innerHTML = "";
  222. if (player.prefs.pred.cock)
  223. document.getElementById("stat-balls").innerHTML = "Balls: " + round(player.balls.fullness(),0) + "/" + player.balls.capacity;
  224. else
  225. document.getElementById("stat-balls").innerHTML = "";
  226. if (player.prefs.pred.unbirth)
  227. document.getElementById("stat-womb").innerHTML = "Womb: " + round(player.womb.fullness(),0) + "/" + player.womb.capacity;
  228. else
  229. document.getElementById("stat-womb").innerHTML = "";
  230. if (player.prefs.pred.breast)
  231. document.getElementById("stat-breasts").innerHTML = "Breasts: " + round(player.breasts.fullness(),0) + "/" + player.breasts.capacity;
  232. else
  233. document.getElementById("stat-breasts").innerHTML = "";
  234. }
  235. function advanceTimeTo(newTime) {
  236. advanceTime((86400 + newTime - time) % 86400);
  237. }
  238. function advanceTime(amount) {
  239. time = (time + amount);
  240. date += Math.floor(time / 86400);
  241. time = time % 86400;
  242. player.restoreHealth(amount);
  243. player.restoreStamina(amount);
  244. update(player.stomach.digest(amount));
  245. update(player.bowels.digest(amount));
  246. update(player.balls.digest(amount));
  247. update(player.womb.digest(amount));
  248. update(player.breasts.digest(amount));
  249. update(player.buildArousal(amount));
  250. }
  251. function renderTime(time) {
  252. let suffix = (time < 43200) ? "AM" : "PM";
  253. let hour = Math.floor((time % 43200) / 3600);
  254. if (hour == 0)
  255. hour = 12;
  256. let minute = Math.floor(time / 60) % 60;
  257. if (minute < 9)
  258. minute = "0" + minute;
  259. return hour + ":" + minute + " " + suffix;
  260. }
  261. function move(direction) {
  262. if (noLog)
  263. clearScreen();
  264. else
  265. clearLogBreak();
  266. let target = currentRoom.exits[direction];
  267. if (target == null) {
  268. alert("Tried to move to an empty room!");
  269. return;
  270. }
  271. moveTo(target,currentRoom.exitDescs[direction]);
  272. }
  273. function updateActions() {
  274. actions = [];
  275. currentRoom.objects.forEach(function (object) {
  276. object.actions.forEach(function (action) {
  277. if (action.conditions == undefined || action.conditions.reduce((result, cond) => result && cond(player), true))
  278. actions.push(action);
  279. });
  280. });
  281. }
  282. function moveToByName(roomName, desc="You go places lol", loading=false) {
  283. moveTo(world[roomName], desc, loading);
  284. }
  285. function moveTo(room,desc="You go places lol", loading=false) {
  286. currentRoom = room;
  287. if (!loading)
  288. advanceTime(30);
  289. update([desc,newline]);
  290. currentRoom.visit();
  291. updateDisplay();
  292. }
  293. function next_step(stage) {
  294. document.querySelector("#character-step-" + (stage - 1)).style.display = "none";
  295. document.querySelector("#character-step-" + stage).style.display = "block";
  296. }
  297. window.addEventListener('load', function(event) {
  298. document.getElementById("character-step-1-next").addEventListener("click", function() { next_step(2); });
  299. document.getElementById("start-button").addEventListener("click", start, false);
  300. });
  301. function start() {
  302. applySettings(generateSettings());
  303. transformVorePrefs(player.prefs);
  304. document.getElementById("create").style.display = "none";
  305. document.getElementById("game").style.display = "block";
  306. document.getElementById("stat-button-status").addEventListener("click", status, false);
  307. document.getElementById("log-button").addEventListener("click", toggleLog, false);
  308. loadCompass();
  309. loadDialog();
  310. world = createWorld();
  311. currentRoom = world["Bedroom"];
  312. respawnRoom = currentRoom;
  313. update(new Array(50).fill(newline));
  314. update(["Welcome to Feast."]);
  315. moveTo(currentRoom,"");
  316. updateDisplay();
  317. }
  318. // copied from Stroll LUL
  319. function generateSettings() {
  320. let form = document.forms.namedItem("character-form");
  321. let settings = {};
  322. for (let i=0; i<form.length; i++) {
  323. let value = form[i].value == "" ? form[i].placeholder : form[i].value;
  324. if (form[i].type == "text")
  325. if (form[i].value == "")
  326. settings[form[i].name] = form[i].placeholder;
  327. else
  328. settings[form[i].name] = value;
  329. else if (form[i].type == "number")
  330. settings[form[i].name] = parseFloat(value);
  331. else if (form[i].type == "checkbox") {
  332. settings[form[i].name] = form[i].checked;
  333. } else if (form[i].type == "radio") {
  334. let name = form[i].name;
  335. if (form[i].checked) {
  336. if (form[i].value == "true")
  337. settings[name] = true;
  338. else if (form[i].value == "false")
  339. settings[name] = false;
  340. else
  341. settings[name] = form[i].value;
  342. }
  343. } else if (form[i].type == "select-one") {
  344. settings[form[i].name] = form[i][form[i].selectedIndex].value;
  345. }
  346. }
  347. return settings;
  348. }
  349. function applySettings(settings) {
  350. player.name = settings.name;
  351. player.species = settings.species;
  352. for (let key in settings) {
  353. if (settings.hasOwnProperty(key)) {
  354. if (key.match(/prefs/)) {
  355. let tokens = key.split("-");
  356. let pref = player.prefs;
  357. // construct missing child dictionaries if needed :)
  358. pref = tokens.slice(1,-1).reduce(function(pref, key) {
  359. if (pref[key] == undefined)
  360. pref[key] = {};
  361. return pref[key];
  362. }, pref);
  363. pref[tokens.slice(-1)[0]] = settings[key];
  364. } else if(key.match(/parts/)) {
  365. let tokens = key.split("-");
  366. player.parts[tokens[1]] = settings[key] >= 1;
  367. if (player.prefs.pred == undefined)
  368. player.prefs.pred = {};
  369. player.prefs.pred[tokens[1]] = settings[key] >= 2;
  370. }
  371. }
  372. }
  373. }
  374. // turn things like "1" into a number
  375. function transformVorePrefs(prefs) {
  376. let prey = false;
  377. for (let key in prefs.vore) {
  378. if (prefs.vore.hasOwnProperty(key)) {
  379. switch(prefs.vore[key]) {
  380. case "0": prefs.vore[key] = 0; break;
  381. case "1": prefs.vore[key] = 0.5; prey = true; break;
  382. case "2": prefs.vore[key] = 1; prey = true; break;
  383. case "3": prefs.vore[key] = 2; prey = true; break;
  384. }
  385. }
  386. }
  387. prefs.prey = prey;
  388. return prefs;
  389. }
  390. function saveSettings() {
  391. window.localStorage.setItem("settings", JSON.stringify(generateSettings()));
  392. }
  393. function retrieveSettings() {
  394. return JSON.parse(window.localStorage.getItem("settings"));
  395. }
  396. function clearScreen() {
  397. let log = document.getElementById("log");
  398. let child = log.firstChild;
  399. while (child != null) {
  400. log.removeChild(child);
  401. child = log.firstChild;
  402. }
  403. }
  404. function update(lines=[]) {
  405. let log = document.getElementById("log");
  406. for (let i=0; i<lines.length; i++) {
  407. let div = document.createElement("div");
  408. div.innerHTML = lines[i];
  409. if (logPadLine === undefined && !noLog) {
  410. logPadLine = div;
  411. logPadLine.classList.add("log-entry-padded");
  412. }
  413. log.appendChild(div);
  414. }
  415. log.scrollTop = log.scrollHeight;
  416. updateDisplay();
  417. }
  418. function clearLogBreak() {
  419. if (logPadLine !== undefined) {
  420. logPadLine.classList.remove("log-entry-padded");
  421. logPadLine = undefined;
  422. }
  423. }
  424. function changeMode(newMode) {
  425. mode = newMode;
  426. let body = document.querySelector("body");
  427. document.getElementById("foe-stats").style.display = "none";
  428. body.className = "";
  429. switch(mode) {
  430. case "explore":
  431. case "dialog":
  432. body.classList.add("explore");
  433. break;
  434. case "combat":
  435. body.classList.add("combat");
  436. document.getElementById("foe-stats").style.display = "block";
  437. break;
  438. case "eaten":
  439. body.classList.add("eaten");
  440. document.getElementById("foe-stats").style.display = "block";
  441. break;
  442. }
  443. updateDisplay();
  444. }
  445. // make it look like eaten mode, even when in combat
  446. function changeBackground(newMode) {
  447. let body = document.querySelector("body");
  448. document.getElementById("foe-stats").style.display = "none";
  449. body.className = "";
  450. switch(newMode) {
  451. case "explore":
  452. case "dialog":
  453. body.classList.add("explore");
  454. break;
  455. case "combat":
  456. body.classList.add("combat");
  457. document.getElementById("foe-stats").style.display = "block";
  458. break;
  459. case "eaten":
  460. body.classList.add("eaten");
  461. document.getElementById("foe-stats").style.display = "block";
  462. break;
  463. }
  464. }
  465. function respawn(respawnRoom) {
  466. if (killingBlow.gameover == undefined) {
  467. if (player.prefs.prey) {
  468. deaths.push("Digested by " + currentFoe.description("a") + " at " + renderTime(time) + " on day " + date);
  469. } else {
  470. deaths.push("Defeated by " + currentFoe.description("a") + " at " + renderTime(time) + " on day " + date);
  471. }
  472. } else {
  473. deaths.push(killingBlow.gameover() + " at " + renderTime(time) + " on day " + date);
  474. }
  475. moveTo(respawnRoom,"You drift through space and time...");
  476. player.clear();
  477. player.stomach.contents = [];
  478. player.bowels.contents = [];
  479. player.bowels.waste = 0;
  480. player.bowels.digested = [];
  481. player.womb.contents = [];
  482. player.womb.waste = 0;
  483. player.womb.digested = [];
  484. player.balls.contents = [];
  485. player.balls.waste = 0;
  486. player.balls.digested = [];
  487. player.breasts.contents = [];
  488. player.breasts.waste = 0;
  489. player.breasts.digested = [];
  490. advanceTime(Math.floor(86400 / 2 * (Math.random() * 0.5 - 0.25 + 1)));
  491. changeMode("explore");
  492. player.health = 100;
  493. update(["You wake back up in your bed."]);
  494. }
  495. function startCombat(opponent) {
  496. currentFoe = opponent;
  497. changeMode("combat");
  498. update(opponent.startCombat(player).concat([newline]));
  499. }
  500. function attackClicked(index) {
  501. if (noLog)
  502. clearScreen();
  503. else
  504. clearLogBreak();
  505. update(playerAttacks[index].attack(currentFoe).concat([newline]));
  506. if (currentFoe.health <= 0) {
  507. currentFoe.defeated();
  508. } else if (mode == "combat") {
  509. let attack = pick(filterPriority(filterValid(currentFoe.attacks, currentFoe, player)), currentFoe, player);
  510. if (attack == null) {
  511. attack = currentFoe.backupAttack;
  512. }
  513. update(attack.attackPlayer(player).concat([newline]));
  514. if (player.health <= -100) {
  515. killingBlow = attack;
  516. if (currentFoe.finishCombat != undefined)
  517. update(currentFoe.finishCombat().concat([newline]));
  518. update(["You die..."]);
  519. respawn(respawnRoom);
  520. } else if (player.health <= 0) {
  521. update(["You're too weak to do anything..."]);
  522. if (player.prefs.prey) {
  523. // nada
  524. } else {
  525. killingBlow = attack;
  526. update(["You die..."]);
  527. respawn(respawnRoom);
  528. }
  529. }
  530. if (currentFoe.status != undefined) {
  531. let status = currentFoe.status();
  532. if (status.length > 0)
  533. update(status.concat([newline]));
  534. }
  535. }
  536. }
  537. function attackHovered(index) {
  538. document.getElementById("combat-desc").innerHTML = playerAttacks[index].desc;
  539. }
  540. function struggleClicked(index) {
  541. if (noLog)
  542. clearScreen();
  543. else
  544. clearLogBreak();
  545. let struggle = struggles[index];
  546. let result = struggle.struggle(player);
  547. update(result.lines.concat([newline]));
  548. if (result.escape == "stay") {
  549. changeMode("combat");
  550. } else if (result.escape == "escape") {
  551. changeMode("explore");
  552. } else {
  553. let digest = pick(filterValid(currentFoe.digests, currentFoe, player), currentFoe, player);
  554. if (digest == null) {
  555. digest = currentFoe.backupDigest;
  556. }
  557. update(digest.digest(player).concat([newline]));
  558. if (player.health <= -100) {
  559. killingBlow = digest;
  560. update(currentFoe.finishDigest().concat([newline]));
  561. respawn(respawnRoom);
  562. }
  563. }
  564. }
  565. function struggleHovered(index) {
  566. document.getElementById("eaten-desc").innerHTML = currentFoe.struggles[index].desc;
  567. }
  568. function startDialog(dialog) {
  569. if (noLog)
  570. clearScreen();
  571. else
  572. clearLogBreak();
  573. currentDialog = dialog;
  574. changeMode("dialog");
  575. update(currentDialog.text.concat([newline]));
  576. currentDialog.visit();
  577. updateDisplay();
  578. }
  579. function dialogClicked(index) {
  580. currentDialog = currentDialog.choices[index].node;
  581. update(currentDialog.text.concat([newline]));
  582. currentDialog.visit();
  583. if (currentDialog.choices.length == 0 && mode == "dialog") {
  584. changeMode("explore");
  585. updateDisplay();
  586. }
  587. }
  588. function loadDialog() {
  589. dialogButtons = Array.from( document.querySelectorAll(".dialog-button"));
  590. for (let i = 0; i < dialogButtons.length; i++) {
  591. dialogButtons[i].addEventListener("click", function() { dialogClicked(i); });
  592. }
  593. }
  594. function loadCompass() {
  595. dirButtons[NORTH_WEST] = document.getElementById("compass-north-west");
  596. dirButtons[NORTH_WEST].addEventListener("click", function() {
  597. move(NORTH_WEST);
  598. });
  599. dirButtons[NORTH] = document.getElementById("compass-north");
  600. dirButtons[NORTH].addEventListener("click", function() {
  601. move(NORTH);
  602. });
  603. dirButtons[NORTH_EAST] = document.getElementById("compass-north-east");
  604. dirButtons[NORTH_EAST].addEventListener("click", function() {
  605. move(NORTH_EAST);
  606. });
  607. dirButtons[WEST] = document.getElementById("compass-west");
  608. dirButtons[WEST].addEventListener("click", function() {
  609. move(WEST);
  610. });
  611. dirButtons[EAST] = document.getElementById("compass-east");
  612. dirButtons[EAST].addEventListener("click", function() {
  613. move(EAST);
  614. });
  615. dirButtons[SOUTH_WEST] = document.getElementById("compass-south-west");
  616. dirButtons[SOUTH_WEST].addEventListener("click", function() {
  617. move(SOUTH_WEST);
  618. });
  619. dirButtons[SOUTH] = document.getElementById("compass-south");
  620. dirButtons[SOUTH].addEventListener("click", function() {
  621. move(SOUTH);
  622. });
  623. dirButtons[SOUTH_EAST] = document.getElementById("compass-south-east");
  624. dirButtons[SOUTH_EAST].addEventListener("click", function() {
  625. move(SOUTH_EAST);
  626. });
  627. document.getElementById("compass-look").addEventListener("click", look, false);
  628. }
  629. function look() {
  630. update([currentRoom.description]);
  631. }
  632. function status() {
  633. let lines = [];
  634. lines.push("You are a " + player.species);
  635. lines.push(newline);
  636. if (player.stomach.contents.length > 0) {
  637. lines.push("Your stomach bulges with prey.");
  638. player.stomach.contents.map(function(prey) {
  639. let state = "";
  640. let healthRatio = prey.health / prey.maxHealth;
  641. if (healthRatio > 0.75) {
  642. state = "is thrashing in your gut";
  643. } else if (healthRatio > 0.5) {
  644. state = "is squirming in your belly";
  645. } else if (healthRatio > 0.25) {
  646. state = "is pressing out at your stomach walls";
  647. } else if (healthRatio > 0) {
  648. state = "is weakly squirming";
  649. } else {
  650. state = "has stopped moving";
  651. }
  652. lines.push(prey.description("A") + " " + state);
  653. });
  654. lines.push(newline);
  655. }
  656. if (player.bowels.contents.length > 0) {
  657. lines.push("Your bowels churn with prey.");
  658. player.bowels.contents.map(function(prey) {
  659. let state = "";
  660. let healthRatio = prey.health / prey.maxHealth;
  661. if (healthRatio > 0.75) {
  662. state = "is writhing in your bowels";
  663. } else if (healthRatio > 0.5) {
  664. state = "is struggling against your intestines";
  665. } else if (healthRatio > 0.25) {
  666. state = "is bulging out of your lower belly";
  667. } else if (healthRatio > 0) {
  668. state = "is squirming weakly, slipping deeper and deeper";
  669. } else {
  670. state = "has succumbed to your bowels";
  671. }
  672. lines.push(prey.description("A") + " " + state);
  673. });
  674. lines.push(newline);
  675. }
  676. if (player.parts.cock) {
  677. if (player.balls.contents.length > 0) {
  678. lines.push("Your balls are bulging with prey.");
  679. player.balls.contents.map(function(prey) {
  680. let state = "";
  681. let healthRatio = prey.health / prey.maxHealth;
  682. if (healthRatio > 0.75) {
  683. state = "is writhing in your sac";
  684. } else if (healthRatio > 0.5) {
  685. state = "is struggling in a pool of cum";
  686. } else if (healthRatio > 0.25) {
  687. state = "is starting to turn soft";
  688. } else if (healthRatio > 0) {
  689. state = "is barely visible anymore";
  690. } else {
  691. state = "has succumbed to your balls";
  692. }
  693. lines.push(prey.description("A") + " " + state);
  694. });
  695. lines.push(newline);
  696. } else {
  697. if (player.balls.waste > 0) {
  698. lines.push("Your balls are heavy with cum.");
  699. lines.push(newline);
  700. }
  701. }
  702. }
  703. if (player.parts.unbirth) {
  704. if (player.womb.contents.length > 0) {
  705. lines.push("Your slit drips, hinting at prey trapped within.");
  706. player.womb.contents.map(function(prey) {
  707. let state = "";
  708. let healthRatio = prey.health / prey.maxHealth;
  709. if (healthRatio > 0.75) {
  710. state = "is thrashing in your womb";
  711. } else if (healthRatio > 0.5) {
  712. state = "is pressing out inside your lower belly";
  713. } else if (healthRatio > 0.25) {
  714. state = "is still trying to escape";
  715. } else if (healthRatio > 0) {
  716. state = "is barely moving";
  717. } else {
  718. state = "is dissolving into femcum";
  719. }
  720. lines.push(prey.description("A") + " " + state);
  721. });
  722. lines.push(newline);
  723. } else {
  724. if (player.womb.waste > 0) {
  725. lines.push("Your slit drips, holding back a tide of femcum.");
  726. lines.push(newline);
  727. }
  728. }
  729. }
  730. if (player.parts.breast) {
  731. if (player.breasts.contents.length > 0) {
  732. lines.push("Your breasts are bulging with prey.");
  733. player.breasts.contents.map(function(prey) {
  734. let state = "";
  735. let healthRatio = prey.health / prey.maxHealth;
  736. if (healthRatio > 0.75) {
  737. state = "is struggling to escape";
  738. } else if (healthRatio > 0.5) {
  739. state = "is putting up a fight";
  740. } else if (healthRatio > 0.25) {
  741. state = "is starting to weaken";
  742. } else if (healthRatio > 0) {
  743. state = "is struggling to keep their head free of your milk";
  744. } else {
  745. state = "has succumbed, swiftly melting into milk";
  746. }
  747. lines.push(prey.description("A") + " " + state);
  748. });
  749. lines.push(newline);
  750. } else {
  751. if (player.breasts.waste > 0) {
  752. lines.push("Your breasts slosh with milk.");
  753. lines.push(newline);
  754. }
  755. }
  756. }
  757. update(lines);
  758. }
  759. let toSave = ["str","dex","con","name","species","health","stamina"];
  760. function saveGame() {
  761. let save = {};
  762. save.player = {};
  763. save.player.str = player.str;
  764. save.player.dex = player.dex;
  765. save.player.con = player.con;
  766. save.player.name = player.name;
  767. save.player.species = player.species;
  768. save.player.health = player.health;
  769. save.player.health = player.stamina;
  770. save.prefs = JSON.stringify(player.prefs);
  771. save.position = currentRoom.name;
  772. save.date = date;
  773. save.time = time;
  774. save.deaths = deaths;
  775. let stringified = JSON.stringify(save);
  776. window.localStorage.setItem("save", stringified);
  777. }
  778. function loadGame() {
  779. changeMode("explore");
  780. let save = JSON.parse(window.localStorage.getItem("save"));
  781. let playerSave = save.player;
  782. for (let key in playerSave) {
  783. if (playerSave.hasOwnProperty(key)) {
  784. player[key] = playerSave[key];
  785. }
  786. }
  787. player.prefs = JSON.parse(save.prefs);
  788. deaths = save.deaths;
  789. date = save.date;
  790. time = save.time;
  791. clearScreen();
  792. moveToByName(save.position, "");
  793. }
  794. // wow polyfills
  795. if (![].includes) {
  796. Array.prototype.includes = function(searchElement /*, fromIndex*/ ) {
  797. 'use strict';
  798. var O = Object(this);
  799. var len = parseInt(O.length) || 0;
  800. if (len === 0) {
  801. return false;
  802. }
  803. var n = parseInt(arguments[1]) || 0;
  804. var k;
  805. if (n >= 0) {
  806. k = n;
  807. } else {
  808. k = len + n;
  809. if (k < 0) {k = 0;}
  810. }
  811. var currentElement;
  812. while (k < len) {
  813. currentElement = O[k];
  814. if (searchElement === currentElement ||
  815. (searchElement !== searchElement && currentElement !== currentElement)) {
  816. return true;
  817. }
  818. k++;
  819. }
  820. return false;
  821. };
  822. }