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;
}

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


+ 1
- 9
feast.html View File

@@ -50,15 +50,7 @@
</div>
</div>
<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 class="stats">
<div id="foe-stats">


+ 27
- 0
feast.js View File

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

let noLog = false;
let logPadLine = undefined;

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

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

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


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

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

log.appendChild(div);
}

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

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

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

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

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


Loading…
Cancel
Save