crunch
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

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