소스 검색

more work in saving and loading. Added more dialog options

Saving
jsb5468 5 년 전
부모
커밋
0317ed49cd
3개의 변경된 파일72개의 추가작업 그리고 18개의 파일을 삭제
  1. +5
    -5
      combat.js
  2. +16
    -2
      dialog.js
  3. +51
    -11
      feast.js

+ 5
- 5
combat.js 파일 보기

@@ -41,10 +41,10 @@ function statHealthCheck(attacker, defender, stat) {
function punchAttack(attacker) {
return {
name: "Punch",
desc: "Punch a nerd",
desc: pickString("Hit them with your fists.","Punch a nerd.","Hit them in the face."),
attack: function(defender) {

return ["You punch " + defender.description("the") + " for " + attack(attacker, defender, attacker.str) + " damage"];
return ["You punch " + defender.description("the") + pickString(" for "," right in the face for "," and deal ",", leaving a bruise and doing "," with a meaty THWACK, dealing ") + attack(attacker, defender, attacker.str) + " damage"];
},
attackPlayer: function(defender) {
return [attacker.description("The") + " punches you for " + attack(attacker, defender, attacker.str) + " damage"];
@@ -64,7 +64,7 @@ function flankAttack(attacker) {
return ["You run around " + defender.description("the") + " and attack for " + attack(attacker, defender, attacker.dex) + " damage"];
},
attackPlayer: function(defender) {
return [attacker.description("The") + " runs past you, then turns and hits you for " + attack(attacker, defender, attacker.str) + " damage"];
return [attacker.description("The") + pickString(" runs past you, then turns and hits you for "," bonks you for "," slashes at you, leaving a nasty cut and dealiing ", " punches you in the jaw, dealing "," wallops you for ") + attack(attacker, defender, attacker.str) + " damage"];
}, requirements: [
function(attacker, defender) { return isNormal(attacker) && isNormal(defender); }
],
@@ -83,10 +83,10 @@ function grapple(attacker, weightFactor = 1) {
attacker.changeStamina(-20);
defender.changeStamina(-20);
defender.flags.grappled = true;
return ["You charge at " + defender.description("the") + ", tackling them and knocking them to the ground."];
return [pickString("You manage to get " + defender.description("the") + " in a headlock.","You charge at " + defender.description("the") + ", tackling them and knocking them to the ground.", "You pin " + defender.description("the") + " to the ground.")];
} else {
attacker.changeStamina(-20);
return ["You charge at " + defender.description("the") + ", but they dodge out of the way!"];
return [pickString("You charge at " + defender.description("the") + ", but they dodge out of the way!","You attempt to grapple " + defender.description("the") + ", but they slip from your grasp."," You try and wrestle " + defender.description("the") + " to the ground, but they break your grip.")];
}
},
attackPlayer: function(defender) {


+ 16
- 2
dialog.js 파일 보기

@@ -1,5 +1,19 @@
"use strict";

function pickString(...array){
var strings = array;
var pick = strings[~~(Math.random() * strings.length)];
return pick;
}

function pickStringChance(chance, ...array) {
if (Math.random() < chance) {
return pickString(...array);
} else {
return ""
}
}

function DialogNode() {
this.text = [];
this.hooks = [];
@@ -27,7 +41,7 @@ function EatDude() {

let eatHim = new DialogNode();

eatHim.text = ["You eat the nerd. Burp."];
eatHim.text = [pickString("You eat the nerd. Burp.","You devour the unsuspecting nerd.")];
eatHim.hooks.push(function() { player.stomach.feed(nerd); });

let dontEatHim = new DialogNode();
@@ -71,7 +85,7 @@ function FallenFoe(foe) {
{
let nodeEat = new DialogNode();
this.addChoice("Devour!",nodeEat);
nodeEat.text = ["You grab your helpless prey and force them down your gullet. You hack up their wallet a minute later, finding $" + foe.cash + " inside."];
nodeEat.text = [pickString("You grab your helpless prey and force them down your gullet. You hack up their wallet a minute later, finding $" + foe.cash + " inside.","You force them down your maw and while they are going down, you grab their wallet. Once they are safely in your stomach, you open it to find $" + foe.cash + ".","You eat them, but not before taking $" + foe.cash + " from their wallet.")];

nodeEat.requirements.push( function(attacker, defender) {
return defender.prefs.prey;


+ 51
- 11
feast.js 파일 보기

@@ -367,7 +367,7 @@ function next_step(stage) {

window.addEventListener('load', function(event) {
document.getElementById("character-step-1-next").addEventListener("click", function() { next_step(2); });
document.getElementById("character-load").addEventListener("click", startLoaded, false);
document.getElementById("character-load").addEventListener("click", loadGame, false);
document.getElementById("start-button").addEventListener("click", start, false);
});

@@ -380,6 +380,7 @@ function start() {
document.getElementById("log-button").addEventListener("click", toggleLog, false);
document.getElementById("load-button").addEventListener("click", loadGameButton, false);
document.getElementById("save-button").addEventListener("click", saveGameButton, false);
document.getElementById("inventory-button").addEventListener("click", overfillVerifier, false);
loadCompass();
loadDialog();
setupStrechableOrgans();
@@ -389,7 +390,8 @@ function start() {
update(new Array(50).fill(newline));
update(["Welcome to Feast."]);
moveTo(currentRoom,"");
updateDisplay();

}

// copied from Stroll LUL
@@ -910,6 +912,11 @@ function status() {
update(lines);
}

function overfillVerifier(){
testoutput = checkOverfill("stomach");
update([testoutput]);
}

function checkOverfill(organ,returnValue=false, returnPercent=false){
let percentFilled = (round(player[organ].fullness(),0) / player[organ].capacity);
if (returnValue == false){
@@ -969,9 +976,21 @@ function saveGame() {
save.player.name = player.name;
save.player.species = player.species;
save.player.health = player.health;
save.player.health = player.stamina;
save.player.stamina = player.stamina;

save.stomach = player.stomach.contents; //organs
save.bowels = player.bowels.contents;
save.balls = player.balls.contents;
save.womb = player.womb.contents;
save.breasts = player.breasts.contents;

save.prefs = JSON.stringify(player.prefs);
save.stomachsize = player.stomach.capacity; //organs
save.bowelssize = player.bowels.capacity;
save.ballssize = player.balls.capacity;
save.wombsize = player.womb.capacity;
save.breastssize = player.breasts.capacity;

save.prefs = player.prefs;

save.position = currentRoom.name;
save.date = date;
@@ -987,6 +1006,8 @@ function saveGame() {
}

function loadGame() {

start();
changeMode("explore");
let save = JSON.parse(window.localStorage.getItem("save"));

@@ -998,25 +1019,44 @@ function loadGame() {
}
}

player.prefs = JSON.parse(save.prefs);
player.prefs = save.prefs;
deaths = save.deaths;
setupStrechableOrgans();

date = save.date;
time = save.time;



//save.stomach.forEach(Creature.call(thisArg, owner);
//player.bowels.contents = save.bowels;
//player.balls.contents = save.balls;
//player.womb.contents = save.womb;
//player.breasts.contents = save.breasts;

player.stomach.capacity = save.stomachsize;
player.bowels.capacity = save.bowelssize;
player.balls.capacity = save.ballssize;
player.womb.capacity = save.wombsize;
player.breasts.capacity = save.breastssize;




clearScreen();
moveToByName(save.position, "");
update(["Game loaded."]);
// update([JSON.stringify(player.stomach.contents)]);
// update(["spacer"]);
// update([save.stomach]);
update(["Game loaded."]);
updateDisplay();
}

function startLoaded() { //used to load the game via the main menu
start();
loadGame();
}


//these work in conjunction with buttonConfirm/buttonConfirmEnd and any functions that call them.
var confirmTimer; //this is areference to the active setTimeout, only used to allow clearTimeout to know thich timeout to clear
var confirmTimer; //this is a reference to the active setTimeout, only used to allow clearTimeout to know thich timeout to clear
let confirmState = ""; //this records which function is asking for confirmation "" means nothing is asking for confirmation.
let confirmStateText = ""; //this is where the original button text is stored when the button reads "Confirm?"



불러오는 중...
취소
저장