Procházet zdrojové kódy

Added a function to change stats w/ automatic bounds checking

tags/v0.1.1
Fen Dweller před 6 roky
rodič
revize
00878e9c40
2 změnil soubory, kde provedl 27 přidání a 35 odebrání
  1. +8
    -0
      game.js
  2. +19
    -35
      stories/fen-snack.js

+ 8
- 0
game.js Zobrazit soubor

@@ -40,6 +40,14 @@ function initGamePostSetup(state) {
});
}

function changeStat(stat, amount, state) {
let value = state.player.stats[stat].value;
value += amount;
value = Math.max(value, state.player.stats[stat].min);
value = Math.min(value, state.player.stats[stat].max);
state.player.stats[stat].value = value;
}

// TODO: format string this lol
function renderTime(time) {
let hours = Math.floor(time / 3600) % 12;


+ 19
- 35
stories/fen-snack.js Zobrazit soubor

@@ -29,8 +29,8 @@ stories.push({
start: "stomach",
setup: state => {
state.info.time = 86400 - 60 * 25 - 25;
state.player.stats.health = {name: "Health", type: "meter", value: 100, max: 100, color: "rgb(255,0,0)"};
state.player.stats.stamina = {name: "Stamina", type: "meter", value: 100, max: 100, color: "rgb(100,255,0)"};
state.player.stats.health = {name: "Health", type: "meter", value: 100, min: 0, max: 100, color: "rgb(255,0,0)"};
state.player.stats.stamina = {name: "Stamina", type: "meter", value: 100, min: 0, max: 100, color: "rgb(100,255,0)"};

startTimer({
id: "movement",
@@ -64,15 +64,15 @@ stories.push({
let bonus = state.player.flags.submission ? 10 : 1;

if (location.startsWith("stomach")) {
state.player.stats.health.value -= 1;
changeStat("health", -1, state);
}

if (location.startsWith("intestines")) {
state.player.stats.health.value -= 0.75;
changeStat("health", -0.75, state);
}
if (location.startsWith("bowels")) {
state.player.stats.health.value -= 0.5;
changeStat("health", -0.5, state);
}


@@ -109,25 +109,16 @@ stories.push({
let bonus = state.player.flags.submission ? -3 : 0;
bonus += state.player.flags.pinned ? -0.5 : 0;
if (location.startsWith("stomach")) {
state.player.stats.stamina.value += 1 + bonus;
changeStat("stamina", 1 + bonus, state);
}

if (location.startsWith("intestines")) {
state.player.stats.stamina.value += 0.5 + bonus;
changeStat("stamina", 0.5 + bonus, state);
}

if (location.startsWith("bowels")) {
state.player.stats.stamina.value += -0.5 + bonus;
}

if (state.player.stats.stamina.value > 100) {
state.player.stats.stamina.value = 100;
changeStat("stamina", -0.5 + bonus, state);
}

if (state.player.stats.stamina.value < 0) {
state.player.stats.stamina.value = 0;
}

return true;
},
delay: 500,
@@ -175,8 +166,7 @@ stories.push({
id: "stomach-churns",
func: state => {
if (Math.random() > 0.6) {
state.player.stats.stamina.value -= 25;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
changeStat("stamina", -25, state);
print(["The crux's stomach clenches around you, smothering you in the beast's slimy embrace."]);
playSfx("sfx/stomach-churn.ogg");
}
@@ -202,8 +192,7 @@ stories.push({
name: "Rub",
desc: "Knead on the muscular folds that surround your tasty little body",
execute: (room, state) => {
state.player.stats.stamina.value -= 15;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
changeStat("stamina", -15, state);
print(["You rub all over your prison's walls. Fen's stomach gurgles in response."]);
}
},
@@ -235,16 +224,14 @@ stories.push({
let stamina = state.player.stats.stamina.value;
let escape;
if (Math.random() > stamina/100) {
stamina -= 50;
changeStat("stamina", -50, state);
print(["Fen's stomach clenches and ripples, smothering your face in wet flesh and keeping you nice and trapped."]);
playSfx("sfx/stomach-to-intestines-fail.ogg");
escape = false;
} else {
stamina -= 25;
changeStat("stamina", -25, state);
escape = true;
}
stamina = Math.max(stamina, 0)
state.player.stats.stamina.value = stamina;
return escape;
}
],
@@ -274,8 +261,7 @@ stories.push({
func: state => {
if (Math.random() > 0.6) {
if (state.player.stats.stamina.value > 50) {
state.player.stats.stamina.value -= 25;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
changeStat("stamina", -25, state);
print(["Your prison's walls ripple and grind, shoving you against the valve leading to the crux's boiling stomach - but you manage to resist the powerful pull."]);
playSfx("sfx/intestines-churn-stay.ogg");
} else {
@@ -340,8 +326,7 @@ stories.push({
name: "Rub",
desc: "Knead on the muscular folds that surround your tasty little body",
execute: (room, state) => {
state.player.stats.stamina.value -= 20;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
changeStat("stamina", -20, state);
print(["You rub all over your prison's walls. Fen's guts barely move."]);
}
},
@@ -375,17 +360,17 @@ stories.push({
id: "bowels-churns",
func: state => {
if (state.player.stats.stamina.value > 50) {
state.player.stats.stamina.value -= 25;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
changeStat("stamina", -25, state);
print(["Fen's bowels clench and churn, grinding you into their musky walls."]);
playSfx("sfx/bowels-churn-safe.ogg");
} else {
changeStat("stamina", -100, state);
startTimer({
id: "digestion",
func: state => {
let bonus = state.player.flags.submission ? 10 : 1;

state.player.stats.health.value -= 1;
changeStat("health", -1, state);
return 500 / bonus;
},
delay: 1000,
@@ -450,8 +435,7 @@ stories.push({
name: "Rub",
desc: "Knead on the muscular folds that surround your tasty little body",
execute: (room, state) => {
state.player.stats.stamina.value -= 50;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
changeStat("stamina", -25, state);
print(["You rub all over your prison's walls. Fen's bowels clench in on you as he rurrs with pleasure."]);
}
},


Načítá se…
Zrušit
Uložit