jos game
Build and Push Docker Images / build-and-push (push) Successful in 45s

This commit is contained in:
Bram committed 2026-11-18 13:16:44 +01:00
1 parent 94f1021fd0
commit 2aad61c81f
12 files changed
+2673

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
README.md
.git
.gitignore
.env
.env.*
__pycache__/
*.pyc
+1
View File
@@ -0,0 +1 @@
GIFT_CODE=VUL-JE-CADEAUBONCODE-IN
+3
View File
@@ -0,0 +1,3 @@
.env
__pycache__/
*.pyc
+19
View File
@@ -0,0 +1,19 @@
FROM python:3.13-alpine
ENV PYTHONUNBUFFERED=1 \
PORT=8000
WORKDIR /app
RUN addgroup -S game && adduser -S game -G game
COPY --chown=game:game app/ /app/
USER game
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"
CMD ["python", "-u", "server.py"]
+73
View File
@@ -0,0 +1,73 @@
# De Grote Sloop van Jos
Een klein verjaardagsspel in de browser. Jos sloopt een kamer met een hamer en
een koevoet. Alle acht stukken moeten weg, inclusief de spiegel aan de wand.
Pas wanneer alles gesloopt is, geeft de server de cadeauboncode vrij.
## Snel starten
1. Zet je cadeauboncode in een lokaal `.env`-bestand:
```bash
cp .env.example .env
```
Pas daarna `GIFT_CODE` aan in `.env`.
2. Start de container:
```bash
docker compose up -d --build
```
3. Open `http://<server-ip>:8004`.
De code staat bewust niet in de statische bestanden. De browser vraagt de code
pas op via `POST /api/reveal` wanneer alle objecten als gesloopt gemeld zijn.
## Spel aanpassen
- **Naam, datum en teksten**: pas `app/game.json` aan. Daar staan ook de
objecten, hun werktuig, het aantal slagen en de tekstjes.
- **Cadeauboncode**: via `GIFT_CODE` in `.env` of in `docker-compose.yml`.
Zonder ingestelde code wordt de placeholder `VUL-JE-CADEAUBONCODE-IN` getoond.
- **Poort**: pas de mapping `8004:8000` in `docker-compose.yml` aan.
- **Opnieuw bouwen na aanpassingen**:
```bash
docker compose up -d --build
```
## Hoe het spel werkt
- Kies de hamer (toets `1`) of de koevoet (toets `2`).
- Glas en breekbaar werk vraag je hamer; vastgeschroefd werk vraag je koevoet.
- Bij een verkeerd werktuig gebeurt er niets, maar krijg je na twee pogingen
een hint.
- De slooplijst onder de kamer toont wat er nog over is. Klik op een chip om
het juiste stuk in de kamer te laten oplichten.
- Na de laatste slag opent het cadeaubonbewijs met de code en een kopieerknop.
## Lokaal draaien zonder Docker
```bash
GIFT_CODE=MIJN-CODE python3 app/server.py
```
Open daarna `http://localhost:8000`. Er zijn geen extra Python-pakketten nodig.
## Bestanden
```text
.
├── Dockerfile
├── docker-compose.yml
├── .env.example
└── app
├── game.json # naam, datum, objecten en teksten
├── server.py # statische server + code onthullen
└── static
├── index.html # kamer en tekeningen
├── style.css # vormgeving, schade en animaties
└── game.js # spel logica, geluid en confetti
```
+72
View File
@@ -0,0 +1,72 @@
{
"recipient": "Jos",
"eventDate": "18 oktober",
"title": "De Grote Sloop van Jos",
"subtitle": "Sloop de kamer, vind je cadeaubon",
"objects": [
{
"id": "spiegel",
"label": "Spiegel",
"tool": "hamer",
"hp": 3,
"hint": "Een spiegel is glas. Glas sla je met de hamer, niet met de koevoet.",
"done": "De spiegel ligt aan diggelen. Zeven jaar ongeluk? Daar zorgen we later wel voor."
},
{
"id": "schilderij",
"label": "Schilderij",
"tool": "koevoet",
"hp": 3,
"hint": "Dat schilderij hangt aan stevige vijzen. Wrik het los met de koevoet.",
"done": "Het zeezicht hangt nu op de vloer. Letterlijk."
},
{
"id": "klok",
"label": "Muurklok",
"tool": "hamer",
"hp": 2,
"hint": "Een muurklok is geen schroefpaneel. Tik hem van de muur met de hamer.",
"done": "Tijd om te slopen. Bijzonder toepasselijk."
},
{
"id": "kast",
"label": "Boekenkast",
"tool": "koevoet",
"hp": 4,
"hint": "Die kast zit vol vijzen en spijkers. Koevoet, Jos.",
"done": "De boeken zijn vrij. De kast niet."
},
{
"id": "zetel",
"label": "Zetel",
"tool": "hamer",
"hp": 3,
"hint": "Een zetel sloop je niet met een koevoet. Sla ermee met de hamer.",
"done": "Waar ga je nu in zitten? Nergens meer."
},
{
"id": "tafel",
"label": "Salontafel",
"tool": "hamer",
"hp": 3,
"hint": "Dat tafelblad breekt met de hamer. De koevoet hapt niet.",
"done": "Tafel af. De koffie kan wachten."
},
{
"id": "deur",
"label": "Deur",
"tool": "koevoet",
"hp": 3,
"hint": "De deur zit in de scharnieren. Wrik hem los met de koevoet.",
"done": "Deur weg. Vrije doorgang naar de cadeaubon."
},
{
"id": "plant",
"label": "Plant",
"tool": "hamer",
"hp": 2,
"hint": "Een bloempot van klei? Hamer ertegen.",
"done": "Groen gesloopt. De pot is nu scherven."
}
]
}
+157
View File
@@ -0,0 +1,157 @@
#!/usr/bin/env python3
"""Kleine server voor het sloopspel.
Serveert de statische game en geeft de cadeauboncode pas vrij wanneer de
client meldt dat alle objecten gesloopt zijn.
"""
from __future__ import annotations
import json
import os
import sys
from http import HTTPStatus
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from urllib.parse import urlparse
BASE_DIR = Path(__file__).resolve().parent
STATIC_DIR = BASE_DIR / "static"
GAME_FILE = BASE_DIR / "game.json"
with GAME_FILE.open(encoding="utf-8") as handle:
GAME = json.load(handle)
REQUIRED_OBJECTS = frozenset(item["id"] for item in GAME["objects"])
DEFAULT_CODE = "VUL-JE-CADEAUBONCODE-IN"
GIFT_CODE = (os.environ.get("GIFT_CODE") or DEFAULT_CODE).strip()
MAX_BODY_BYTES = 16 * 1024
def public_config() -> dict:
config = {
"recipient": GAME.get("recipient", "Jos"),
"eventDate": GAME.get("eventDate", "18 oktober"),
"title": GAME.get("title", "De Grote Sloop"),
"subtitle": GAME.get("subtitle", "Sloop de kamer, vind je cadeaubon"),
"objects": GAME["objects"],
}
config["recipient"] = os.environ.get("RECIPIENT", config["recipient"])
config["eventDate"] = os.environ.get("EVENT_DATE", config["eventDate"])
config["title"] = os.environ.get("GAME_TITLE", config["title"])
config["subtitle"] = os.environ.get("GAME_SUBTITLE", config["subtitle"])
return config
class GameRequestHandler(SimpleHTTPRequestHandler):
server_version = "JosSloopGame/1.0"
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=str(STATIC_DIR), **kwargs)
def end_headers(self) -> None:
self.send_header("X-Content-Type-Options", "nosniff")
self.send_header("Referrer-Policy", "no-referrer")
self.send_header("X-Frame-Options", "SAMEORIGIN")
self.send_header(
"Cache-Control",
"no-store" if self.path.startswith("/api/") else "no-cache",
)
super().end_headers()
def do_GET(self) -> None:
path = urlparse(self.path).path
if path == "/api/config":
self.send_json(HTTPStatus.OK, public_config())
return
if path == "/healthz":
self.send_json(HTTPStatus.OK, {"ok": True})
return
super().do_GET()
def do_POST(self) -> None:
path = urlparse(self.path).path
if path != "/api/reveal":
self.send_json(HTTPStatus.NOT_FOUND, {"ok": False, "error": "Onbekend pad."})
return
try:
length = int(self.headers.get("Content-Length", "0"))
except ValueError:
length = 0
if length <= 0 or length > MAX_BODY_BYTES:
self.send_json(
HTTPStatus.BAD_REQUEST,
{"ok": False, "error": "Ongeldige aanvraag."},
)
return
try:
payload = json.loads(self.rfile.read(length))
except (json.JSONDecodeError, UnicodeDecodeError):
self.send_json(
HTTPStatus.BAD_REQUEST,
{"ok": False, "error": "Ongeldige aanvraag."},
)
return
completed = payload.get("completed") if isinstance(payload, dict) else None
if not isinstance(completed, list) or not all(
isinstance(item, str) for item in completed
):
self.send_json(
HTTPStatus.BAD_REQUEST,
{"ok": False, "error": "Ongeldige aanvraag."},
)
return
missing = sorted(REQUIRED_OBJECTS.difference(completed))
if missing:
self.send_json(
HTTPStatus.CONFLICT,
{
"ok": False,
"error": "De kamer is nog niet volledig gesloopt.",
"missing": missing,
},
)
return
self.send_json(
HTTPStatus.OK,
{
"ok": True,
"code": GIFT_CODE,
"recipient": public_config()["recipient"],
"eventDate": public_config()["eventDate"],
},
)
def send_json(self, status: HTTPStatus, payload: dict) -> None:
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
self.send_response(status)
self.send_header("Content-Type", "application/json; charset=utf-8")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def main() -> None:
port = int(os.environ.get("PORT", "8000"))
if GIFT_CODE == DEFAULT_CODE:
print(
"WAARSCHUWING: GIFT_CODE is niet ingesteld; de placeholder wordt getoond.",
file=sys.stderr,
)
server = ThreadingHTTPServer(("0.0.0.0", port), GameRequestHandler)
print(f"Sloopspel draait op http://0.0.0.0:{port}", flush=True)
try:
server.serve_forever()
except KeyboardInterrupt:
pass
finally:
server.server_close()
if __name__ == "__main__":
main()
+749
View File
@@ -0,0 +1,749 @@
(() => {
"use strict";
const $ = (selector, root = document) => root.querySelector(selector);
const $$ = (selector, root = document) => Array.from(root.querySelectorAll(selector));
const room = $("#room");
const shell = $("#game-shell");
const log = $("#log");
const chips = $("#chips");
const progressText = $("#progress-text");
const progressPercent = $("#progress-percent");
const progressTrack = $("#progress-track");
const progressBar = $("#progress-bar");
const modal = $("#modal");
const voucherCode = $("#voucher-code");
const voucherRecipient = $("#voucher-recipient");
const voucherDate = $("#voucher-date");
const voucherNote = $("#voucher-note");
const copyButton = $("#copy-code");
const playAgainButton = $("#play-again");
const soundButton = $("#sound-toggle");
const confettiCanvas = $("#confetti");
const confettiContext = confettiCanvas.getContext("2d");
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const GLASS_OBJECTS = new Set(["spiegel", "klok"]);
const DEBRIS_COLORS = {
spiegel: ["#d9f2f7", "#a9d6e1", "#ffffff", "#7fb3c2"],
schilderij: ["#c99a3f", "#4c8b9b", "#f8d9a0", "#6b4425"],
klok: ["#f3e4c1", "#c99a3f", "#3d2a1c"],
kast: ["#7b5330", "#b9553f", "#d09a45", "#4f7d75"],
zetel: ["#4e837d", "#6b9d96", "#39716b"],
tafel: ["#8a5b34", "#6d4527", "#d6b15b", "#5f3b20"],
deur: ["#8a5b34", "#744924", "#c99a3f"],
plant: ["#b2603d", "#4f8747", "#67a05a", "#8d4328"]
};
const TOOL_LABELS = {
hamer: "hamer",
koevoet: "koevoet"
};
const HIT_LINES = {
hamer: ["Bonk!", "Krak!", "Goeie tik!", "Dat klinkt bevredigend."],
koevoet: ["Krak!", "Wrikken maar.", "Iets lossers.", "De vijzen geven mee."]
};
const state = {
tool: "hamer",
config: null,
objects: new Map(),
brokenCount: 0,
soundOn: true,
finished: false,
audio: null,
lastFocus: null,
confettiFrame: null,
confettiParticles: []
};
try {
state.soundOn = window.localStorage.getItem("jos-sloop-geluid") !== "uit";
} catch {
state.soundOn = true;
}
function pick(list) {
return list[Math.floor(Math.random() * list.length)];
}
function wait(ms) {
return new Promise((resolve) => window.setTimeout(resolve, ms));
}
function setLog(message, kind = "normal") {
log.textContent = message;
log.classList.toggle("is-warning", kind === "warning");
log.classList.toggle("is-done", kind === "done");
}
function updateSoundButton() {
soundButton.setAttribute("aria-pressed", String(state.soundOn));
const label = state.soundOn ? "Geluid dempen" : "Geluid aanzetten";
soundButton.setAttribute("aria-label", label);
soundButton.title = label;
}
function ensureAudio() {
if (!state.soundOn) {
return null;
}
if (!state.audio) {
const AudioContextClass = window.AudioContext || window.webkitAudioContext;
if (!AudioContextClass) {
return null;
}
try {
state.audio = new AudioContextClass();
} catch {
return null;
}
}
if (state.audio.state === "suspended") {
state.audio.resume().catch(() => {});
}
return state.audio;
}
function playTone({ freq = 200, endFreq = freq, type = "sine", duration = 0.16, gain = 0.15, delay = 0 }) {
const context = ensureAudio();
if (!context) {
return;
}
const start = context.currentTime + delay;
const oscillator = context.createOscillator();
const volume = context.createGain();
oscillator.type = type;
oscillator.frequency.setValueAtTime(Math.max(20, freq), start);
oscillator.frequency.exponentialRampToValueAtTime(Math.max(20, endFreq), start + duration);
volume.gain.setValueAtTime(0.0001, start);
volume.gain.exponentialRampToValueAtTime(Math.max(0.0001, gain), start + 0.012);
volume.gain.exponentialRampToValueAtTime(0.0001, start + duration);
oscillator.connect(volume).connect(context.destination);
oscillator.start(start);
oscillator.stop(start + duration + 0.03);
}
function playNoise({ duration = 0.2, gain = 0.2, frequency = 900, delay = 0 } = {}) {
const context = ensureAudio();
if (!context) {
return;
}
const frames = Math.max(1, Math.floor(context.sampleRate * duration));
const buffer = context.createBuffer(1, frames, context.sampleRate);
const data = buffer.getChannelData(0);
for (let index = 0; index < frames; index += 1) {
data[index] = (Math.random() * 2 - 1) * (1 - index / frames);
}
const source = context.createBufferSource();
source.buffer = buffer;
const filter = context.createBiquadFilter();
filter.type = "bandpass";
filter.frequency.value = frequency;
filter.Q.value = 0.8;
const volume = context.createGain();
volume.gain.value = gain;
source.connect(filter).connect(volume).connect(context.destination);
source.start(context.currentTime + delay);
}
function playHit(tool) {
if (tool === "hamer") {
playTone({ freq: 190, endFreq: 58, type: "triangle", duration: 0.18, gain: 0.3 });
playNoise({ duration: 0.1, gain: 0.14, frequency: 1400 });
} else {
playTone({ freq: 95, endFreq: 48, type: "sawtooth", duration: 0.22, gain: 0.18 });
playNoise({ duration: 0.16, gain: 0.1, frequency: 620 });
}
}
function playWrong() {
playTone({ freq: 310, endFreq: 190, type: "square", duration: 0.11, gain: 0.09 });
playTone({ freq: 170, endFreq: 120, type: "triangle", duration: 0.16, gain: 0.08, delay: 0.08 });
}
function playBreak(objectId) {
if (GLASS_OBJECTS.has(objectId)) {
playNoise({ duration: 0.5, gain: 0.32, frequency: 3400 });
playTone({ freq: 1750, endFreq: 260, type: "triangle", duration: 0.42, gain: 0.13 });
playNoise({ duration: 0.24, gain: 0.12, frequency: 1800, delay: 0.12 });
} else {
playNoise({ duration: 0.34, gain: 0.26, frequency: 720 });
playTone({ freq: 125, endFreq: 42, type: "sawtooth", duration: 0.32, gain: 0.2 });
}
}
function playFanfare() {
const notes = [523.25, 659.25, 783.99, 1046.5];
notes.forEach((frequency, index) => {
playTone({
freq: frequency,
endFreq: frequency,
type: "triangle",
duration: 0.28,
gain: 0.13,
delay: index * 0.13
});
});
playTone({ freq: 1318.5, endFreq: 1318.5, type: "sine", duration: 0.6, gain: 0.1, delay: 0.55 });
}
function selectTool(tool) {
if (!TOOL_LABELS[tool]) {
return;
}
state.tool = tool;
$$(".tool-btn").forEach((button) => {
const active = button.dataset.tool === tool;
button.classList.toggle("is-active", active);
button.setAttribute("aria-pressed", String(active));
});
}
function objectCenter(element) {
const rect = element.getBoundingClientRect();
return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
}
function spawnSwing(x, y, tool, good) {
const source = $(`.tool-btn[data-tool="${tool}"] svg`);
if (!source) {
return;
}
const wrap = document.createElement("div");
wrap.className = `swing${good ? "" : " bad"}`;
wrap.style.left = `${x}px`;
wrap.style.top = `${y}px`;
wrap.appendChild(source.cloneNode(true));
document.body.appendChild(wrap);
window.setTimeout(() => wrap.remove(), 460);
}
function spawnDebris(x, y, colors, count, power = 1) {
if (reduceMotion) {
return;
}
for (let index = 0; index < count; index += 1) {
const size = 5 + Math.random() * 8;
const particle = document.createElement("span");
particle.className = "debris";
particle.style.width = `${size}px`;
particle.style.height = `${size}px`;
particle.style.left = `${x}px`;
particle.style.top = `${y}px`;
particle.style.marginLeft = `${-size / 2}px`;
particle.style.marginTop = `${-size / 2}px`;
particle.style.background = pick(colors);
particle.style.clipPath = Math.random() > 0.5
? "polygon(50% 0, 100% 100%, 0 72%)"
: "polygon(0 15%, 100% 0, 75% 100%, 10% 88%)";
document.body.appendChild(particle);
const angle = Math.random() * Math.PI * 2;
const speed = (45 + Math.random() * 135) * power;
const dx = Math.cos(angle) * speed;
const dy = Math.sin(angle) * speed - (35 + Math.random() * 65) * power;
const rotation = (Math.random() * 2 - 1) * 520;
particle.animate(
[
{ transform: "translate(0, 0) rotate(0deg)", opacity: 1 },
{ transform: `translate(${dx}px, ${dy + 260 * power}px) rotate(${rotation}deg)`, opacity: 0 }
],
{
duration: 520 + Math.random() * 520,
easing: "cubic-bezier(.12,.62,.35,1)"
}
).onfinish = () => particle.remove();
}
}
function spawnFloatText(x, y, text, bad = false) {
if (reduceMotion) {
return;
}
const node = document.createElement("span");
node.className = `float-text${bad ? " bad" : ""}`;
node.textContent = text;
node.style.left = `${x}px`;
node.style.top = `${y}px`;
document.body.appendChild(node);
window.setTimeout(() => node.remove(), 850);
}
function leaveRubble(object) {
const roomRect = room.getBoundingClientRect();
const objectRect = object.element.getBoundingClientRect();
if (roomRect.width === 0 || roomRect.height === 0) {
return;
}
const x = ((objectRect.left + objectRect.width / 2 - roomRect.left) / roomRect.width) * 100;
const objectBottom = ((objectRect.bottom - roomRect.top) / roomRect.height) * 100;
const y = Math.min(93, Math.max(78, objectBottom + 1));
const colors = DEBRIS_COLORS[object.meta.id] || ["#8a6a49", "#5f452f"];
const pile = document.createElement("span");
pile.className = "rubble";
pile.style.left = `${x}%`;
pile.style.top = `${y}%`;
const pieces = 5 + Math.floor(Math.random() * 4);
for (let index = 0; index < pieces; index += 1) {
const piece = document.createElement("i");
piece.style.left = `${8 + Math.random() * 78}%`;
piece.style.top = `${12 + Math.random() * 70}%`;
piece.style.width = `${12 + Math.random() * 22}%`;
piece.style.height = `${14 + Math.random() * 28}%`;
piece.style.background = pick(colors);
piece.style.transform = `rotate(${Math.random() * 120 - 60}deg)`;
piece.style.clipPath = Math.random() > 0.5
? "polygon(50% 0, 100% 100%, 0 74%)"
: "polygon(0 16%, 100% 0, 76% 100%, 8% 86%)";
pile.appendChild(piece);
}
room.appendChild(pile);
}
function shakeShell() {
if (reduceMotion) {
return;
}
shell.classList.remove("is-shaking");
void shell.offsetWidth;
shell.classList.add("is-shaking");
window.setTimeout(() => shell.classList.remove("is-shaking"), 260);
}
function updateProgress() {
const total = state.objects.size;
const percentage = total === 0 ? 0 : Math.round((state.brokenCount / total) * 100);
progressText.textContent = `${state.brokenCount} / ${total} stukken gesloopt`;
progressPercent.textContent = `${percentage}%`;
progressBar.style.width = `${percentage}%`;
progressTrack.setAttribute("aria-valuenow", String(percentage));
room.style.setProperty("--chaos", total === 0 ? "0" : String(state.brokenCount / total));
}
function hitObject(object, event) {
if (!object || object.broken || state.finished || !state.config) {
return;
}
ensureAudio();
const hasPointer = typeof event.clientX === "number" && (event.clientX !== 0 || event.clientY !== 0);
const point = hasPointer
? { x: event.clientX, y: event.clientY }
: objectCenter(object.element);
const correctTool = state.tool === object.meta.tool;
spawnSwing(point.x, point.y, state.tool, correctTool);
object.element.classList.remove("is-hit");
void object.element.offsetWidth;
object.element.classList.add("is-hit");
window.setTimeout(() => object.element.classList.remove("is-hit"), 300);
if (!correctTool) {
object.wrong += 1;
playWrong();
shakeShell();
spawnDebris(point.x, point.y, ["#c8bda6", "#8f826b"], 6, 0.55);
spawnFloatText(point.x, point.y - 12, "BONK?", true);
const extra = object.wrong >= 2 ? ` ${object.meta.hint}` : " Probeer eens een ander werktuig.";
setLog(`Met de ${TOOL_LABELS[state.tool]} op de ${object.meta.label.toLowerCase()}? Dat werkt niet.${extra}`, "warning");
return;
}
object.hits += 1;
const stage = Math.min(3, Math.ceil((object.hits / object.meta.hp) * 3));
object.element.dataset.stage = String(stage);
playHit(state.tool);
shakeShell();
spawnDebris(point.x, point.y, DEBRIS_COLORS[object.meta.id] || ["#c8bda6"], 5 + object.hits * 2, 0.75);
spawnFloatText(point.x, point.y - 12, state.tool === "hamer" ? "BONK" : "KRAK");
const remaining = object.meta.hp - object.hits;
if (remaining > 0) {
const line = pick(HIT_LINES[state.tool]);
const suffix = remaining === 1 ? "nog 1 slag" : `nog ${remaining} slagen`;
setLog(`${line} De ${object.meta.label.toLowerCase()} heeft ${suffix} nodig.`);
return;
}
breakObject(object, point);
}
function breakObject(object, point) {
object.broken = true;
state.brokenCount += 1;
object.element.dataset.stage = "3";
object.element.classList.add("is-broken");
object.element.disabled = true;
const center = objectCenter(object.element);
const colors = DEBRIS_COLORS[object.meta.id] || ["#c8bda6"];
spawnDebris(center.x, center.y, colors, object.meta.id === "spiegel" ? 38 : 26, 1.35);
if (object.meta.id === "spiegel") {
spawnDebris(center.x, center.y, ["#ffffff", "#e8fbff", "#bfe8f1"], 18, 1.1);
}
playBreak(object.meta.id);
leaveRubble(object);
setLog(object.meta.done, "done");
if (object.chip) {
object.chip.classList.add("done");
}
updateProgress();
if (state.brokenCount === state.objects.size) {
finishGame();
}
}
function buildChips() {
chips.innerHTML = "";
state.objects.forEach((object) => {
const chip = document.createElement("button");
chip.type = "button";
chip.className = "chip";
chip.textContent = object.meta.label;
chip.addEventListener("click", () => {
if (object.broken) {
setLog(`${object.meta.label} is al gesloopt. ${object.meta.done}`);
return;
}
object.element.classList.remove("pulse");
void object.element.offsetWidth;
object.element.classList.add("pulse");
window.setTimeout(() => object.element.classList.remove("pulse"), 700);
const hint = object.wrong >= 2 ? ` ${object.meta.hint}` : "";
setLog(`Nog te slopen: ${object.meta.label.toLowerCase()}.${hint}`);
});
object.chip = chip;
chips.appendChild(chip);
});
}
function applyConfig(config) {
const setText = (selector, value) => {
const node = $(selector);
if (node && value) {
node.textContent = value;
}
};
setText("#recipient-name", config.recipient);
setText("#footer-name", config.recipient);
setText("#event-date", config.eventDate);
setText("#footer-date", config.eventDate);
setText("#game-title", config.title);
setText("#game-subtitle", config.subtitle);
setText("#voucher-date", config.eventDate);
setText("#voucher-recipient", `Voor ${config.recipient}`);
if (config.title) {
document.title = config.title;
}
}
function buildObjects(config) {
const elements = new Map(
$$(".object").map((element) => [element.dataset.id, element])
);
config.objects.forEach((meta) => {
const element = elements.get(meta.id);
if (!element) {
console.warn(`Geen tekenwerk gevonden voor object "${meta.id}".`);
return;
}
const object = {
meta,
element,
hits: 0,
wrong: 0,
broken: false,
chip: null
};
element.disabled = false;
element.setAttribute("aria-label", `${meta.label} slopen`);
element.addEventListener("click", (event) => hitObject(object, event));
state.objects.set(meta.id, object);
elements.delete(meta.id);
});
state.brokenCount = 0;
updateProgress();
buildChips();
}
async function finishGame() {
state.finished = true;
room.style.setProperty("--chaos", "1");
setLog("Alles is gesloopt. Achter de spiegel zat een envelop met je cadeaubon...", "done");
window.setTimeout(() => {
openModal();
launchConfetti();
playFanfare();
}, 650);
}
function openModal() {
state.lastFocus = document.activeElement;
voucherCode.textContent = "code wordt gezocht...";
voucherNote.textContent = "";
voucherNote.style.color = "";
modal.hidden = false;
window.setTimeout(() => copyButton.focus(), 80);
requestVoucher();
}
async function requestVoucher() {
const completed = Array.from(state.objects.values())
.filter((object) => object.broken)
.map((object) => object.meta.id);
try {
const response = await fetch("/api/reveal", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ completed })
});
const data = await response.json().catch(() => ({}));
if (!response.ok || !data.ok) {
throw new Error(data.error || "De code kon niet worden opgehaald.");
}
voucherCode.textContent = data.code;
voucherRecipient.textContent = `Voor ${data.recipient || state.config.recipient}`;
voucherDate.textContent = data.eventDate || state.config.eventDate;
voucherNote.textContent = "De code staat klaar. Kopieer hem of houd deze pagina open.";
} catch (error) {
voucherCode.textContent = "—";
voucherNote.textContent = `${error.message} Herlaad de pagina en probeer opnieuw.`;
voucherNote.style.color = "#a33b22";
}
}
function resetGame() {
state.finished = false;
state.brokenCount = 0;
state.objects.forEach((object) => {
object.hits = 0;
object.wrong = 0;
object.broken = false;
object.element.disabled = false;
object.element.classList.remove("is-broken", "is-hit", "pulse");
delete object.element.dataset.stage;
if (object.chip) {
object.chip.classList.remove("done");
}
});
room.style.setProperty("--chaos", "0");
updateProgress();
setLog("Nieuwe kamer, zelfde sloopwoede. Alles moet weg, ook de spiegel.");
modal.hidden = true;
voucherCode.textContent = "...";
voucherNote.textContent = "";
stopConfetti();
$$(".debris, .swing, .float-text, .rubble").forEach((node) => node.remove());
copyButton.classList.remove("is-copied");
copyButton.textContent = "Kopieer";
const activeTool = $(".tool-btn.is-active");
if (activeTool) {
activeTool.focus();
} else if (state.lastFocus && typeof state.lastFocus.focus === "function") {
state.lastFocus.focus();
}
}
function resizeConfetti() {
const ratio = Math.min(2, window.devicePixelRatio || 1);
confettiCanvas.width = Math.floor(window.innerWidth * ratio);
confettiCanvas.height = Math.floor(window.innerHeight * ratio);
confettiContext.setTransform(ratio, 0, 0, ratio, 0, 0);
}
function launchConfetti() {
if (reduceMotion) {
return;
}
resizeConfetti();
const colors = ["#ffc93c", "#e86f2b", "#f6ead2", "#6da34d", "#4f837c", "#d2573f"];
state.confettiParticles = Array.from({ length: 170 }, () => ({
x: Math.random() * window.innerWidth,
y: -30 - Math.random() * window.innerHeight * 0.5,
vx: (Math.random() - 0.5) * 130,
vy: 80 + Math.random() * 170,
width: 5 + Math.random() * 7,
height: 8 + Math.random() * 10,
rotation: Math.random() * Math.PI,
spin: (Math.random() - 0.5) * 11,
color: pick(colors)
}));
if (state.confettiFrame) {
window.cancelAnimationFrame(state.confettiFrame);
}
let last = performance.now();
const tick = (now) => {
const delta = Math.min(0.05, (now - last) / 1000);
last = now;
confettiContext.clearRect(0, 0, window.innerWidth, window.innerHeight);
let visible = 0;
state.confettiParticles.forEach((particle) => {
particle.vy += 190 * delta;
particle.x += particle.vx * delta;
particle.y += particle.vy * delta;
particle.rotation += particle.spin * delta;
if (particle.y < window.innerHeight + 40) {
visible += 1;
}
confettiContext.save();
confettiContext.translate(particle.x, particle.y);
confettiContext.rotate(particle.rotation);
confettiContext.fillStyle = particle.color;
confettiContext.fillRect(-particle.width / 2, -particle.height / 2, particle.width, particle.height);
confettiContext.restore();
});
if (visible > 0) {
state.confettiFrame = window.requestAnimationFrame(tick);
} else {
state.confettiFrame = null;
confettiContext.clearRect(0, 0, window.innerWidth, window.innerHeight);
}
};
state.confettiFrame = window.requestAnimationFrame(tick);
window.setTimeout(stopConfetti, 8000);
}
function stopConfetti() {
if (state.confettiFrame) {
window.cancelAnimationFrame(state.confettiFrame);
state.confettiFrame = null;
}
state.confettiParticles = [];
confettiContext.clearRect(0, 0, window.innerWidth, window.innerHeight);
}
function legacyCopy(text) {
const field = document.createElement("textarea");
field.value = text;
field.setAttribute("readonly", "");
field.style.position = "fixed";
field.style.opacity = "0";
document.body.appendChild(field);
field.select();
try {
document.execCommand("copy");
} catch {
}
field.remove();
}
async function copyCode() {
const code = voucherCode.textContent.trim();
if (!code || code === "..." || code.startsWith("code wordt")) {
return;
}
try {
await navigator.clipboard.writeText(code);
} catch {
legacyCopy(code);
}
copyButton.textContent = "Gekopieerd";
copyButton.classList.add("is-copied");
voucherNote.textContent = "De code staat op je klembord.";
voucherNote.style.color = "";
window.setTimeout(() => {
copyButton.textContent = "Kopieer";
copyButton.classList.remove("is-copied");
}, 2200);
}
function bindEvents() {
$$(".tool-btn").forEach((button) => {
button.addEventListener("click", () => selectTool(button.dataset.tool));
});
document.addEventListener("keydown", (event) => {
if (event.key === "1") {
selectTool("hamer");
} else if (event.key === "2") {
selectTool("koevoet");
}
});
soundButton.addEventListener("click", () => {
state.soundOn = !state.soundOn;
try {
window.localStorage.setItem("jos-sloop-geluid", state.soundOn ? "aan" : "uit");
} catch {
}
updateSoundButton();
if (state.soundOn) {
playTone({ freq: 660, endFreq: 880, type: "triangle", duration: 0.12, gain: 0.09 });
}
});
copyButton.addEventListener("click", copyCode);
playAgainButton.addEventListener("click", resetGame);
window.addEventListener("resize", () => {
if (state.confettiParticles.length > 0) {
resizeConfetti();
}
});
}
async function init() {
$$(".object").forEach((element) => {
element.disabled = true;
});
updateSoundButton();
bindEvents();
try {
const response = await fetch("/api/config", { cache: "no-store" });
if (!response.ok) {
throw new Error("De spellijn is niet bereikbaar.");
}
const config = await response.json();
state.config = config;
applyConfig(config);
buildObjects(config);
setLog("Kies je werktuig en sla de kamer kort en klein. Alles moet weg, ook de spiegel.");
} catch (error) {
setLog(`De kamer kon niet geladen worden: ${error.message}`, "warning");
progressText.textContent = "Niet geladen";
progressPercent.textContent = "—";
}
}
init();
})();
@@ -0,0 +1,355 @@
<!doctype html>
<html lang="nl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#171512">
<meta name="description" content="Sloop de kamer van Jos met hamer en koevoet en vind de cadeaubon.">
<title>De Grote Sloop van Jos</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="page">
<header class="hero">
<p class="eyebrow"><span id="recipient-name">Jos</span> wordt gevierd op <span id="event-date">18 oktober</span></p>
<h1 id="game-title">De Grote Sloop van Jos</h1>
<p class="tagline" id="game-subtitle">Sloop de kamer, vind je cadeaubon</p>
</header>
<main class="game-shell" id="game-shell">
<div class="hud">
<div class="toolbar" role="group" aria-label="Kies je werktuig">
<button type="button" class="tool-btn is-active" data-tool="hamer" aria-pressed="true">
<svg viewBox="0 0 48 48" aria-hidden="true" focusable="false">
<g fill="currentColor">
<path d="M25.6 5.2 38.4 11l-3.1 6.7-12.8-5.8z"/>
<path d="m28.2 17.2 5.3 2.4-15.2 25.6-5.3-3.1z"/>
</g>
</svg>
<span class="tool-name">Hamer</span>
<kbd>1</kbd>
</button>
<button type="button" class="tool-btn" data-tool="koevoet" aria-pressed="false">
<svg viewBox="0 0 48 48" aria-hidden="true" focusable="false">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
<path d="M10 42 29 15" stroke-width="5"/>
<path d="M29 15c2.1-4.5 6.5-6.5 10.2-4.2l-3.1 5.1c-1.7-.8-3.2 0-4.2 2.1z" fill="currentColor" stroke-width="1.5"/>
<path d="m10 42-2.8 3.4 6 1.4z" fill="currentColor" stroke-width="1.5"/>
</g>
</svg>
<span class="tool-name">Koevoet</span>
<kbd>2</kbd>
</button>
</div>
<div class="progress" aria-live="polite">
<div class="progress-copy">
<span id="progress-text">0 / 8 stukken gesloopt</span>
<span id="progress-percent">0%</span>
</div>
<div class="progress-track" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" id="progress-track">
<span id="progress-bar"></span>
</div>
</div>
<button type="button" class="icon-btn" id="sound-toggle" aria-pressed="true" aria-label="Geluid dempen" title="Geluid dempen">
<svg class="sound-on" viewBox="0 0 32 32" aria-hidden="true" focusable="false">
<path d="M5 12h5l6-5v18l-6-5H5z" fill="currentColor"/>
<path d="M20 11c1.7 1.2 2.7 3 2.7 5s-1 3.8-2.7 5M23.5 7.5C26.2 9.4 28 12.1 28 16s-1.8 6.6-4.5 8.5" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/>
</svg>
<svg class="sound-off" viewBox="0 0 32 32" aria-hidden="true" focusable="false">
<path d="M5 12h5l6-5v18l-6-5H5z" fill="currentColor"/>
<path d="m21 12 8 8m0-8-8 8" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
</svg>
</button>
</div>
<section class="stage" aria-label="Kamer om te slopen">
<div class="room" id="room">
<div class="room-decor" aria-hidden="true">
<div class="wallpaper"></div>
<div class="ceiling-band"></div>
<div class="bunting">
<span></span><span></span><span></span><span></span><span></span><span></span>
</div>
<div class="wall-lamp">
<span class="lamp-cord"></span>
<span class="lamp-shade"></span>
</div>
<div class="floor"></div>
<div class="rug"></div>
<div class="baseboard"></div>
<div class="wall-stain stain-one"></div>
<div class="wall-stain stain-two"></div>
<div class="debris-bed"></div>
<div class="dust"></div>
</div>
<button type="button" class="object obj-deur" data-id="deur" aria-label="Deur slopen">
<span class="art">
<svg viewBox="0 0 110 200" aria-hidden="true" focusable="false">
<rect x="2" y="3" width="106" height="194" rx="3" fill="#4e331f"/>
<rect x="10" y="11" width="90" height="179" rx="2" fill="#8a5b34"/>
<rect x="18" y="22" width="74" height="64" rx="2" fill="#744924"/>
<rect x="18" y="96" width="74" height="80" rx="2" fill="#744924"/>
<rect x="25" y="29" width="60" height="50" rx="1" fill="#9a673c"/>
<rect x="25" y="103" width="60" height="66" rx="1" fill="#9a673c"/>
<circle cx="88" cy="101" r="4" fill="#e6bd58"/>
<rect x="90" y="97" width="8" height="8" rx="3" fill="#c99a3f"/>
<rect x="4" y="24" width="6" height="16" rx="2" fill="#b58b45"/>
<rect x="4" y="160" width="6" height="16" rx="2" fill="#b58b45"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M49 0 45 25 53 41 44 67 50 100"/><path class="c2" d="M0 46 28 41 45 25M53 41 76 34 100 40"/><path class="c3" d="M20 100 33 74 44 67M76 34 70 57 84 77"/></svg>
</span>
</button>
<button type="button" class="object obj-spiegel" data-id="spiegel" aria-label="Spiegel slopen">
<span class="art">
<svg viewBox="0 0 100 160" aria-hidden="true" focusable="false">
<defs>
<linearGradient id="mirror-glass" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#eaf8fb"/>
<stop offset=".3" stop-color="#a9d6e1"/>
<stop offset=".55" stop-color="#d5eef4"/>
<stop offset=".8" stop-color="#7fb3c2"/>
<stop offset="1" stop-color="#598fa0"/>
</linearGradient>
<linearGradient id="mirror-frame" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#f1d07f"/>
<stop offset=".5" stop-color="#c99a3f"/>
<stop offset="1" stop-color="#946821"/>
</linearGradient>
</defs>
<path d="M8 30Q8 8 50 8t42 22v114q0 10-10 10H18q-10 0-10-10Z" fill="url(#mirror-frame)"/>
<path d="M15 30q0-15 35-15t35 15v113q0 4-4 4H19q-4 0-4-4Z" fill="url(#mirror-glass)"/>
<path d="m22 29 27-14-13 57Z" fill="#fff" opacity=".45"/>
<path d="m58 92 20-50 6 14-18 56Z" fill="#fff" opacity=".22"/>
<path d="m21 122 14-26 9 36Z" fill="#fff" opacity=".16"/>
<rect x="8" y="30" width="84" height="124" rx="12" fill="none" stroke="#7a5518" stroke-opacity=".45"/>
<g class="mirror-cracks" fill="none" stroke="#22404a" stroke-width="1.15" stroke-linecap="round">
<path class="crack crack-1" d="M58 16 52 46 63 61 54 84 60 112 56 146"/>
<path class="crack crack-1" d="m63 61 19-7M54 84 31 76M60 112l19 7"/>
<path class="crack crack-2" d="M15 58 37 52 52 46M85 88 68 81 63 61M19 127 37 116 54 84"/>
<path class="crack crack-3" d="M15 94 29 88 31 76M85 130 70 128 60 112M34 147 42 128 56 146"/>
</g>
</svg>
</span>
</button>
<button type="button" class="object obj-schilderij" data-id="schilderij" aria-label="Schilderij slopen">
<span class="art">
<svg viewBox="0 0 120 90" aria-hidden="true" focusable="false">
<defs>
<linearGradient id="paint-sky" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#f8d9a0"/>
<stop offset=".65" stop-color="#eaa36d"/>
<stop offset="1" stop-color="#c97854"/>
</linearGradient>
<linearGradient id="paint-sea" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#4c8b9b"/>
<stop offset="1" stop-color="#255565"/>
</linearGradient>
</defs>
<rect x="2" y="2" width="116" height="86" rx="3" fill="#5d3a22"/>
<rect x="8" y="8" width="104" height="74" rx="1" fill="#c99a3f"/>
<rect x="12" y="12" width="96" height="62" fill="url(#paint-sky)"/>
<circle cx="78" cy="31" r="11" fill="#fff0bf" opacity=".9"/>
<rect x="12" y="50" width="96" height="24" fill="url(#paint-sea)"/>
<path d="M12 51h96M18 58h18M54 58h30M31 65h22M66 66h25" stroke="#f3e4c4" stroke-width="1.5" opacity=".55"/>
<path d="M47 49h18l-4 6H50Z" fill="#3c2718"/>
<path d="m56 50 1-13 8 13" fill="#f6ead0"/>
<path d="M64 37v13" stroke="#5d3a22" stroke-width="1.2"/>
<rect x="8" y="8" width="104" height="74" fill="none" stroke="#8a5d21" stroke-width="2"/>
<rect x="12" y="12" width="96" height="62" fill="none" stroke="#6b4425" stroke-opacity=".55"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 0 46 27 54 44 45 68 51 100"/><path class="c2" d="M0 45 27 40 46 27M54 44 78 36 100 42"/><path class="c3" d="M18 100 33 74 45 68M78 36 71 59 86 78"/></svg>
</span>
</button>
<button type="button" class="object obj-klok" data-id="klok" aria-label="Muurklok slopen">
<span class="art">
<svg viewBox="0 0 100 100" aria-hidden="true" focusable="false">
<circle cx="50" cy="50" r="47" fill="#3d2a1c"/>
<circle cx="50" cy="50" r="42" fill="#f3e4c1"/>
<circle cx="50" cy="50" r="42" fill="none" stroke="#c99a3f" stroke-width="2"/>
<g stroke="#5b4227" stroke-width="2.2" stroke-linecap="round">
<path d="M50 13v6M50 81v6M13 50h6M81 50h6"/>
<path d="M26 26l4 4M70 70l4 4M74 26l-4 4M30 70l-4 4" stroke-width="1.4" opacity=".6"/>
</g>
<g stroke="#3d2a1c" stroke-linecap="round">
<path d="M50 50 49 74" stroke-width="4"/>
<path d="m50 50 17-11" stroke-width="3"/>
</g>
<circle cx="50" cy="50" r="4" fill="#c99a3f"/>
<circle cx="50" cy="50" r="2" fill="#3d2a1c"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 0 46 31 55 48 47 75 51 100"/><path class="c2" d="M0 48 29 42 46 31M55 48 79 41 100 47"/><path class="c3" d="M16 100 32 76 47 75M79 41 70 64 87 82"/></svg>
</span>
</button>
<button type="button" class="object obj-kast" data-id="kast" aria-label="Boekenkast slopen">
<span class="art">
<svg viewBox="0 0 120 200" aria-hidden="true" focusable="false">
<rect x="3" y="3" width="114" height="194" rx="4" fill="#5f3f26"/>
<rect x="11" y="11" width="98" height="178" fill="#352317"/>
<rect x="11" y="68" width="98" height="5" fill="#7b5330"/>
<rect x="11" y="126" width="98" height="5" fill="#7b5330"/>
<rect x="11" y="184" width="98" height="5" fill="#7b5330"/>
<g>
<rect x="17" y="22" width="11" height="46" rx="1" fill="#b9553f"/>
<rect x="30" y="18" width="9" height="50" rx="1" fill="#4f7d75"/>
<rect x="41" y="25" width="13" height="43" rx="1" fill="#d09a45"/>
<rect x="56" y="20" width="8" height="48" rx="1" fill="#6b5b95"/>
<rect x="66" y="27" width="12" height="41" rx="1" fill="#a63c3c"/>
<path d="m81 68 10-45 9 2-10 43Z" fill="#49728f"/>
<rect x="93" y="24" width="10" height="44" rx="1" fill="#7d8f4b"/>
</g>
<g>
<rect x="17" y="78" width="10" height="48" rx="1" fill="#4f7d75"/>
<rect x="29" y="74" width="12" height="52" rx="1" fill="#c0703f"/>
<rect x="43" y="80" width="8" height="46" rx="1" fill="#d4b156"/>
<rect x="53" y="76" width="13" height="50" rx="1" fill="#7c4d6b"/>
<rect x="68" y="82" width="9" height="44" rx="1" fill="#4b6f95"/>
<rect x="79" y="77" width="12" height="49" rx="1" fill="#8b4a3c"/>
<rect x="93" y="83" width="10" height="43" rx="1" fill="#5d7a4a"/>
</g>
<g>
<rect x="17" y="136" width="12" height="48" rx="1" fill="#8b4a3c"/>
<rect x="31" y="132" width="9" height="52" rx="1" fill="#d09a45"/>
<rect x="42" y="138" width="11" height="46" rx="1" fill="#4f7d75"/>
<rect x="55" y="134" width="8" height="50" rx="1" fill="#a63c3c"/>
<rect x="65" y="139" width="12" height="45" rx="1" fill="#6b5b95"/>
<rect x="79" y="135" width="9" height="49" rx="1" fill="#c0703f"/>
<rect x="90" y="140" width="13" height="44" rx="1" fill="#49728f"/>
</g>
<path d="M11 11h98v178H11Z" fill="none" stroke="#8a6238" stroke-width="2"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M52 0 48 24 56 40 47 66 53 100"/><path class="c2" d="M0 44 26 39 48 24M56 40 78 32 100 38"/><path class="c3" d="M18 100 34 73 47 66M78 32 70 57 86 78"/></svg>
</span>
</button>
<button type="button" class="object obj-plant" data-id="plant" aria-label="Plant slopen">
<span class="art">
<svg viewBox="0 0 100 160" aria-hidden="true" focusable="false">
<path d="M50 116c-2-22 2-40 12-55" fill="none" stroke="#3f6b3a" stroke-width="4" stroke-linecap="round"/>
<path d="M50 118c-6-18-16-30-28-38" fill="none" stroke="#3f6b3a" stroke-width="4" stroke-linecap="round"/>
<path d="M50 120c5-15 15-25 26-31" fill="none" stroke="#3f6b3a" stroke-width="4" stroke-linecap="round"/>
<path d="M62 61c-2-20 9-34 24-37-2 18-9 30-24 37Z" fill="#4f8747"/>
<path d="M59 74c-12-14-12-29-6-41 13 10 18 24 6 41Z" fill="#67a05a"/>
<path d="M22 80c4-17 16-27 31-26-6 16-16 24-31 26Z" fill="#477c42"/>
<path d="M29 91c-12-8-18-20-16-32 14 5 23 15 16 32Z" fill="#5f9954"/>
<path d="M76 89c11-7 17-18 16-30-13 4-22 14-16 30Z" fill="#397036"/>
<path d="M50 116c-3-11-3-22 0-33 3 11 4 22 0 33Z" fill="#77ab68"/>
<path d="M20 116h60l-7 40H27Z" fill="#b2603d"/>
<path d="M20 116h60l-2 10H22Z" fill="#c97a52"/>
<path d="M27 156h46l-1 4H28Z" fill="#8d4328"/>
<path d="M30 124h40" stroke="#8d4328" stroke-width="2" opacity=".5"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 8 46 34 55 50 46 72 52 100"/><path class="c2" d="M0 48 28 43 46 34M55 50 80 44 100 50"/><path class="c3" d="M18 100 33 77 46 72M80 44 72 66 88 84"/></svg>
</span>
</button>
<button type="button" class="object obj-zetel" data-id="zetel" aria-label="Zetel slopen">
<span class="art">
<svg viewBox="0 0 220 140" aria-hidden="true" focusable="false">
<rect x="24" y="14" width="172" height="72" rx="22" fill="#3f6f6a"/>
<rect x="38" y="28" width="66" height="46" rx="14" fill="#4e837d"/>
<rect x="116" y="28" width="66" height="46" rx="14" fill="#4e837d"/>
<rect x="12" y="52" width="196" height="58" rx="16" fill="#467a74"/>
<rect x="12" y="52" width="32" height="64" rx="16" fill="#39716b"/>
<rect x="176" y="52" width="32" height="64" rx="16" fill="#39716b"/>
<rect x="35" y="72" width="150" height="30" rx="10" fill="#5b8f89"/>
<rect x="43" y="76" width="60" height="22" rx="8" fill="#6b9d96"/>
<rect x="117" y="76" width="60" height="22" rx="8" fill="#6b9d96"/>
<rect x="150" y="54" width="32" height="28" rx="7" fill="#c47d4f" transform="rotate(8 166 68)"/>
<rect x="42" y="108" width="10" height="22" rx="3" fill="#4a331f"/>
<rect x="168" y="108" width="10" height="22" rx="3" fill="#4a331f"/>
<path d="M39 63c20 10 60 12 82 2" fill="none" stroke="#7aa9a2" stroke-width="2" opacity=".6"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M52 0 47 28 56 45 46 70 53 100"/><path class="c2" d="M0 44 27 39 47 28M56 45 79 37 100 44"/><path class="c3" d="M17 100 33 73 46 70M79 37 71 60 87 79"/></svg>
</span>
</button>
<button type="button" class="object obj-tafel" data-id="tafel" aria-label="Salontafel slopen">
<span class="art">
<svg viewBox="0 0 200 100" aria-hidden="true" focusable="false">
<path d="M18 30h164l-9 18H27Z" fill="#8a5b34"/>
<path d="M27 48h146v8H27Z" fill="#6d4527"/>
<rect x="36" y="56" width="9" height="34" rx="2" fill="#5f3b20"/>
<rect x="155" y="56" width="9" height="34" rx="2" fill="#5f3b20"/>
<path d="M54 28h28l-2 18H56Z" fill="#d6b15b"/>
<path d="M60 23h18l2 5H58Z" fill="#ead6a0"/>
<path d="M108 18h24v12h-24Z" fill="#f1e4c8"/>
<path d="M112 21h16M112 25h12" stroke="#9e8d70" stroke-width="1.4"/>
<path d="M148 20h14v10h-14Z" fill="#c46c4b"/>
<path d="M162 21h6v8h-6Z" fill="#c46c4b"/>
<path d="M151 30h9v1.5h-9Z" fill="#8d4328"/>
<path d="M18 30h164" stroke="#a56f42" stroke-width="2"/>
</svg>
</span>
<span class="damage" aria-hidden="true">
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 0 46 30 55 47 47 73 52 100"/><path class="c2" d="M0 47 28 42 46 30M55 47 79 40 100 47"/><path class="c3" d="M18 100 33 76 47 73M79 40 71 63 87 82"/></svg>
</span>
</button>
<div class="room-tag" aria-hidden="true">SLOOPZONE 18/10</div>
</div>
</section>
<div class="underbar">
<p class="log" id="log" role="status" aria-live="polite">Kamer wordt klaargezet...</p>
<div class="chips" id="chips" aria-label="Slooplijst"></div>
</div>
<p class="controls-hint">Klik op een stuk om te slaan. Wissel van werktuig met <kbd>1</kbd> en <kbd>2</kbd>. Glas vraagt een hamer, vastgeschroefd werk een koevoet.</p>
</main>
<footer class="footer">
<span>Met liefde gesloopt voor <span id="footer-name">Jos</span></span>
<span class="footer-date" id="footer-date">18 oktober</span>
</footer>
</div>
<canvas id="confetti" aria-hidden="true"></canvas>
<div class="modal" id="modal" hidden>
<div class="modal-backdrop"></div>
<section class="voucher" role="dialog" aria-modal="true" aria-labelledby="voucher-title" aria-describedby="voucher-lead">
<p class="voucher-kicker">Sloopbewijs nr. 18/10</p>
<h2 id="voucher-title">Kamer met succes gesloopt</h2>
<p class="voucher-lead" id="voucher-lead">Jos, het stofmasker mag af. Onder het behang zat een envelop met je cadeau.</p>
<div class="voucher-card">
<span class="voucher-label">Cadeaubon</span>
<span class="voucher-recipient" id="voucher-recipient">Voor Jos</span>
<div class="voucher-code-row">
<code id="voucher-code">...</code>
<button type="button" class="copy-btn" id="copy-code">Kopieer</button>
</div>
<span class="voucher-foot"><span id="voucher-date">18 oktober</span> · Geldig op vertoon van een brede glimlach</span>
</div>
<p class="voucher-note" id="voucher-note" role="status"></p>
<div class="modal-actions">
<button type="button" class="primary-btn" id="play-again">Nog eens slopen</button>
</div>
</section>
</div>
<script src="game.js"></script>
</body>
</html>
File diff suppressed because it is too large. Load diff
+11
View File
@@ -0,0 +1,11 @@
services:
jos-sloop-game:
build: .
image: bramkel/jos-sloop-game:latest
container_name: jos-sloop-game
ports:
- "8004:8000"
environment:
- TZ=Europe/Brussels
- GIFT_CODE=${GIFT_CODE:-VUL-JE-CADEAUBONCODE-IN}
restart: unless-stopped
+1
View File
@@ -0,0 +1 @@
latest