munch
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

949 líneas
27 KiB

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