crunch
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

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