Selaa lähdekoodia

Added General Save/Load/Inventory buttons

*added a new panel with save/load options
*added a confirmation system to work with the save/load options
*moved Save/Load messages into the saveGame/loadGame Functions
tags/v0.2.9
jsb5468 5 vuotta sitten
vanhempi
commit
7e76622b3e
4 muutettua tiedostoa jossa 73 lisäystä ja 5 poistoa
  1. +12
    -0
      feast.css
  2. +8
    -1
      feast.html
  3. +53
    -0
      feast.js
  4. +0
    -4
      objects.js

+ 12
- 0
feast.css Näytä tiedosto

@@ -65,6 +65,12 @@ button {
font-size: 18px;
user-select: none;
}
.option-button {
width: 100px;
height: 50px;
font-size: 18px;
user-select: none;
}

#compass {
padding: 10px;
@@ -149,6 +155,12 @@ button {
flex: 1;
}

.options {
flex-wrap: wrap;
max-width: 100px;
height:50%;
}

#player-stats {
height: 75%;
}


+ 8
- 1
feast.html Näytä tiedosto

@@ -47,10 +47,17 @@
<div class="stat-line" id="stat-breasts">Fractal Prospectus: 99/100</div>
<button class="stat-button" id="stat-button-status">Status</button>
<button class="stat-button" id="log-button">Log: Enabled</button>
</div>
</div>
<div id="log">
</div>
<div class="options">
<div id="options">
<button class="option-button" id="save-button">Save Game</button>
<button class="option-button" id="load-button">Load Game</button>
<button class="option-button" id="inventory-button">Inventory</button>
</div>
</div>
<div class="stats">
<div id="foe-stats">


+ 53
- 0
feast.js Näytä tiedosto

@@ -376,6 +376,8 @@ function start() {
document.getElementById("game").style.display = "block";
document.getElementById("stat-button-status").addEventListener("click", status, false);
document.getElementById("log-button").addEventListener("click", toggleLog, false);
document.getElementById("load-button").addEventListener("click", loadGameButton, false);
document.getElementById("save-button").addEventListener("click", saveGameButton, false);
loadCompass();
loadDialog();
world = createWorld();
@@ -520,6 +522,7 @@ function changeMode(newMode) {
mode = newMode;
let body = document.querySelector("body");
document.getElementById("foe-stats").style.display = "none";
document.getElementById("options").style.display = "block";
body.className = "";
switch(mode) {
case "explore":
@@ -529,9 +532,11 @@ function changeMode(newMode) {
case "combat":
body.classList.add("combat");
document.getElementById("foe-stats").style.display = "block";
document.getElementById("options").style.display = "none";
break;
case "eaten":
body.classList.add("eaten");
document.getElementById("options").style.display = "none";
document.getElementById("foe-stats").style.display = "block";
break;
}
@@ -931,6 +936,8 @@ function saveGame() {
let stringified = JSON.stringify(save);

window.localStorage.setItem("save", stringified);
update(["Game saved."]);
updateDisplay();
}

function loadGame() {
@@ -953,12 +960,58 @@ function loadGame() {

clearScreen();
moveToByName(save.position, "");
update(["Game loaded."]);
updateDisplay();
}

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

var confirmTimer;
let confirmState = "";
let confirmStateText = "";

function buttonConfirm(targetedButton, buttonText){
if(confirmState != ""){
buttonConfirmEnd();
}
document.getElementById([targetedButton]).innerHTML = "Confirm?"; //changes button text to "Confirm?"
confirmState = targetedButton;
confirmStateText = buttonText;
confirmTimer = setTimeout(buttonConfirmEnd, 5000); //5000 is 5 seconds
}

function buttonConfirmEnd(){
let targetedButtonText = document.getElementById([confirmState]).innerHTML;
document.getElementById([confirmState]).innerHTML = [confirmStateText];
confirmState = "";
clearTimeout(confirmTimer);
}

function saveGameButton(){
let targetedButton = "save-button";
if (confirmState === targetedButton){
buttonConfirmEnd();
saveGame();
}else{
buttonConfirm(targetedButton, "Save Game");
}
}

function loadGameButton(){
let targetedButton = "load-button";
if (confirmState === targetedButton){
buttonConfirmEnd();
loadGame();
}else{
buttonConfirm(targetedButton, "Load Game");
}
}



// wow polyfills

if (![].includes) {


+ 0
- 4
objects.js Näytä tiedosto

@@ -105,16 +105,12 @@ function Bed() {
"name": "Save Game",
"action": function() {
saveGame();
update(["Game saved."]);
updateDisplay();
}
});
this.actions.push({
"name": "Load Game",
"action": function() {
loadGame();
update(["Game loaded."]);
updateDisplay();
}
});
this.actions.push({


Loading…
Peruuta
Tallenna