Refactor org web content and simplify shared UI
All checks were successful
Build Org Website / build (push) Successful in 44s
All checks were successful
Build Org Website / build (push) Successful in 44s
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
var script = document.createElement("script");
|
||||
script.src = "/assets/scripts/pages/ash-below-lake.js";
|
||||
script.defer = true;
|
||||
document.head.appendChild(script);
|
||||
}());
|
||||
114
assets/scripts/pages/archive-world-state.js
Normal file
114
assets/scripts/pages/archive-world-state.js
Normal file
@@ -0,0 +1,114 @@
|
||||
(function (root, factory) {
|
||||
"use strict";
|
||||
|
||||
const api = factory();
|
||||
if (typeof module === "object" && module.exports) module.exports = api;
|
||||
root.ArchiveWorldState = api;
|
||||
}(typeof globalThis !== "undefined" ? globalThis : this, function () {
|
||||
"use strict";
|
||||
|
||||
const VERSION = 1;
|
||||
const STORAGE_KEY = "zxh_archive_world_v1";
|
||||
const PALETTES = Object.freeze(["brass", "moss", "berry"]);
|
||||
const LANDMARK_IDS = Object.freeze([
|
||||
"gate",
|
||||
"library",
|
||||
"study",
|
||||
"inn",
|
||||
"workshop",
|
||||
"playroom",
|
||||
"museum",
|
||||
"garden"
|
||||
]);
|
||||
const SPAWN = Object.freeze({ x: 640, y: 830 });
|
||||
|
||||
function validateName(value) {
|
||||
const name = String(value || "").trim().replace(/\s+/g, " ");
|
||||
return name.length >= 1 && name.length <= 20 ? name : null;
|
||||
}
|
||||
|
||||
function validatePalette(value) {
|
||||
return PALETTES.includes(value) ? value : null;
|
||||
}
|
||||
|
||||
function fresh(name, palette) {
|
||||
return {
|
||||
version: VERSION,
|
||||
name: validateName(name) || "",
|
||||
palette: validatePalette(palette) || "brass",
|
||||
discovered: [],
|
||||
complete: false,
|
||||
position: { x: SPAWN.x, y: SPAWN.y },
|
||||
soundEnabled: false
|
||||
};
|
||||
}
|
||||
|
||||
function clamp(value, min, max, fallback) {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? Math.min(max, Math.max(min, number)) : fallback;
|
||||
}
|
||||
|
||||
function normalize(candidate) {
|
||||
if (!candidate || candidate.version !== VERSION) return null;
|
||||
const name = validateName(candidate.name);
|
||||
const palette = validatePalette(candidate.palette);
|
||||
if (!name || !palette) return null;
|
||||
|
||||
const discovered = Array.isArray(candidate.discovered)
|
||||
? Array.from(new Set(candidate.discovered.filter((id) => LANDMARK_IDS.includes(id))))
|
||||
: [];
|
||||
|
||||
return {
|
||||
version: VERSION,
|
||||
name,
|
||||
palette,
|
||||
discovered,
|
||||
complete: LANDMARK_IDS.every((id) => discovered.includes(id)),
|
||||
position: {
|
||||
x: clamp(candidate.position && candidate.position.x, 36, 1244, SPAWN.x),
|
||||
y: clamp(candidate.position && candidate.position.y, 36, 924, SPAWN.y)
|
||||
},
|
||||
soundEnabled: candidate.soundEnabled === true
|
||||
};
|
||||
}
|
||||
|
||||
function parse(raw) {
|
||||
if (!raw) return null;
|
||||
try {
|
||||
return normalize(JSON.parse(raw));
|
||||
} catch (_error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function discover(state, landmarkId) {
|
||||
const current = normalize(state);
|
||||
if (!current || !LANDMARK_IDS.includes(landmarkId)) return current;
|
||||
if (!current.discovered.includes(landmarkId)) current.discovered.push(landmarkId);
|
||||
current.complete = LANDMARK_IDS.every((id) => current.discovered.includes(id));
|
||||
return current;
|
||||
}
|
||||
|
||||
function withPosition(state, x, y) {
|
||||
const current = normalize(state);
|
||||
if (!current) return null;
|
||||
current.position.x = clamp(x, 36, 1244, SPAWN.x);
|
||||
current.position.y = clamp(y, 36, 924, SPAWN.y);
|
||||
return current;
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
VERSION,
|
||||
STORAGE_KEY,
|
||||
PALETTES,
|
||||
LANDMARK_IDS,
|
||||
SPAWN,
|
||||
validateName,
|
||||
validatePalette,
|
||||
fresh,
|
||||
normalize,
|
||||
parse,
|
||||
discover,
|
||||
withPosition
|
||||
});
|
||||
}));
|
||||
420
assets/scripts/pages/archive-world.js
Normal file
420
assets/scripts/pages/archive-world.js
Normal file
@@ -0,0 +1,420 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const State = window.ArchiveWorldState;
|
||||
const LANDMARKS = Object.freeze({
|
||||
gate: landmark("Town Gate", "Arrivals", 640, 830,
|
||||
"The old gate remembers every arrival. Begin at the dashboard or follow the newest paths.",
|
||||
[["Home", "/"], ["Recently updated", "/recently-updated.html"], ["Contact", "/home/contact.html"]]),
|
||||
library: landmark("Grand Library", "Knowledge", 260, 285,
|
||||
"Long-lived explanations, categories, and learning notes fill the blue-roofed library.",
|
||||
[["Posts", "/posts/posts-list.html"], ["Categories", "/home/categories.html"], ["Posts introduction", "/posts/posts-intro.html"]]),
|
||||
study: landmark("Guild Study", "Work", 640, 250,
|
||||
"Engineering notes, professional lessons, and active competencies cover every desk.",
|
||||
[["Career", "/posts/career/career-list.html"], ["Competency status", "/home/status.html"], ["Probation objectives", "/posts/career/probation-objectives.html"]]),
|
||||
inn: landmark("Kitchen Inn", "Daily life", 1005, 270,
|
||||
"Weekly reviews and ordinary days stay warm beside the inn's oven.",
|
||||
[["Blogs", "/blogs/blogs-list.html"], ["Weekly reviews", "/tags/review.html"], ["Blogs introduction", "/blogs/blogs-intro.html"]]),
|
||||
workshop: landmark("Workshop", "Living systems", 1030, 535,
|
||||
"Trackers, services, plans, and practical machinery keep the town moving.",
|
||||
[["Services", "/home/services.html"], ["Wird tracker", "/home/wird-tracker.html"], ["Countdowns", "/home/countdown.html"], ["Backlog", "/home/backlog.html"]]),
|
||||
playroom: landmark("Playroom", "Experiments", 1005, 765,
|
||||
"Games, generators, and stranger little mechanisms glow behind the bright windows.",
|
||||
[["Play hub", "/play/play.html"], ["The Rain Index", "/play/the-rain-index.html"], ["House of Pages", "/play/house.html"]]),
|
||||
museum: landmark("Lima Museum", "Keepsakes", 275, 765,
|
||||
"Personal fragments, older writing, and small memories rest beneath the glass roof.",
|
||||
[["Lima archive", "/lima/index.html"], ["Older writing", "/blogs/2025/2025-list.html"], ["Memory Cabinet", "/play/memory.html"]]),
|
||||
garden: landmark("Notes Garden", "Connections", 220, 515,
|
||||
"Loose notes, paths between topics, and recently tended pages grow beyond the trellis.",
|
||||
[["Notes wall", "/home/notes.html"], ["Categories", "/home/categories.html"], ["Recently updated", "/recently-updated.html"], ["Sitemap", "/sitemap.html"]])
|
||||
});
|
||||
|
||||
const PALETTE_TINTS = Object.freeze({
|
||||
brass: 0xf1c46f,
|
||||
moss: 0x91c788,
|
||||
berry: 0xd894ad
|
||||
});
|
||||
|
||||
const controller = {
|
||||
state: null,
|
||||
scene: null,
|
||||
lock: false,
|
||||
move: { up: false, down: false, left: false, right: false },
|
||||
reducedMotion: window.matchMedia("(prefers-reduced-motion: reduce)").matches,
|
||||
saveTimer: 0
|
||||
};
|
||||
|
||||
function landmark(title, eyebrow, x, y, description, links) {
|
||||
return Object.freeze({ title, eyebrow, x, y, description, links: Object.freeze(links) });
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
function init() {
|
||||
const root = document.querySelector('.archive-world[data-play-page="archive-world"]');
|
||||
if (!root || !State) return;
|
||||
|
||||
const stored = State.parse(localStorage.getItem(State.STORAGE_KEY));
|
||||
controller.state = stored;
|
||||
bindInterface(root);
|
||||
|
||||
if (!window.Phaser) {
|
||||
setStatus(root, "The world engine could not load. Every destination remains available in the plain directory.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stored) {
|
||||
startGame(root);
|
||||
} else {
|
||||
openSetup(root);
|
||||
}
|
||||
}
|
||||
|
||||
function bindInterface(root) {
|
||||
const setup = root.querySelector("[data-world-setup]");
|
||||
const setupForm = root.querySelector("[data-world-setup-form]");
|
||||
const preview = root.querySelector("[data-world-preview]");
|
||||
const journal = root.querySelector("[data-world-journal]");
|
||||
|
||||
setup.addEventListener("cancel", (event) => event.preventDefault());
|
||||
setupForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const data = new FormData(setupForm);
|
||||
const name = State.validateName(data.get("name"));
|
||||
const palette = State.validatePalette(data.get("palette"));
|
||||
const error = root.querySelector("[data-world-setup-error]");
|
||||
if (!name || !palette) {
|
||||
error.textContent = "Choose a palette and enter a name between 1 and 20 characters.";
|
||||
return;
|
||||
}
|
||||
controller.state = State.fresh(name, palette);
|
||||
persist();
|
||||
setup.close();
|
||||
startGame(root);
|
||||
});
|
||||
|
||||
root.querySelector("[data-world-preview-close]").addEventListener("click", () => preview.close());
|
||||
preview.addEventListener("close", () => {
|
||||
controller.lock = false;
|
||||
root.querySelector("#archive-world-game").focus();
|
||||
});
|
||||
|
||||
root.querySelector("[data-world-journal-open]").addEventListener("click", () => {
|
||||
renderJournal(root);
|
||||
controller.lock = true;
|
||||
journal.showModal();
|
||||
});
|
||||
root.querySelector("[data-world-journal-close]").addEventListener("click", () => journal.close());
|
||||
journal.addEventListener("close", () => {
|
||||
controller.lock = false;
|
||||
root.querySelector("[data-world-journal-open]").focus();
|
||||
});
|
||||
|
||||
root.querySelector("[data-world-sound]").addEventListener("click", () => toggleSound(root));
|
||||
root.querySelector("[data-world-reset]").addEventListener("click", () => {
|
||||
if (!window.confirm("Reset your traveler, discoveries, and saved position?")) return;
|
||||
localStorage.removeItem(State.STORAGE_KEY);
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
root.querySelectorAll("[data-world-move]").forEach((button) => {
|
||||
const direction = button.dataset.worldMove;
|
||||
const down = (event) => {
|
||||
event.preventDefault();
|
||||
controller.move[direction] = true;
|
||||
};
|
||||
const up = (event) => {
|
||||
event.preventDefault();
|
||||
controller.move[direction] = false;
|
||||
};
|
||||
button.addEventListener("pointerdown", down);
|
||||
button.addEventListener("pointerup", up);
|
||||
button.addEventListener("pointercancel", up);
|
||||
button.addEventListener("pointerleave", up);
|
||||
});
|
||||
root.querySelector("[data-world-interact]").addEventListener("click", () => {
|
||||
if (controller.scene) controller.scene.interact();
|
||||
});
|
||||
|
||||
window.addEventListener("pagehide", savePosition);
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (document.hidden) savePosition();
|
||||
});
|
||||
}
|
||||
|
||||
function openSetup(root) {
|
||||
const dialog = root.querySelector("[data-world-setup]");
|
||||
window.setTimeout(() => {
|
||||
dialog.showModal();
|
||||
dialog.querySelector("input[name=name]").focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function startGame(root) {
|
||||
renderHud(root);
|
||||
const game = new Phaser.Game({
|
||||
type: Phaser.AUTO,
|
||||
parent: "archive-world-game",
|
||||
width: 960,
|
||||
height: 640,
|
||||
backgroundColor: "#17251e",
|
||||
pixelArt: true,
|
||||
roundPixels: true,
|
||||
physics: {
|
||||
default: "arcade",
|
||||
arcade: { debug: false }
|
||||
},
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_BOTH
|
||||
},
|
||||
scene: ArchiveTownScene,
|
||||
input: {
|
||||
keyboard: true,
|
||||
mouse: true,
|
||||
touch: true
|
||||
}
|
||||
});
|
||||
root.dataset.gameReady = "true";
|
||||
root.querySelector("#archive-world-game").focus();
|
||||
window.archiveWorldGame = game;
|
||||
}
|
||||
|
||||
class ArchiveTownScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super("ArchiveTown");
|
||||
this.nearest = null;
|
||||
this.lastStepAt = 0;
|
||||
this.wasMoving = false;
|
||||
}
|
||||
|
||||
preload() {
|
||||
this.load.image("archive-town", "/assets/images/play/archive-world/archive-town.webp");
|
||||
this.load.image("traveler", "/assets/images/play/archive-world/traveler.png");
|
||||
this.load.audio("ambient", "/assets/audio/archive-world/ambient.ogg");
|
||||
this.load.audio("step", "/assets/audio/archive-world/step.wav");
|
||||
this.load.audio("discover", "/assets/audio/archive-world/discover.wav");
|
||||
this.load.audio("portal", "/assets/audio/archive-world/portal.wav");
|
||||
}
|
||||
|
||||
create() {
|
||||
controller.scene = this;
|
||||
this.add.image(0, 0, "archive-town").setOrigin(0).setDepth(0);
|
||||
this.physics.world.setBounds(0, 0, 1280, 960);
|
||||
|
||||
this.markers = {};
|
||||
Object.entries(LANDMARKS).forEach(([id, item]) => {
|
||||
const marker = this.add.circle(item.x, item.y, 22, 0xf4d98a, 0.16)
|
||||
.setStrokeStyle(3, 0xf8e6a7, 0.9)
|
||||
.setDepth(2);
|
||||
marker.setData("landmarkId", id);
|
||||
this.markers[id] = marker;
|
||||
if (!controller.reducedMotion) {
|
||||
this.tweens.add({
|
||||
targets: marker,
|
||||
scale: 1.18,
|
||||
alpha: 0.58,
|
||||
duration: 900,
|
||||
yoyo: true,
|
||||
repeat: -1,
|
||||
delay: Object.keys(LANDMARKS).indexOf(id) * 90
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.player = this.physics.add.sprite(
|
||||
controller.state.position.x,
|
||||
controller.state.position.y,
|
||||
"traveler"
|
||||
).setDepth(4).setTint(PALETTE_TINTS[controller.state.palette]);
|
||||
this.player.setCollideWorldBounds(true);
|
||||
this.player.body.setSize(28, 34).setOffset(8, 58);
|
||||
|
||||
this.cameras.main.setBounds(0, 0, 1280, 960);
|
||||
this.cameras.main.startFollow(this.player, true, controller.reducedMotion ? 1 : 0.12, controller.reducedMotion ? 1 : 0.12);
|
||||
|
||||
this.cursors = this.input.keyboard.createCursorKeys();
|
||||
this.keys = this.input.keyboard.addKeys({
|
||||
up: Phaser.Input.Keyboard.KeyCodes.W,
|
||||
down: Phaser.Input.Keyboard.KeyCodes.S,
|
||||
left: Phaser.Input.Keyboard.KeyCodes.A,
|
||||
right: Phaser.Input.Keyboard.KeyCodes.D,
|
||||
interact: Phaser.Input.Keyboard.KeyCodes.E,
|
||||
enter: Phaser.Input.Keyboard.KeyCodes.ENTER
|
||||
});
|
||||
|
||||
this.ambient = this.sound.add("ambient", { loop: true, volume: 0.24 });
|
||||
this.stepSound = this.sound.add("step", { volume: 0.22 });
|
||||
this.discoverSound = this.sound.add("discover", { volume: 0.35 });
|
||||
this.portalSound = this.sound.add("portal", { volume: 0.3 });
|
||||
if (controller.state.soundEnabled) this.enableSound();
|
||||
|
||||
setStatus(document.querySelector(".archive-world"), `Welcome, ${controller.state.name}. Walk near a glowing landmark and press E, Space, or Enter.`);
|
||||
this.updateNearest();
|
||||
}
|
||||
|
||||
update(time) {
|
||||
if (!this.player) return;
|
||||
let dx = 0;
|
||||
let dy = 0;
|
||||
if (!controller.lock) {
|
||||
if (this.cursors.left.isDown || this.keys.left.isDown || controller.move.left) dx -= 1;
|
||||
if (this.cursors.right.isDown || this.keys.right.isDown || controller.move.right) dx += 1;
|
||||
if (this.cursors.up.isDown || this.keys.up.isDown || controller.move.up) dy -= 1;
|
||||
if (this.cursors.down.isDown || this.keys.down.isDown || controller.move.down) dy += 1;
|
||||
}
|
||||
|
||||
const moving = dx !== 0 || dy !== 0;
|
||||
if (moving) {
|
||||
const vector = new Phaser.Math.Vector2(dx, dy).normalize().scale(175);
|
||||
this.player.setVelocity(vector.x, vector.y);
|
||||
if (dx) this.player.setFlipX(dx < 0);
|
||||
if (!controller.reducedMotion) {
|
||||
this.player.rotation = Math.sin(time / 80) * 0.025;
|
||||
this.player.setScale(1, 0.98 + Math.abs(Math.sin(time / 95)) * 0.04);
|
||||
}
|
||||
if (controller.state.soundEnabled && time - this.lastStepAt > 340) {
|
||||
this.stepSound.play();
|
||||
this.lastStepAt = time;
|
||||
}
|
||||
if (time - controller.saveTimer > 700) {
|
||||
controller.saveTimer = time;
|
||||
savePosition();
|
||||
}
|
||||
} else {
|
||||
this.player.setVelocity(0, 0);
|
||||
this.player.rotation = 0;
|
||||
this.player.setScale(1);
|
||||
}
|
||||
this.wasMoving = moving;
|
||||
this.updateNearest();
|
||||
|
||||
if (!controller.lock && (
|
||||
Phaser.Input.Keyboard.JustDown(this.keys.interact) ||
|
||||
Phaser.Input.Keyboard.JustDown(this.keys.enter) ||
|
||||
Phaser.Input.Keyboard.JustDown(this.cursors.space)
|
||||
)) this.interact();
|
||||
}
|
||||
|
||||
updateNearest() {
|
||||
let nearest = null;
|
||||
let distance = Infinity;
|
||||
Object.entries(LANDMARKS).forEach(([id, item]) => {
|
||||
const nextDistance = Phaser.Math.Distance.Between(this.player.x, this.player.y, item.x, item.y);
|
||||
if (nextDistance < distance) {
|
||||
nearest = id;
|
||||
distance = nextDistance;
|
||||
}
|
||||
this.markers[id].setStrokeStyle(nextDistance < 95 ? 5 : 3, nextDistance < 95 ? 0xffffff : 0xf8e6a7, 0.95);
|
||||
});
|
||||
const next = distance < 95 ? nearest : null;
|
||||
if (next !== this.nearest) {
|
||||
this.nearest = next;
|
||||
const root = document.querySelector(".archive-world");
|
||||
setStatus(root, next
|
||||
? `${LANDMARKS[next].title} is nearby. Press E, Space, Enter, or Explore.`
|
||||
: "Follow the stone paths toward a glowing landmark.");
|
||||
}
|
||||
}
|
||||
|
||||
interact() {
|
||||
if (controller.lock) return;
|
||||
if (!this.nearest) {
|
||||
setStatus(document.querySelector(".archive-world"), "Move closer to one of the glowing landmark circles.");
|
||||
return;
|
||||
}
|
||||
openPreview(document.querySelector(".archive-world"), this.nearest);
|
||||
}
|
||||
|
||||
enableSound() {
|
||||
if (this.sound.locked && this.sound.unlock) this.sound.unlock();
|
||||
this.sound.mute = false;
|
||||
if (!this.ambient.isPlaying) this.ambient.play();
|
||||
}
|
||||
|
||||
disableSound() {
|
||||
this.sound.mute = true;
|
||||
if (this.ambient.isPlaying) this.ambient.pause();
|
||||
}
|
||||
}
|
||||
|
||||
function openPreview(root, id) {
|
||||
const item = LANDMARKS[id];
|
||||
if (!item) return;
|
||||
const wasDiscovered = controller.state.discovered.includes(id);
|
||||
controller.state = State.discover(controller.state, id);
|
||||
persist();
|
||||
controller.lock = true;
|
||||
|
||||
root.querySelector("[data-world-preview-eyebrow]").textContent = item.eyebrow;
|
||||
root.querySelector("[data-world-preview-title]").textContent = item.title;
|
||||
root.querySelector("[data-world-preview-description]").textContent = item.description;
|
||||
const links = root.querySelector("[data-world-preview-links]");
|
||||
links.replaceChildren();
|
||||
item.links.forEach(([label, href]) => {
|
||||
const anchor = document.createElement("a");
|
||||
anchor.href = href;
|
||||
anchor.textContent = label;
|
||||
anchor.addEventListener("click", () => {
|
||||
if (controller.scene && controller.state.soundEnabled) controller.scene.portalSound.play();
|
||||
savePosition();
|
||||
});
|
||||
links.appendChild(anchor);
|
||||
});
|
||||
|
||||
renderHud(root);
|
||||
if (!wasDiscovered && controller.scene && controller.state.soundEnabled) controller.scene.discoverSound.play();
|
||||
root.querySelector("[data-world-preview]").showModal();
|
||||
setStatus(root, wasDiscovered
|
||||
? `${item.title} is already recorded in your journal.`
|
||||
: `${item.title} was added to your discovery journal.`);
|
||||
}
|
||||
|
||||
function toggleSound(root) {
|
||||
if (!controller.state || !controller.scene) return;
|
||||
controller.state.soundEnabled = !controller.state.soundEnabled;
|
||||
if (controller.state.soundEnabled) controller.scene.enableSound();
|
||||
else controller.scene.disableSound();
|
||||
persist();
|
||||
renderHud(root);
|
||||
setStatus(root, controller.state.soundEnabled ? "Ambient sound is on." : "Sound is muted.");
|
||||
}
|
||||
|
||||
function savePosition() {
|
||||
if (!controller.state || !controller.scene || !controller.scene.player) return;
|
||||
controller.state = State.withPosition(controller.state, controller.scene.player.x, controller.scene.player.y);
|
||||
persist();
|
||||
}
|
||||
|
||||
function persist() {
|
||||
if (controller.state) localStorage.setItem(State.STORAGE_KEY, JSON.stringify(controller.state));
|
||||
}
|
||||
|
||||
function renderHud(root) {
|
||||
if (!controller.state) return;
|
||||
root.querySelector("[data-world-player]").textContent = controller.state.name;
|
||||
root.querySelector("[data-world-discovery-count]").textContent = `${controller.state.discovered.length} / ${State.LANDMARK_IDS.length}`;
|
||||
root.querySelector("[data-world-sound]").textContent = controller.state.soundEnabled ? "Sound: on" : "Sound: muted";
|
||||
const badge = root.querySelector("[data-world-badge]");
|
||||
badge.hidden = !controller.state.complete;
|
||||
renderJournal(root);
|
||||
}
|
||||
|
||||
function renderJournal(root) {
|
||||
if (!controller.state) return;
|
||||
const list = root.querySelector("[data-world-journal-list]");
|
||||
list.replaceChildren();
|
||||
State.LANDMARK_IDS.forEach((id) => {
|
||||
const row = document.createElement("li");
|
||||
const found = controller.state.discovered.includes(id);
|
||||
row.className = found ? "is-discovered" : "";
|
||||
row.textContent = `${found ? "Discovered" : "Unexplored"} — ${LANDMARKS[id].title}`;
|
||||
list.appendChild(row);
|
||||
});
|
||||
}
|
||||
|
||||
function setStatus(root, message) {
|
||||
const status = root && root.querySelector("[data-world-status]");
|
||||
if (status) status.textContent = message;
|
||||
}
|
||||
}());
|
||||
File diff suppressed because it is too large
Load Diff
@@ -236,5 +236,7 @@ async function loadBoard() {
|
||||
populateMobileControls(items);
|
||||
}
|
||||
|
||||
renderLevelTabs();
|
||||
loadBoard();
|
||||
if (document.getElementById("kanban-board")) {
|
||||
renderLevelTabs();
|
||||
loadBoard();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
caption: "A wooden moon rolls beneath the cabinet whenever nobody is looking.",
|
||||
curated: [
|
||||
["Play hub", "/play/play.html"],
|
||||
["Ash Below the Lake", "/play/rpg.html"],
|
||||
["The Archive World", "/play/rpg.html"],
|
||||
["The Rain Index", "/play/the-rain-index.html"]
|
||||
],
|
||||
include: ["/play/"],
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
const root = $(".play-root[data-play-page]");
|
||||
if (!root) return;
|
||||
const page = root.dataset.playPage;
|
||||
const inits = { hub, memory, constellation, poem, bookshelf, recipe, timeline, ink, terminal, study, sigil, rpg };
|
||||
const inits = { hub, memory, constellation, poem, bookshelf, ink, terminal, study, sigil };
|
||||
if (inits[page]) inits[page](root);
|
||||
});
|
||||
|
||||
@@ -256,63 +256,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recipe(root) {
|
||||
const wheel = $("[data-recipe-spin]", root);
|
||||
const result = $("[data-recipe-result]", root);
|
||||
const groups = [
|
||||
["Rice", "Flatbread", "Roast potatoes", "Noodles"],
|
||||
["Lemon chicken", "Spiced lentils", "Tomato eggs", "Pepper stew"],
|
||||
["Cucumber salad", "Mint yoghurt", "Pickled onions", "Charred greens"],
|
||||
["Serve with stories", "Eat outside", "Use the blue plates", "Make extra tea"]
|
||||
];
|
||||
let spin = 0;
|
||||
let feast = 0;
|
||||
wheel.addEventListener("click", () => {
|
||||
spin += 540 + Math.floor(Math.random() * 540);
|
||||
feast += 1;
|
||||
wheel.style.transform = `rotate(${spin}deg)`;
|
||||
result.innerHTML = groups.map((group) => `<li>${pick(group)}</li>`).join("") + (feast % 4 === 0 ? "<li>Bonus: someone gets the last crispy bit.</li>" : "");
|
||||
});
|
||||
wheel.click();
|
||||
}
|
||||
|
||||
function timeline(root) {
|
||||
const items = [
|
||||
{ year: "2022", text: "The personal web habit begins." },
|
||||
{ year: "2025", text: "Org publishing becomes the main site engine." },
|
||||
{ year: "2025", text: "Weekly reviews and career notes grow into a library." },
|
||||
{ year: "2026", text: "Dashboards, services, and authoring tools join the site." },
|
||||
{ year: "2026", text: "The play wing opens." }
|
||||
];
|
||||
const list = $("[data-timeline-list]", root);
|
||||
const status = $("[data-timeline-status]", root);
|
||||
const paradox = document.createElement("button");
|
||||
paradox.type = "button";
|
||||
paradox.textContent = "Paradox";
|
||||
$("[data-timeline-shuffle]", root).insertAdjacentElement("afterend", paradox);
|
||||
setupSortable(list, render, check);
|
||||
$("[data-timeline-shuffle]", root).addEventListener("click", () => render(shuffle(items)));
|
||||
paradox.addEventListener("click", () => render([...items].reverse()));
|
||||
render(shuffle(items));
|
||||
|
||||
function render(source) {
|
||||
list.innerHTML = "";
|
||||
source.forEach((item, index) => {
|
||||
const card = document.createElement("div");
|
||||
card.className = "timeline-card";
|
||||
card.draggable = true;
|
||||
card.dataset.value = String(items.indexOf(item));
|
||||
card.innerHTML = `<span>${item.year}</span><strong>${item.text}</strong>`;
|
||||
list.appendChild(card);
|
||||
});
|
||||
check();
|
||||
}
|
||||
function check() {
|
||||
const current = $$(".timeline-card", list).map((card) => Number(card.dataset.value));
|
||||
status.textContent = current.every((value, index) => value === index) ? "Timeline restored" : "Arrange the cards";
|
||||
}
|
||||
}
|
||||
|
||||
function ink(root) {
|
||||
const canvas = $("[data-ink-canvas]", root);
|
||||
const ctx = canvas.getContext("2d");
|
||||
@@ -492,353 +435,6 @@
|
||||
draw();
|
||||
}
|
||||
|
||||
function rpg(root) {
|
||||
if (window.AshBelowLakeRpg) return window.AshBelowLakeRpg(root);
|
||||
const canvas = $("[data-rpg-canvas]", root);
|
||||
const ctx = canvas.getContext("2d");
|
||||
const els = {
|
||||
speaker: $("[data-rpg-speaker]", root),
|
||||
line: $("[data-rpg-line]", root),
|
||||
room: $("[data-rpg-room]", root),
|
||||
route: $("[data-rpg-route]", root),
|
||||
hearts: $("[data-rpg-hearts]", root),
|
||||
quests: $("[data-rpg-quests]", root),
|
||||
inventory: $("[data-rpg-inventory]", root),
|
||||
status: $("[data-rpg-status]", root)
|
||||
};
|
||||
const tile = 32;
|
||||
const saveSlot = "hollow-archive";
|
||||
const fallbackKey = "play:rpg:hollow-archive";
|
||||
const items = {
|
||||
lamp: { label: "Desk Lamp", room: "entrance", x: 10, y: 8, color: "#f2c94c" },
|
||||
page: { label: "Loose Page", room: "stacks", x: 18, y: 5, color: "#f7efe0" },
|
||||
key: { label: "Basement Key", room: "garden", x: 4, y: 11, color: "#d59b45" }
|
||||
};
|
||||
const npcs = {
|
||||
archivist: { name: "Archivist", room: "entrance", x: 6, y: 6, color: "#b98bff" },
|
||||
shade: { name: "Shy Shade", room: "stacks", x: 17, y: 9, color: "#6ed0d4" },
|
||||
gate: { name: "Iron Door", room: "garden", x: 19, y: 10, color: "#8a8f98" }
|
||||
};
|
||||
const rooms = {
|
||||
entrance: {
|
||||
name: "Entrance",
|
||||
floor: "#353029",
|
||||
exits: [{ x: 22, y: 7, to: "stacks", px: 1, py: 7 }],
|
||||
walls: rects([[0, 0, 24, 1], [0, 15, 24, 1], [0, 0, 1, 16], [23, 0, 1, 6], [23, 9, 1, 7], [8, 3, 1, 8], [14, 7, 5, 1]])
|
||||
},
|
||||
stacks: {
|
||||
name: "Stacks",
|
||||
floor: "#242d35",
|
||||
exits: [{ x: 0, y: 7, to: "entrance", px: 22, py: 7 }, { x: 23, y: 12, to: "garden", px: 1, py: 12 }],
|
||||
walls: rects([[0, 0, 24, 1], [0, 15, 24, 1], [0, 0, 1, 6], [0, 9, 1, 7], [23, 0, 1, 11], [23, 14, 1, 2], [4, 3, 2, 10], [10, 2, 2, 11], [16, 3, 2, 5]])
|
||||
},
|
||||
garden: {
|
||||
name: "Moon Garden",
|
||||
floor: "#21362e",
|
||||
exits: [{ x: 0, y: 12, to: "stacks", px: 22, py: 12 }],
|
||||
walls: rects([[0, 0, 24, 1], [0, 15, 24, 1], [0, 0, 1, 11], [0, 14, 1, 2], [23, 0, 1, 16], [7, 4, 10, 1], [7, 10, 1, 4], [13, 10, 1, 4]])
|
||||
}
|
||||
};
|
||||
let state = freshState();
|
||||
let running = false;
|
||||
|
||||
function freshState() {
|
||||
return {
|
||||
room: "entrance",
|
||||
player: { x: 3, y: 7, facing: "down" },
|
||||
inventory: [],
|
||||
flags: {},
|
||||
route: "Undecided",
|
||||
hearts: 3,
|
||||
ending: null,
|
||||
message: { speaker: "Archivist", line: "The archive waits. Find the lamp, help the shade, then decide what to do with the locked door." }
|
||||
};
|
||||
}
|
||||
|
||||
function rects(sources) {
|
||||
const set = new Set();
|
||||
sources.forEach(([x, y, w, h]) => {
|
||||
for (let yy = y; yy < y + h; yy += 1) for (let xx = x; xx < x + w; xx += 1) set.add(`${xx},${yy}`);
|
||||
});
|
||||
return set;
|
||||
}
|
||||
|
||||
function draw() {
|
||||
const room = rooms[state.room];
|
||||
ctx.fillStyle = "#14110e";
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
for (let y = 0; y < 16; y += 1) {
|
||||
for (let x = 0; x < 24; x += 1) {
|
||||
ctx.fillStyle = room.walls.has(`${x},${y}`) ? "#181716" : room.floor;
|
||||
ctx.fillRect(x * tile, y * tile, tile, tile);
|
||||
ctx.strokeStyle = "rgba(255,255,255,0.035)";
|
||||
ctx.strokeRect(x * tile, y * tile, tile, tile);
|
||||
}
|
||||
}
|
||||
room.exits.forEach((exit) => drawGlyph(exit.x, exit.y, "#c48a41", "door"));
|
||||
Object.entries(items).forEach(([id, item]) => {
|
||||
if (item.room === state.room && !state.inventory.includes(id)) drawGlyph(item.x, item.y, item.color, "item");
|
||||
});
|
||||
Object.values(npcs).forEach((npc) => {
|
||||
if (npc.room === state.room) drawGlyph(npc.x, npc.y, npc.color, npc.name === "Iron Door" ? "doorNpc" : "npc");
|
||||
});
|
||||
drawPlayer();
|
||||
renderHud();
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
|
||||
function drawGlyph(x, y, color, kind) {
|
||||
const px = x * tile;
|
||||
const py = y * tile;
|
||||
ctx.fillStyle = color;
|
||||
if (kind === "item") {
|
||||
ctx.fillRect(px + 10, py + 10, 12, 12);
|
||||
ctx.fillStyle = "rgba(255,255,255,0.45)";
|
||||
ctx.fillRect(px + 13, py + 7, 6, 6);
|
||||
} else if (kind === "door" || kind === "doorNpc") {
|
||||
ctx.fillRect(px + 7, py + 4, 18, 25);
|
||||
ctx.fillStyle = "#211812";
|
||||
ctx.fillRect(px + 20, py + 16, 3, 3);
|
||||
} else {
|
||||
ctx.beginPath();
|
||||
ctx.arc(px + 16, py + 12, 9, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.fillRect(px + 8, py + 20, 16, 8);
|
||||
}
|
||||
}
|
||||
|
||||
function drawPlayer() {
|
||||
const px = state.player.x * tile;
|
||||
const py = state.player.y * tile;
|
||||
ctx.fillStyle = "#f35f5f";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(px + 16, py + 7);
|
||||
ctx.bezierCurveTo(px + 2, py + 2, px + 1, py + 22, px + 16, py + 28);
|
||||
ctx.bezierCurveTo(px + 31, py + 22, px + 30, py + 2, px + 16, py + 7);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = "#fff8e8";
|
||||
ctx.fillRect(px + 11, py + 13, 4, 4);
|
||||
ctx.fillRect(px + 18, py + 13, 4, 4);
|
||||
}
|
||||
|
||||
function renderHud() {
|
||||
els.speaker.textContent = state.message.speaker;
|
||||
els.line.textContent = state.ending ? endingLine() : state.message.line;
|
||||
els.room.textContent = rooms[state.room].name;
|
||||
els.route.textContent = state.route;
|
||||
els.hearts.textContent = String(state.hearts);
|
||||
els.inventory.innerHTML = state.inventory.length
|
||||
? state.inventory.map((id) => `<li>${items[id].label}</li>`).join("")
|
||||
: "<li>Empty</li>";
|
||||
const questRows = [
|
||||
["Find a light", state.inventory.includes("lamp")],
|
||||
["Return the loose page to the shade", state.flags.shadeHelped],
|
||||
["Open, force, or leave the iron door", Boolean(state.ending)]
|
||||
];
|
||||
els.quests.innerHTML = questRows.map(([text, done]) => `<li class="${done ? "is-done" : ""}">${done ? "Done: " : ""}${text}</li>`).join("");
|
||||
}
|
||||
|
||||
function move(dx, dy, facing) {
|
||||
if (!running || state.ending) return;
|
||||
state.player.facing = facing;
|
||||
const nx = state.player.x + dx;
|
||||
const ny = state.player.y + dy;
|
||||
const room = rooms[state.room];
|
||||
const exit = room.exits.find((candidate) => candidate.x === nx && candidate.y === ny);
|
||||
if (exit) {
|
||||
state.room = exit.to;
|
||||
state.player.x = exit.px;
|
||||
state.player.y = exit.py;
|
||||
say("Narrator", `You enter ${rooms[state.room].name}.`);
|
||||
autosave();
|
||||
return;
|
||||
}
|
||||
if (nx < 0 || ny < 0 || nx > 23 || ny > 15 || room.walls.has(`${nx},${ny}`) || npcAt(nx, ny)) return;
|
||||
state.player.x = nx;
|
||||
state.player.y = ny;
|
||||
const item = itemAt(nx, ny);
|
||||
if (item) take(item);
|
||||
}
|
||||
|
||||
function act() {
|
||||
if (!running) return start();
|
||||
if (state.ending) return;
|
||||
const front = inFront();
|
||||
const npc = npcAt(front.x, front.y);
|
||||
if (npc) talk(npc);
|
||||
else {
|
||||
const here = itemAt(state.player.x, state.player.y);
|
||||
if (here) take(here);
|
||||
else say("Narrator", "Dust moves in the light. Nothing asks to be changed here.");
|
||||
}
|
||||
autosave();
|
||||
}
|
||||
|
||||
function inFront() {
|
||||
const delta = { up: [0, -1], down: [0, 1], left: [-1, 0], right: [1, 0] }[state.player.facing] || [0, 1];
|
||||
return { x: state.player.x + delta[0], y: state.player.y + delta[1] };
|
||||
}
|
||||
|
||||
function itemAt(x, y) {
|
||||
return Object.keys(items).find((id) => {
|
||||
const item = items[id];
|
||||
return item.room === state.room && item.x === x && item.y === y && !state.inventory.includes(id);
|
||||
});
|
||||
}
|
||||
|
||||
function npcAt(x, y) {
|
||||
return Object.keys(npcs).find((id) => {
|
||||
const npc = npcs[id];
|
||||
return npc.room === state.room && npc.x === x && npc.y === y;
|
||||
});
|
||||
}
|
||||
|
||||
function take(id) {
|
||||
state.inventory.push(id);
|
||||
if (id === "lamp") state.route = "Gentle";
|
||||
if (id === "key" && !state.flags.shadeHelped) state.route = "Power";
|
||||
say("Found", `${items[id].label} joined your inventory.`);
|
||||
}
|
||||
|
||||
function talk(id) {
|
||||
if (id === "archivist") {
|
||||
if (!state.inventory.includes("lamp")) say("Archivist", "Take the lamp from the lower desk. The stacks dislike being crossed in the dark.");
|
||||
else if (!state.flags.shadeHelped) say("Archivist", "A loose page has gone missing. The quiet reader in the stacks knows where it belongs.");
|
||||
else say("Archivist", "You have been kind to a forgotten page. The garden door will remember that.");
|
||||
}
|
||||
if (id === "shade") {
|
||||
if (!state.inventory.includes("page")) say("Shy Shade", "I lost the page with my name on it. It fell somewhere nearby.");
|
||||
else {
|
||||
state.flags.shadeHelped = true;
|
||||
state.inventory = state.inventory.filter((item) => item !== "page");
|
||||
state.route = "Mercy";
|
||||
say("Shy Shade", "You returned my page instead of keeping it. Take the honest route through the garden.");
|
||||
}
|
||||
}
|
||||
if (id === "gate") {
|
||||
if (state.flags.shadeHelped) end("mercy");
|
||||
else if (state.inventory.includes("key")) end("power");
|
||||
else end("quiet");
|
||||
}
|
||||
}
|
||||
|
||||
function end(kind) {
|
||||
state.ending = kind;
|
||||
state.route = kind === "mercy" ? "Mercy" : kind === "power" ? "Power" : "Quiet";
|
||||
say("Ending", endingLine());
|
||||
save();
|
||||
}
|
||||
|
||||
function endingLine() {
|
||||
if (state.ending === "mercy") return "Mercy ending: the iron door opens without a sound, and every returned page remembers your name.";
|
||||
if (state.ending === "power") return "Power ending: the key turns, but the archive grows colder around the missing page.";
|
||||
if (state.ending === "quiet") return "Quiet ending: you leave the locked door alone. Some mysteries stay intact.";
|
||||
return state.message.line;
|
||||
}
|
||||
|
||||
function say(speaker, line) {
|
||||
state.message = { speaker, line };
|
||||
}
|
||||
|
||||
function start() {
|
||||
running = true;
|
||||
say("Archivist", "Walk the archive. Speak gently, or take what you need. The route will notice.");
|
||||
els.status.textContent = "Started. Progress autosaves after room changes and actions.";
|
||||
}
|
||||
|
||||
async function save() {
|
||||
localStorage.setItem(fallbackKey, JSON.stringify(state));
|
||||
try {
|
||||
const response = await fetch(`/api/play/rpg/save/${saveSlot}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ payload: state })
|
||||
});
|
||||
if (!response.ok) throw new Error(`Save failed: ${response.status}`);
|
||||
els.status.textContent = "Saved to backend.";
|
||||
} catch (_error) {
|
||||
els.status.textContent = "Saved locally. Backend save API was not reachable.";
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const response = await fetch(`/api/play/rpg/save/${saveSlot}`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
state = normalizeState(data.payload);
|
||||
running = true;
|
||||
els.status.textContent = "Loaded from backend.";
|
||||
return;
|
||||
}
|
||||
} catch (_error) {
|
||||
/* Fall through to local save. */
|
||||
}
|
||||
const local = localStorage.getItem(fallbackKey);
|
||||
if (local) {
|
||||
state = normalizeState(JSON.parse(local));
|
||||
running = true;
|
||||
els.status.textContent = "Loaded local save.";
|
||||
} else {
|
||||
els.status.textContent = "No save found.";
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeState(candidate) {
|
||||
return Object.assign(freshState(), candidate || {}, {
|
||||
player: Object.assign(freshState().player, (candidate && candidate.player) || {}),
|
||||
inventory: Array.isArray(candidate && candidate.inventory) ? candidate.inventory.filter((id) => items[id]) : [],
|
||||
flags: Object.assign({}, (candidate && candidate.flags) || {}),
|
||||
message: Object.assign(freshState().message, (candidate && candidate.message) || {})
|
||||
});
|
||||
}
|
||||
|
||||
function autosave() {
|
||||
save();
|
||||
}
|
||||
|
||||
$("[data-rpg-start]", root).addEventListener("click", start);
|
||||
$("[data-rpg-save]", root).addEventListener("click", save);
|
||||
$("[data-rpg-load]", root).addEventListener("click", load);
|
||||
$("[data-rpg-reset]", root).addEventListener("click", async () => {
|
||||
state = freshState();
|
||||
running = false;
|
||||
localStorage.removeItem(fallbackKey);
|
||||
try {
|
||||
await fetch(`/api/play/rpg/save/${saveSlot}`, { method: "DELETE" });
|
||||
els.status.textContent = "Reset and cleared backend save.";
|
||||
} catch (_error) {
|
||||
els.status.textContent = "Reset locally. Backend save API was not reachable.";
|
||||
}
|
||||
});
|
||||
$("[data-rpg-act]", root).addEventListener("click", act);
|
||||
$$("[data-rpg-move]", root).forEach((button) => {
|
||||
const moves = { up: [0, -1, "up"], down: [0, 1, "down"], left: [-1, 0, "left"], right: [1, 0, "right"] };
|
||||
button.addEventListener("click", () => move(...moves[button.dataset.rpgMove]));
|
||||
});
|
||||
window.addEventListener("keydown", (event) => {
|
||||
if (!root.isConnected) return;
|
||||
const tag = event.target.tagName;
|
||||
if (tag === "INPUT" || tag === "TEXTAREA") return;
|
||||
const keys = {
|
||||
ArrowUp: [0, -1, "up"], w: [0, -1, "up"],
|
||||
ArrowDown: [0, 1, "down"], s: [0, 1, "down"],
|
||||
ArrowLeft: [-1, 0, "left"], a: [-1, 0, "left"],
|
||||
ArrowRight: [1, 0, "right"], d: [1, 0, "right"]
|
||||
};
|
||||
if (keys[event.key]) {
|
||||
event.preventDefault();
|
||||
move(...keys[event.key]);
|
||||
}
|
||||
if (event.key === " " || event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
act();
|
||||
}
|
||||
});
|
||||
draw();
|
||||
load();
|
||||
}
|
||||
|
||||
function setupSortable(container, _render, after) {
|
||||
let dragged = null;
|
||||
container.addEventListener("dragstart", (event) => {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
if (!document.getElementById("wird-app")) return;
|
||||
|
||||
const API = "/api/wird";
|
||||
|
||||
// type: "count" | "juz" | "min" | "rating" | "nafl" | "khatm"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* Event listener for scrolling and changing the active label on the TOC */
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const toc = document.querySelector("#text-table-of-contents");
|
||||
if (!toc) { console.warn("No #text-table-of-contents found"); return; }
|
||||
if (!toc) return;
|
||||
|
||||
const links = toc.querySelectorAll('a[href^="#"]'); // '^=' is a starts with operator.
|
||||
// <a href="#introduction">Intro</a> matches
|
||||
if (!links.length) { console.warn("No ToC links found"); return; }
|
||||
if (!links.length) return;
|
||||
|
||||
// Map: id -> link
|
||||
const linkById = new Map();
|
||||
@@ -14,7 +14,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) linkById.set(id, a);
|
||||
});
|
||||
if (!linkById.size) { console.warn("No matching headings with IDs"); return; }
|
||||
if (!linkById.size) return;
|
||||
|
||||
// Headings to observe (h2–h4 usually)
|
||||
const headings = [...document.querySelectorAll("h2[id], h3[id], h4[id]")]
|
||||
|
||||
1
assets/scripts/vendor/phaser-4.1.0.min.js
vendored
Normal file
1
assets/scripts/vendor/phaser-4.1.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user