11 Commits

Author SHA1 Message Date
pyrex a3c16e1aca Deal with save corruption correctly 2025-02-24 20:13:48 -08:00
pyrex 2c121f0c8a Integrate save system 2025-02-24 20:09:15 -08:00
pyrex 32b6bf0b53 Merge branch 'main' into savesystem 2025-02-24 19:18:05 -08:00
kistaro 6fe843bf55 Save on end-of-day, or after endgame.
Putting it here avoids a circular reference problem
2025-02-23 22:30:57 -08:00
kistaro 93ef512554 oops, forgot to save the split-up of save.ts 2025-02-23 22:28:34 -08:00
kistaro 3a968af5ca autoformat the world 2025-02-23 22:25:19 -08:00
kistaro 2837461add create StateManager from file 2025-02-23 22:23:27 -08:00
kistaro 58b8bbc27b oops, missed revisions in StateManager 2025-02-23 22:21:10 -08:00
kistaro a149938f00 violently read player from file 2025-02-23 22:20:05 -08:00
kistaro b24e24a7ca Merge branch 'main' into savesystem 2025-02-23 20:59:52 -08:00
kistaro 3aba0beac5 prototype for writing a save 2025-02-23 20:59:15 -08:00
5 changed files with 11 additions and 21 deletions
-8
View File
@@ -111,14 +111,6 @@ class Input {
return this.#mousePosition;
}
isAnyKeyDown(...keys: string[]) : boolean {
for (const k of keys) {
if(this.isKeyDown(k)) {
return true
}
}
return false
}
isKeyDown(key: string): boolean {
return this.#keyDown[key];
}
+3 -3
View File
@@ -84,12 +84,12 @@ export class Hotbar {
#offerSleep() {
let bloodAmount = getPlayerProgress().getBlood();
let sleepText = "You're exhausted. Sleep and save your game?";
let sleepText = "You're exhausted.";
if (bloodAmount > 100) {
sleepText =
"You've got some energy left -- are you sure you want to sleep and save your game?";
"You've got some energy left -- are you sure you want to sleep?";
} else if (bloodAmount > 2000) {
sleepText = "Are you sure you want to sleep and save your game? You have so much energy.";
sleepText = "Are you sure you want to sleep? You have so much energy.";
}
getCheckModal().show(
+4 -4
View File
@@ -155,19 +155,19 @@ export class HuntMode {
let mvdx = 0;
let mvdy = 0;
if (I.isAnyKeyDown("w", "k", "ArrowUp")) {
if (I.isKeyDown("w")) {
touched = true;
mvdy -= amt;
}
if (I.isAnyKeyDown("s", "j", "ArrowDown")) {
if (I.isKeyDown("s")) {
touched = true;
mvdy += amt;
}
if (I.isAnyKeyDown("a", "h", "ArrowLeft")) {
if (I.isKeyDown("a")) {
touched = true;
mvdx -= amt;
}
if (I.isAnyKeyDown("d", "l", "ArrowRight")) {
if (I.isKeyDown("d")) {
touched = true;
mvdx += amt;
}
+3 -5
View File
@@ -30,8 +30,6 @@ const NUM_ROOMS_DESIRED = 1;
const EXTRA_CONNECTOR_CHANCE = 0.15;
const WINDING_PERCENT = 50;
const DEBUG = false;
// This is an implementation of Nystrom's algorithm:
// https://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/
class Knife {
@@ -100,7 +98,7 @@ class Knife {
}
showDebug(merged: Record<number, number>) {
if (DEBUG) {
if (true) {
let out = "";
let errors: string[] = [];
const size = this.#regions.size;
@@ -112,7 +110,7 @@ class Knife {
return this.#sealedWalls.get(loc) ? "◘" : "█";
}
let r = this.#regions.get(loc);
if (r !== null) {
if (typeof r === "number") {
const resolved = merged[r];
if (typeof resolved === "number") {
r = resolved;
@@ -757,7 +755,7 @@ function dedup(items: number[]): number[] {
}
function showDebug(grid: LoadedNewMap) {
if (DEBUG) {
if (true) {
let out = "";
for (let y = 0; y < grid.size.h; y++) {
for (let x = 0; x < grid.size.w; x++) {
+1 -1
View File
@@ -17,5 +17,5 @@ Your Progenitor
PS: Left mouse + WASD. Like Quake! Arrows or HJKL work too.`,
PS: Left mouse + WASD. Like Quake!`,
]);