diff --git a/Dockers/jos-sloop-game/.dockerignore b/Dockers/jos-sloop-game/.dockerignore new file mode 100644 index 0000000..b3066d8 --- /dev/null +++ b/Dockers/jos-sloop-game/.dockerignore @@ -0,0 +1,7 @@ +README.md +.git +.gitignore +.env +.env.* +__pycache__/ +*.pyc diff --git a/Dockers/jos-sloop-game/.env.example b/Dockers/jos-sloop-game/.env.example new file mode 100644 index 0000000..a7ceb86 --- /dev/null +++ b/Dockers/jos-sloop-game/.env.example @@ -0,0 +1 @@ +GIFT_CODE=VUL-JE-CADEAUBONCODE-IN diff --git a/Dockers/jos-sloop-game/.gitignore b/Dockers/jos-sloop-game/.gitignore new file mode 100644 index 0000000..cff5543 --- /dev/null +++ b/Dockers/jos-sloop-game/.gitignore @@ -0,0 +1,3 @@ +.env +__pycache__/ +*.pyc diff --git a/Dockers/jos-sloop-game/Dockerfile b/Dockers/jos-sloop-game/Dockerfile new file mode 100644 index 0000000..b2f7ab5 --- /dev/null +++ b/Dockers/jos-sloop-game/Dockerfile @@ -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"] diff --git a/Dockers/jos-sloop-game/README.md b/Dockers/jos-sloop-game/README.md new file mode 100644 index 0000000..2190187 --- /dev/null +++ b/Dockers/jos-sloop-game/README.md @@ -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://: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 +``` diff --git a/Dockers/jos-sloop-game/app/game.json b/Dockers/jos-sloop-game/app/game.json new file mode 100644 index 0000000..23e3ef1 --- /dev/null +++ b/Dockers/jos-sloop-game/app/game.json @@ -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." + } + ] +} diff --git a/Dockers/jos-sloop-game/app/server.py b/Dockers/jos-sloop-game/app/server.py new file mode 100644 index 0000000..35437a9 --- /dev/null +++ b/Dockers/jos-sloop-game/app/server.py @@ -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() diff --git a/Dockers/jos-sloop-game/app/static/game.js b/Dockers/jos-sloop-game/app/static/game.js new file mode 100644 index 0000000..59b43de --- /dev/null +++ b/Dockers/jos-sloop-game/app/static/game.js @@ -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(); +})(); diff --git a/Dockers/jos-sloop-game/app/static/index.html b/Dockers/jos-sloop-game/app/static/index.html new file mode 100644 index 0000000..6ca9237 --- /dev/null +++ b/Dockers/jos-sloop-game/app/static/index.html @@ -0,0 +1,355 @@ + + + + + + + + De Grote Sloop van Jos + + + +
+
+

Jos wordt gevierd op 18 oktober

+

De Grote Sloop van Jos

+

Sloop de kamer, vind je cadeaubon

+
+ +
+
+
+ + +
+ +
+
+ 0 / 8 stukken gesloopt + 0% +
+
+ +
+
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+
+ +
+

Kamer wordt klaargezet...

+
+
+ +

Klik op een stuk om te slaan. Wissel van werktuig met 1 en 2. Glas vraagt een hamer, vastgeschroefd werk een koevoet.

