Browse Source

Squashed some commits because Fen made an oops again

tags/v0.2.9
Fen Dweller 7 years ago
parent
commit
0b471c8f0e
3 changed files with 31 additions and 9 deletions
  1. +3
    -0
      feast.css
  2. +1
    -9
      feast.html
  3. +27
    -0
      feast.js

+ 3
- 0
feast.css View File

@@ -141,6 +141,9 @@ button {
overflow: auto; overflow: auto;
} }


.log-entry-padded {
margin: 50px 0px 0px 0px;
}
.stats { .stats {
float: right; float: right;
flex: 1; flex: 1;


+ 1
- 9
feast.html View File

@@ -50,15 +50,7 @@
</div> </div>
</div> </div>
<div id="log"> <div id="log">
<div>
Welcome to Feast v0.2.8
</div>
<div>
&nbsp;
</div>
<div>
It's early morning, and you feel like eating a bunch of people
</div>
</div> </div>
<div class="stats"> <div class="stats">
<div id="foe-stats"> <div id="foe-stats">


+ 27
- 0
feast.js View File

@@ -23,6 +23,7 @@ let deaths = [];
let respawnRoom; let respawnRoom;


let noLog = false; let noLog = false;
let logPadLine = undefined;


let MIDNIGHT = 0; let MIDNIGHT = 0;
let MORNING = 21600; let MORNING = 21600;
@@ -313,6 +314,9 @@ function renderTime(time) {
function move(direction) { function move(direction) {
if (noLog) if (noLog)
clearScreen(); clearScreen();
else
clearLogBreak();

let target = currentRoom.exits[direction]; let target = currentRoom.exits[direction];
if (target == null) { if (target == null) {
alert("Tried to move to an empty room!"); alert("Tried to move to an empty room!");
@@ -372,6 +376,8 @@ function start() {
world = createWorld(); world = createWorld();
currentRoom = world["Bedroom"]; currentRoom = world["Bedroom"];
respawnRoom = currentRoom; respawnRoom = currentRoom;
update(new Array(50).fill(newline));
update(["Welcome to Feast."]);
moveTo(currentRoom,""); moveTo(currentRoom,"");
updateDisplay(); updateDisplay();
} }
@@ -479,9 +485,17 @@ function clearScreen() {


function update(lines=[]) { function update(lines=[]) {
let log = document.getElementById("log"); let log = document.getElementById("log");


for (let i=0; i<lines.length; i++) { for (let i=0; i<lines.length; i++) {
let div = document.createElement("div"); let div = document.createElement("div");
div.innerHTML = lines[i]; div.innerHTML = lines[i];

if (logPadLine === undefined && !noLog) {
logPadLine = div;
logPadLine.classList.add("log-entry-padded");
}

log.appendChild(div); log.appendChild(div);
} }


@@ -490,6 +504,13 @@ function update(lines=[]) {
updateDisplay(); updateDisplay();
} }


function clearLogBreak() {
if (logPadLine !== undefined) {
logPadLine.classList.remove("log-entry-padded");
logPadLine = undefined;
}
}

function changeMode(newMode) { function changeMode(newMode) {
mode = newMode; mode = newMode;
let body = document.querySelector("body"); let body = document.querySelector("body");
@@ -578,6 +599,8 @@ function startCombat(opponent) {
function attackClicked(index) { function attackClicked(index) {
if (noLog) if (noLog)
clearScreen(); clearScreen();
else
clearLogBreak();
update(playerAttacks[index].attack(currentFoe).concat([newline])); update(playerAttacks[index].attack(currentFoe).concat([newline]));


if (currentFoe.health <= 0) { if (currentFoe.health <= 0) {
@@ -623,6 +646,8 @@ function attackHovered(index) {
function struggleClicked(index) { function struggleClicked(index) {
if (noLog) if (noLog)
clearScreen(); clearScreen();
else
clearLogBreak();
let struggle = struggles[index]; let struggle = struggles[index];


let result = struggle.struggle(player); let result = struggle.struggle(player);
@@ -657,6 +682,8 @@ function struggleHovered(index) {
function startDialog(dialog) { function startDialog(dialog) {
if (noLog) if (noLog)
clearScreen(); clearScreen();
else
clearLogBreak();
currentDialog = dialog; currentDialog = dialog;
changeMode("dialog"); changeMode("dialog");
update(currentDialog.text.concat([newline])); update(currentDialog.text.concat([newline]));


Loading…
Cancel
Save