From 0390d549095d01f4c728d585b90dfb474a24ebfc Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Mon, 31 Aug 2020 10:27:29 -0600 Subject: [PATCH] Styled the whole page; reimplemented pausing; implemented success, score, and time --- button.png | Bin 0 -> 187 bytes js/main.js | 205 ++++++++++++++++++++++++++++++++++++++---------- js/tiletypes.js | 7 +- style.css | 176 +++++++++++++++++++++++++++++++++-------- 4 files changed, 312 insertions(+), 76 deletions(-) create mode 100644 button.png diff --git a/button.png b/button.png new file mode 100644 index 0000000000000000000000000000000000000000..27b74a51fc78d37c9aab55d8be340666606253bd GIT binary patch literal 187 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDB3?!H8JlO)I6p}rHd>I(3)EF2VS{N990fib~ zFff$rGcdf0XJD|J&cGmEP$RmF5h%eQ;1l91B_-wM<<-;Evw7S0yZ7(EF&Ewkl(P18 zaSX9Iot&T`yCZ@1hsu 0) { - if (!(children[0] instanceof Node) && typeof(children[0]) !== "string" && typeof(children[0]) !== "number") { + if (!(children[0] instanceof Node) && children[0] !== undefined && typeof(children[0]) !== "string" && typeof(children[0]) !== "number") { let [attrs] = children.splice(0, 1); for (let [key, value] of Object.entries(attrs)) { el.setAttribute(key, value); @@ -235,7 +235,8 @@ class Level { // playing: normal play // success: has been won // failure: died - // paused: paused + // note that pausing is NOT handled here, but by whatever's driving our + // event loop! this.state = 'playing'; } @@ -244,6 +245,14 @@ class Level { this.player = null; this.actors = []; this.chips_remaining = this.stored_level.chips_required; + if (this.stored_level.time_limit === 0) { + this.time_remaining = null; + } + else { + this.time_remaining = this.stored_level.time_limit; + } + this.bonus_points = 0; + this.tic_counter = 0; this.hint_shown = null; @@ -282,9 +291,8 @@ class Level { advance_tic(player_direction) { if (this.state !== 'playing') { - // FIXME this breaks the step buttons; maybe pausing should be in game only - //console.warn(`Level.advance_tic() called when state is ${this.state}`); - //return; + console.warn(`Level.advance_tic() called when state is ${this.state}`); + return; } // XXX this entire turn order is rather different in ms rules @@ -388,6 +396,17 @@ class Level { if (this.state === 'success' || this.state === 'failure') break; } + + if (this.time_remaining !== null) { + this.tic_counter++; + while (this.tic_counter > 20) { + this.tic_counter -= 20; + this.time_remaining -= 1; + if (this.time_remaining <= 0) { + this.fail("Time's up!"); + } + } + } } fail(message) { @@ -395,6 +414,10 @@ class Level { this.fail_message = message; } + win() { + this.state = 'success'; + } + // Try to move the given actor one tile in the given direction and update // their cooldown. Return true if successful. attempt_step(actor, direction) { @@ -526,34 +549,58 @@ class Level { // TODO: // - some kinda visual theme i guess lol -// - level /number/ // - level password, if any -// - set name -// - timer! -// - intro splash with list of available levels +// - timer!!!!! +// - bonus points (cc2 only, or maybe only if got any so far this level) +// - intro splash with list of available level packs // - button: quit to splash // - button: options // - implement winning and show score for this level // - show current score so far +// - about, help const GAME_UI_HTML = ` +
+

Lexy's Labyrinth

+ +
+
+

Chip's Challenge Level Pack 1

+ +

Level 1 — Key Pyramid

+ +
-
-