浏览代码

Added a basic disposal system

tags/v0.2.8
Fen Dweller 7 年前
父节点
当前提交
c871a8f187
共有 5 个文件被更改,包括 61 次插入4 次删除
  1. +3
    -1
      .jshintrc
  2. +4
    -0
      feast.css
  3. +7
    -2
      feast.html
  4. +20
    -1
      feast.js
  5. +27
    -0
      objects.js

+ 3
- 1
.jshintrc 查看文件

@@ -2,5 +2,7 @@
"indent": 1, "indent": 1,
"esversion": 6, "esversion": 6,
"node": true, "node": true,
"sub": true
"sub": true,
"-W117": false,
"-W083": false
} }

+ 4
- 0
feast.css 查看文件

@@ -142,3 +142,7 @@ button {
#character-form-list { #character-form-list {
list-style-type: none; list-style-type: none;
} }

#character-form {
font-size: 20pt;
}

+ 7
- 2
feast.html 查看文件

@@ -24,14 +24,15 @@
<div id="game"> <div id="game">
<div id="game-and-stats"> <div id="game-and-stats">
<div id="log"> <div id="log">
Welcome to Feast v0.0.5
Welcome to Feast v0.1.0
</div> </div>
<div id="stats"> <div id="stats">
<div class="stat-line" id="time">Time: to get a watch</div>
<div class="stat-line" id="time">Time: to file a bug report, because you shouldn't see this!</div>
<div class="stat-line" id="stat-name">Vim: 15</div> <div class="stat-line" id="stat-name">Vim: 15</div>
<div class="stat-line" id="stat-health">Pulchritude: 44</div> <div class="stat-line" id="stat-health">Pulchritude: 44</div>
<div class="stat-line" id="stat-stamina">Imagination: 97</div> <div class="stat-line" id="stat-stamina">Imagination: 97</div>
<div class="stat-line" id="stat-fullness">Candy Corn: 3</div> <div class="stat-line" id="stat-fullness">Candy Corn: 3</div>
<div class="stat-line" id="stat-bowels">Emotions: 35/100</div>
</div> </div>
</div> </div>
<div id="footer"> <div id="footer">
@@ -145,6 +146,10 @@
<li> <li>
<label for="character-prefs-player-prey">Player can be eaten</label> <label for="character-prefs-player-prey">Player can be eaten</label>
<input type="checkbox" id="character-prefs-player-prey" name="prefs-player-prey" checked=true /> <input type="checkbox" id="character-prefs-player-prey" name="prefs-player-prey" checked=true />
<li>
<li>
<label for="character-prefs-player-scat">Disposal/scat</label>
<input type="checkbox" id="character-prefs-player-scat" name="prefs-player-scat"/>
<li> <li>
<button type="button" id="start-button">Start</button> <button type="button" id="start-button">Start</button>
</li> </li>


+ 20
- 1
feast.js 查看文件

@@ -21,6 +21,19 @@ let prefs = {
} }
}; };


function join(things) {
if (things.length == 1) {
return "a " + things[0].description();
} else if (things.length == 2) {
return "a " + things[0].description() + " and a " + things[1].description();
} else {
let line = "";
line = things.slice(0,-1).reduce((line, prey) => line + "a " + prey.description() + ", ", line);
line += " and a " + things[things.length-1].description();
return line;
}
}

function pickRandom(list) { function pickRandom(list) {
return list[Math.floor(Math.random() * list.length)]; return list[Math.floor(Math.random() * list.length)];
} }
@@ -195,6 +208,11 @@ function updateDisplay() {
document.getElementById("stat-health").innerHTML = "Health: " + round(player.health,0) + "/" + round(player.maxHealth,0); document.getElementById("stat-health").innerHTML = "Health: " + round(player.health,0) + "/" + round(player.maxHealth,0);
document.getElementById("stat-stamina").innerHTML = "Stamina: " + round(player.stamina,0) + "/" + round(player.maxStamina,0); document.getElementById("stat-stamina").innerHTML = "Stamina: " + round(player.stamina,0) + "/" + round(player.maxStamina,0);
document.getElementById("stat-fullness").innerHTML = "Fullness: " + round(player.fullness(),0); document.getElementById("stat-fullness").innerHTML = "Fullness: " + round(player.fullness(),0);
if (prefs.player.scat) {
document.getElementById("stat-bowels").innerHTML = "Bowels: " + round(player.bowels.fullness,0);
} else {
document.getElementById("stat-bowels").innerHTML = "";
}
} }


function advanceTime(amount) { function advanceTime(amount) {
@@ -234,7 +252,8 @@ function moveTo(room,desc="You go places lol") {


currentRoom.objects.forEach(function (object) { currentRoom.objects.forEach(function (object) {
object.actions.forEach(function (action) { object.actions.forEach(function (action) {
actions.push(action);
if (action.conditions == undefined || action.conditions.reduce((result, cond) => result && cond(prefs), true))
actions.push(action);
}); });
}); });




+ 27
- 0
objects.js 查看文件

@@ -34,6 +34,33 @@ function Toilet() {
update(["You admire the toilet."]); update(["You admire the toilet."]);
} }
}); });
this.actions.push({
"name": "Use toilet",
"action": function() {
let lines = [];

lines.push("You sit down on the toilet.");

if (player.bowels.fullness == 0) {
lines.push("But nothing happens.");
} else {
lines.push("You grunt and clench, squeezing out the remains of your former prey.");
}

if (player.bowels.contents.length > 0) {
lines.push("The remains of " + join(player.bowels.contents) + " empty into the sewers as you flush them away.");
}

player.bowels.contents = [];

update(lines);
},
"conditions": [
function(prefs) {
return prefs.player.scat == true;
}
]
});
} }


function TV() { function TV() {


正在加载...
取消
保存