+
+ +
+ Met liefde gesloopt voor Jos + 18 oktober +
+
+ + + + + + + + diff --git a/Dockers/jos-sloop-game/app/static/style.css b/Dockers/jos-sloop-game/app/static/style.css new file mode 100644 index 0000000..7e17d3c --- /dev/null +++ b/Dockers/jos-sloop-game/app/static/style.css @@ -0,0 +1,1225 @@ +:root { + color-scheme: dark; + --ink: #171512; + --panel: #221d17; + --panel-2: #2c251d; + --line: #4a3d2d; + --cream: #f6ead2; + --muted: #b7aa93; + --yellow: #ffc93c; + --orange: #e86f2b; + --green: #6da34d; + --shadow: 0 24px 60px rgba(0, 0, 0, .45); +} + +* { + box-sizing: border-box; +} + +html, +body { + min-height: 100%; +} + +body { + margin: 0; + padding: 0; + font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif; + background: + radial-gradient(ellipse at 50% -10%, rgba(255, 201, 60, .1), transparent 55%), + radial-gradient(ellipse at 80% 110%, rgba(232, 111, 43, .08), transparent 50%), + var(--ink); + color: var(--cream); + overflow-x: hidden; +} + +body::before { + content: ""; + position: fixed; + inset: 0 0 auto; + height: 10px; + background: repeating-linear-gradient(45deg, var(--yellow) 0 14px, #1b1916 14px 28px); + z-index: 3000; +} + +button { + font: inherit; + color: inherit; +} + +.page { + width: min(1180px, 100%); + margin: 0 auto; + padding: clamp(22px, 4vw, 42px) clamp(12px, 3vw, 30px) 38px; +} + +.hero { + text-align: center; + margin-bottom: clamp(18px, 3vw, 30px); +} + +.eyebrow { + display: inline-flex; + flex-wrap: wrap; + justify-content: center; + gap: .35em; + margin: 0 0 12px; + padding: 7px 15px; + border: 1px solid rgba(255, 201, 60, .35); + border-radius: 999px; + background: rgba(255, 201, 60, .07); + color: var(--yellow); + font-size: clamp(.72rem, 1.5vw, .85rem); + font-weight: 700; + letter-spacing: .13em; + text-transform: uppercase; +} + +.eyebrow span { + color: var(--cream); +} + +h1 { + margin: 0; + font-size: clamp(2rem, 6vw, 4.1rem); + line-height: .98; + letter-spacing: -.02em; + text-transform: uppercase; + text-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 40px rgba(255, 201, 60, .12); +} + +.tagline { + margin: 12px 0 0; + color: var(--muted); + font-size: clamp(.95rem, 2vw, 1.15rem); +} + +.game-shell { + position: relative; + padding: clamp(10px, 2vw, 18px); + border: 1px solid var(--line); + border-radius: 22px; + background: linear-gradient(180deg, #272119, #1e1a15); + box-shadow: var(--shadow); +} + +.hud { + display: grid; + grid-template-columns: auto minmax(200px, 1fr) auto; + gap: clamp(10px, 2vw, 22px); + align-items: center; + margin-bottom: 14px; +} + +.toolbar { + display: flex; + gap: 8px; +} + +.tool-btn { + display: flex; + align-items: center; + gap: 9px; + min-height: 54px; + padding: 8px 14px 8px 10px; + border: 1px solid #544632; + border-radius: 13px; + background: #191510; + color: var(--muted); + cursor: pointer; + transition: transform .12s, background .15s, color .15s, border-color .15s, box-shadow .15s; +} + +.tool-btn svg { + width: 32px; + height: 32px; + flex: none; + transform: rotate(-12deg); +} + +.tool-btn[data-tool="koevoet"] svg { + transform: rotate(-4deg); +} + +.tool-btn:hover { + border-color: #7a6446; + color: var(--cream); + transform: translateY(-1px); +} + +.tool-btn.is-active { + border-color: #ffd868; + background: linear-gradient(180deg, #ffd35c, #f0a51f); + color: #241b0c; + box-shadow: 0 5px 0 #a56c13, 0 10px 24px rgba(255, 201, 60, .16); + transform: translateY(-2px); +} + +.tool-btn:active { + transform: translateY(1px); + box-shadow: none; +} + +.tool-name { + font-weight: 800; + letter-spacing: .02em; +} + +kbd { + display: inline-block; + min-width: 20px; + padding: 2px 5px; + border: 1px solid currentColor; + border-radius: 5px; + font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; + font-size: .68rem; + line-height: 1.2; + text-align: center; + opacity: .65; +} + +.progress-copy { + display: flex; + justify-content: space-between; + gap: 12px; + margin-bottom: 7px; + color: var(--muted); + font-size: clamp(.74rem, 1.4vw, .86rem); + font-weight: 700; + letter-spacing: .06em; + text-transform: uppercase; +} + +#progress-percent { + color: var(--yellow); +} + +.progress-track { + height: 15px; + border: 1px solid #4a3d2d; + border-radius: 999px; + background: #120f0c; + overflow: hidden; +} + +#progress-bar { + display: block; + width: 0; + height: 100%; + border-radius: inherit; + background: + repeating-linear-gradient(-45deg, rgba(255, 255, 255, .22) 0 8px, transparent 8px 16px), + linear-gradient(90deg, var(--orange), var(--yellow)); + transition: width .35s cubic-bezier(.2, .8, .3, 1); +} + +.icon-btn { + display: grid; + place-items: center; + width: 48px; + height: 48px; + padding: 0; + border: 1px solid #544632; + border-radius: 50%; + background: #191510; + color: var(--muted); + cursor: pointer; + transition: color .15s, border-color .15s, transform .12s; +} + +.icon-btn:hover { + color: var(--cream); + border-color: #7a6446; + transform: translateY(-1px); +} + +.icon-btn svg { + width: 25px; + height: 25px; +} + +.icon-btn .sound-off { + display: none; +} + +.icon-btn[aria-pressed="false"] .sound-on { + display: none; +} + +.icon-btn[aria-pressed="false"] .sound-off { + display: block; +} + +.stage { + padding: clamp(4px, 1vw, 8px); + border-radius: 16px; + background: #0e0c0a; + box-shadow: inset 0 2px 18px rgba(0, 0, 0, .7); +} + +.room { + --chaos: 0; + position: relative; + aspect-ratio: 16 / 10; + overflow: hidden; + border-radius: 11px; + background: #d7c4a5; + isolation: isolate; +} + +.room::after { + content: ""; + position: absolute; + inset: 0; + z-index: 30; + pointer-events: none; + background: + radial-gradient(ellipse at 50% -5%, rgba(255, 243, 206, .3), transparent 55%), + radial-gradient(ellipse at 50% 110%, rgba(0, 0, 0, .42), transparent 62%), + radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(20, 12, 5, .28)); +} + +.room-decor { + position: absolute; + inset: 0; + pointer-events: none; +} + +.wallpaper { + position: absolute; + inset: 0 0 24% 0; + background-color: #d9c7a8; + background-image: + repeating-linear-gradient(90deg, rgba(105, 76, 44, .075) 0 2px, transparent 2px 46px), + repeating-linear-gradient(0deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 34px), + radial-gradient(circle at 18% 24%, rgba(255, 247, 222, .3), transparent 36%), + radial-gradient(circle at 82% 62%, rgba(132, 92, 51, .08), transparent 44%), + linear-gradient(180deg, #e2d2b5, #cdb692); +} + +.ceiling-band { + position: absolute; + inset: 0 0 auto; + height: 6%; + background: linear-gradient(180deg, #3b2c1f, #6d5137); + border-bottom: 3px solid #8b6c49; + box-shadow: 0 4px 12px rgba(0, 0, 0, .22); +} + +.floor { + position: absolute; + inset: 76% 0 0; + background-color: #67462f; + background-image: + repeating-linear-gradient(90deg, #745036 0 76px, #5c3d27 76px 81px), + repeating-linear-gradient(0deg, rgba(0, 0, 0, .14) 0 2px, transparent 2px 34px), + linear-gradient(180deg, #7c5639, #452c1c); + border-top: 2px solid #3b2617; +} + +.floor::after { + content: ""; + position: absolute; + inset: 0; + background: linear-gradient(90deg, rgba(0, 0, 0, .18), transparent 12%, transparent 88%, rgba(0, 0, 0, .18)); +} + +.baseboard { + position: absolute; + left: 0; + right: 0; + top: 74.4%; + height: 2.2%; + background: linear-gradient(180deg, #a07a51, #6a482e 55%, #4d3220); + border-top: 1px solid #b99263; + box-shadow: 0 3px 5px rgba(0, 0, 0, .28); + z-index: 1; +} + +.bunting { + position: absolute; + top: 5.6%; + left: 27%; + display: flex; + justify-content: space-around; + width: 46%; + height: 8%; + z-index: 2; +} + +.bunting::before { + content: ""; + position: absolute; + top: 0; + left: -2%; + width: 104%; + height: 3px; + border-radius: 3px; + background: #5a3a22; + box-shadow: 0 1px 2px rgba(0, 0, 0, .3); +} + +.bunting span { + width: 7.5%; + height: 78%; + margin-top: 2px; + clip-path: polygon(0 0, 100% 0, 50% 100%); + filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .2)); +} + +.bunting span:nth-child(1), +.bunting span:nth-child(4) { + background: #d2573f; +} + +.bunting span:nth-child(2), +.bunting span:nth-child(5) { + background: #e3b448; +} + +.bunting span:nth-child(3), +.bunting span:nth-child(6) { + background: #4f837c; +} + +.wall-lamp { + position: absolute; + top: 0; + left: 47.6%; + width: 4.8%; + height: 24%; + z-index: 4; +} + +.wall-lamp::after { + content: ""; + position: absolute; + top: 13%; + left: 50%; + width: 340%; + aspect-ratio: 1; + transform: translateX(-50%); + border-radius: 50%; + background: radial-gradient(circle, rgba(255, 241, 190, .36), transparent 64%); +} + +.lamp-cord { + display: block; + width: 2px; + height: 48%; + margin: 0 auto; + background: #30251a; +} + +.lamp-shade { + display: block; + width: 100%; + height: 18%; + background: linear-gradient(180deg, #3f3022, #241b13); + clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%); + filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .3)); +} + +.rug { + position: absolute; + left: 35%; + top: 80%; + width: 36%; + height: 13.5%; + z-index: 1; + border-radius: 50%; + transform: rotate(-1.5deg); + background: + radial-gradient(ellipse at center, transparent 0 34%, rgba(255, 228, 178, .16) 35% 38%, transparent 39% 52%, rgba(255, 228, 178, .14) 53% 56%, transparent 57%), + repeating-linear-gradient(90deg, #7e4b3b 0 18px, #8e5743 18px 36px); + box-shadow: inset 0 0 24px rgba(0, 0, 0, .3), 0 3px 8px rgba(0, 0, 0, .2); +} + +.wall-stain { + position: absolute; + border-radius: 50%; + background: rgba(104, 72, 39, .08); + filter: blur(12px); + z-index: 0; +} + +.stain-one { + top: 33%; + left: 60%; + width: 12%; + height: 11%; +} + +.stain-two { + top: 60%; + left: 37%; + width: 9%; + height: 8%; +} + +.debris-bed { + position: absolute; + inset: 0; + z-index: 0; + opacity: calc(var(--chaos) * .5); + background: + radial-gradient(circle at 22% 84%, rgba(70, 48, 30, .45) 0 2px, transparent 3px), + radial-gradient(circle at 31% 90%, rgba(70, 48, 30, .35) 0 3px, transparent 4px), + radial-gradient(circle at 62% 87%, rgba(70, 48, 30, .4) 0 2px, transparent 3px), + radial-gradient(circle at 74% 92%, rgba(70, 48, 30, .3) 0 3px, transparent 4px); +} + +.dust { + position: absolute; + inset: 0; + z-index: 29; + pointer-events: none; + opacity: calc(var(--chaos) * .55); + background: + radial-gradient(ellipse at 30% 70%, rgba(150, 120, 82, .2), transparent 40%), + radial-gradient(ellipse at 70% 40%, rgba(160, 130, 90, .15), transparent 44%); + transition: opacity .5s; +} + +.object { + position: absolute; + display: block; + padding: 0; + border: 0; + background: none; + cursor: pointer; + -webkit-tap-highlight-color: transparent; + transform-origin: center bottom; +} + +.object .art, +.object .damage { + position: absolute; + inset: 0; + display: block; +} + +.object .art { + transition: transform .18s ease, filter .2s ease; + transform-origin: center bottom; +} + +.object svg { + display: block; + width: 100%; + height: 100%; + overflow: visible; +} + +.object::before { + content: ""; + position: absolute; + inset: -4%; + z-index: 4; + border: 2px dashed transparent; + border-radius: 12px; + pointer-events: none; + transition: border-color .15s, background .15s; +} + +.object:hover::before, +.object:focus-visible::before { + border-color: rgba(255, 201, 60, .9); + background: rgba(255, 201, 60, .07); +} + +.object.pulse::before { + animation: target-pulse .75s ease; +} + +@keyframes target-pulse { + 0%, 100% { + border-color: rgba(255, 201, 60, 0); + box-shadow: 0 0 0 0 rgba(255, 201, 60, 0); + } + 35% { + border-color: rgba(255, 201, 60, 1); + box-shadow: 0 0 0 8px rgba(255, 201, 60, .16); + } + 70% { + border-color: rgba(255, 201, 60, .5); + box-shadow: 0 0 0 16px rgba(255, 201, 60, 0); + } +} + +.object:focus-visible { + outline: none; +} + +.object:disabled { + cursor: default; +} + +.damage { + z-index: 3; + opacity: 0; + pointer-events: none; + transition: opacity .2s; +} + +.damage path { + fill: none; + stroke: rgba(38, 26, 14, .78); + stroke-width: 1.4; + stroke-linecap: round; + stroke-linejoin: round; + vector-effect: non-scaling-stroke; +} + +.object[data-stage="1"] .damage { + opacity: .48; +} + +.object[data-stage="1"] .damage .c2, +.object[data-stage="1"] .damage .c3, +.object[data-stage="2"] .damage .c3 { + opacity: 0; +} + +.object[data-stage="2"] .damage { + opacity: .68; +} + +.object[data-stage="3"] .damage { + opacity: .88; +} + +.mirror-cracks .crack { + opacity: 0; + transition: opacity .2s; +} + +.obj-spiegel[data-stage="1"] .crack-1 { + opacity: 1; +} + +.obj-spiegel[data-stage="2"] .crack-2 { + opacity: 1; +} + +.obj-spiegel[data-stage="3"] .crack-3 { + opacity: 1; +} + +.obj-deur { + left: 74.5%; + top: 21%; + width: 15.5%; + height: 55%; + z-index: 3; +} + +.obj-spiegel { + left: 6.5%; + top: 12%; + width: 15%; + height: 27%; + z-index: 4; +} + +.obj-schilderij { + left: 27%; + top: 16%; + width: 15.5%; + height: 23%; + z-index: 4; +} + +.obj-klok { + left: 58.5%; + top: 12%; + width: 9%; + height: 14.4%; + z-index: 4; +} + +.obj-kast { + left: 1.7%; + top: 42%; + width: 17.5%; + height: 40%; + z-index: 5; +} + +.obj-plant { + left: 20.5%; + top: 60%; + width: 8.5%; + height: 22%; + z-index: 6; +} + +.obj-zetel { + left: 49%; + top: 57%; + width: 22.5%; + height: 23%; + z-index: 6; +} + +.obj-tafel { + left: 42%; + top: 71%; + width: 23%; + height: 17%; + z-index: 7; +} + +.room-tag { + position: absolute; + left: 76.5%; + top: 88%; + z-index: 8; + padding: 3px 7px; + border: 1px solid rgba(255, 201, 60, .55); + background: rgba(28, 22, 15, .5); + color: var(--yellow); + font-size: .5rem; + font-weight: 800; + letter-spacing: .18em; + transform: rotate(-3deg); + opacity: .8; +} + +.rubble { + position: absolute; + width: 11%; + height: 4.5%; + transform: translate(-50%, -50%); + pointer-events: none; + z-index: 9; + opacity: .92; +} + +.rubble i { + position: absolute; + display: block; + border-radius: 1px; + box-shadow: 0 1px 2px rgba(0, 0, 0, .25); +} + +.object[data-stage="1"] .art { + filter: saturate(.92) brightness(.98); +} + +.object[data-stage="2"] .art { + filter: saturate(.82) brightness(.95); + transform: rotate(-.7deg); +} + +.object[data-stage="3"] .art { + filter: saturate(.66) brightness(.9); + transform: rotate(.9deg) translateY(.6%); +} + +.object.is-hit .art { + animation: hit-wobble .26s ease-out; +} + +.object.is-broken { + pointer-events: none; +} + +.object.is-broken::before { + display: none; +} + +.object.is-broken .art { + animation: crumble .62s cubic-bezier(.35, 0, .55, 1) forwards; +} + +.object.is-broken .damage { + opacity: 0 !important; +} + +.obj-spiegel.is-broken .art { + animation: shatter .7s cubic-bezier(.3, 0, .4, 1) forwards; +} + +@keyframes hit-wobble { + 0% { transform: translate(0, 0) rotate(0); } + 28% { transform: translate(-1.5%, .8%) rotate(-1.4deg); } + 55% { transform: translate(1.6%, -.7%) rotate(1.2deg); } + 78% { transform: translate(-.8%, .3%) rotate(-.5deg); } + 100% { transform: translate(0, 0) rotate(0); } +} + +@keyframes crumble { + 0% { opacity: 1; } + 35% { transform: translateY(1.5%) rotate(3deg) scale(.97); opacity: 1; } + 100% { transform: translateY(9%) rotate(8deg) scale(.72); opacity: 0; filter: blur(3px); } +} + +@keyframes shatter { + 0% { opacity: 1; } + 30% { transform: scale(1.04) rotate(-2deg); opacity: 1; } + 100% { transform: translateY(12%) scale(.48) rotate(9deg); opacity: 0; filter: blur(2px); } +} + +.game-shell.is-shaking { + animation: shell-shake .24s linear; +} + +@keyframes shell-shake { + 0%, 100% { transform: translate(0, 0); } + 20% { transform: translate(-3px, 2px) rotate(-.08deg); } + 45% { transform: translate(3px, -1px) rotate(.08deg); } + 70% { transform: translate(-2px, 1px); } +} + +.underbar { + margin-top: 14px; +} + +.log { + min-height: 3.2em; + margin: 0 0 12px; + padding: 11px 15px; + border-left: 4px solid var(--yellow); + border-radius: 0 10px 10px 0; + background: #14110d; + color: #e5d9c4; + font-size: clamp(.86rem, 1.6vw, .98rem); + line-height: 1.45; +} + +.log.is-warning { + border-left-color: var(--orange); + color: #ffd1ad; +} + +.log.is-done { + border-left-color: var(--green); +} + +.chips { + display: flex; + flex-wrap: wrap; + gap: 7px; +} + +.chip { + display: inline-flex; + align-items: center; + gap: 7px; + padding: 6px 11px; + border: 1px solid #4a3d2d; + border-radius: 999px; + background: #191510; + color: #cbbfa9; + font-size: clamp(.7rem, 1.4vw, .8rem); + font-weight: 700; + cursor: pointer; + transition: border-color .15s, color .15s, transform .12s, opacity .2s; +} + +.chip::before { + content: ""; + width: 8px; + height: 8px; + flex: none; + border-radius: 50%; + background: #746044; + box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); +} + +.chip:hover { + border-color: #7a6446; + color: var(--cream); + transform: translateY(-1px); +} + +.chip.done { + opacity: .55; + text-decoration: line-through; +} + +.chip.done::before { + background: var(--green); +} + +.chip.pulse { + animation: chip-pulse .55s ease; +} + +@keyframes chip-pulse { + 0%, 100% { transform: scale(1); border-color: #4a3d2d; } + 45% { transform: scale(1.08); border-color: var(--yellow); } +} + +.controls-hint { + margin: 14px 2px 0; + color: #8f836f; + font-size: clamp(.74rem, 1.4vw, .84rem); + line-height: 1.6; +} + +.controls-hint kbd { + color: #cbbfa9; +} + +.footer { + display: flex; + justify-content: space-between; + gap: 14px; + margin-top: 22px; + padding: 0 4px; + color: #827662; + font-size: .78rem; + letter-spacing: .04em; +} + +.footer-date { + color: #a1937a; + font-weight: 700; + text-transform: uppercase; + letter-spacing: .12em; +} + +.swing { + position: fixed; + z-index: 2400; + width: 74px; + height: 74px; + color: var(--yellow); + pointer-events: none; + filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); + transform-origin: 50% 85%; + animation: swing-strike .36s cubic-bezier(.3, .7, .4, 1) forwards; +} + +.swing.bad { + color: #b8b0a2; + animation: swing-bad .4s ease-out forwards; +} + +.swing svg { + width: 100%; + height: 100%; +} + +@keyframes swing-strike { + 0% { transform: translate(-50%, -85%) rotate(-78deg) scale(.82); opacity: 0; } + 22% { opacity: 1; } + 58% { transform: translate(-50%, -85%) rotate(16deg) scale(1.08); opacity: 1; } + 100% { transform: translate(-50%, -85%) rotate(4deg) scale(.88); opacity: 0; } +} + +@keyframes swing-bad { + 0% { transform: translate(-50%, -85%) rotate(-20deg) scale(.8); opacity: 0; } + 30% { transform: translate(-50%, -85%) rotate(28deg) scale(1); opacity: 1; } + 55% { transform: translate(-50%, -85%) rotate(10deg) scale(1); opacity: 1; } + 100% { transform: translate(-50%, -85%) rotate(24deg) scale(.85); opacity: 0; } +} + +.debris { + position: fixed; + z-index: 2300; + width: 9px; + height: 9px; + pointer-events: none; + will-change: transform, opacity; +} + +.float-text { + position: fixed; + z-index: 2400; + color: var(--yellow); + font-weight: 900; + font-size: 1rem; + letter-spacing: .06em; + text-shadow: 0 2px 0 rgba(0, 0, 0, .65); + pointer-events: none; + animation: float-up .8s ease-out forwards; +} + +.float-text.bad { + color: #c8c0b2; +} + +@keyframes float-up { + 0% { transform: translate(-50%, 0) scale(.8); opacity: 0; } + 20% { opacity: 1; transform: translate(-50%, -14px) scale(1.06); } + 100% { transform: translate(-50%, -54px) scale(1); opacity: 0; } +} + +#confetti { + position: fixed; + inset: 0; + z-index: 2600; + width: 100%; + height: 100%; + pointer-events: none; +} + +.modal { + position: fixed; + inset: 0; + z-index: 2500; + display: grid; + place-items: center; + padding: 22px; + overflow-y: auto; +} + +.modal[hidden] { + display: none; +} + +.modal-backdrop { + position: fixed; + inset: 0; + background: rgba(9, 7, 5, .84); + backdrop-filter: blur(7px); + animation: fade-in .3s ease; +} + +.voucher { + position: relative; + width: min(570px, 100%); + padding: clamp(22px, 5vw, 38px); + border: 1px solid #e2c98d; + border-radius: 18px; + background: + radial-gradient(circle at 15% 10%, rgba(255, 255, 255, .8), transparent 32%), + linear-gradient(145deg, #fff9e9, #eddfbe); + box-shadow: 0 30px 80px rgba(0, 0, 0, .65); + color: #2b2114; + text-align: center; + transform: rotate(-1deg); + animation: voucher-pop .45s cubic-bezier(.2, .9, .3, 1.2); +} + +.voucher::before { + content: ""; + position: absolute; + inset: 10px; + border: 2px dashed rgba(146, 108, 43, .5); + border-radius: 12px; + pointer-events: none; +} + +.voucher-kicker { + margin: 0 0 8px; + color: #9a742f; + font-size: .72rem; + font-weight: 800; + letter-spacing: .2em; + text-transform: uppercase; +} + +.voucher h2 { + margin: 0; + font-size: clamp(1.5rem, 4.5vw, 2.25rem); + line-height: 1.05; + text-transform: uppercase; + letter-spacing: -.01em; +} + +.voucher-lead { + max-width: 40ch; + margin: 12px auto 20px; + color: #5d4a30; + font-size: clamp(.9rem, 2vw, 1rem); + line-height: 1.55; +} + +.voucher-card { + margin: 0 auto; + padding: 16px; + border: 2px dashed #b38a3f; + border-radius: 14px; + background: rgba(255, 255, 255, .45); +} + +.voucher-label { + display: block; + color: #9a742f; + font-size: .68rem; + font-weight: 800; + letter-spacing: .26em; + text-transform: uppercase; +} + +.voucher-recipient { + display: block; + margin: 5px 0 12px; + font-size: clamp(1.05rem, 2.6vw, 1.25rem); + font-weight: 800; +} + +.voucher-code-row { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 8px; +} + +#voucher-code { + display: inline-block; + max-width: 100%; + padding: 10px 15px; + border-radius: 8px; + background: #2b2114; + color: #ffdf8a; + font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; + font-size: clamp(1rem, 3.6vw, 1.5rem); + font-weight: 700; + letter-spacing: .12em; + overflow-wrap: anywhere; + box-shadow: inset 0 2px 6px rgba(0, 0, 0, .3); +} + +.copy-btn, +.primary-btn { + border: 0; + border-radius: 9px; + cursor: pointer; + font-weight: 800; + transition: transform .12s, box-shadow .15s, background .15s; +} + +.copy-btn { + padding: 10px 14px; + background: #2b2114; + color: #fff1ca; + font-size: .78rem; +} + +.copy-btn:hover, +.primary-btn:hover { + transform: translateY(-1px); +} + +.copy-btn:active, +.primary-btn:active { + transform: translateY(1px); +} + +.copy-btn.is-copied { + background: #3f6b3a; +} + +.voucher-foot { + display: block; + margin-top: 12px; + color: #7d6745; + font-size: .7rem; + letter-spacing: .04em; +} + +.voucher-note { + min-height: 1.3em; + margin: 13px 0 0; + color: #7a5d31; + font-size: .82rem; + font-weight: 700; +} + +.modal-actions { + margin-top: 16px; +} + +.primary-btn { + padding: 11px 22px; + background: #2b2114; + color: #ffdf8a; + font-size: .9rem; + box-shadow: 0 4px 0 #0f0c08; +} + +.primary-btn:hover { + background: #3a2c1a; +} + +@keyframes voucher-pop { + 0% { transform: rotate(-4deg) scale(.86); opacity: 0; } + 100% { transform: rotate(-1deg) scale(1); opacity: 1; } +} + +@keyframes fade-in { + from { opacity: 0; } + to { opacity: 1; } +} + +@media (max-width: 820px) { + .hud { + grid-template-columns: 1fr auto; + } + + .toolbar { + grid-column: 1 / -1; + } + + .progress { + grid-column: 1; + } + + .tool-btn { + flex: 1; + justify-content: center; + } +} + +@media (max-width: 560px) { + .page { + padding-top: 20px; + } + + .hero { + margin-bottom: 16px; + } + + .tool-btn { + min-height: 48px; + padding: 7px 8px; + gap: 6px; + } + + .tool-btn svg { + width: 27px; + height: 27px; + } + + .tool-name { + font-size: .82rem; + } + + .icon-btn { + width: 42px; + height: 42px; + } + + .log { + min-height: 4.4em; + } + + .room-tag { + display: none; + } + + .footer { + flex-direction: column; + align-items: center; + gap: 8px; + } + + .voucher { + transform: none; + } +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: .01ms !important; + animation-iteration-count: 1 !important; + transition-duration: .01ms !important; + } +} diff --git a/Dockers/jos-sloop-game/docker-compose.yml b/Dockers/jos-sloop-game/docker-compose.yml new file mode 100644 index 0000000..9898d8f --- /dev/null +++ b/Dockers/jos-sloop-game/docker-compose.yml @@ -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 diff --git a/Dockers/jos-sloop-game/version b/Dockers/jos-sloop-game/version new file mode 100644 index 0000000..b9bc2fd --- /dev/null +++ b/Dockers/jos-sloop-game/version @@ -0,0 +1 @@ +latest \ No newline at end of file