/** * ============================================================================================== * Modul: DVL17 — DAS VERRÜCKTE LABYRINTH (BORLAND C++ 3.1 DOS / PROCESSING EDITION) * Datei: dvl17.pde * Framework: DTIM-ZEC MODULAR PHYSICS FRAMEWORK (DAMTP ACADEMIC STANDARD) * Version: 17.2.0 (Authentic DOS Hostage, Stamina & 1/3-Victory-Point Rules · Browser-Safe) * Author: Jan Buehring & Adaptive Intelligence Synthesis Network (Google AI) * License: MIT License * Copyright: (c) 2026 Jan Bühring & Adaptive Intelligence Synthesis Network (Google AI) * Plattform: Processing 4.5.6 (Linux x64) & Processing.js (processing.min.js) * * Regeln & Steuerung: * [1. Karte schieben] : Reservekarte beim aktiven Piraten (oder [R]) drehen, dann Randpfeil klicken. * Schiebt man einen Gegner vom Feld (-1 Energie), landet er als Geisel auf * dem eigenen Kartenplatz! * [2. Geisel halten] : Sitzt ein Gegner auf deiner Reservekarte, kannst du mit [G] deinen Zug * überspringen, ihn gefangen halten und +1 Lebensenergie gewinnen. * [3. Pirat laufen] : [W/A/S/D] / [Pfeile] oder direkt auf ein begehbares Nachbarfeld klicken. * Je weniger Lebensenergie du hast, desto schlechter kannst du laufen! * [4. Zug beenden] : [Y] / [Enter] beendet den Zug ordentlich -> hohe Erholungschance bei * hoher Restenergie! * [5. Siegpunkte] : Exakt 4 Punkte = +1 Siegpunkt | Rundenende mit != 4 Punkten = +3 Siegpunkte! * [H] : Sehhilfe (DTIM Standard / Farbenblind / Max-Kontrast). * ============================================================================================== */ // ============================================================================================== // MODUL 1: GLOBALE SYSTEMKONSTANTEN & ZUSTAND (100% PROCESSING.JS-SICHER) // ============================================================================================== int MAX_GRID = 9; int gridN = 7; // Standard 7x7 (wie int feld = 7 im DOS-Original), umschaltbar 5 / 7 / 9 int MAX_ENERGY = 7; // Lebensenergie 0 .. 7 (wie pts1..pts4 = 7) int SERIES_GOAL_VP = 5; // Gesamtsieg der Serie ab 5 Siegpunkten float BOARD_X = 255.0; float BOARD_Y = 98.0; float BOARD_SIZE = 550.0; MazeTile[][] board = new MazeTile[9][9]; MazeTile spareTile; PirateAgent[] pirates = new PirateAgent[4]; int activePirate = 0; // 0..3 (Pirat 1 bis Pirat 4) int turnPhase = 0; // 0 = Karte einschieben / Geisel halten, 1 = Laufen, 2 = Rundenende boolean editorMode = false; int roundNumber = 1; int roundWinner = -1; int awardedVP = 0; String roundEndReason = ""; int a11yTheme = 0; // 0: DTIM Standard, 1: Farbenblind (Blau/Gold), 2: Max-Kontrast // Sperre gegen direktes Zurückschieben desselben Pfeils int blockedArrowSide = -1; // 0=Oben, 1=Rechts, 2=Unten, 3=Links int blockedArrowIndex = -1; // Flüssige Schiebe-Animation int animAxis = -1; // -1=Keine, 0=Reihe, 1=Spalte int animLineIndex = 0; float animOffsetPx = 0.0; boolean[][] reachable = new boolean[9][9]; String statusLine = "Pirat 1 beginnt: Drehe deine Karte [R] und schiebe sie über einen Randpfeil ein!"; // ============================================================================================== // MODUL 2: DATENSTRUKTUREN (KACHEL-TOPOLOGIE & PIRATEN MIT LEBENSENERGIE + GEISELSTATUS) // ============================================================================================== class MazeTile { boolean n; boolean e; boolean s; boolean w; int lootType; // 0 = leer, 1 = Silber-Schatz (+1 Punkt), 2 = Gold-Doppelschatz (+2 Punkte) MazeTile(boolean north, boolean east, boolean south, boolean west) { n = north; e = east; s = south; w = west; lootType = 0; } void rotateClockwise() { boolean oldN = n; n = w; w = s; s = e; e = oldN; } } class PirateAgent { int id; String name; int gx; int gy; float vx; float vy; int energy; // Lebensenergie 0 .. 7 int roundPoints; // In dieser Runde gesammelte Punkte (Ziel: 4 oder != 4) int victoryPoints; // Gesamte Siegpunkte über alle Runden (+1 oder +3) int stepsTaken; // Schritte im aktuellen Zug int maxStepsTurn; // Erlaubte Schritte abhängig von Lebensenergie int captiveOf; // -1 = frei auf dem Feld, 0..3 = als Geisel auf Kartenplatz von Pirat X! PirateAgent(int idx, String label, int startX, int startY) { id = idx; name = label; gx = startX; gy = startY; vx = float(startX); vy = float(startY); energy = MAX_ENERGY; roundPoints = 0; victoryPoints = 0; stepsTaken = 0; maxStepsTurn = 4; captiveOf = -1; } } // ============================================================================================== // MODUL 3: FARB-PALETTEN (SCHWARZ / BLUTROT / NACHTBLAU / SILBERGRAU + SEHHILFE) // ============================================================================================== int getUiColor(int theme, int role) { // role: 0=Bg, 1=Panel, 2=Blood/Primary, 3=Blue/Secondary, 4=Accent, 5=WallDark, 6=PathLight if (theme == 1) { if (role == 0) return color(5, 9, 17); if (role == 1) return color(11, 17, 29); if (role == 2) return color(180, 120, 10); if (role == 3) return color(10, 75, 130); if (role == 4) return color(251, 191, 36); if (role == 5) return color(15, 23, 42); return color(226, 238, 255); } if (theme == 2) { if (role == 0) return color(0, 0, 0); if (role == 1) return color(0, 0, 0); if (role == 2) return color(0, 0, 0); if (role == 3) return color(0, 0, 0); if (role == 4) return color(255, 255, 0); if (role == 5) return color(0, 0, 0); return color(255, 255, 255); } if (role == 0) return color(6, 8, 14); if (role == 1) return color(13, 16, 26); if (role == 2) return color(122, 16, 38); if (role == 3) return color(18, 46, 98); if (role == 4) return color(225, 55, 85); if (role == 5) return color(14, 18, 28); return color(232, 238, 248); } int getPirateColor(int theme, int pIdx) { if (theme == 1) { if (pIdx == 0) return color(56, 189, 248); // Himmelblau if (pIdx == 1) return color(251, 191, 36); // Gold-Amber if (pIdx == 2) return color(52, 211, 153); // Mint-Smaragd return color(244, 114, 182); // Rosa-Magenta } if (theme == 2) { if (pIdx == 0) return color(0, 255, 255); if (pIdx == 1) return color(255, 255, 0); if (pIdx == 2) return color(0, 255, 120); return color(255, 120, 255); } if (pIdx == 0) return color(58, 135, 255); // Pirat 1: Blau if (pIdx == 1) return color(35, 210, 115); // Pirat 2: Grün if (pIdx == 2) return color(0, 225, 245); // Pirat 3: Cyan return color(235, 55, 80); // Pirat 4: Blutrot } // ============================================================================================== // MODUL 4: INITIALISIERUNG & RUNDEN-AUFBAU // ============================================================================================== void setup() { size(1060, 760); noSmooth(); frameRate(60); for (int i = 0; i < 4; i++) { pirates[i] = new PirateAgent(i, "Pirat " + (i + 1), 0, 0); } startNewRound(true); } void startNewRound(boolean resetSeriesVP) { if (resetSeriesVP) { roundNumber = 1; for (int i = 0; i < 4; i++) { pirates[i].victoryPoints = 0; } } activePirate = 0; turnPhase = 0; editorMode = false; roundWinner = -1; awardedVP = 0; roundEndReason = ""; blockedArrowSide = -1; blockedArrowIndex = -1; animAxis = -1; animOffsetPx = 0.0; for (int y = 0; y < gridN; y++) { for (int x = 0; x < gridN; x++) { board[x][y] = createRandomTile(); } } // Vier Start-Ecken öffnen board[0][0] = new MazeTile(false, true, true, false); board[gridN - 1][0] = new MazeTile(false, false, true, true); board[0][gridN - 1] = new MazeTile(true, true, false, false); board[gridN - 1][gridN - 1] = new MazeTile(true, false, false, true); spareTile = createRandomTile(); int[] sx = { 0, gridN - 1, 0, gridN - 1 }; int[] sy = { 0, 0, gridN - 1, gridN - 1 }; for (int i = 0; i < 4; i++) { pirates[i].gx = sx[i]; pirates[i].gy = sy[i]; pirates[i].vx = float(sx[i]); pirates[i].gy = sy[i]; pirates[i].vy = float(sy[i]); pirates[i].energy = MAX_ENERGY; pirates[i].roundPoints = 0; pirates[i].stepsTaken = 0; pirates[i].maxStepsTurn = 4; pirates[i].captiveOf = -1; } // 7 Silber-Schätze (+1 Punkt) und 3 Gold-Doppelschätze (+2 Punkte) verteilen // Damit sind sowohl exakte 4-Punkte-Siege (1 SP) als auch 5-Punkte-Überholsiege (3 SP) möglich! for (int s = 0; s < 7; s++) spawnLootTile(1); for (int g = 0; g < 3; g++) spawnLootTile(2); computeReachableTiles(); statusLine = "Runde " + roundNumber + " · Pirat 1: Karte drehen [R] & einschieben (4 Pkt = 1 SP | !=4 Pkt = 3 SP)"; } MazeTile createRandomTile() { int kind = int(random(0, 3)); MazeTile t; if (kind == 0) t = new MazeTile(true, false, true, false); else if (kind == 1) t = new MazeTile(true, true, false, false); else t = new MazeTile(true, true, false, true); int rots = int(random(0, 4)); for (int r = 0; r < rots; r++) { t.rotateClockwise(); } return t; } void spawnLootTile(int lootKind) { for (int attempt = 0; attempt < 150; attempt++) { int rx = int(random(0, gridN)); int ry = int(random(0, gridN)); if (board[rx][ry].lootType != 0) continue; boolean onStart = (rx == 0 && ry == 0) || (rx == gridN - 1 && ry == 0) || (rx == 0 && ry == gridN - 1) || (rx == gridN - 1 && ry == gridN - 1); if (!onStart) { board[rx][ry].lootType = lootKind; return; } } } // ============================================================================================== // MODUL 5: HAUPTSCHLEIFE & RENDERING // ============================================================================================== void draw() { background(getUiColor(a11yTheme, 0)); if (abs(animOffsetPx) > 0.4) { animOffsetPx = lerp(animOffsetPx, 0.0, 0.28); } else { animOffsetPx = 0.0; animAxis = -1; } for (int i = 0; i < 4; i++) { if (pirates[i].captiveOf == -1) { pirates[i].vx = lerp(pirates[i].vx, float(pirates[i].gx), 0.28); pirates[i].vy = lerp(pirates[i].vy, float(pirates[i].gy), 0.28); } } // 1. Obere Steuer- & Regel-Leiste drawTopBar(); // 2. Vier Piraten-Terminals links & rechts drawPirateCard(0, 14, 68); drawPirateCard(2, 14, 416); drawPirateCard(1, 834, 68); drawPirateCard(3, 834, 416); // 3. Zentrales Spielfeld & Einschub-Pfeile drawInsertionArrows(); drawLabyrinthBoard(); // 4. Untere Statusleiste drawBottomStatusBar(); // 5. Runden-Sieg-Dialog (1 Siegpunkt bei == 4 Pkt, 3 Siegpunkte bei != 4 Pkt) if (turnPhase == 2 && roundWinner >= 0) { drawRoundVictoryModal(); } } void drawTopBar() { fill(getUiColor(a11yTheme, 1)); noStroke(); rect(0, 0, width, 54); stroke(getUiColor(a11yTheme, 4)); line(0, 54, width, 54); fill(255); textSize(14); textAlign(LEFT, CENTER); text("DVL17 — PIRATEN-LABYRINTH (RUNDE " + roundNumber + ")", 16, 17); fill(210, 225, 245); textSize(11); text("Siegpunkte-Regel: Genau 4 Punkte = +1 SP | Rundenende mit != 4 Punkten = +3 SP (Serie bis " + SERIES_GOAL_VP + " SP)", 16, 37); drawUiButton(535, 10, 108, 34, "Neu Würfeln", getUiColor(a11yTheme, 3)); drawUiButton(651, 10, 96, 34, "Feld: " + gridN + "x" + gridN, getUiColor(a11yTheme, 3)); int edBg = editorMode ? getUiColor(a11yTheme, 2) : color(24, 30, 44); drawUiButton(755, 10, 148, 34, editorMode ? "Editor: AN (-1 E)" : "Editor: AUS", edBg); String a11yLbl = "Sehhilfe [H]"; if (a11yTheme == 1) a11yLbl = "Farbenblind"; if (a11yTheme == 2) a11yLbl = "Max-Kontrast"; drawUiButton(911, 10, 134, 34, a11yLbl, getUiColor(a11yTheme, 3)); } void drawPirateCard(int pIdx, float px, float py) { float pw = 212.0; float ph = 330.0; PirateAgent p = pirates[pIdx]; boolean isTurn = (activePirate == pIdx && turnPhase != 2); int pCol = getPirateColor(a11yTheme, pIdx); fill(getUiColor(a11yTheme, 1)); if (isTurn) { stroke(pCol); strokeWeight(2.5); } else { stroke(48, 58, 82); strokeWeight(1.0); } rect(px, py, pw, ph, 8); strokeWeight(1.0); // Kopfbalken mit Piratenname & Siegpunkten fill(pCol); noStroke(); rect(px + 10, py + 8, pw - 20, 28, 5); fill(a11yTheme == 2 ? color(0) : color(8, 10, 16)); textSize(13); textAlign(LEFT, CENTER); text(p.name, px + 18, py + 22); textAlign(RIGHT, CENTER); text(p.victoryPoints + " SP", px + pw - 18, py + 22); // Status-Badge (Aktiv / Wartet / ALS GEISEL GEFANGEN) if (p.captiveOf != -1) { fill(145, 22, 42); stroke(255, 120, 140); } else if (isTurn) { fill(getUiColor(a11yTheme, 2)); stroke(getUiColor(a11yTheme, 4)); } else { fill(20, 25, 38); stroke(55, 68, 95); } rect(px + 10, py + 42, pw - 20, 24, 4); fill(255); textSize(11); textAlign(CENTER, CENTER); String badgeTxt = "Wartet"; if (p.captiveOf != -1) { badgeTxt = "GEISEL BEI PIRAT " + (p.captiveOf + 1); } else if (isTurn) { badgeTxt = (turnPhase == 0) ? "1. Karte schieben / Geisel" : "2. Laufen (" + (p.maxStepsTurn - p.stepsTaken) + " Schr.)"; } text(badgeTxt, px + pw * 0.5, py + 54); // Punkte (4-Punkte-Ziel) & Lebensenergie-Balken (0..7) fill(240, 245, 255); textSize(12); textAlign(LEFT, TOP); String ptHint = (p.roundPoints == 4) ? " [ZIEL 4!]" : ""; text("Punkte: " + p.roundPoints + " / 4" + ptHint, px + 12, py + 72); text("Lebensenergie: " + p.energy + " / " + MAX_ENERGY, px + 12, py + 92); fill(28, 35, 52); noStroke(); rect(px + 12, py + 110, pw - 24, 10, 3); int eCol = color(35, 210, 115); if (p.energy <= 2) eCol = color(235, 55, 80); else if (p.energy <= 4) eCol = color(251, 191, 36); fill(eCol); rect(px + 12, py + 110, map(p.energy, 0, MAX_ENERGY, 0, pw - 24), 10, 3); // Reserve-Kartenplatz (zeigt eigene Karte + eventuell gefangene Geisel darauf!) float miniSize = 86.0; float miniX = px + (pw - miniSize) * 0.5; float miniY = py + 138.0; int hostageIdx = getHostageOfPirate(pIdx); if (isTurn) { fill(210, 225, 245); textSize(10); textAlign(CENTER, BOTTOM); text("Kartenplatz (Klick = Drehen):", px + pw * 0.5, miniY - 3); drawTileGraphic(spareTile, miniX, miniY, miniSize, false, pIdx, hostageIdx); drawUiButton(px + 12, miniY + miniSize + 8, pw - 24, 26, "Karte drehen [R]", getUiColor(a11yTheme, 3)); if (hostageIdx != -1 && turnPhase == 0) { // Spezielle dvl17-Regel: Zug überspringen & Gegner als Geisel halten (+1 Energie)! drawUiButton(px + 12, miniY + miniSize + 38, pw - 24, 28, "Geisel halten [G] (+1 E)", getUiColor(a11yTheme, 2)); } else if (turnPhase == 1) { drawUiButton(px + 12, miniY + miniSize + 38, pw - 24, 28, "Ordentlich beenden [Y]", getUiColor(a11yTheme, 2)); } else { drawUiButton(px + 12, miniY + miniSize + 38, pw - 24, 28, "Ohne Schub laufen [S]", color(30, 38, 56)); } // Zusätzlicher Runden-Showdown-Button (wenn man != 4 Punkte hat und nicht 4 erreichen will) drawUiButton(px + 12, miniY + miniSize + 70, pw - 24, 22, "Runde werten [V]", color(42, 50, 72)); } else { fill(18, 22, 34); stroke(45, 55, 78); rect(miniX, miniY, miniSize, miniSize, 5); if (hostageIdx != -1) { drawPirateTokenOnCard(hostageIdx, miniX + miniSize * 0.5, miniY + miniSize * 0.5, 28.0); } else { fill(145, 160, 185); textSize(10); textAlign(CENTER, CENTER); text("Kartenplatz\nfrei", px + pw * 0.5, miniY + miniSize * 0.5); } } } int getHostageOfPirate(int captorIdx) { for (int i = 0; i < 4; i++) { if (pirates[i].captiveOf == captorIdx) { return i; } } return -1; } void drawInsertionArrows() { float tileSz = BOARD_SIZE / float(gridN); int arrowCol = (turnPhase == 0) ? getUiColor(a11yTheme, 4) : color(55, 68, 95); for (int idx = 1; idx < gridN; idx += 2) { float mid = idx * tileSz + tileSz * 0.5; if (!(blockedArrowSide == 0 && blockedArrowIndex == idx)) drawArrowBadge(BOARD_X + mid, BOARD_Y - 16, 0, arrowCol); if (!(blockedArrowSide == 2 && blockedArrowIndex == idx)) drawArrowBadge(BOARD_X + mid, BOARD_Y + BOARD_SIZE + 16, 2, arrowCol); if (!(blockedArrowSide == 3 && blockedArrowIndex == idx)) drawArrowBadge(BOARD_X - 16, BOARD_Y + mid, 3, arrowCol); if (!(blockedArrowSide == 1 && blockedArrowIndex == idx)) drawArrowBadge(BOARD_X + BOARD_SIZE + 16, BOARD_Y + mid, 1, arrowCol); } } void drawArrowBadge(float cx, float cy, int dir, int col) { fill(getUiColor(a11yTheme, 1)); stroke(col); strokeWeight(turnPhase == 0 ? 1.8 : 1.0); ellipse(cx, cy, 24, 24); fill(turnPhase == 0 ? color(255) : color(130)); noStroke(); if (dir == 0) triangle(cx - 5, cy - 3, cx + 5, cy - 3, cx, cy + 5); if (dir == 2) triangle(cx - 5, cy + 3, cx + 5, cy + 3, cx, cy - 5); if (dir == 3) triangle(cx - 3, cy - 5, cx - 3, cy + 5, cx + 5, cy); if (dir == 1) triangle(cx + 3, cy - 5, cx + 3, cy + 5, cx - 5, cy); strokeWeight(1.0); } void drawLabyrinthBoard() { fill(getUiColor(a11yTheme, 5)); stroke(getUiColor(a11yTheme, 4)); strokeWeight(2.0); rect(BOARD_X - 2, BOARD_Y - 2, BOARD_SIZE + 4, BOARD_SIZE + 4, 4); strokeWeight(1.0); float tileSz = BOARD_SIZE / float(gridN); for (int y = 0; y < gridN; y++) { for (int x = 0; x < gridN; x++) { float dx = BOARD_X + x * tileSz; float dy = BOARD_Y + y * tileSz; if (animAxis == 0 && y == animLineIndex) dx += animOffsetPx; if (animAxis == 1 && x == animLineIndex) dy += animOffsetPx; boolean isReach = (turnPhase == 1 && reachable[x][y]); drawTileGraphic(board[x][y], dx, dy, tileSz, isReach, activePirate, -1); } } // Freie Piraten auf dem Spielfeld zeichnen (Geiseln sitzen auf den Kartenplätzen!) for (int p = 0; p < 4; p++) { if (pirates[p].captiveOf != -1) continue; float px = BOARD_X + pirates[p].vx * tileSz + tileSz * 0.5; float py = BOARD_Y + pirates[p].vy * tileSz + tileSz * 0.5; int pCol = getPirateColor(a11yTheme, p); if (p == activePirate) { noFill(); stroke(255); strokeWeight(2.0); ellipse(px, py, tileSz * 0.52, tileSz * 0.52); } fill(pCol); stroke(0); strokeWeight(1.5); ellipse(px, py, tileSz * 0.36, tileSz * 0.36); fill(a11yTheme == 2 ? color(0) : color(255)); textSize(11); textAlign(CENTER, CENTER); text(str(p + 1), px, py - 1); } strokeWeight(1.0); } void drawTileGraphic(MazeTile t, float tx, float ty, float sz, boolean highlightReach, int currentP, int captiveOnTile) { float third = sz / 3.0; int wallCol = getUiColor(a11yTheme, 5); int pathCol = getUiColor(a11yTheme, 6); fill(wallCol); stroke(38, 48, 72); rect(tx, ty, sz, sz); noStroke(); fill(pathCol); rect(tx + third, ty + third, third, third); if (t.n) rect(tx + third, ty, third, third); if (t.s) rect(tx + third, ty + third * 2.0, third, third); if (t.w) rect(tx, ty + third, third, third); if (t.e) rect(tx + third * 2.0, ty + third, third, third); if (highlightReach) { int pCol = getPirateColor(a11yTheme, currentP); fill(red(pCol), green(pCol), blue(pCol), 72); rect(tx + 2, ty + 2, sz - 4, sz - 4); } // Schatz-Punkte zeichnen (Silber = +1 Punkt, Gold = +2 Punkte) if (t.lootType > 0) { float cx = tx + sz * 0.5; float cy = ty + sz * 0.5; if (t.lootType == 2) fill(255, 205, 45); else fill(140, 175, 235); stroke(0); strokeWeight(1.4); ellipse(cx, cy, third * 0.72, third * 0.72); fill(0); textSize(10); textAlign(CENTER, CENTER); text(t.lootType == 2 ? "+2" : "+1", cx, cy - 1); strokeWeight(1.0); } // Gefangene Geisel direkt auf der Reservekarte darstellen if (captiveOnTile >= 0) { drawPirateTokenOnCard(captiveOnTile, tx + sz * 0.5, ty + sz * 0.5, sz * 0.34); } } void drawPirateTokenOnCard(int pIdx, float cx, float cy, float diam) { int pCol = getPirateColor(a11yTheme, pIdx); fill(pCol); stroke(255); strokeWeight(2.0); ellipse(cx, cy, diam, diam); fill(0); textSize(11); textAlign(CENTER, CENTER); text("G" + (pIdx + 1), cx, cy - 1); strokeWeight(1.0); } void drawBottomStatusBar() { fill(getUiColor(a11yTheme, 1)); stroke(59, 110, 194); rect(236, 682, 588, 64, 8); fill(255); textSize(12); textAlign(LEFT, TOP); text(statusLine, 250, 692); fill(195, 210, 235); textSize(11); text("[R] Drehen | [G] Geisel halten | [W/A/S/D] Laufen | [Y] Ordentlich beenden | [H] Sehhilfe", 250, 718); } void drawRoundVictoryModal() { fill(4, 5, 12, 228); noStroke(); rect(0, 54, width, height - 54); fill(getUiColor(a11yTheme, 1)); stroke(getPirateColor(a11yTheme, roundWinner)); strokeWeight(2.5); rect(250, 200, 560, 290, 10); strokeWeight(1.0); fill(getPirateColor(a11yTheme, roundWinner)); noStroke(); rect(251, 201, 558, 42, 9); fill(a11yTheme == 2 ? color(0) : color(8, 10, 16)); textSize(16); textAlign(CENTER, CENTER); text("RUNDENSIEG: " + pirates[roundWinner].name.toUpperCase() + " (+" + awardedVP + " SIEGPUNKTE!)", width * 0.5, 222); fill(242, 246, 255); textSize(13); textAlign(CENTER, TOP); text(roundEndReason + "\n\nAktueller Serienstand (Ziel: " + SERIES_GOAL_VP + " Siegpunkte):\n" + "Pirat 1: " + pirates[0].victoryPoints + " SP | Pirat 2: " + pirates[1].victoryPoints + " SP | " + "Pirat 3: " + pirates[2].victoryPoints + " SP | Pirat 4: " + pirates[3].victoryPoints + " SP", 275, 262, 510, 145); boolean seriesFinished = (pirates[roundWinner].victoryPoints >= SERIES_GOAL_VP); String btnTxt = seriesFinished ? "NEUE SERIE STARTEN" : "NÄCHSTE RUNDE STARTEN >>"; drawUiButton(390, 425, 280, 42, btnTxt, getUiColor(a11yTheme, 2)); } void drawUiButton(float bx, float by, float bw, float bh, String label, int bgCol) { if (a11yTheme == 2) { fill(0); stroke(255, 255, 0); } else { fill(bgCol); stroke(125, 160, 220); } rect(bx, by, bw, bh, 5); fill(a11yTheme == 2 ? color(255, 255, 0) : color(255)); textSize(11); textAlign(CENTER, CENTER); text(label, bx + bw * 0.5, by + bh * 0.5); } // ============================================================================================== // MODUL 6: SCHIEBE-MECHANIK, GEISELNAHME, ERSCHÖPFUNG & SIEGPUNKTE-LOGIK // ============================================================================================== void insertSpareTileAt(int side, int idx) { if (turnPhase != 0) return; if (side == blockedArrowSide && idx == blockedArrowIndex) { statusLine = "Direktes Zurückschieben ist gesperrt — wähle einen anderen Pfeil!"; return; } PirateAgent mover = pirates[activePirate]; float tileSz = BOARD_SIZE / float(gridN); // Prüfe, ob eine bisher gehaltene Geisel auf unserer Reservekarte sitzt -> kommt auf die neue Kachel mit aufs Feld! int releasedHostage = getHostageOfPirate(activePirate); int entryX = idx; int entryY = 0; if (side == 0) { entryX = idx; entryY = 0; } if (side == 2) { entryX = idx; entryY = gridN - 1; } if (side == 3) { entryX = 0; entryY = idx; } if (side == 1) { entryX = gridN - 1; entryY = idx; } MazeTile pushedOut; int pushedOffVictim = -1; if (side == 0) { pushedOut = board[idx][gridN - 1]; for (int y = gridN - 1; y > 0; y--) board[idx][y] = board[idx][y - 1]; board[idx][0] = spareTile; spareTile = pushedOut; for (int p = 0; p < 4; p++) { if (pirates[p].captiveOf == -1 && pirates[p].gx == idx) { if (pirates[p].gy == gridN - 1) pushedOffVictim = p; else pirates[p].gy++; } } animAxis = 1; animLineIndex = idx; animOffsetPx = -tileSz; blockedArrowSide = 2; blockedArrowIndex = idx; } else if (side == 2) { pushedOut = board[idx][0]; for (int y = 0; y < gridN - 1; y++) board[idx][y] = board[idx][y + 1]; board[idx][gridN - 1] = spareTile; spareTile = pushedOut; for (int p = 0; p < 4; p++) { if (pirates[p].captiveOf == -1 && pirates[p].gx == idx) { if (pirates[p].gy == 0) pushedOffVictim = p; else pirates[p].gy--; } } animAxis = 1; animLineIndex = idx; animOffsetPx = tileSz; blockedArrowSide = 0; blockedArrowIndex = idx; } else if (side == 3) { pushedOut = board[gridN - 1][idx]; for (int x = gridN - 1; x > 0; x--) board[x][idx] = board[x - 1][idx]; board[0][idx] = spareTile; spareTile = pushedOut; for (int p = 0; p < 4; p++) { if (pirates[p].captiveOf == -1 && pirates[p].gy == idx) { if (pirates[p].gx == gridN - 1) pushedOffVictim = p; else pirates[p].gx++; } } animAxis = 0; animLineIndex = idx; animOffsetPx = -tileSz; blockedArrowSide = 1; blockedArrowIndex = idx; } else { pushedOut = board[0][idx]; for (int x = 0; x < gridN - 1; x++) board[x][idx] = board[x + 1][idx]; board[gridN - 1][idx] = spareTile; spareTile = pushedOut; for (int p = 0; p < 4; p++) { if (pirates[p].captiveOf == -1 && pirates[p].gy == idx) { if (pirates[p].gx == 0) pushedOffVictim = p; else pirates[p].gx--; } } animAxis = 0; animLineIndex = idx; animOffsetPx = tileSz; blockedArrowSide = 3; blockedArrowIndex = idx; } // Bisherige Geisel kehrt mit der eingeschobenen Karte zurück auf das Brett if (releasedHostage != -1) { pirates[releasedHostage].captiveOf = -1; pirates[releasedHostage].gx = entryX; pirates[releasedHostage].gy = entryY; pirates[releasedHostage].vx = float(entryX); pirates[releasedHostage].vy = float(entryY); } // Wurde jemand vom Feld geschoben? -> Landet auf unserem Kartenplatz & kostet 1 Lebensenergie! if (pushedOffVictim != -1) { if (pushedOffVictim == activePirate) { // Eigener Pirat wurde rausgeschoben -> taucht auf der eingeschobenen Karte wieder auf mover.gx = entryX; mover.gy = entryY; mover.vx = float(entryX); mover.vy = float(entryY); } else { pirates[pushedOffVictim].captiveOf = activePirate; mover.energy = max(0, mover.energy - 1); statusLine = mover.name + " schiebt " + pirates[pushedOffVictim].name + " vom Feld auf seinen Kartenplatz (-1 Energie)!"; if (checkAllRivalsCaptured(activePirate)) { finishRoundWithWinner(activePirate, "Alle Mitspieler wurden als Geiseln festgesetzt!"); return; } } } prepareMovementPhase(); } // Spezielle dvl17-Aktion: Zug überspringen & den Gegner als Geisel auf dem Kartenplatz halten! void holdHostageAndSkipTurn() { int hostage = getHostageOfPirate(activePirate); if (turnPhase != 0 || hostage == -1) return; PirateAgent mover = pirates[activePirate]; mover.energy = min(MAX_ENERGY, mover.energy + 1); statusLine = mover.name + " überspringt den Zug, hält " + pirates[hostage].name + " als Geisel und gewinnt +1 Energie!"; advanceToNextPirate(); } void prepareMovementPhase() { turnPhase = 1; PirateAgent p = pirates[activePirate]; p.stepsTaken = 0; // Maximale Schrittweite richtet sich nach der verbleibenden Lebensenergie! if (p.energy >= 6) p.maxStepsTurn = 4; else if (p.energy >= 4) p.maxStepsTurn = 3; else if (p.energy >= 2) p.maxStepsTurn = 2; else if (p.energy == 1) p.maxStepsTurn = 1; else p.maxStepsTurn = 0; computeReachableTiles(); checkLootPickup(activePirate); if (turnPhase != 2 && pushedMessageEmpty()) { if (p.maxStepsTurn == 0) { statusLine = p.name + " hat 0 Lebensenergie und kann nicht laufen — beende ordentlich mit [Y] zur Erholung!"; } else { statusLine = p.name + ": Bis zu " + p.maxStepsTurn + " Schritte (Energie " + p.energy + "/7) | [Y] Ordentlich beenden"; } } } boolean pushedMessageEmpty() { return !statusLine.contains("Kartenplatz (-1 Energie)"); } void tryStepPirate(int dx, int dy) { if (turnPhase != 1) return; PirateAgent p = pirates[activePirate]; if (p.stepsTaken >= p.maxStepsTurn) { statusLine = p.name + " hat sein Schrittlimit erreicht — beende den Zug ordentlich mit [Y]!"; return; } int nx = p.gx + dx; int ny = p.gy + dy; if (nx < 0 || nx >= gridN || ny < 0 || ny >= gridN) return; MazeTile cur = board[p.gx][p.gy]; MazeTile next = board[nx][ny]; boolean canPass = false; if (dy == -1 && cur.n && next.s) canPass = true; if (dy == 1 && cur.s && next.n) canPass = true; if (dx == -1 && cur.w && next.e) canPass = true; if (dx == 1 && cur.e && next.w) canPass = true; if (!canPass) return; // Erschöpfungs-Wurf aus deinem Originalcode: life = (int)random(0, energie) // Bei wenig Lebensenergie wird das Laufen immer unsicherer! int staminaRoll = int(random(0, p.energy + 1)); if (p.energy <= 2 && staminaRoll == 0) { p.stepsTaken++; statusLine = p.name + " stolpert vor Erschöpfung (Energie " + p.energy + "/7)! [Y] für Erholung."; return; } p.gx = nx; p.gy = ny; p.stepsTaken++; // Jeder 2. Schritt kostet 1 Punkt Lebensenergie if (p.stepsTaken % 2 == 0 && p.energy > 0) { p.energy--; } checkLootPickup(activePirate); if (turnPhase != 2) { int rem = max(0, p.maxStepsTurn - p.stepsTaken); statusLine = p.name + " zieht nach (" + nx + "," + ny + ") · Restschritte: " + rem + " · Energie: " + p.energy + "/7"; } } // Ordentliches Zugende [Y]: Höhere Erholungschance, je mehr Lebensenergie noch vorhanden ist! void finishTurnOrderly() { if (turnPhase == 2) return; PirateAgent p = pirates[activePirate]; int roll = int(random(0, MAX_ENERGY)); if (p.energy > 0 && roll < p.energy) { int gain = (p.energy >= 5) ? 2 : 1; p.energy = min(MAX_ENERGY, p.energy + gain); statusLine = p.name + " beendet ordentlich und erholt sich (+ " + gain + " Lebensenergie -> " + p.energy + "/7)!"; } else if (p.energy == 0) { p.energy = 1; statusLine = p.name + " schöpft nach totaler Erschöpfung wieder +1 Lebensenergie."; } else { statusLine = p.name + " beendet den Zug ordentlich (keine zusätzliche Erholung gewürfelt)."; } advanceToNextPirate(); } void advanceToNextPirate() { if (turnPhase == 2) return; for (int step = 1; step <= 4; step++) { int candidate = (activePirate + step) % 4; if (pirates[candidate].captiveOf == -1) { activePirate = candidate; turnPhase = 0; computeReachableTiles(); return; } } } void checkLootPickup(int pIdx) { PirateAgent p = pirates[pIdx]; MazeTile tile = board[p.gx][p.gy]; if (tile.lootType > 0) { int ptsGain = tile.lootType; tile.lootType = 0; p.roundPoints += ptsGain; spawnLootTile(ptsGain); // Exakt 4 Punkte beendet die Runde sofort mit +1 Siegpunkt! if (p.roundPoints == 4) { finishRoundWithWinner(pIdx, p.name + " hat genau 4 Punkte eingesammelt!"); } else if (p.roundPoints > 4) { // Überbieten auf 5+ Punkte (ungleich 4!) bringt +3 Siegpunkte! finishRoundWithWinner(pIdx, p.name + " beendet mit " + p.roundPoints + " Punkten (ungleich 4)!"); } else { statusLine = p.name + " sammelt +" + ptsGain + " Punkt(e) -> Stand: " + p.roundPoints + " Punkte!"; } } } boolean checkAllRivalsCaptured(int captorIdx) { int freeRivals = 0; for (int i = 0; i < 4; i++) { if (i != captorIdx && pirates[i].captiveOf == -1) { freeRivals++; } } return (freeRivals == 0); } void evaluateRoundEndNow() { int bestIdx = 0; for (int i = 1; i < 4; i++) { if (pirates[i].roundPoints > pirates[bestIdx].roundPoints) { bestIdx = i; } } finishRoundWithWinner(bestIdx, "Vorzeitige Rundenwertung: " + pirates[bestIdx].name + " führt mit " + pirates[bestIdx].roundPoints + " Punkten!"); } void finishRoundWithWinner(int wIdx, String reason) { roundWinner = wIdx; turnPhase = 2; // Originale dvl17-Siegpunkte-Regel: // Genau 4 Punkte = 1 Siegpunkt | Ungleich 4 Punkte = 3 Siegpunkte! if (pirates[wIdx].roundPoints == 4) { awardedVP = 1; roundEndReason = reason + "\nGenau 4 Punkte erreicht -> +1 Siegpunkt!"; } else { awardedVP = 3; roundEndReason = reason + "\nRundenende mit " + pirates[wIdx].roundPoints + " Punkten (ungleich 4) -> +3 Siegpunkte!"; } pirates[wIdx].victoryPoints += awardedVP; } void computeReachableTiles() { for (int y = 0; y < MAX_GRID; y++) { for (int x = 0; x < MAX_GRID; x++) { reachable[x][y] = false; } } PirateAgent p = pirates[activePirate]; if (p.captiveOf != -1) return; reachable[p.gx][p.gy] = true; int[] qx = new int[81]; int[] qy = new int[81]; int[] qd = new int[81]; int head = 0; int tail = 0; qx[tail] = p.gx; qy[tail] = p.gy; qd[tail] = 0; tail++; int remSteps = max(0, p.maxStepsTurn - p.stepsTaken); while (head < tail) { int cx = qx[head]; int cy = qy[head]; int cd = qd[head]; head++; if (cd >= remSteps) continue; MazeTile cur = board[cx][cy]; if (cy > 0 && cur.n && board[cx][cy - 1].s && !reachable[cx][cy - 1]) { reachable[cx][cy - 1] = true; qx[tail] = cx; qy[tail] = cy - 1; qd[tail] = cd + 1; tail++; } if (cy < gridN - 1 && cur.s && board[cx][cy + 1].n && !reachable[cx][cy + 1]) { reachable[cx][cy + 1] = true; qx[tail] = cx; qy[tail] = cy + 1; qd[tail] = cd + 1; tail++; } if (cx > 0 && cur.w && board[cx - 1][cy].e && !reachable[cx - 1][cy]) { reachable[cx - 1][cy] = true; qx[tail] = cx - 1; qy[tail] = cy; qd[tail] = cd + 1; tail++; } if (cx < gridN - 1 && cur.e && board[cx + 1][cy].w && !reachable[cx + 1][cy]) { reachable[cx + 1][cy] = true; qx[tail] = cx + 1; qy[tail] = cy; qd[tail] = cd + 1; tail++; } } } void handleEditorWallClick(int gx, int gy, float localX, float localY, float tileSz) { PirateAgent p = pirates[activePirate]; if (p.energy <= 0) { statusLine = p.name + " hat 0 Lebensenergie für den Editor!"; return; } MazeTile t = board[gx][gy]; float dTop = localY; float dBottom = tileSz - localY; float dLeft = localX; float dRight = tileSz - localX; float minD = min(min(dTop, dBottom), min(dLeft, dRight)); if (minD == dTop) t.n = !t.n; else if (minD == dBottom) t.s = !t.s; else if (minD == dLeft) t.w = !t.w; else t.e = !t.e; p.energy--; computeReachableTiles(); statusLine = "Editor: Durchgang auf (" + gx + "," + gy + ") geändert (-1 Lebensenergie -> " + p.energy + "/7)"; } // ============================================================================================== // MODUL 7: MAUS- & TASTATUR-STEUERUNG // ============================================================================================== void mousePressed() { if (turnPhase == 2) { if (mouseX >= 390 && mouseX <= 670 && mouseY >= 425 && mouseY <= 467) { boolean resetAll = (pirates[roundWinner].victoryPoints >= SERIES_GOAL_VP); if (!resetAll) roundNumber++; startNewRound(resetAll); } return; } // 1. Top-Leiste Buttons if (mouseY <= 54) { if (mouseX >= 535 && mouseX <= 643) { startNewRound(false); return; } if (mouseX >= 651 && mouseX <= 747) { gridN = (gridN == 5) ? 7 : ((gridN == 7) ? 9 : 5); startNewRound(false); return; } if (mouseX >= 755 && mouseX <= 903) { editorMode = !editorMode; statusLine = editorMode ? "Editor AKTIV: Klick auf eine Wandkante ändert den Durchgang (-1 Energie)." : "Editor deaktiviert."; return; } if (mouseX >= 911 && mouseX <= 1045) { a11yTheme = (a11yTheme + 1) % 3; return; } return; } // 2. Klicks in der Karte des aktiven Piraten float cardX = (activePirate == 0 || activePirate == 2) ? 14.0 : 834.0; float cardY = (activePirate < 2) ? 68.0 : 416.0; if (mouseX >= cardX && mouseX <= cardX + 212.0 && mouseY >= cardY && mouseY <= cardY + 330.0) { float miniY = cardY + 138.0; float miniSize = 86.0; // Reservekarte oder "Karte drehen" if (mouseY >= miniY && mouseY <= miniY + miniSize + 34.0) { spareTile.rotateClockwise(); return; } // "Geisel halten [G]" / "Ordentlich beenden [Y]" / "Ohne Schub laufen [S]" if (mouseY >= miniY + miniSize + 38.0 && mouseY <= miniY + miniSize + 66.0) { int hostageIdx = getHostageOfPirate(activePirate); if (hostageIdx != -1 && turnPhase == 0) { holdHostageAndSkipTurn(); } else if (turnPhase == 1) { finishTurnOrderly(); } else { prepareMovementPhase(); } return; } // "Runde werten [V]" (für != 4 Punkte Taktik) if (mouseY >= miniY + miniSize + 70.0 && mouseY <= miniY + miniSize + 94.0) { evaluateRoundEndNow(); return; } } float tileSz = BOARD_SIZE / float(gridN); // 3. Randpfeile zum Einschieben der Karte (Phase 0) if (turnPhase == 0) { for (int idx = 1; idx < gridN; idx += 2) { float mid = idx * tileSz + tileSz * 0.5; if (dist(mouseX, mouseY, BOARD_X + mid, BOARD_Y - 16) < 16.0) { insertSpareTileAt(0, idx); return; } if (dist(mouseX, mouseY, BOARD_X + mid, BOARD_Y + BOARD_SIZE + 16) < 16.0) { insertSpareTileAt(2, idx); return; } if (dist(mouseX, mouseY, BOARD_X - 16, BOARD_Y + mid) < 16.0) { insertSpareTileAt(3, idx); return; } if (dist(mouseX, mouseY, BOARD_X + BOARD_SIZE + 16, BOARD_Y + mid) < 16.0) { insertSpareTileAt(1, idx); return; } } } // 4. Klick direkt aufs Spielfeld (Editor oder Schritt auf angrenzendes erreichbares Feld) if (mouseX >= BOARD_X && mouseX < BOARD_X + BOARD_SIZE && mouseY >= BOARD_Y && mouseY < BOARD_Y + BOARD_SIZE) { int gx = constrain(floor((mouseX - BOARD_X) / tileSz), 0, gridN - 1); int gy = constrain(floor((mouseY - BOARD_Y) / tileSz), 0, gridN - 1); if (editorMode) { float localX = (mouseX - BOARD_X) - gx * tileSz; float localY = (mouseY - BOARD_Y) - gy * tileSz; handleEditorWallClick(gx, gy, localX, localY, tileSz); return; } if (turnPhase == 1) { PirateAgent p = pirates[activePirate]; int dx = gx - p.gx; int dy = gy - p.gy; if (abs(dx) + abs(dy) == 1) { tryStepPirate(dx, dy); } } } } void keyPressed() { if (key == 'h' || key == 'H') { a11yTheme = (a11yTheme + 1) % 3; return; } if (turnPhase == 2) return; if (key == 'r' || key == 'R') { spareTile.rotateClockwise(); return; } if (key == 'g' || key == 'G') { holdHostageAndSkipTurn(); return; } if (key == 'v' || key == 'V') { evaluateRoundEndNow(); return; } if (key == 'y' || key == 'Y' || key == ENTER || key == RETURN) { if (turnPhase == 1) finishTurnOrderly(); return; } if (key == 's' || key == 'S') { if (turnPhase == 0) { prepareMovementPhase(); return; } } if (turnPhase == 1) { if (key == 'w' || key == 'W') tryStepPirate(0, -1); if (key == 's' || key == 'S') tryStepPirate(0, 1); if (key == 'a' || key == 'A') tryStepPirate(-1, 0); if (key == 'd' || key == 'D') tryStepPirate(1, 0); if (key == CODED) { if (keyCode == UP) tryStepPirate(0, -1); if (keyCode == DOWN) tryStepPirate(0, 1); if (keyCode == LEFT) tryStepPirate(-1, 0); if (keyCode == RIGHT) tryStepPirate(1, 0); } } }