Raidplaner: tactics on the maps of all dungeons and raids, with tokens that move from step to step
Asked for in Discord: "raidplan.io bitte einbauen für die harten Dungeons". raidplan.io has no Aion 2
(only WoW, FFXIV, Lost Ark, New World), so the map tactics got what it offers.
- Dungeon maps: the in-game map textures of 11 expeditions, 7 transcendence dungeons, the 3 sanctuaries
(Ludra, Corroded Decontamination Facility, Chalice of Muspel), the 6 awakening towers and 3
subjugations, as published by the DPS meter Waffle-ens/waffle_meter (dotnet/Assets/Maps, pinned
commit). assets/map/dungeons/dungeons.json is kept by hand: groups, slugs (= tactics.map_slug),
German names from the Global client (aion2.app), KR/TW-only dungeons marked as unavailable, boss
hints for the awakening towers. scripts/download_dungeon_maps.py fetches the images, writes
dungeons/<slug>.webp (2048 px, about 3 MB in total, in Git) and the previews, and finds the dungeon
area (bounds) by comparing each map with the shared background of all maps. Two empty arenas
(round, square) are drawn in code.
- Viewer: image maps and arenas next to the tile maps (MapView.drawImageMap/drawArena, half zoom
steps, opens fitted to the dungeon beside the tactic panel), map picker with the tabs "Welt" and
"Dungeons & Raids", each area remembers its last map, no category panel without markers. The mouse
wheel zooms to the cursor.
- New page raidplan.php ("Raidplaner" in the menu, map.view) = map.php started in the dungeon area.
Location links on dungeon maps point to /raidplan.php and are recognized in texts and by the
calendar picker.
- Tokens (shape type 'token', TokenIcons.js): classes, roles, players 1-8, markers A-D and symbols,
boss, add, danger, stack, spread, tower, orb, bomb. Colour and size come from the toolbar, numbers
and letters count up while placing, tokens are drawn above areas. Server whitelist
TACTIC_TOKEN_ICONS.
- Move tool (✥) with label/delete actions above the selected shape, double click and Del; new action
shape_update in tactics_api.php (points and label, same permissions, snapshot before). Undo also
reverts moves and labels. Rectangle and cone tools, saved as areas.
- Step transitions: tactic_shapes.ref is kept by "Kopie dieses Schritts", tactic copies and restores
(existing shapes get s<id>), so the same shape glides to its new place when stepping or playing;
play button (and space) runs through all steps. 🔗 copies a link to the tactic and step
(?taktik=&schritt=), which opens it after loading.
- Live view: the bot relay only knows the old shape types and events, so placing tokens and moving
send "changed" and the others reload - no bot deploy needed.
- Schema version 60 (tactic_shapes.icon, .ref, enum 'token'; also in sql/schema.sql), tour step on the
dashboard, patch notes and README.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86
README.md
|
|
@ -29,6 +29,9 @@ und wird später ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Berei
|
|||
- Karte: interaktive Zoom-Karte aller Regionen (Verteron, Altgard, Eltnen, Morheim, Poeta,
|
||||
Ishalgen, Reshanta) mit Markern und Kategorie-Filtern, dazu Taktiken in Schritten, die
|
||||
direkt auf die Karte gezeichnet werden
|
||||
- Raidplaner (wie raidplan.io): dieselben Taktiken auf den Karten aller Dungeons und Raids aus dem
|
||||
Spiel und auf leeren Arenen - mit Figuren für Klassen, Rollen, Spieler und Bosse, die beim
|
||||
Blättern von Schritt zu Schritt an ihre neue Stelle laufen
|
||||
- Lumipunkte: Punkte für Raids, Events und andere Aktivitäten an einzelne oder viele
|
||||
Mitglieder vergeben, mit Rangliste und Verlauf
|
||||
- Lumishop: Mitglieder beantragen Gegenstände gegen Lumipunkte, die Leitung bewilligt oder
|
||||
|
|
@ -442,12 +445,15 @@ Die Seite **Karte** (`map.php`) zeigt eine interaktive Karte aller Regionen: Ver
|
|||
Altgard, Eltnen, Morheim, Poeta, Ishalgen, Abyss Reshanta A/B sowie Chaotic Middle/Upper
|
||||
Reshanta. Oben wird die Region gewählt, unten links lassen sich die Marker-Kategorien
|
||||
(Orte, Monster, NPCs, Ressourcen, Sammelbares, Quests …) einzeln, gruppenweise oder mit
|
||||
„Alle anzeigen“/„Alle verstecken“ auf einmal ein- und ausblenden (beim Öffnen sind alle versteckt), beim Überfahren eines Markers erscheint sein Name. Zoomen per Mausrad, `+`/`-`
|
||||
oder die Knöpfe oben rechts, verschieben per Ziehen, `0` setzt die Ansicht zurück.
|
||||
„Alle anzeigen“/„Alle verstecken“ auf einmal ein- und ausblenden (beim Öffnen sind alle versteckt), beim Überfahren eines Markers erscheint sein Name. Zoomen per Mausrad (zur Mausposition), `+`/`-`
|
||||
oder die Knöpfe oben rechts, verschieben per Ziehen, `0` setzt die Ansicht zurück. Die
|
||||
Kartenauswahl hat zwei Reiter: **Welt** (diese Regionen) und **Dungeons & Raids** (siehe
|
||||
Raidplaner unten); jeder Bereich merkt sich seine zuletzt gewählte Karte.
|
||||
|
||||
**Orte teilen:** Der 📍-Knopf in der Leiste oben rechts markiert per Klick einen Ort (Name
|
||||
optional, der nächste Marker wird vorgeschlagen) und erzeugt einen Link wie
|
||||
`/map.php?karte=verteron&x=2149&y=1962&zoom=4&ort=Treffpunkt`. Wer ihn öffnet, landet direkt dort,
|
||||
`/map.php?karte=verteron&x=2149&y=1962&zoom=4&ort=Treffpunkt` (auf Dungeon-Karten `/raidplan.php?…`).
|
||||
Wer ihn öffnet, landet direkt dort,
|
||||
mit pulsierendem Pin. In Kommentaren, Bildunterschriften und Termin-Beschreibungen werden solche
|
||||
Links automatisch zu „📍 Verteron – Treffpunkt“ und zählen für die Moderation nicht als (fremder)
|
||||
Link. Beim Kalender-Termin gibt es „🗺️ Ort auf der Karte wählen“: Die Karte öffnet sich im
|
||||
|
|
@ -504,17 +510,30 @@ Administratoren und Entwickler haben alle Rechte, private Taktiken anderer sehen
|
|||
nicht. Die Gruppen (z.B. eine Gruppe „Stratege“ mit `map.tactics`) werden unter
|
||||
Berechtigungsgruppen eingerichtet.
|
||||
|
||||
Werkzeuge: Verschieben (✋), Stift, Pfeil, Linie, Fläche (Eckpunkte klicken, Doppelklick oder
|
||||
Enter schließt ab), Kreis, Punkt mit Beschriftung, Text und Radierer (Zeichnung anklicken),
|
||||
dazu Farbe und Strichstärke. ↶ bzw. Strg+Z nimmt die eigenen Zeichnungen der laufenden
|
||||
Sitzung im aktuellen Schritt zurück, Esc bricht ab und schaltet zurück aufs Verschieben.
|
||||
Zoomen per Mausrad und Verschieben mit rechter oder mittlerer Maustaste gehen auch mitten im
|
||||
Zeichnen.
|
||||
Werkzeuge: Karte verschieben (✋), Auswählen und verschieben (✥), Figur setzen (♟, siehe
|
||||
Raidplaner), Stift, Pfeil, Linie, Kreis, Rechteck (von Ecke zu Ecke ziehen), Kegel (von der Spitze
|
||||
in die Richtung ziehen, Winkel 30° bis Halbkreis), Fläche (Eckpunkte klicken, Doppelklick oder
|
||||
Enter schließt ab), Punkt mit Beschriftung, Text und Radierer (Zeichnung anklicken), dazu Farbe
|
||||
und Strichstärke (bei Figuren deren Größe). Rechteck und Kegel werden als Fläche gespeichert.
|
||||
Mit ✥ zieht man eine Zeichnung an eine andere Stelle; angetippt erscheinen ✎ (Beschriftung) und
|
||||
🗑 über ihr, ein Doppelklick beschriftet direkt, Entf löscht. ↶ bzw. Strg+Z nimmt die eigenen
|
||||
Änderungen der laufenden Sitzung im aktuellen Schritt zurück (Neues verschwindet, Verschobenes
|
||||
springt zurück), Esc bricht ab und schaltet zurück aufs Verschieben der Karte. Zoomen per
|
||||
Mausrad und Verschieben mit rechter oder mittlerer Maustaste gehen auch mitten im Zeichnen.
|
||||
|
||||
Jede Zeichnung wird sofort gespeichert und ist für alle sichtbar, die die Taktik sehen dürfen.
|
||||
Die Punkte liegen in den Weltkoordinaten der Karte (dieselben wie die Marker), Zoomstufe und
|
||||
Fenstergröße spielen also keine Rolle.
|
||||
|
||||
**Blättern und Abspielen:** Jede Zeichnung trägt eine Kennung (`tactic_shapes.ref`), die „+ Kopie
|
||||
dieses Schritts“ und das Kopieren einer Taktik mitnehmen. Beim Blättern erkennt die Karte daran
|
||||
dieselbe Zeichnung im neuen Schritt und lässt sie in 0,7 Sekunden an ihre neue Stelle laufen;
|
||||
neue Zeichnungen blenden ein, wegfallende aus (bei „Bewegung reduzieren“ im System nicht). Der
|
||||
Knopf mit dem Play-Kreis rechts in der Schritt-Leiste (oder die Leertaste) spielt alle Schritte
|
||||
nacheinander ab. **🔗** kopiert einen Link auf die Taktik beim aktuellen Schritt
|
||||
(`/map.php?karte=…&taktik=12&schritt=3`, auf Dungeon-Karten `/raidplan.php?…`); private Taktiken
|
||||
öffnet er nur für ihren Ersteller.
|
||||
|
||||
**Live-Ansicht:** Wer eine Taktik offen hat, sieht Striche der anderen schon, während sie
|
||||
entstehen (mit dem Namen an der Stiftspitze), gespeicherte und gelöschte Zeichnungen sofort, und
|
||||
nach Änderungen an Schritten oder der Taktik lädt die Karte von selbst neu. Mehrere können
|
||||
|
|
@ -541,6 +560,9 @@ wird; die Schritt-Leiste zeigt „✏️ Name“, solange jemand im angezeigten
|
|||
- Grenzen im Bot: 80 Verbindungen je Taktik, 5 je Konto und Taktik, 40 Ereignisse pro Sekunde je
|
||||
Verbindung. Offene Verbindungen enden nie von selbst - `main.py` wartet beim Beenden deshalb
|
||||
höchstens 3 Sekunden auf sie (`timeout_graceful_shutdown`), sonst hinge jeder Neustart.
|
||||
- Figuren (Form `token`) und das Verschieben/Beschriften kennt der Verteiler nicht (er prüft Formen
|
||||
und Ereignisse streng). Nach solchen Änderungen schickt die Karte deshalb nur „geändert“, und die
|
||||
anderen laden die Taktik neu - der Bot musste dafür nicht geändert werden.
|
||||
- Oberfläche: `assets/map/js/services/TacticLiveService.js` (Verbindung, Bündeln, Neuverbinden),
|
||||
Anzeige in `TacticController.js` und `TacticLayer.js`.
|
||||
|
||||
|
|
@ -567,7 +589,51 @@ Die Tabellen `tactics`, `tactic_steps` und `tactic_shapes` stehen im Abschnitt
|
|||
der Karte“ in `sql/schema.sql`. Fehlen sie, zeigt die Kartenseite oben einen Hinweis mit dem
|
||||
Knopf **Tabellen jetzt anlegen** (nur mit `roles.manage`). Die Tabelle `tactic_revisions`
|
||||
(Verlauf und Papierkorb, bewusst ohne Fremdschlüssel auf `tactics`) und die drei
|
||||
Berechtigungen legt die automatische Schema-Prüfung an (`includes/schema.php`).
|
||||
Berechtigungen legt die automatische Schema-Prüfung an (`includes/schema.php`), ebenso die
|
||||
Spalten `tactic_shapes.icon` und `tactic_shapes.ref` samt Form `token` (bestehende Zeichnungen
|
||||
bekommen dabei je eine eigene Kennung `s<ID>`).
|
||||
|
||||
#### Raidplaner
|
||||
|
||||
Der Menüpunkt **Raidplaner** (`raidplan.php`) ist dieselbe Karte mit denselben Taktiken, Rechten,
|
||||
Verlauf und Live-Ansicht - sie startet nur im Reiter **Dungeons & Raids** (`?bereich=dungeons`)
|
||||
und merkt sich dort ihre eigene letzte Karte. Angestoßen von einem Mitglied, das raidplan.io für
|
||||
die schweren Dungeons wollte; raidplan.io selbst kennt Aion 2 nicht.
|
||||
|
||||
- **Karten:** die Dungeon-Karten aus dem Spiel für die Expeditionen, Transzendenz-Dungeons,
|
||||
Refugien (Raids: Abgrundsveredelung: Ludra, Läuterungsstätte der Korrosion, Kelch von Muspel),
|
||||
die sechs Erwachen-Türme und drei Unterwerfungen, dazu eine leere **Arena rund** und
|
||||
**Arena eckig** (werden gezeichnet, mit Himmelsrichtungen und Hilfslinien) für Bossmechaniken.
|
||||
Jede Dungeon-Karte ist ein Bild (`assets/map/dungeons/<slug>.webp`, 2048 px, zusammen knapp
|
||||
3 MB, mit dem Code in Git); beim Öffnen zoomt die Karte auf den Teil mit dem Dungeon, gezoomt
|
||||
wird in halben Stufen. Dungeons, die es bisher nur in Korea/Taiwan gibt, sind in der Auswahl und
|
||||
auf der Karte gekennzeichnet (`"unavailable": true`).
|
||||
- **Liste:** `assets/map/dungeons/dungeons.json` pflegt man von Hand - Gruppen, Reihenfolge,
|
||||
deutsche Namen (aus dem Global-Client, aion2.app/de/db/dungeons, Stand 18.09.2026; was es dort
|
||||
noch nicht gibt, trägt den englischen Namen), Hinweise (bei Erwachen der Boss) und die
|
||||
KR/TW-Kennzeichnung. Der `slug` ist die Karte der Taktiken (`tactics.map_slug`) und darf sich
|
||||
nie ändern. Die Zuordnung der Erwachen-Karten folgt der Nummerierung der Spieldaten
|
||||
(`TYPE_AWAKEN_001` = Altar der Albträume …) - der Boss-Hinweis auf der Karte hilft beim Prüfen.
|
||||
- **Bilder neu laden:** `python assets/map/scripts/download_dungeon_maps.py` (braucht Pillow und
|
||||
numpy) holt die Karten aus dem Repository [Waffle-ens/waffle_meter](https://github.com/Waffle-ens/waffle_meter)
|
||||
(`dotnet/Assets/Maps`, ein DPS-Meter, das die Karten aus dem Spielclient veröffentlicht) beim
|
||||
Commit aus `dungeons.json` (`source.commit`, mit `--commit` ein anderer), schreibt Karte und
|
||||
Vorschaubild (`assets/map/previews/<slug>.webp`) und trägt Bildgröße und Ausschnitt (`bounds`)
|
||||
ein - gefunden per Vergleich mit dem gemeinsamen Hintergrund aller Karten. Dort liegen noch
|
||||
weitere Karten (Siegel-Dungeons `TYPE_CAVE_…`, `TYPE_RUINS_…` u.a., die noch unbenannten
|
||||
`TYPE_DREAM_…`, `TYPE_RIFT_A01`, `Draconic_001`); eine neue Karte = ein Eintrag mit `key` in
|
||||
der Liste und das Script einmal laufen lassen.
|
||||
- **Figuren (♟):** Klassen (Wappen aus `assets/images/Classes/normalized/`), Rollen (Tank, Heiler,
|
||||
Schaden), Spieler 1-8, Markierungen A-D und Symbole, Boss, Gegner, Gefahr, Sammeln, Verteilen,
|
||||
Turm, Kugel, Bombe - gezeichnet in `assets/map/js/views/TokenIcons.js`, erlaubt sind nur die in
|
||||
`TACTIC_TOKEN_ICONS` (`includes/tactics.php`). Die Farbe färbt Rand bzw. Fläche (z.B. Gruppe 1
|
||||
blau, Gruppe 2 rot), die Strichstärke wählt die Größe. Spieler 1-8 und A-D zählen beim Setzen
|
||||
weiter. Figuren liegen immer über Flächen und Linien. Ihre Größe wächst mit der Karte
|
||||
(10 Welteinheiten), damit eine Aufstellung zum Raum passt, bleibt aber zwischen 8 und 40 Pixeln.
|
||||
- **Ablauf wie bei raidplan.io:** Aufstellung setzen, „+ Kopie dieses Schritts“, Figuren mit ✥
|
||||
verschieben, Mechaniken mit Kreis, Kegel oder Rechteck einzeichnen - beim Blättern und Abspielen
|
||||
laufen die Figuren an ihre neue Stelle. Neue Taktiken im Raidplaner starten mit dem
|
||||
Figuren-Werkzeug.
|
||||
|
||||
Die frühere Taktikkarte (eigene Marker, Kartenbauer) wurde durch diese Karte ersetzt. Ihre
|
||||
Tabellen `map_categories`, `map_markers`, `map_tactics` und `map_tactic_shapes` sowie die
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@
|
|||
// Antwort der Karte: nur von unserer eigenen Seite annehmen
|
||||
window.addEventListener('message', function (event) {
|
||||
if (event.origin !== window.location.origin || !event.data || event.data.type !== 'lumina-map-pick' || !field) return;
|
||||
if (typeof event.data.url !== 'string' || event.data.url.indexOf('/map.php?') !== 0) return;
|
||||
// Orte auf Dungeon-Karten verlinken auf den Raidplaner
|
||||
if (typeof event.data.url !== 'string' || !/^\/(map|raidplan)\.php\?/.test(event.data.url)) return;
|
||||
setLocation(field, event.data.url, String(event.data.label || ''));
|
||||
close();
|
||||
});
|
||||
|
|
|
|||
BIN
assets/map/dungeons/arkanis.webp
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
assets/map/dungeons/awaken-1.webp
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
assets/map/dungeons/awaken-2.webp
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
assets/map/dungeons/awaken-3.webp
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
assets/map/dungeons/awaken-4.webp
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
assets/map/dungeons/awaken-5.webp
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
assets/map/dungeons/awaken-6.webp
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
assets/map/dungeons/bakron-island.webp
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
assets/map/dungeons/blasphemy-lab.webp
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/map/dungeons/blue-breath-isle.webp
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
assets/map/dungeons/cradle-nihility.webp
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
assets/map/dungeons/daeva-citadel.webp
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
assets/map/dungeons/dead-dramata-nest.webp
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
assets/map/dungeons/deus-center.webp
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
assets/map/dungeons/draconic-2.webp
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
assets/map/dungeons/draconic-4.webp
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
assets/map/dungeons/draconic-5.webp
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
assets/map/dungeons/draupnir.webp
Normal file
|
After Width: | Height: | Size: 89 KiB |
79
assets/map/dungeons/dungeons.json
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"_info": "Dungeon- und Raid-Karten fuer den Raidplaner. Die Liste pflegt man hier von Hand (Reihenfolge, Namen, Hinweise); scripts/download_dungeon_maps.py laedt dazu die Kartenbilder, schreibt dungeons/<slug>.webp und previews/<slug>.webp und traegt size und bounds ein. slug = map_slug der Taktiken - nie aendern, sonst verlieren die Taktiken ihre Karte.",
|
||||
"_quelle": "Kartenbilder aus dem Spielclient, veroeffentlicht im Repository Waffle-ens/waffle_meter (dotnet/Assets/Maps). Deutsche Namen aus dem Global-Client (aion2.app/de/db/dungeons, Stand 18.09.2026); was es dort noch nicht gibt, traegt den Namen der KR/TW-Version.",
|
||||
"source": {
|
||||
"repo": "Waffle-ens/waffle_meter",
|
||||
"path": "dotnet/Assets/Maps",
|
||||
"commit": "6b6d334a904ab1b4e7e3ed8b2bf4477f93bda585"
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"id": "expedition",
|
||||
"name": "Expeditionen",
|
||||
"maps": [
|
||||
{ "slug": "krao-cave", "key": "KraoCave", "name": "Kraohöhle", "size": [2048, 2048], "bounds": [1060, 1060, 3026, 3026] },
|
||||
{ "slug": "urugugu-canyon", "key": "Urugugu_Canyon", "name": "Uruguguschlucht", "size": [2048, 2048], "bounds": [516, 140, 3650, 3570] },
|
||||
{ "slug": "fire-temple", "key": "Fire_Temple", "name": "Feuertempel", "size": [2048, 2048], "bounds": [772, 900, 3114, 3002] },
|
||||
{ "slug": "draupnir", "key": "Draupnir", "name": "Draupnir", "size": [2048, 2048], "bounds": [972, 412, 3930, 2930] },
|
||||
{ "slug": "bakron-island", "key": "BakronIsland", "name": "Vakrons Luftinsel", "size": [2048, 2048], "bounds": [1012, 1116, 3162, 3226] },
|
||||
{ "slug": "horn-cave", "key": "HornCave", "name": "Grimmhornhöhle", "size": [2048, 2048], "bounds": [620, 540, 3234, 3514] },
|
||||
{ "slug": "dead-dramata-nest", "key": "DeadDramataNest", "name": "Nest des Toten Dramatha", "unavailable": true, "size": [2048, 2048], "bounds": [1260, 1220, 3034, 3170] },
|
||||
{ "slug": "cradle-nihility", "key": "CradleNihility", "name": "Wiege des Nichts", "unavailable": true, "size": [2048, 2048], "bounds": [564, 668, 3514, 3266] },
|
||||
{ "slug": "blue-breath-isle", "key": "BlueBreathIsle", "name": "Insel des Blauatems", "unavailable": true, "size": [2048, 2048], "bounds": [1204, 628, 3170, 3226] },
|
||||
{ "slug": "phantoms-hall", "key": "PhantomsHall", "name": "Illusionskorridor", "unavailable": true, "size": [2048, 2048], "bounds": [1500, 932, 2698, 3210] },
|
||||
{ "slug": "daeva-citadel", "key": "DaevaCitadel", "name": "Zitadelle der gefallenen Daeva", "unavailable": true, "size": [2048, 2048], "bounds": [212, 1324, 3730, 3626] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "transcendence",
|
||||
"name": "Transzendenz",
|
||||
"maps": [
|
||||
{ "slug": "deus-center", "key": "DeusCenter", "name": "Forschungsbasis Deus", "size": [2048, 2048], "bounds": [676, 884, 3058, 2658] },
|
||||
{ "slug": "arkanis", "key": "Arkanis", "name": "Zersplitterter Arkanis", "size": [2048, 2048], "bounds": [948, 708, 3626, 3370] },
|
||||
{ "slug": "sunken-temple", "key": "SunkenTemple", "name": "Versunkener Lebenstempel", "unavailable": true, "size": [2048, 2048], "bounds": [564, 1436, 3210, 3146] },
|
||||
{ "slug": "mirror-heart", "key": "MirrorHeart", "name": "Roter Spiegel des Verlangens", "unavailable": true, "size": [2048, 2048], "bounds": [436, 628, 3666, 3506] },
|
||||
{ "slug": "fafnite-gully", "key": "FafniteGully", "name": "Abyss-Hornhöhle", "unavailable": true, "size": [2048, 2048], "bounds": [980, 724, 2586, 3450] },
|
||||
{ "slug": "blasphemy-lab", "key": "BlasphemyLab", "name": "Consumed Deus Research Base", "unavailable": true, "size": [2048, 2048], "bounds": [548, 964, 3538, 3162] },
|
||||
{ "slug": "legacy-noiran", "key": "LegacyNoiran", "name": "Noiran's Hidden Legacy", "unavailable": true, "size": [2048, 2048], "bounds": [564, 524, 3162, 2690] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sanctuary",
|
||||
"name": "Refugium (Raids)",
|
||||
"maps": [
|
||||
{ "slug": "reforged-abyss", "key": "ReforgedAbyss", "name": "Abgrundsveredelung: Ludra", "size": [1638, 2048], "bounds": [410, 0, 3686, 4096] },
|
||||
{ "slug": "erosion-purifier", "key": "ErosionPurifier", "name": "Läuterungsstätte der Korrosion", "unavailable": true, "size": [2048, 2048], "bounds": [1396, 1148, 2698, 2930] },
|
||||
{ "slug": "muspel-grail", "key": "MusphelHolyGrail", "name": "Kelch von Muspel", "unavailable": true, "size": [2048, 2048], "bounds": [916, 628, 3634, 3786] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "awakening",
|
||||
"name": "Erwachen",
|
||||
"maps": [
|
||||
{ "slug": "awaken-1", "key": "TYPE_AWAKEN_001", "name": "Altar der Albträume", "hint": "Boss: Fragmentierter Aponos", "size": [2048, 2048], "bounds": [820, 1108, 3274, 2970] },
|
||||
{ "slug": "awaken-2", "key": "TYPE_AWAKEN_002", "name": "Versteck des Tyrannen", "hint": "Boss: Menox", "size": [2048, 2048], "bounds": [660, 844, 3434, 3242] },
|
||||
{ "slug": "awaken-3", "key": "TYPE_AWAKEN_003", "name": "Sanktuarium des Hasses", "hint": "Boss: Federsturmduduri", "size": [2048, 2048], "bounds": [1100, 860, 3018, 3306] },
|
||||
{ "slug": "awaken-4", "key": "TYPE_AWAKEN_004", "name": "Kammer der Laufbahn", "hint": "Boss: Claudia", "size": [2048, 2048], "bounds": [1220, 1540, 2850, 3170] },
|
||||
{ "slug": "awaken-5", "key": "TYPE_AWAKEN_005", "name": "Vergessener Speicher", "hint": "Boss: Karlix", "size": [2048, 2048], "bounds": [1204, 1188, 2882, 2858] },
|
||||
{ "slug": "awaken-6", "key": "TYPE_AWAKEN_006", "name": "Schlafstätte der Toten", "hint": "Boss: Eloen", "size": [2048, 2048], "bounds": [828, 1196, 3282, 2906] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "subjugation",
|
||||
"name": "Unterwerfung",
|
||||
"maps": [
|
||||
{ "slug": "draconic-2", "key": "Draconic_002", "name": "Feste der Beritrabrigade", "size": [2048, 2048], "bounds": [1180, 1164, 2930, 2962] },
|
||||
{ "slug": "draconic-4", "key": "Draconic_004", "name": "Orcus' Grab", "size": [2048, 2048], "bounds": [1460, 1428, 2674, 2730] },
|
||||
{ "slug": "draconic-5", "key": "Draconic_005", "name": "Fafnitschmelze", "size": [2048, 2048], "bounds": [1452, 1164, 2754, 3066] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "arena",
|
||||
"name": "Leere Arenen",
|
||||
"maps": [
|
||||
{ "slug": "arena-round", "arena": "round", "name": "Arena rund", "hint": "Für Bossmechaniken ohne Kartenbild" },
|
||||
{ "slug": "arena-square", "arena": "square", "name": "Arena eckig", "hint": "Für Bossmechaniken ohne Kartenbild" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
assets/map/dungeons/erosion-purifier.webp
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
assets/map/dungeons/fafnite-gully.webp
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
assets/map/dungeons/fire-temple.webp
Normal file
|
After Width: | Height: | Size: 110 KiB |
BIN
assets/map/dungeons/horn-cave.webp
Normal file
|
After Width: | Height: | Size: 109 KiB |
BIN
assets/map/dungeons/krao-cave.webp
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
assets/map/dungeons/legacy-noiran.webp
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
assets/map/dungeons/mirror-heart.webp
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
assets/map/dungeons/muspel-grail.webp
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
assets/map/dungeons/phantoms-hall.webp
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
assets/map/dungeons/reforged-abyss.webp
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
assets/map/dungeons/sunken-temple.webp
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
assets/map/dungeons/urugugu-canyon.webp
Normal file
|
After Width: | Height: | Size: 117 KiB |
|
|
@ -64,23 +64,36 @@
|
|||
<!-- Zeichenwerkzeuge (eigene Taktiken; fremde oeffentliche mit map.tactics, offizielle mit map.tactics.highlight) -->
|
||||
<div id="tactic-toolbar" class="hidden">
|
||||
<button type="button" class="tool active" data-tool="pan" title="Karte verschieben (Esc)">✋</button>
|
||||
<button type="button" class="tool" data-tool="move" title="Auswählen und verschieben: Figur oder Zeichnung ziehen, antippen zum Beschriften oder Löschen">✥</button>
|
||||
<button type="button" class="tool" data-tool="token" title="Figur setzen: Klasse, Rolle, Spieler, Markierung oder Boss auswählen und auf die Karte klicken">♟</button>
|
||||
<button type="button" class="tool" data-tool="pen" title="Stift: frei zeichnen">✏️</button>
|
||||
<button type="button" class="tool" data-tool="arrow" title="Pfeil: ziehen">➜</button>
|
||||
<button type="button" class="tool" data-tool="line" title="Linie: ziehen">╱</button>
|
||||
<button type="button" class="tool" data-tool="area" title="Fläche: Eckpunkte klicken, Doppelklick oder Enter schließt ab">⬠</button>
|
||||
<button type="button" class="tool" data-tool="circle" title="Kreis: von der Mitte aus ziehen">◯</button>
|
||||
<button type="button" class="tool" data-tool="rect" title="Rechteck: von Ecke zu Ecke ziehen">▭</button>
|
||||
<button type="button" class="tool" data-tool="cone" title="Kegel (z.B. Frontalangriff): von der Spitze in die Richtung ziehen">◭</button>
|
||||
<button type="button" class="tool" data-tool="area" title="Fläche: Eckpunkte klicken, Doppelklick oder Enter schließt ab">⬠</button>
|
||||
<button type="button" class="tool" data-tool="point" title="Punkt mit Beschriftung setzen">📍</button>
|
||||
<button type="button" class="tool" data-tool="text" title="Text setzen">T</button>
|
||||
<button type="button" class="tool" data-tool="eraser" title="Radierer: Zeichnung anklicken">⌫</button>
|
||||
<button type="button" class="tool" id="tool-undo" title="Letzte eigene Zeichnung in diesem Schritt entfernen (Strg+Z)">↶</button>
|
||||
<button type="button" class="tool" id="tool-undo" title="Letzte eigene Änderung in diesem Schritt zurücknehmen (Strg+Z)">↶</button>
|
||||
<input type="color" id="tool-color" value="#ffd700" title="Farbe">
|
||||
<select id="tool-width" title="Strichstärke">
|
||||
<select id="tool-width" title="Strichstärke bzw. Größe der Figuren">
|
||||
<option value="2">dünn</option>
|
||||
<option value="4" selected>mittel</option>
|
||||
<option value="7">dick</option>
|
||||
<option value="12">sehr dick</option>
|
||||
</select>
|
||||
<select id="tool-angle" class="hidden" title="Öffnungswinkel des Kegels">
|
||||
<option value="30">Kegel 30°</option>
|
||||
<option value="60">Kegel 60°</option>
|
||||
<option value="90" selected>Kegel 90°</option>
|
||||
<option value="120">Kegel 120°</option>
|
||||
<option value="180">Halbkreis</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Figuren zum Setzen (Werkzeug ♟) - gezeichnet von TokenIcons -->
|
||||
<div id="token-palette" class="hidden"></div>
|
||||
<div class="tp-body" id="tp-body">
|
||||
<div id="tp-list"></div>
|
||||
<p class="tp-message hidden" id="tp-message"></p>
|
||||
|
|
@ -88,7 +101,8 @@
|
|||
<div class="tp-detail-head">
|
||||
<strong id="tp-name"></strong>
|
||||
<span class="tp-head-tools">
|
||||
<!-- Kopieren darf jeder, der die Taktik sieht -->
|
||||
<!-- Teilen und Kopieren darf jeder, der die Taktik sieht -->
|
||||
<button type="button" class="tp-icon" id="tp-share" title="Link zu dieser Taktik kopieren (öffnet sie beim aktuellen Schritt)">🔗</button>
|
||||
<button type="button" class="tp-icon" id="tp-copy" title="Ganze Taktik als eigene Kopie anlegen">⧉</button>
|
||||
<span class="tp-edit-only">
|
||||
<button type="button" class="tp-icon" id="tp-history" title="Verlauf: früheren Stand wiederherstellen">🕘</button>
|
||||
|
|
@ -132,6 +146,14 @@
|
|||
<div class="sb-desc" id="sb-desc"></div>
|
||||
</div>
|
||||
<button type="button" id="sb-next" title="Nächster Schritt (→)">▶</button>
|
||||
<!-- Abspielen: die Schritte laufen nacheinander ab, Figuren wandern an ihre neue Stelle -->
|
||||
<button type="button" id="sb-play" title="Abspielen: alle Schritte nacheinander zeigen (Leertaste)" aria-pressed="false" aria-label="Abspielen"></button>
|
||||
</div>
|
||||
|
||||
<!-- Aktionen fuer die mit ✥ ausgewaehlte Zeichnung -->
|
||||
<div id="shape-actions" class="panel hidden">
|
||||
<button type="button" data-shape-action="label" title="Beschriftung ändern">✎</button>
|
||||
<button type="button" data-shape-action="delete" class="tp-danger" title="Löschen">🗑</button>
|
||||
</div>
|
||||
|
||||
<!-- Zoom level indicator -->
|
||||
|
|
@ -151,6 +173,7 @@
|
|||
<div class="map-picker-panel panel">
|
||||
<div class="map-picker-head">
|
||||
<h2 id="map-picker-title">Karte wählen</h2>
|
||||
<div id="map-picker-tabs" class="hidden" role="tablist"></div>
|
||||
<button type="button" id="map-picker-close" aria-label="Schließen">✕</button>
|
||||
</div>
|
||||
<div id="map-picker-list"></div>
|
||||
|
|
@ -181,6 +204,7 @@
|
|||
<script src="js/controllers/MapController.js"></script>
|
||||
<script src="js/services/TacticService.js"></script>
|
||||
<script src="js/services/TacticLiveService.js"></script>
|
||||
<script src="js/views/TokenIcons.js"></script>
|
||||
<script src="js/views/TacticLayer.js"></script>
|
||||
<script src="js/controllers/TacticController.js"></script>
|
||||
<script src="js/controllers/LocationController.js"></script>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,21 @@ const CONFIG = {
|
|||
// Local maps list (generated by download scripts to avoid CORS)
|
||||
MAPS_LIST: 'data/maps.json',
|
||||
|
||||
// Raidplaner: Dungeon- und Raid-Karten (je ein Bild, dungeons/<slug>.webp) und leere Arenen.
|
||||
// Liste, Gruppen, Namen und Ausschnitte stehen in dungeons/dungeons.json (mit dem Code ausgeliefert).
|
||||
DUNGEONS_LIST: 'dungeons/dungeons.json',
|
||||
DUNGEONS_DIR: 'dungeons',
|
||||
// Radius der leeren Arenen in Welteinheiten (Mitte der Welt) - passend zur Groesse der Figuren
|
||||
// (10 Welteinheiten, TacticLayer.tokenRadius): etwa 15 Figuren passen nebeneinander in den Radius
|
||||
ARENA_RADIUS: 160,
|
||||
|
||||
// Bereiche der Kartenauswahl: Weltkarten (Karte) und Dungeons & Raids (Raidplaner). Jeder merkt
|
||||
// sich seine zuletzt gewaehlte Karte; map.php bzw. raidplan.php waehlen ihn per ?bereich=...
|
||||
AREAS: [
|
||||
{ id: 'welt', label: 'Welt', storage: 'lumina_map', page: '/map.php' },
|
||||
{ id: 'dungeons', label: 'Dungeons & Raids', storage: 'lumina_raidmap', page: '/raidplan.php' },
|
||||
],
|
||||
|
||||
// Icons, die unter ihrem Dateinamen nicht (richtig) in data/icons liegen:
|
||||
// Pfad aus den Markerdaten (ohne ?...) -> Dateiname in data/icons.
|
||||
// - Die Quelle hat zwei verschiedene kibelisk.png: /admin/... (blauer Elyos-Kisk, Verteron und
|
||||
|
|
|
|||
|
|
@ -214,17 +214,19 @@ class LocationController {
|
|||
return this.map.mapData.currentMap ? this.map.mapData.currentMap.name : '';
|
||||
}
|
||||
|
||||
/** Pfad des Links, z.B. /map.php?karte=verteron&x=1&y=2&zoom=5&ort=Portal */
|
||||
/** Pfad des Links, z.B. /map.php?karte=verteron&x=1&y=2&zoom=5&ort=Portal (Dungeon-Karten: /raidplan.php) */
|
||||
linkPath() {
|
||||
if (!this.pin || !this.map.mapData.currentMap) return '';
|
||||
const map = this.map.mapData.currentMap;
|
||||
if (!this.pin || !map) return '';
|
||||
const params = new URLSearchParams({
|
||||
karte: this.map.mapData.currentMap.slug,
|
||||
karte: map.slug,
|
||||
x: String(this.pin.x),
|
||||
y: String(this.pin.y),
|
||||
zoom: String(Math.max(this.view.zoom, CONFIG.MIN_ZOOM + 2)),
|
||||
// Links kennen nur ganze Zoomstufen (Dungeon-Karten zoomen in halben)
|
||||
zoom: String(Math.max(Math.round(this.view.zoom), CONFIG.MIN_ZOOM + 2)),
|
||||
});
|
||||
if (this.label) params.set('ort', this.label);
|
||||
return '/map.php?' + params.toString();
|
||||
return this.map.areaInfo(map.area).page + '?' + params.toString();
|
||||
}
|
||||
|
||||
updateLink() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ class MapController {
|
|||
// DOM elements
|
||||
this.canvas = document.getElementById('map-canvas');
|
||||
this.mapPicker = document.getElementById('map-picker');
|
||||
this.mapPickerTabs = document.getElementById('map-picker-tabs');
|
||||
this.mapPickerList = document.getElementById('map-picker-list');
|
||||
this.categoryPanel = document.getElementById('category-panel');
|
||||
this.mapPickerBtn = document.getElementById('map-picker-btn');
|
||||
this.mapCurrentName = document.getElementById('map-current-name');
|
||||
this.categoriesList = document.getElementById('categories-list');
|
||||
|
|
@ -19,6 +21,12 @@ class MapController {
|
|||
this.loadingOverlay = document.getElementById('loading-overlay');
|
||||
this.tooltip = document.getElementById('tooltip');
|
||||
|
||||
// Bereich: Weltkarten (Karte) oder Dungeons & Raids (Raidplaner) - bestimmt die Startkarte und
|
||||
// den Reiter der Kartenauswahl (?bereich=dungeons von raidplan.php)
|
||||
const requestedArea = new URLSearchParams(window.location.search).get('bereich');
|
||||
this.area = CONFIG.AREAS.some(a => a.id === requestedArea) ? requestedArea : CONFIG.AREAS[0].id;
|
||||
this.pickerArea = this.area;
|
||||
|
||||
// Initialize view
|
||||
this.view = new MapView(this.canvas);
|
||||
this.view.resize();
|
||||
|
|
@ -39,18 +47,20 @@ class MapController {
|
|||
// Discover available maps
|
||||
await this.discoverMaps();
|
||||
|
||||
// Zuletzt gewaehlte Karte, sonst die Standardkarte, sonst die erste
|
||||
// Zuletzt gewaehlte Karte des Bereichs, sonst die Standardkarte, sonst die erste
|
||||
if (this.mapData.maps.length > 0) {
|
||||
const areaMaps = this.mapData.maps.filter(m => m.area === this.area);
|
||||
const candidates = areaMaps.length ? areaMaps : this.mapData.maps;
|
||||
let saved = null;
|
||||
try {
|
||||
saved = localStorage.getItem('lumina_map');
|
||||
saved = localStorage.getItem(this.areaInfo(this.area).storage);
|
||||
} catch (e) {
|
||||
saved = null;
|
||||
}
|
||||
const has = slug => this.mapData.maps.some(m => m.slug === slug);
|
||||
const has = slug => candidates.some(m => m.slug === slug);
|
||||
// Ein geteilter Ort (?karte=...) hat Vorrang vor der zuletzt gewaehlten Karte
|
||||
const linked = this.locations ? this.locations.requestedMap() : null;
|
||||
const slug = linked || (has(saved) ? saved : (has(CONFIG.DEFAULT_MAP) ? CONFIG.DEFAULT_MAP : this.mapData.maps[0].slug));
|
||||
const slug = linked || (has(saved) ? saved : (has(CONFIG.DEFAULT_MAP) ? CONFIG.DEFAULT_MAP : candidates[0].slug));
|
||||
await this.loadMap(slug);
|
||||
if (this.locations) this.locations.applyLink();
|
||||
}
|
||||
|
|
@ -87,12 +97,49 @@ class MapController {
|
|||
console.warn('Failed to load maps list:', e);
|
||||
}
|
||||
|
||||
// Dungeon- und Raid-Karten des Raidplaners - kommen mit dem Code, nicht mit dem Datenordner
|
||||
try {
|
||||
const response = await fetch(CONFIG.DUNGEONS_LIST, { cache: 'no-cache' });
|
||||
if (!response.ok) throw new Error('dungeons.json not found');
|
||||
const data = await response.json();
|
||||
const version = String((data.source && data.source.commit) || '').slice(0, 10);
|
||||
for (const group of data.groups || []) {
|
||||
for (const entry of group.maps || []) {
|
||||
this.mapData.addMap({
|
||||
id: entry.slug,
|
||||
slug: entry.slug,
|
||||
name: entry.name,
|
||||
kind: entry.arena ? 'arena' : 'image',
|
||||
area: 'dungeons',
|
||||
group: group.name,
|
||||
hint: entry.hint,
|
||||
unavailable: entry.unavailable,
|
||||
bounds: entry.arena ? MapView.arenaBounds() : entry.bounds,
|
||||
arena: entry.arena,
|
||||
version
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to load dungeon maps:', e);
|
||||
}
|
||||
|
||||
// Populate map selector dropdown
|
||||
this.populateMapSelector();
|
||||
}
|
||||
|
||||
areaInfo(id) {
|
||||
return CONFIG.AREAS.find(a => a.id === id) || CONFIG.AREAS[0];
|
||||
}
|
||||
|
||||
/** Karten, die es auf unserem Patch noch nicht gibt (Weltkarten laut CONFIG, Dungeons laut dungeons.json). */
|
||||
isUnavailable(map) {
|
||||
return !!map && (map.unavailable || CONFIG.MAP_UNAVAILABLE.includes(map.slug));
|
||||
}
|
||||
|
||||
/**
|
||||
* Kartenauswahl aufbauen: pro Gebiet eine Reihe Karten mit Vorschaubild.
|
||||
* Kartenauswahl aufbauen: Reiter je Bereich (Welt / Dungeons & Raids), darin pro Gebiet bzw.
|
||||
* Gruppe eine Reihe Karten mit Vorschaubild.
|
||||
*/
|
||||
populateMapSelector() {
|
||||
const maps = this.mapData.maps;
|
||||
|
|
@ -103,35 +150,69 @@ class MapController {
|
|||
return;
|
||||
}
|
||||
|
||||
// Nach den Gebieten aus CONFIG.MAP_ZONES ordnen (maps.json kennt keine Gebiete).
|
||||
const zones = {};
|
||||
// Weltkarten nach den Gebieten aus CONFIG.MAP_ZONES ordnen (maps.json kennt keine Gebiete).
|
||||
const worldMaps = maps.filter(m => m.area === 'welt');
|
||||
const sections = [];
|
||||
for (const zone of CONFIG.MAP_ZONES) {
|
||||
const zoneMaps = zone.maps.map(slug => maps.find(m => m.slug === slug)).filter(Boolean);
|
||||
if (zoneMaps.length) zones[zone.name] = zoneMaps;
|
||||
const zoneMaps = zone.maps.map(slug => worldMaps.find(m => m.slug === slug)).filter(Boolean);
|
||||
if (zoneMaps.length) sections.push({ area: 'welt', name: zone.name, maps: zoneMaps });
|
||||
}
|
||||
const assigned = new Set(CONFIG.MAP_ZONES.flatMap(zone => zone.maps));
|
||||
const rest = maps.filter(m => !assigned.has(m.slug));
|
||||
if (rest.length) zones['Weitere'] = rest;
|
||||
const rest = worldMaps.filter(m => !assigned.has(m.slug));
|
||||
if (rest.length) sections.push({ area: 'welt', name: 'Weitere', maps: rest });
|
||||
|
||||
for (const [zoneName, zoneMaps] of Object.entries(zones)) {
|
||||
// Dungeon-Karten in ihren Gruppen, wie in dungeons.json
|
||||
const groups = [];
|
||||
maps.filter(m => m.area === 'dungeons').forEach(map => {
|
||||
let group = groups.find(g => g.name === map.group);
|
||||
if (!group) {
|
||||
group = { area: 'dungeons', name: map.group, maps: [] };
|
||||
groups.push(group);
|
||||
}
|
||||
group.maps.push(map);
|
||||
});
|
||||
sections.push(...groups);
|
||||
|
||||
// Reiter nur, wenn es beide Bereiche gibt
|
||||
const areas = CONFIG.AREAS.filter(a => sections.some(s => s.area === a.id));
|
||||
this.mapPickerTabs.textContent = '';
|
||||
this.mapPickerTabs.classList.toggle('hidden', areas.length < 2);
|
||||
areas.forEach(area => {
|
||||
const tab = document.createElement('button');
|
||||
tab.type = 'button';
|
||||
tab.className = 'map-picker-tab';
|
||||
tab.dataset.area = area.id;
|
||||
tab.setAttribute('role', 'tab');
|
||||
tab.textContent = area.label;
|
||||
tab.addEventListener('click', () => this.showPickerArea(area.id));
|
||||
this.mapPickerTabs.appendChild(tab);
|
||||
});
|
||||
|
||||
for (const sectionInfo of sections) {
|
||||
const section = document.createElement('section');
|
||||
section.className = 'map-picker-zone';
|
||||
section.dataset.area = sectionInfo.area;
|
||||
const heading = document.createElement('h3');
|
||||
heading.textContent = zoneName;
|
||||
heading.textContent = sectionInfo.name;
|
||||
const grid = document.createElement('div');
|
||||
grid.className = 'map-picker-grid';
|
||||
|
||||
for (const map of zoneMaps) {
|
||||
for (const map of sectionInfo.maps) {
|
||||
const card = document.createElement('button');
|
||||
card.type = 'button';
|
||||
card.className = 'map-card';
|
||||
card.dataset.slug = map.slug;
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = `${CONFIG.PREVIEWS_DIR}/${map.slug}.webp`;
|
||||
img.alt = '';
|
||||
// Nicht lazy: die zehn kleinen Vorschauen (~300 KB) laden gleich mit, damit sie
|
||||
// beim Oeffnen der Auswahl sofort da sind.
|
||||
if (map.kind === 'arena') {
|
||||
img.src = MapView.arenaPreview(map.arena);
|
||||
} else {
|
||||
img.src = `${CONFIG.PREVIEWS_DIR}/${map.slug}.webp${map.version ? '?v=' + map.version : ''}`;
|
||||
// Die zehn Weltkarten (~300 KB) laden gleich mit, damit sie beim Oeffnen der Auswahl
|
||||
// sofort da sind - die vielen Dungeon-Karten erst, wenn ihr Reiter offen ist.
|
||||
if (map.area !== 'welt') img.loading = 'lazy';
|
||||
}
|
||||
img.decoding = 'async';
|
||||
img.onerror = () => img.remove();
|
||||
|
||||
|
|
@ -140,11 +221,19 @@ class MapController {
|
|||
name.textContent = map.name;
|
||||
|
||||
card.append(img, name);
|
||||
if (CONFIG.MAP_UNAVAILABLE.includes(map.slug)) {
|
||||
if (map.hint) {
|
||||
const hint = document.createElement('span');
|
||||
hint.className = 'map-card-hint';
|
||||
hint.textContent = map.hint;
|
||||
card.appendChild(hint);
|
||||
}
|
||||
if (this.isUnavailable(map)) {
|
||||
card.classList.add('unavailable');
|
||||
const note = document.createElement('span');
|
||||
note.className = 'map-card-note';
|
||||
note.textContent = 'Auf unserem Patch noch nicht verfügbar';
|
||||
note.textContent = map.area === 'dungeons'
|
||||
? 'Bisher nur in Korea/Taiwan'
|
||||
: 'Auf unserem Patch noch nicht verfügbar';
|
||||
card.appendChild(note);
|
||||
}
|
||||
card.addEventListener('click', () => {
|
||||
|
|
@ -159,14 +248,37 @@ class MapController {
|
|||
section.append(heading, grid);
|
||||
this.mapPickerList.appendChild(section);
|
||||
}
|
||||
this.showPickerArea(this.pickerArea);
|
||||
}
|
||||
|
||||
/** Reiter der Kartenauswahl wechseln. */
|
||||
showPickerArea(areaId) {
|
||||
if (!this.mapPickerList.querySelector(`.map-picker-zone[data-area="${areaId}"]`)) {
|
||||
// Den Bereich gibt es nicht (z.B. Weltkarten noch nicht hochgeladen): den ersten vorhandenen
|
||||
const first = this.mapPickerList.querySelector('.map-picker-zone');
|
||||
areaId = first ? first.dataset.area : CONFIG.AREAS[0].id;
|
||||
}
|
||||
this.pickerArea = areaId;
|
||||
this.mapPickerTabs.querySelectorAll('.map-picker-tab').forEach(tab => {
|
||||
const active = tab.dataset.area === areaId;
|
||||
tab.classList.toggle('active', active);
|
||||
tab.setAttribute('aria-selected', String(active));
|
||||
});
|
||||
this.mapPickerList.querySelectorAll('.map-picker-zone').forEach(section => {
|
||||
section.classList.toggle('hidden', section.dataset.area !== areaId);
|
||||
});
|
||||
this.mapPickerList.scrollTop = 0;
|
||||
}
|
||||
|
||||
openMapPicker() {
|
||||
// Die Auswahl oeffnet im Bereich der aktuellen Karte
|
||||
if (this.mapData.currentMap) this.showPickerArea(this.mapData.currentMap.area);
|
||||
this.mapPickerList.querySelectorAll('.map-card').forEach(card => {
|
||||
card.classList.toggle('active', card.dataset.slug === this.mapData.currentMap?.slug);
|
||||
});
|
||||
this.mapPicker.classList.remove('hidden');
|
||||
const active = this.mapPickerList.querySelector('.map-card.active') || this.mapPickerList.querySelector('.map-card');
|
||||
const active = this.mapPickerList.querySelector('.map-card.active')
|
||||
|| this.mapPickerList.querySelector('.map-picker-zone:not(.hidden) .map-card');
|
||||
if (active) active.focus();
|
||||
}
|
||||
|
||||
|
|
@ -187,13 +299,23 @@ class MapController {
|
|||
|
||||
if (!mapInfo) throw new Error(`Map ${slug} not found`);
|
||||
this.mapCurrentName.textContent = mapInfo.name;
|
||||
document.getElementById('map-unavailable').classList.toggle('hidden', !CONFIG.MAP_UNAVAILABLE.includes(slug));
|
||||
const unavailable = document.getElementById('map-unavailable');
|
||||
unavailable.textContent = mapInfo.area === 'dungeons'
|
||||
? '⚠️ Diese Karte gibt es bisher nur in Korea/Taiwan – bei uns kommt sie später.'
|
||||
: '⚠️ Diese Karte ist auf unserem Patch noch nicht verfügbar.';
|
||||
unavailable.classList.toggle('hidden', !this.isUnavailable(mapInfo));
|
||||
// Die Karte gehoert zu ihrem Bereich (auch wenn sie ueber den anderen Reiter gewaehlt wurde)
|
||||
this.area = mapInfo.area;
|
||||
document.body.classList.toggle('map-kind-tiles', mapInfo.kind === 'tiles');
|
||||
try {
|
||||
localStorage.setItem('lumina_map', slug);
|
||||
localStorage.setItem(this.areaInfo(mapInfo.area).storage, slug);
|
||||
} catch (e) {
|
||||
// ohne Speicher eben jedes Mal die Standardkarte
|
||||
}
|
||||
|
||||
if (mapInfo.kind === 'tiles') {
|
||||
this.view.zoomStep = 1;
|
||||
this.view.fitBounds = null;
|
||||
// Load tile manifest
|
||||
await this.tileService.loadManifest(slug);
|
||||
// Nur so weit zoomen, wie es Kacheln gibt (manche Karten enden bei Stufe 5)
|
||||
|
|
@ -206,6 +328,15 @@ class MapController {
|
|||
} catch (e) {
|
||||
console.warn(`No markers found for ${slug}`);
|
||||
}
|
||||
} else {
|
||||
// Dungeon-Karte (ein Bild) oder leere Arena: feiner zoomen, beim Oeffnen auf den Dungeon
|
||||
this.view.zoomStep = 0.5;
|
||||
this.view.maxZoom = CONFIG.MAX_ZOOM;
|
||||
this.view.fitBounds = mapInfo.bounds || [CONFIG.WORLD_MIN_X, CONFIG.WORLD_MIN_Y, CONFIG.WORLD_MAX_X, CONFIG.WORLD_MAX_Y];
|
||||
if (mapInfo.kind === 'image') await this.view.loadMapImage(mapInfo);
|
||||
}
|
||||
// Marker und ihre Kategorien gibt es nur auf den Weltkarten
|
||||
this.categoryPanel.classList.toggle('hidden', mapInfo.kind !== 'tiles');
|
||||
|
||||
// Reset view and render
|
||||
this.view.resetView();
|
||||
|
|
@ -429,13 +560,17 @@ class MapController {
|
|||
this.render();
|
||||
});
|
||||
|
||||
// Mouse wheel zoom
|
||||
// Mausrad zoomt zur Mausposition - der Punkt unter dem Zeiger bleibt stehen (Bossraeume
|
||||
// liegen auf den Dungeon-Karten oft am Rand)
|
||||
this.canvas.addEventListener('wheel', (e) => {
|
||||
e.preventDefault();
|
||||
if (e.deltaY < 0) {
|
||||
if (this.view.zoomIn()) this.render();
|
||||
} else {
|
||||
if (this.view.zoomOut()) this.render();
|
||||
const rect = this.canvas.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const y = e.clientY - rect.top;
|
||||
// Von der Zeichenebene weitergereicht (ohne Position): zur Mitte
|
||||
const inside = e.clientX || e.clientY;
|
||||
if (this.view.zoomAt(e.deltaY < 0 ? 1 : -1, inside ? x : this.canvas.width / 2, inside ? y : this.canvas.height / 2)) {
|
||||
this.render();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
* entscheidet der Server (can_create, can_highlight, pro Taktik can_edit/can_delete/...).
|
||||
* Die gewaehlte Taktik ist live (TacticLiveService): Striche anderer erscheinen, waehrend sie
|
||||
* entstehen, gespeicherte Aenderungen sofort, dazu wer gerade dabei ist.
|
||||
*
|
||||
* Raidplaner: Figuren (Form 'token', TokenIcons), Verschieben/Beschriften mit ✥, Rechteck und
|
||||
* Kegel (gespeichert als Flaeche). Zeichnungen mit derselben Kennung (ref) laufen beim Blaettern
|
||||
* und Abspielen von ihrer Stelle im vorigen Schritt an die neue.
|
||||
*/
|
||||
|
||||
class TacticController {
|
||||
|
|
@ -32,11 +36,29 @@ class TacticController {
|
|||
this.tool = 'pan';
|
||||
this.draft = null;
|
||||
this.drawing = false;
|
||||
this.undoStacks = {}; // step_id -> IDs der in dieser Sitzung gezeichneten Formen
|
||||
// step_id -> eigene Aenderungen dieser Sitzung zum Zuruecknehmen: {kind: 'create', id} oder
|
||||
// {kind: 'update', id, points, label} (Stand vor dem Verschieben/Beschriften)
|
||||
this.undoStacks = {};
|
||||
this.loadToken = 0;
|
||||
this.dialogOpen = false;
|
||||
this.dialogCancel = null;
|
||||
|
||||
// Raidplaner: Figuren, Verschieben, animierte Schritte, Abspielen
|
||||
this.tokenIcon = 'num-1'; // Figur, die das Werkzeug ♟ als naechstes setzt
|
||||
this.drag = null; // Zeichnung, die gerade mit ✥ verschoben wird
|
||||
this.selectedShapeId = null;
|
||||
this.anim = null; // laufender Uebergang zwischen zwei Schritten
|
||||
this.animFrame = null;
|
||||
this.playTimer = null; // Abspielen laeuft
|
||||
this.reducedMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
// Link auf eine Taktik (?taktik=12&schritt=3, "🔗"): nach dem ersten Laden der Karte oeffnen
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const linkedTactic = parseInt(params.get('taktik'), 10);
|
||||
this.pendingLink = linkedTactic > 0
|
||||
? { slug: params.get('karte'), tactic: linkedTactic, step: Math.max(1, parseInt(params.get('schritt'), 10) || 1) }
|
||||
: null;
|
||||
|
||||
// Live-Ansicht der gewaehlten Taktik: wer dabei ist und welche Striche bei anderen gerade entstehen
|
||||
this.live = new TacticLiveService(this.service, {
|
||||
onEvent: (event, tacticId) => this.onLiveEvent(event, tacticId),
|
||||
|
|
@ -67,6 +89,7 @@ class TacticController {
|
|||
highlight: $('tp-highlight'),
|
||||
highlightSelect: $('tp-highlight-select'),
|
||||
copy: $('tp-copy'),
|
||||
share: $('tp-share'),
|
||||
history: $('tp-history'),
|
||||
edit: $('tp-edit'),
|
||||
del: $('tp-delete'),
|
||||
|
|
@ -79,10 +102,14 @@ class TacticController {
|
|||
toolbar: $('tactic-toolbar'),
|
||||
color: $('tool-color'),
|
||||
width: $('tool-width'),
|
||||
angle: $('tool-angle'),
|
||||
undo: $('tool-undo'),
|
||||
palette: $('token-palette'),
|
||||
shapeActions: $('shape-actions'),
|
||||
stepBar: $('step-bar'),
|
||||
prev: $('sb-prev'),
|
||||
next: $('sb-next'),
|
||||
play: $('sb-play'),
|
||||
sbTitle: $('sb-title'),
|
||||
sbDesc: $('sb-desc'),
|
||||
dialog: $('tactic-dialog'),
|
||||
|
|
@ -100,6 +127,8 @@ class TacticController {
|
|||
this.layer.resize();
|
||||
this.redraw();
|
||||
});
|
||||
// Klassen-Wappen in der Figurenauswahl nachzeichnen, sobald sie geladen sind
|
||||
TokenIcons.onImageLoad(() => this.renderPaletteIcons());
|
||||
|
||||
this.bindPanel();
|
||||
this.bindToolbar();
|
||||
|
|
@ -139,8 +168,27 @@ class TacticController {
|
|||
this.slug = slug;
|
||||
this.selectedId = null;
|
||||
this.stepIndex = 0;
|
||||
this.stopPlay();
|
||||
this.anim = null;
|
||||
this.setTool('pan');
|
||||
await this.reload();
|
||||
this.openPendingLink();
|
||||
}
|
||||
|
||||
/** Link auf eine Taktik (?taktik=...&schritt=...): einmal nach dem Laden ihrer Karte oeffnen. */
|
||||
openPendingLink() {
|
||||
const link = this.pendingLink;
|
||||
if (!link || (link.slug && link.slug !== this.slug)) return;
|
||||
this.pendingLink = null;
|
||||
const tactic = this.tactics.find(t => t.id === link.tactic);
|
||||
if (!tactic) {
|
||||
this.toast('Diese Taktik gibt es nicht mehr – oder sie ist privat und nur für ihren Ersteller sichtbar.', true);
|
||||
return;
|
||||
}
|
||||
this.selectedId = tactic.id;
|
||||
this.stepIndex = Math.min(link.step, tactic.steps.length) - 1;
|
||||
this.renderUI();
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -298,6 +346,7 @@ class TacticController {
|
|||
}
|
||||
|
||||
this.el.toolbar.classList.toggle('hidden', !this.canEditCurrent());
|
||||
this.el.palette.classList.toggle('hidden', !this.canEditCurrent() || this.tool !== 'token');
|
||||
this.renderStepBar();
|
||||
this.syncLive();
|
||||
this.renderLive();
|
||||
|
|
@ -338,13 +387,27 @@ class TacticController {
|
|||
this.el.sbDesc.classList.toggle('hidden', !step.description);
|
||||
this.el.prev.disabled = this.stepIndex === 0;
|
||||
this.el.next.disabled = this.stepIndex >= total - 1;
|
||||
this.el.play.disabled = total < 2;
|
||||
// Kreis mit Dreieck bzw. zwei Balken - sonst verwechselt man ihn mit ▶ (naechster Schritt)
|
||||
this.el.play.innerHTML = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" '
|
||||
+ 'stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/>'
|
||||
+ (this.playTimer
|
||||
? '<line x1="10" y1="8.5" x2="10" y2="15.5"/><line x1="14" y1="8.5" x2="14" y2="15.5"/>'
|
||||
: '<polygon points="10 8 16 12 10 16" fill="currentColor"/>')
|
||||
+ '</svg>';
|
||||
this.el.play.setAttribute('aria-label', this.playTimer ? 'Anhalten' : 'Abspielen');
|
||||
this.el.play.setAttribute('aria-pressed', String(!!this.playTimer));
|
||||
this.el.play.title = this.playTimer
|
||||
? 'Anhalten (Leertaste)'
|
||||
: 'Abspielen: alle Schritte nacheinander zeigen (Leertaste)';
|
||||
}
|
||||
|
||||
redraw() {
|
||||
const tactic = this.currentTactic();
|
||||
const step = this.currentStep();
|
||||
|
||||
this.layer.shapes = step ? step.shapes : [];
|
||||
this.layer.shapes = step ? this.animatedShapes(step) : [];
|
||||
this.layer.selectedId = this.tool === 'move' ? this.selectedShapeId : null;
|
||||
this.layer.ghostShapes = tactic && this.showGhosts
|
||||
? tactic.steps.slice(0, this.stepIndex).flatMap(s => s.shapes)
|
||||
: [];
|
||||
|
|
@ -357,6 +420,97 @@ class TacticController {
|
|||
: [];
|
||||
this.layer.draft = this.draft;
|
||||
this.layer.draw();
|
||||
this.placeShapeActions();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Uebergang zwischen Schritten: dieselbe Figur (gleiche ref) laeuft an ihre neue Stelle
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
static ease(t) {
|
||||
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uebergang vom Schritt mit den Zeichnungen fromShapes zum jetzigen Schritt starten: Zeichnungen
|
||||
* mit derselben Kennung (ref, gleiche Art und Punktzahl) wandern, neue blenden ein, wegfallende aus.
|
||||
*/
|
||||
startTransition(fromShapes) {
|
||||
const step = this.currentStep();
|
||||
this.anim = null;
|
||||
if (!step || !fromShapes || this.reducedMotion) return;
|
||||
|
||||
const byRef = new Map(fromShapes.filter(s => s.ref).map(s => [s.ref, s]));
|
||||
const kept = new Set();
|
||||
const moves = new Map();
|
||||
step.shapes.forEach(shape => {
|
||||
const from = shape.ref ? byRef.get(shape.ref) : null;
|
||||
if (!from) return;
|
||||
kept.add(shape.ref);
|
||||
if (from.type === shape.type && from.points.length === shape.points.length) moves.set(shape.id, from.points);
|
||||
});
|
||||
const leaving = fromShapes.filter(s => !s.ref || !kept.has(s.ref));
|
||||
const entering = new Set(step.shapes.filter(s => !s.ref || !byRef.has(s.ref)).map(s => s.id));
|
||||
if (moves.size === 0 && leaving.length === 0 && entering.size === 0) return;
|
||||
|
||||
this.anim = { stepId: step.id, start: performance.now(), duration: 700, moves, leaving, entering };
|
||||
const tick = () => {
|
||||
this.animFrame = null;
|
||||
if (!this.anim) return;
|
||||
if (performance.now() - this.anim.start >= this.anim.duration) this.anim = null;
|
||||
this.redraw();
|
||||
if (this.anim) this.animFrame = requestAnimationFrame(tick);
|
||||
};
|
||||
if (this.animFrame) cancelAnimationFrame(this.animFrame);
|
||||
this.animFrame = requestAnimationFrame(tick);
|
||||
}
|
||||
|
||||
/** Die Zeichnungen des Schritts, waehrend eines Uebergangs mit Zwischenpositionen und Blende. */
|
||||
animatedShapes(step) {
|
||||
const anim = this.anim;
|
||||
if (!anim || anim.stepId !== step.id) return step.shapes;
|
||||
const t = TacticController.ease(Math.min(1, (performance.now() - anim.start) / anim.duration));
|
||||
const shapes = step.shapes.map(shape => {
|
||||
const from = anim.moves.get(shape.id);
|
||||
if (from) {
|
||||
return {
|
||||
...shape,
|
||||
points: shape.points.map((p, i) => [from[i][0] + (p[0] - from[i][0]) * t, from[i][1] + (p[1] - from[i][1]) * t])
|
||||
};
|
||||
}
|
||||
return anim.entering.has(shape.id) ? { ...shape, _alpha: t } : shape;
|
||||
});
|
||||
// Wegfallende blenden unter den anderen aus (anklicken lassen sie sich nicht mehr)
|
||||
return anim.leaving.map(shape => ({ ...shape, id: `leaving-${shape.id}`, _alpha: 1 - t, _leaving: true })).concat(shapes);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Abspielen
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
togglePlay() {
|
||||
if (this.playTimer) {
|
||||
this.stopPlay();
|
||||
return;
|
||||
}
|
||||
const tactic = this.currentTactic();
|
||||
if (!tactic || tactic.steps.length < 2) return;
|
||||
// Am Ende angekommen: von vorn
|
||||
if (this.stepIndex >= tactic.steps.length - 1) this.goToStep(0, true);
|
||||
this.playTimer = setInterval(() => {
|
||||
const current = this.currentTactic();
|
||||
if (current && this.stepIndex < current.steps.length - 1) this.goToStep(this.stepIndex + 1, true);
|
||||
// Beim letzten Schritt angekommen (oder Taktik weg): fertig
|
||||
if (!current || this.stepIndex >= current.steps.length - 1) this.stopPlay();
|
||||
}, 2600);
|
||||
this.renderStepBar();
|
||||
}
|
||||
|
||||
stopPlay() {
|
||||
if (!this.playTimer) return;
|
||||
clearInterval(this.playTimer);
|
||||
this.playTimer = null;
|
||||
this.renderStepBar();
|
||||
}
|
||||
|
||||
/** Neu zeichnen, hoechstens einmal pro Bild - Live-Striche kommen in schneller Folge. */
|
||||
|
|
@ -605,6 +759,9 @@ class TacticController {
|
|||
|
||||
select(id) {
|
||||
this.cancelDraft();
|
||||
this.stopPlay();
|
||||
this.anim = null;
|
||||
this.selectedShapeId = null;
|
||||
this.selectedId = this.selectedId === id ? null : id;
|
||||
this.stepIndex = 0;
|
||||
if (!this.selectedId) this.setTool('pan');
|
||||
|
|
@ -612,13 +769,18 @@ class TacticController {
|
|||
this.redraw();
|
||||
}
|
||||
|
||||
goToStep(index) {
|
||||
/** Zu einem Schritt blaettern - mit Uebergang vom bisherigen. byPlayer: vom Abspielen (laeuft weiter). */
|
||||
goToStep(index, byPlayer = false) {
|
||||
const tactic = this.currentTactic();
|
||||
if (!tactic) return;
|
||||
if (!byPlayer) this.stopPlay();
|
||||
const target = Math.max(0, Math.min(index, tactic.steps.length - 1));
|
||||
if (target === this.stepIndex) return;
|
||||
const from = this.currentStep();
|
||||
this.cancelDraft();
|
||||
this.selectedShapeId = null;
|
||||
this.stepIndex = target;
|
||||
this.startTransition(from ? from.shapes : null);
|
||||
this.renderUI();
|
||||
this.redraw();
|
||||
}
|
||||
|
|
@ -651,10 +813,15 @@ class TacticController {
|
|||
this.selectedId = result.tactic_id;
|
||||
this.stepIndex = 0;
|
||||
await this.reload();
|
||||
if (this.canEditCurrent()) this.setTool('pen');
|
||||
// Im Raidplaner beginnt man mit der Aufstellung, auf den Weltkarten mit dem Stift
|
||||
const dungeon = this.map.mapData.currentMap && this.map.mapData.currentMap.area === 'dungeons';
|
||||
if (this.canEditCurrent()) this.setTool(dungeon ? 'token' : 'pen');
|
||||
const next = dungeon
|
||||
? 'Stell jetzt die Figuren für Schritt 1 auf – für den nächsten Schritt „+ Kopie dieses Schritts“ und verschieben.'
|
||||
: 'Zeichne jetzt Schritt 1 ein.';
|
||||
this.toast(values.visibility === 'public'
|
||||
? 'Öffentliche Taktik angelegt – zeichne jetzt Schritt 1 ein.'
|
||||
: 'Private Taktik angelegt – nur du siehst sie. Zeichne jetzt Schritt 1 ein.');
|
||||
? `Öffentliche Taktik angelegt. ${next}`
|
||||
: `Private Taktik angelegt – nur du siehst sie. ${next}`);
|
||||
}
|
||||
|
||||
async editTactic() {
|
||||
|
|
@ -843,19 +1010,191 @@ class TacticController {
|
|||
|
||||
setTool(tool) {
|
||||
this.cancelDraft();
|
||||
this.drag = null;
|
||||
if (tool !== 'move') this.selectedShapeId = null;
|
||||
this.tool = tool;
|
||||
this.layer.hoverId = null;
|
||||
this.layer.canvas.classList.toggle('drawing', tool !== 'pan');
|
||||
this.layer.canvas.classList.toggle('erasing', tool === 'eraser');
|
||||
this.layer.canvas.classList.toggle('moving', tool === 'move');
|
||||
this.el.toolbar.querySelectorAll('.tool[data-tool]').forEach(btn => {
|
||||
btn.classList.toggle('active', btn.dataset.tool === tool);
|
||||
});
|
||||
this.el.palette.classList.toggle('hidden', tool !== 'token' || !this.canEditCurrent());
|
||||
this.el.angle.classList.toggle('hidden', tool !== 'cone');
|
||||
if (tool === 'area') {
|
||||
this.toast('Eckpunkte anklicken – Doppelklick oder Enter schließt die Fläche ab.');
|
||||
} else if (tool === 'token') {
|
||||
this.renderPaletteIcons();
|
||||
this.toast('Figur auswählen und auf die Karte klicken – Spielernummern und Markierungen zählen von selbst weiter.');
|
||||
} else if (tool === 'move') {
|
||||
this.toast('Figur oder Zeichnung ziehen zum Verschieben – antippen zum Beschriften oder Löschen.');
|
||||
}
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Figuren (Werkzeug ♟)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/** Auswahl der Figuren aufbauen - einmal; die Bilder zeichnet renderPaletteIcons. */
|
||||
buildPalette() {
|
||||
const esc = TacticController.esc;
|
||||
this.el.palette.innerHTML = TOKEN_ICONS.map(group => `
|
||||
<div class="tk-group">
|
||||
<div class="tk-group-title">${esc(group.group)}</div>
|
||||
<div class="tk-grid">
|
||||
${group.items.map(item => `
|
||||
<button type="button" class="tk-item" data-icon="${item.id}" title="${esc(item.label)}" aria-label="${esc(item.label)}">
|
||||
<canvas width="32" height="32"></canvas>
|
||||
</button>`).join('')}
|
||||
</div>
|
||||
</div>`).join('');
|
||||
this.el.palette.addEventListener('click', event => {
|
||||
const button = event.target.closest('.tk-item');
|
||||
if (!button) return;
|
||||
this.tokenIcon = button.dataset.icon;
|
||||
this.markPaletteSelection();
|
||||
});
|
||||
this.renderPaletteIcons();
|
||||
}
|
||||
|
||||
/** Figuren der Auswahl in der gewaehlten Farbe zeichnen (auch fuer hochaufloesende Bildschirme). */
|
||||
renderPaletteIcons() {
|
||||
if (!this.el.palette || this.el.palette.classList.contains('hidden') && this.paletteDrawn) return;
|
||||
const ratio = window.devicePixelRatio || 1;
|
||||
this.el.palette.querySelectorAll('.tk-item').forEach(button => {
|
||||
const canvas = button.querySelector('canvas');
|
||||
const size = 32;
|
||||
if (canvas.width !== size * ratio) {
|
||||
canvas.width = size * ratio;
|
||||
canvas.height = size * ratio;
|
||||
}
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
||||
ctx.clearRect(0, 0, size, size);
|
||||
const r = 11 * (TokenIcons.scale(button.dataset.icon) > 1 ? 1.15 : 1);
|
||||
TokenIcons.draw(ctx, button.dataset.icon, size / 2, size / 2, r, this.el.color.value);
|
||||
});
|
||||
this.paletteDrawn = true;
|
||||
this.markPaletteSelection();
|
||||
}
|
||||
|
||||
markPaletteSelection() {
|
||||
this.el.palette.querySelectorAll('.tk-item').forEach(button => {
|
||||
button.classList.toggle('active', button.dataset.icon === this.tokenIcon);
|
||||
});
|
||||
}
|
||||
|
||||
/** Figur an einer Stelle setzen; Spielernummern und Markierungen A-D zaehlen danach weiter. */
|
||||
placeToken(point) {
|
||||
const shape = this.newDraft('token', [point]);
|
||||
shape.icon = this.tokenIcon;
|
||||
this.saveShape(shape);
|
||||
const item = TokenIcons.find(this.tokenIcon);
|
||||
if (item && item.next) {
|
||||
this.tokenIcon = item.next;
|
||||
this.markPaletteSelection();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Rechteck und Kegel - gespeichert als Flaeche (Form 'area')
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
static rectPoints(a, b) {
|
||||
return [[a[0], a[1]], [b[0], a[1]], [b[0], b[1]], [a[0], b[1]]];
|
||||
}
|
||||
|
||||
/** Kegel von der Spitze apex in Richtung tip, Oeffnungswinkel in Grad - als Vieleck mit Bogen. */
|
||||
static conePoints(apex, tip, degrees) {
|
||||
const radius = Math.hypot(tip[0] - apex[0], tip[1] - apex[1]);
|
||||
const direction = Math.atan2(tip[1] - apex[1], tip[0] - apex[0]);
|
||||
const half = (degrees * Math.PI / 180) / 2;
|
||||
const segments = Math.max(4, Math.round(degrees / 7.5));
|
||||
const points = degrees >= 360 ? [] : [[apex[0], apex[1]]];
|
||||
for (let i = 0; i <= segments; i++) {
|
||||
const angle = direction - half + (2 * half * i) / segments;
|
||||
points.push([apex[0] + Math.cos(angle) * radius, apex[1] + Math.sin(angle) * radius]);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Verschieben und Beschriften (Werkzeug ✥)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/** Die echte Zeichnung des aktuellen Schritts zu einem Treffer (beim Blaettern sind es Kopien). */
|
||||
realShape(hit) {
|
||||
const step = this.currentStep();
|
||||
return hit && step ? step.shapes.find(s => s.id === hit.id) || null : null;
|
||||
}
|
||||
|
||||
/** Kleine Leiste mit ✎ und 🗑 ueber der ausgewaehlten Zeichnung. */
|
||||
placeShapeActions() {
|
||||
const el = this.el.shapeActions;
|
||||
const step = this.currentStep();
|
||||
const shape = this.tool === 'move' && this.selectedShapeId && !this.drag && step
|
||||
? step.shapes.find(s => s.id === this.selectedShapeId) : null;
|
||||
if (!shape || !this.canEditCurrent()) {
|
||||
el.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
const pts = shape.points.map(p => this.layer.toScreen(p));
|
||||
const top = Math.min(...pts.map(p => p.y));
|
||||
const left = pts.reduce((sum, p) => sum + p.x, 0) / pts.length;
|
||||
const lift = shape.type === 'token' ? this.layer.tokenRadius(shape) + 8 : 12;
|
||||
el.style.left = `${Math.round(left)}px`;
|
||||
el.style.top = `${Math.round(top - lift)}px`;
|
||||
el.classList.remove('hidden');
|
||||
// Beschriften geht bei allem, was eine Beschriftung zeigt
|
||||
el.querySelector('[data-shape-action="label"]').classList.toggle('hidden', ['pen', 'line', 'arrow'].includes(shape.type));
|
||||
}
|
||||
|
||||
async editShapeLabel(shape) {
|
||||
const isText = shape.type === 'text';
|
||||
const values = await this.dialog(isText ? 'Text ändern' : 'Beschriftung', [
|
||||
{ name: 'label', label: isText ? 'Text' : 'Beschriftung (optional)', required: isText, max: 200, value: shape.label,
|
||||
placeholder: shape.type === 'token' ? 'z. B. Name des Spielers' : '' }
|
||||
], 'Speichern');
|
||||
if (!values || values.label === shape.label) return;
|
||||
this.updateShape(shape, { label: values.label });
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeichnung aendern (Stuetzpunkte und/oder Beschriftung) und speichern. Die Karte zeigt die Aenderung
|
||||
* sofort; lehnt der Server ab, springt sie zurueck. remember: fuers Zuruecknehmen merken.
|
||||
*/
|
||||
async updateShape(shape, changes, before = null, remember = true) {
|
||||
const step = this.currentStep();
|
||||
if (!step) return false;
|
||||
const stepId = step.id;
|
||||
const previous = before || { points: shape.points, label: shape.label };
|
||||
if (changes.points) shape.points = changes.points;
|
||||
if (changes.label !== undefined) shape.label = changes.label;
|
||||
this.redraw();
|
||||
|
||||
const payload = { shape_id: shape.id };
|
||||
if (changes.points) payload.points = changes.points.map(p => [Math.round(p[0] * 100) / 100, Math.round(p[1] * 100) / 100]);
|
||||
if (changes.label !== undefined) payload.label = changes.label;
|
||||
const result = await this.run('shape_update', payload);
|
||||
const target = (this.stepById(stepId) || step).shapes.find(s => s.id === shape.id);
|
||||
if (!result) {
|
||||
if (target) Object.assign(target, previous);
|
||||
this.redraw();
|
||||
return false;
|
||||
}
|
||||
if (target) Object.assign(target, result.shape);
|
||||
if (remember) {
|
||||
(this.undoStacks[stepId] = this.undoStacks[stepId] || [])
|
||||
.push({ kind: 'update', id: shape.id, points: previous.points, label: previous.label });
|
||||
}
|
||||
// Der Live-Verteiler kennt Verschieben nicht - die anderen laden die Taktik neu.
|
||||
this.notifyChanged('shapes');
|
||||
this.redraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
cancelDraft() {
|
||||
// Live verschickt und nicht gerade beim Speichern: bei den anderen wieder wegnehmen
|
||||
const draft = this.draft;
|
||||
|
|
@ -929,6 +1268,40 @@ class TacticController {
|
|||
this.layer.canvas.setPointerCapture(event.pointerId);
|
||||
break;
|
||||
|
||||
case 'rect':
|
||||
case 'cone':
|
||||
// Gespeichert wird eine Flaeche; from/to merken sich, wie sie aufgezogen wurde.
|
||||
this.draft = this.newDraft('area', [point, point, point]);
|
||||
this.draft.tool = this.tool;
|
||||
this.draft.from = point;
|
||||
this.draft.to = point;
|
||||
this.drawing = true;
|
||||
this.layer.canvas.setPointerCapture(event.pointerId);
|
||||
break;
|
||||
|
||||
case 'token':
|
||||
this.placeToken(point);
|
||||
break;
|
||||
|
||||
case 'move': {
|
||||
const screen = this.screenAt(event);
|
||||
const shape = this.realShape(this.layer.hitTest(screen.x, screen.y));
|
||||
if (!shape) {
|
||||
// Daneben: Auswahl aufheben und die Karte verschieben lassen
|
||||
this.selectedShapeId = null;
|
||||
this.redraw();
|
||||
this.view.canvas.dispatchEvent(new MouseEvent('mousedown', {
|
||||
clientX: event.clientX, clientY: event.clientY, bubbles: true
|
||||
}));
|
||||
return;
|
||||
}
|
||||
this.anim = null;
|
||||
this.selectedShapeId = shape.id;
|
||||
this.drag = { shape, start: point, orig: shape.points.map(p => [p[0], p[1]]), label: shape.label, moved: false };
|
||||
this.layer.canvas.setPointerCapture(event.pointerId);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'area':
|
||||
// Der letzte Punkt folgt immer der Maus, ein Klick setzt ihn fest.
|
||||
if (!this.draft) {
|
||||
|
|
@ -946,7 +1319,7 @@ class TacticController {
|
|||
|
||||
case 'eraser': {
|
||||
const screen = this.screenAt(event);
|
||||
const hit = this.layer.hitTest(screen.x, screen.y);
|
||||
const hit = this.realShape(this.layer.hitTest(screen.x, screen.y));
|
||||
if (hit) this.deleteShape(hit);
|
||||
break;
|
||||
}
|
||||
|
|
@ -956,7 +1329,7 @@ class TacticController {
|
|||
}
|
||||
|
||||
onPointerMove(event) {
|
||||
if (this.tool === 'eraser') {
|
||||
if (this.tool === 'eraser' || (this.tool === 'move' && !this.drag)) {
|
||||
const screen = this.screenAt(event);
|
||||
const hit = this.layer.hitTest(screen.x, screen.y);
|
||||
const hoverId = hit ? hit.id : null;
|
||||
|
|
@ -966,13 +1339,23 @@ class TacticController {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (this.drag) {
|
||||
this.dragTo(this.worldAt(event));
|
||||
return;
|
||||
}
|
||||
// Ein abgeschlossener Strich wird gerade gespeichert - er folgt der Maus nicht mehr (und geht
|
||||
// live nicht noch einmal raus, sonst taucht er bei den anderen nach dem Speichern wieder auf).
|
||||
if (!this.draft || this.draft.saving) return;
|
||||
|
||||
const point = this.worldAt(event);
|
||||
const points = this.draft.points;
|
||||
if (this.draft.type === 'pen') {
|
||||
if (this.draft.tool === 'rect' || this.draft.tool === 'cone') {
|
||||
if (!this.drawing) return;
|
||||
this.draft.to = point;
|
||||
this.draft.points = this.draft.tool === 'rect'
|
||||
? TacticController.rectPoints(this.draft.from, point)
|
||||
: TacticController.conePoints(this.draft.from, point, parseInt(this.el.angle.value, 10) || 90);
|
||||
} else if (this.draft.type === 'pen') {
|
||||
if (!this.drawing || this.screenDistance(points[points.length - 1], point) < 3) return;
|
||||
points.push(point);
|
||||
} else if (this.draft.type === 'area') {
|
||||
|
|
@ -986,7 +1369,34 @@ class TacticController {
|
|||
this.redraw();
|
||||
}
|
||||
|
||||
/** Gezogene Zeichnung mitfuehren - ganz, und nicht ueber den Rand hinaus, den der Server annimmt. */
|
||||
dragTo(point) {
|
||||
const drag = this.drag;
|
||||
let dx = point[0] - drag.start[0];
|
||||
let dy = point[1] - drag.start[1];
|
||||
if (!drag.moved && this.screenDistance(drag.start, point) < 4) return;
|
||||
drag.moved = true;
|
||||
const xs = drag.orig.map(p => p[0]);
|
||||
const ys = drag.orig.map(p => p[1]);
|
||||
const min = CONFIG.WORLD_MIN_X - 512;
|
||||
const max = CONFIG.WORLD_MAX_X + 512;
|
||||
dx = Math.max(min - Math.min(...xs), Math.min(max - Math.max(...xs), dx));
|
||||
dy = Math.max(min - Math.min(...ys), Math.min(max - Math.max(...ys), dy));
|
||||
drag.shape.points = drag.orig.map(p => [p[0] + dx, p[1] + dy]);
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
onPointerUp() {
|
||||
if (this.drag) {
|
||||
const drag = this.drag;
|
||||
this.drag = null;
|
||||
if (drag.moved) {
|
||||
this.updateShape(drag.shape, { points: drag.shape.points }, { points: drag.orig, label: drag.label });
|
||||
} else {
|
||||
this.redraw(); // nur angetippt: ausgewaehlt, die Leiste mit ✎ und 🗑 erscheint
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!this.drawing || !this.draft) return;
|
||||
this.drawing = false;
|
||||
const draft = this.draft;
|
||||
|
|
@ -999,6 +1409,10 @@ class TacticController {
|
|||
draft.points = TacticLayer.simplify(draft.points, 1.2 / this.layer.scale());
|
||||
this.saveShape(draft);
|
||||
}
|
||||
} else if (draft.from) {
|
||||
// Rechteck/Kegel: nur geklickt, nicht gezogen - nichts anlegen
|
||||
if (this.screenDistance(draft.from, draft.to) < 6) this.cancelDraft();
|
||||
else this.saveShape(draft);
|
||||
} else if (this.screenDistance(draft.points[0], draft.points[1]) < 6) {
|
||||
// Nur geklickt, nicht gezogen - nichts anlegen.
|
||||
this.cancelDraft();
|
||||
|
|
@ -1053,6 +1467,7 @@ class TacticController {
|
|||
const result = await this.run('shape_create', {
|
||||
step_id: stepId,
|
||||
type: shape.type,
|
||||
icon: shape.icon || '',
|
||||
color: shape.color,
|
||||
width: shape.width,
|
||||
label: shape.label,
|
||||
|
|
@ -1065,9 +1480,12 @@ class TacticController {
|
|||
// Inzwischen neu geladen (Aenderung eines anderen)? Dann ist es ein neues Schritt-Objekt.
|
||||
const target = this.stepById(stepId) || step;
|
||||
if (!target.shapes.some(s => s.id === result.shape.id)) target.shapes.push(result.shape);
|
||||
(this.undoStacks[stepId] = this.undoStacks[stepId] || []).push(result.shape.id);
|
||||
if (liveHere) {
|
||||
(this.undoStacks[stepId] = this.undoStacks[stepId] || []).push({ kind: 'create', id: result.shape.id });
|
||||
if (liveHere && TacticController.LIVE_SHAPE_TYPES.includes(result.shape.type)) {
|
||||
this.live.push({ type: 'shape_added', step: stepId, shape: result.shape, draft: shape.liveSent ? shape.liveId : null });
|
||||
} else if (liveHere) {
|
||||
// Figuren kennt der Live-Verteiler nicht - die anderen laden die Taktik neu
|
||||
this.notifyChanged('shapes');
|
||||
}
|
||||
this.renderUI();
|
||||
} else if (shape.liveSent && liveHere) {
|
||||
|
|
@ -1086,11 +1504,13 @@ class TacticController {
|
|||
target.shapes = target.shapes.filter(s => s.id !== shape.id);
|
||||
if (this.live.tacticId === tacticId) this.live.push({ type: 'shape_removed', step: stepId, shape_id: shape.id });
|
||||
this.layer.hoverId = null;
|
||||
if (this.selectedShapeId === shape.id) this.selectedShapeId = null;
|
||||
this.renderUI();
|
||||
this.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
/** Letzte eigene Aenderung im Schritt zuruecknehmen: Neues loeschen, Verschobenes zurueckschieben. */
|
||||
undoLast() {
|
||||
const step = this.currentStep();
|
||||
if (!step) return;
|
||||
|
|
@ -1102,12 +1522,15 @@ class TacticController {
|
|||
|
||||
const stack = this.undoStacks[step.id] || [];
|
||||
while (stack.length) {
|
||||
const shapeId = stack.pop();
|
||||
const shape = step.shapes.find(s => s.id === shapeId);
|
||||
if (shape) {
|
||||
const entry = stack.pop();
|
||||
const shape = step.shapes.find(s => s.id === entry.id);
|
||||
if (!shape) continue;
|
||||
if (entry.kind === 'create') {
|
||||
this.deleteShape(shape);
|
||||
return;
|
||||
} else {
|
||||
this.updateShape(shape, { points: entry.points, label: entry.label }, null, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.toast('In diesem Schritt gibt es nichts rückgängig zu machen.');
|
||||
}
|
||||
|
|
@ -1220,6 +1643,7 @@ class TacticController {
|
|||
el.newBtn.addEventListener('click', () => this.newTactic());
|
||||
el.trash.addEventListener('click', () => this.showTrash());
|
||||
el.copy.addEventListener('click', () => this.copyTactic());
|
||||
el.share.addEventListener('click', () => this.shareTactic());
|
||||
el.history.addEventListener('click', () => this.showHistory());
|
||||
el.edit.addEventListener('click', () => this.editTactic());
|
||||
el.del.addEventListener('click', () => this.deleteTactic());
|
||||
|
|
@ -1264,6 +1688,17 @@ class TacticController {
|
|||
|
||||
el.prev.addEventListener('click', () => this.goToStep(this.stepIndex - 1));
|
||||
el.next.addEventListener('click', () => this.goToStep(this.stepIndex + 1));
|
||||
el.play.addEventListener('click', () => this.togglePlay());
|
||||
|
||||
// ✎ / 🗑 an der ausgewaehlten Zeichnung
|
||||
el.shapeActions.addEventListener('click', event => {
|
||||
const button = event.target.closest('[data-shape-action]');
|
||||
const step = this.currentStep();
|
||||
const shape = step ? step.shapes.find(s => s.id === this.selectedShapeId) : null;
|
||||
if (!button || !shape) return;
|
||||
if (button.dataset.shapeAction === 'label') this.editShapeLabel(shape);
|
||||
else this.deleteShape(shape);
|
||||
});
|
||||
|
||||
// Tasten im Dialog nicht an die Tastenkuerzel der Karte (+, -, 0 ...) weiterreichen.
|
||||
el.dialog.addEventListener('keydown', event => {
|
||||
|
|
@ -1283,6 +1718,9 @@ class TacticController {
|
|||
if (button) this.setTool(button.dataset.tool);
|
||||
});
|
||||
this.el.undo.addEventListener('click', () => this.undoLast());
|
||||
// Die Figuren der Auswahl tragen die gewaehlte Farbe
|
||||
this.el.color.addEventListener('input', () => this.renderPaletteIcons());
|
||||
this.buildPalette();
|
||||
}
|
||||
|
||||
bindCanvas() {
|
||||
|
|
@ -1292,10 +1730,22 @@ class TacticController {
|
|||
canvas.addEventListener('pointerup', () => this.onPointerUp());
|
||||
canvas.addEventListener('pointercancel', () => {
|
||||
this.cancelDraft();
|
||||
if (this.drag) {
|
||||
// Abgebrochenes Ziehen: zurueck an die alte Stelle
|
||||
this.drag.shape.points = this.drag.orig;
|
||||
this.drag = null;
|
||||
}
|
||||
this.redraw();
|
||||
});
|
||||
canvas.addEventListener('dblclick', event => {
|
||||
event.preventDefault();
|
||||
if (this.tool === 'move') {
|
||||
// Doppelklick auf eine Zeichnung: Beschriftung aendern
|
||||
const screen = this.screenAt(event);
|
||||
const shape = this.realShape(this.layer.hitTest(screen.x, screen.y));
|
||||
if (shape && !['pen', 'line', 'arrow'].includes(shape.type)) this.editShapeLabel(shape);
|
||||
return;
|
||||
}
|
||||
this.finishArea();
|
||||
});
|
||||
canvas.addEventListener('contextmenu', event => event.preventDefault());
|
||||
|
|
@ -1304,7 +1754,7 @@ class TacticController {
|
|||
canvas.addEventListener('wheel', event => {
|
||||
event.preventDefault();
|
||||
this.view.canvas.dispatchEvent(new WheelEvent('wheel', {
|
||||
deltaY: event.deltaY, deltaX: event.deltaX, cancelable: true
|
||||
deltaY: event.deltaY, deltaX: event.deltaX, clientX: event.clientX, clientY: event.clientY, cancelable: true
|
||||
}));
|
||||
}, { passive: false });
|
||||
}
|
||||
|
|
@ -1331,7 +1781,50 @@ class TacticController {
|
|||
this.goToStep(this.stepIndex - 1);
|
||||
} else if (event.key === 'ArrowRight' && this.currentTactic()) {
|
||||
this.goToStep(this.stepIndex + 1);
|
||||
} else if (event.key === ' ' && this.currentTactic() && !(tag === 'BUTTON')) {
|
||||
event.preventDefault();
|
||||
this.togglePlay();
|
||||
} else if ((event.key === 'Delete' || event.key === 'Backspace') && this.tool === 'move' && this.selectedShapeId) {
|
||||
const step = this.currentStep();
|
||||
const shape = step ? step.shapes.find(s => s.id === this.selectedShapeId) : null;
|
||||
if (shape && this.canEditCurrent()) this.deleteShape(shape);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Link auf die Taktik
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/** Link zur gewaehlten Taktik beim aktuellen Schritt kopieren (Raidplaner bzw. Karte, je nach Karte). */
|
||||
shareTactic() {
|
||||
const tactic = this.currentTactic();
|
||||
const map = this.map.mapData.currentMap;
|
||||
if (!tactic || !map) return;
|
||||
const area = this.map.areaInfo(map.area);
|
||||
const params = new URLSearchParams({ karte: map.slug, taktik: String(tactic.id) });
|
||||
if (this.stepIndex > 0) params.set('schritt', String(this.stepIndex + 1));
|
||||
const url = window.location.origin + area.page + '?' + params.toString();
|
||||
const done = () => this.toast(tactic.visibility === 'private'
|
||||
? 'Link kopiert – die Taktik ist privat, öffnen kannst ihn nur du.'
|
||||
: 'Link kopiert – einfach in Discord, Termin oder Kommentar einfügen.');
|
||||
const fallback = () => {
|
||||
const input = document.createElement('input');
|
||||
input.value = url;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
input.remove();
|
||||
done();
|
||||
};
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(url).then(done, fallback);
|
||||
} else {
|
||||
fallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Formen, die der Live-Verteiler im Bot kennt (live_tactics.py) - bei allen anderen (Figuren) laden die
|
||||
// anderen die Taktik neu, statt die Zeichnung live zu bekommen.
|
||||
TacticController.LIVE_SHAPE_TYPES = ['pen', 'line', 'arrow', 'area', 'circle', 'point', 'text'];
|
||||
|
|
|
|||
|
|
@ -20,7 +20,16 @@ class MapData {
|
|||
id: mapInfo.id,
|
||||
slug: mapInfo.slug,
|
||||
name: mapInfo.name,
|
||||
zone: mapInfo.zone || 'Unknown'
|
||||
zone: mapInfo.zone || 'Unknown',
|
||||
// tiles = Weltkarte mit Kacheln und Markern, image = Dungeon-Karte (ein Bild), arena = leere Arena
|
||||
kind: mapInfo.kind || 'tiles',
|
||||
area: mapInfo.area || 'welt',
|
||||
group: mapInfo.group || '',
|
||||
hint: mapInfo.hint || '',
|
||||
unavailable: !!mapInfo.unavailable,
|
||||
bounds: mapInfo.bounds || null,
|
||||
arena: mapInfo.arena || null,
|
||||
version: mapInfo.version || ''
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ class MapView {
|
|||
// Hoechste Zoomstufe der aktuellen Karte - MapController.loadMap setzt sie aus dem
|
||||
// Kachel-Manifest (manche Karten haben nur Kacheln bis Stufe 5).
|
||||
this.maxZoom = CONFIG.MAX_ZOOM;
|
||||
// Kacheln gibt es nur in ganzen Stufen; Dungeon-Karten (ein Bild) und leere Arenen zoomen feiner.
|
||||
this.zoomStep = 1;
|
||||
// Ausschnitt [x0, y0, x1, y1], auf den "Ansicht zuruecksetzen" zoomt (Dungeon-Karten), sonst null
|
||||
this.fitBounds = null;
|
||||
// Geladene Kartenbilder der Dungeon-Karten: Slug -> Image
|
||||
this.images = new Map();
|
||||
this.centerWorldX = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
|
||||
this.centerWorldY = (CONFIG.WORLD_MIN_Y + CONFIG.WORLD_MAX_Y) / 2;
|
||||
|
||||
|
|
@ -109,6 +115,16 @@ class MapView {
|
|||
|
||||
if (!mapData.currentMap) return;
|
||||
|
||||
// Dungeon-Karten sind ein einzelnes Bild, leere Arenen werden gezeichnet - beides ohne Kacheln und Marker
|
||||
if (mapData.currentMap.kind === 'image') {
|
||||
this.drawImageMap(mapData.currentMap);
|
||||
return;
|
||||
}
|
||||
if (mapData.currentMap.kind === 'arena') {
|
||||
MapView.drawArena(ctx, mapData.currentMap.arena, (x, y) => this.worldToScreen(x, y), this.worldScale());
|
||||
return;
|
||||
}
|
||||
|
||||
const slug = mapData.currentMap.slug;
|
||||
const worldWidth = CONFIG.WORLD_MAX_X - CONFIG.WORLD_MIN_X;
|
||||
|
||||
|
|
@ -168,6 +184,192 @@ class MapView {
|
|||
tileService.preloadAdjacentZoomLevels(slug, this.zoom, viewBounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kartenbild einer Dungeon-Karte laden (dungeons/<slug>.webp). Liefert das Bild oder null,
|
||||
* wenn es fehlt - dann zeigt die Karte einen Hinweis statt des Bildes.
|
||||
*/
|
||||
loadMapImage(map) {
|
||||
const cached = this.images.get(map.slug);
|
||||
if (cached) return Promise.resolve(cached);
|
||||
return new Promise(resolve => {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
// Nur das aktuelle Bild behalten - entpackt sind es je 16 MB Speicher
|
||||
this.images.clear();
|
||||
this.images.set(map.slug, img);
|
||||
resolve(img);
|
||||
};
|
||||
img.onerror = () => resolve(null);
|
||||
img.src = `${CONFIG.DUNGEONS_DIR}/${map.slug}.webp${map.version ? '?v=' + map.version : ''}`;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wo ein Kartenbild in der Welt liegt: so gross wie moeglich im Quadrat 0..4096, mittig - wie in
|
||||
* scripts/download_dungeon_maps.py (world_bounds), damit dessen Ausschnitte passen.
|
||||
*/
|
||||
static imageRect(width, height) {
|
||||
const worldSize = CONFIG.WORLD_MAX_X - CONFIG.WORLD_MIN_X;
|
||||
const scale = worldSize / Math.max(width, height);
|
||||
return {
|
||||
x: CONFIG.WORLD_MIN_X + (worldSize - width * scale) / 2,
|
||||
y: CONFIG.WORLD_MIN_Y + (worldSize - height * scale) / 2,
|
||||
w: width * scale,
|
||||
h: height * scale
|
||||
};
|
||||
}
|
||||
|
||||
/** Dungeon-Karte: nur den sichtbaren Teil des Bildes zeichnen (weich vergroessert). */
|
||||
drawImageMap(map) {
|
||||
const ctx = this.ctx;
|
||||
// Farbe des Bildrands - herausgezoomt geht die Karte so ohne Kante in den Hintergrund ueber
|
||||
ctx.fillStyle = '#0c1214';
|
||||
ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
||||
const img = this.images.get(map.slug);
|
||||
if (!img) {
|
||||
ctx.fillStyle = '#aaaaaa';
|
||||
ctx.font = "14px 'Segoe UI', sans-serif";
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillText('Das Kartenbild fehlt noch (assets/map/dungeons).', this.canvas.width / 2, this.canvas.height / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
const rect = MapView.imageRect(img.naturalWidth, img.naturalHeight);
|
||||
const view = this.getViewBounds();
|
||||
const x0 = Math.max(rect.x, view.minX);
|
||||
const y0 = Math.max(rect.y, view.minY);
|
||||
const x1 = Math.min(rect.x + rect.w, view.maxX);
|
||||
const y1 = Math.min(rect.y + rect.h, view.maxY);
|
||||
if (x1 <= x0 || y1 <= y0) return;
|
||||
|
||||
const texels = img.naturalWidth / rect.w;
|
||||
const from = this.worldToScreen(x0, y0);
|
||||
const to = this.worldToScreen(x1, y1);
|
||||
ctx.imageSmoothingEnabled = true;
|
||||
ctx.imageSmoothingQuality = 'high';
|
||||
ctx.drawImage(img, (x0 - rect.x) * texels, (y0 - rect.y) * texels, (x1 - x0) * texels, (y1 - y0) * texels,
|
||||
from.x, from.y, to.x - from.x, to.y - from.y);
|
||||
}
|
||||
|
||||
/** Ausschnitt einer leeren Arena (mit Platz fuer die Himmelsrichtungen). */
|
||||
static arenaBounds() {
|
||||
const c = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
|
||||
const r = CONFIG.ARENA_RADIUS * 1.3;
|
||||
return [c - r, c - r, c + r, c + r];
|
||||
}
|
||||
|
||||
/**
|
||||
* Leere Arena (rund oder eckig) zeichnen: Boden mit Hilfslinien, Rand, Himmelsrichtungen.
|
||||
* toScreen(x, y) rechnet Welt- in Bildschirmkoordinaten um, scale = Pixel je Welteinheit.
|
||||
*/
|
||||
static drawArena(ctx, shape, toScreen, scale) {
|
||||
const c = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
|
||||
const center = toScreen(c, c);
|
||||
const r = CONFIG.ARENA_RADIUS * scale;
|
||||
const line = 'rgba(160, 180, 230, 0.13)';
|
||||
const gold = 'rgba(255, 215, 0, 0.65)';
|
||||
|
||||
ctx.save();
|
||||
ctx.fillStyle = '#0b0f1c';
|
||||
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
|
||||
const floor = ctx.createRadialGradient(center.x, center.y, r * 0.1, center.x, center.y, r * 1.2);
|
||||
floor.addColorStop(0, '#23304f');
|
||||
floor.addColorStop(1, '#141b2f');
|
||||
ctx.fillStyle = floor;
|
||||
ctx.strokeStyle = line;
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
if (shape === 'square') {
|
||||
ctx.fillRect(center.x - r, center.y - r, r * 2, r * 2);
|
||||
// Raster in Achteln, die Mittellinien etwas deutlicher
|
||||
for (let i = 1; i < 8; i++) {
|
||||
const offset = -r + (r * 2 * i) / 8;
|
||||
ctx.strokeStyle = i === 4 ? 'rgba(160, 180, 230, 0.26)' : line;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(center.x + offset, center.y - r);
|
||||
ctx.lineTo(center.x + offset, center.y + r);
|
||||
ctx.moveTo(center.x - r, center.y + offset);
|
||||
ctx.lineTo(center.x + r, center.y + offset);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.lineWidth = 2.5;
|
||||
ctx.strokeStyle = '#8fa3d6';
|
||||
ctx.strokeRect(center.x - r, center.y - r, r * 2, r * 2);
|
||||
} else {
|
||||
ctx.beginPath();
|
||||
ctx.arc(center.x, center.y, r, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
// Ringe bei einem und zwei Dritteln, Speichen wie die Stunden einer Uhr
|
||||
[1 / 3, 2 / 3].forEach(part => {
|
||||
ctx.beginPath();
|
||||
ctx.arc(center.x, center.y, r * part, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
});
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const angle = i * Math.PI / 6;
|
||||
ctx.strokeStyle = i % 3 === 0 ? 'rgba(160, 180, 230, 0.26)' : line;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(center.x, center.y);
|
||||
ctx.lineTo(center.x + Math.sin(angle) * r, center.y - Math.cos(angle) * r);
|
||||
ctx.stroke();
|
||||
// Stundenstriche aussen
|
||||
ctx.strokeStyle = gold;
|
||||
ctx.lineWidth = i % 3 === 0 ? 2.5 : 1.5;
|
||||
const inner = r + 4;
|
||||
const outer = r + (i % 3 === 0 ? 16 : 10);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(center.x + Math.sin(angle) * inner, center.y - Math.cos(angle) * inner);
|
||||
ctx.lineTo(center.x + Math.sin(angle) * outer, center.y - Math.cos(angle) * outer);
|
||||
ctx.stroke();
|
||||
ctx.lineWidth = 1;
|
||||
}
|
||||
ctx.lineWidth = 2.5;
|
||||
ctx.strokeStyle = '#8fa3d6';
|
||||
ctx.beginPath();
|
||||
ctx.arc(center.x, center.y, r, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Mitte
|
||||
ctx.strokeStyle = 'rgba(255, 255, 255, 0.35)';
|
||||
ctx.lineWidth = 1.5;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(center.x - 7, center.y);
|
||||
ctx.lineTo(center.x + 7, center.y);
|
||||
ctx.moveTo(center.x, center.y - 7);
|
||||
ctx.lineTo(center.x, center.y + 7);
|
||||
ctx.stroke();
|
||||
|
||||
// Himmelsrichtungen
|
||||
const size = Math.max(11, Math.min(18, r * 0.07));
|
||||
const distance = r + 16 + size;
|
||||
ctx.font = `bold ${Math.round(size)}px 'Segoe UI', sans-serif`;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillStyle = gold;
|
||||
[['N', 0, -1], ['O', 1, 0], ['S', 0, 1], ['W', -1, 0]].forEach(([label, dx, dy]) => {
|
||||
ctx.fillText(label, center.x + dx * distance, center.y + dy * distance);
|
||||
});
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/** Vorschaubild einer leeren Arena fuer die Kartenauswahl (Daten-URL). */
|
||||
static arenaPreview(shape, size = 320) {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = size;
|
||||
canvas.height = size;
|
||||
// Etwas mehr Rand als auf der Karte - im kleinen Bild brauchen die Himmelsrichtungen mehr Platz
|
||||
const c = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
|
||||
const half = CONFIG.ARENA_RADIUS * 1.45;
|
||||
const x0 = c - half;
|
||||
const y0 = c - half;
|
||||
const scale = size / (half * 2);
|
||||
MapView.drawArena(canvas.getContext('2d'), shape, (x, y) => ({ x: (x - x0) * scale, y: (y - y0) * scale }), scale);
|
||||
return canvas.toDataURL('image/png');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft fuer ein laufendes Bild, ob sich die Ansicht (Karte, Zoom, Position, Groesse) seit
|
||||
* seinem Start geaendert hat. Dann ist es veraltet und stoesst einmal ein frisches Bild an -
|
||||
|
|
@ -297,8 +499,8 @@ class MapView {
|
|||
*/
|
||||
zoomIn() {
|
||||
// Nur bis zur hoechsten Stufe dieser Karte - darueber gibt es keine Kacheln
|
||||
if (this.zoom < this.maxZoom) {
|
||||
this.zoom++;
|
||||
if (this.zoom + this.zoomStep <= this.maxZoom + 1e-9) {
|
||||
this.zoom += this.zoomStep;
|
||||
this.clampView();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -309,8 +511,8 @@ class MapView {
|
|||
* Zoom out
|
||||
*/
|
||||
zoomOut() {
|
||||
if (this.zoom > CONFIG.MIN_ZOOM) {
|
||||
this.zoom--;
|
||||
if (this.zoom - this.zoomStep >= CONFIG.MIN_ZOOM - 1e-9) {
|
||||
this.zoom -= this.zoomStep;
|
||||
this.clampView();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -335,12 +537,39 @@ class MapView {
|
|||
* Reset view to default
|
||||
*/
|
||||
resetView() {
|
||||
if (this.fitBounds && this.canvas.width && this.canvas.height) {
|
||||
this.fitTo(this.fitBounds);
|
||||
return;
|
||||
}
|
||||
this.zoom = Math.min(CONFIG.MIN_ZOOM + 1, this.maxZoom);
|
||||
this.centerWorldX = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
|
||||
this.centerWorldY = (CONFIG.WORLD_MIN_Y + CONFIG.WORLD_MAX_Y) / 2;
|
||||
this.clampView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Den Ausschnitt [x0, y0, x1, y1] (Weltkoordinaten) moeglichst gross zeigen: die groesste
|
||||
* Zoomstufe, in die er ganz passt - mit etwas Rand fuer die Fenster ueber der Karte.
|
||||
*/
|
||||
fitTo(bounds) {
|
||||
const [x0, y0, x1, y1] = bounds;
|
||||
const worldWidth = CONFIG.WORLD_MAX_X - CONFIG.WORLD_MIN_X;
|
||||
const width = Math.max(1, x1 - x0);
|
||||
const height = Math.max(1, y1 - y0);
|
||||
// Rechts liegen Taktik-Panel und Zoomleiste ueber der Karte - auf breiten Bildschirmen den Platz
|
||||
// daneben nutzen (auf dem Handy liegen die Fenster eingeklappt oben).
|
||||
const reserved = this.canvas.width > 900 ? 380 : 0;
|
||||
const usable = this.canvas.width - reserved;
|
||||
// Bildschirmpixel je Welteinheit bei Stufe z: canvas.width * 2^(z - MIN_ZOOM) / worldWidth
|
||||
const fitX = Math.log2(0.92 * usable * worldWidth / (width * this.canvas.width));
|
||||
const fitY = Math.log2(0.82 * this.canvas.height * worldWidth / (height * this.canvas.width));
|
||||
const zoom = CONFIG.MIN_ZOOM + Math.floor(Math.min(fitX, fitY) / this.zoomStep) * this.zoomStep;
|
||||
this.zoom = Math.max(CONFIG.MIN_ZOOM, Math.min(this.maxZoom, zoom));
|
||||
this.centerWorldX = (x0 + x1) / 2 + reserved / 2 / this.worldScale();
|
||||
this.centerWorldY = (y0 + y1) / 2;
|
||||
this.clampView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pan by screen delta
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,13 +16,16 @@ class TacticLayer {
|
|||
this.ctx = this.canvas.getContext('2d');
|
||||
|
||||
// Was gezeichnet wird - setzt der TacticController.
|
||||
this.shapes = []; // Zeichnungen des aktuellen Schritts
|
||||
this.shapes = []; // Zeichnungen des aktuellen Schritts (beim Blaettern mit _alpha zum Ein-/Ausblenden)
|
||||
this.ghostShapes = []; // Zeichnungen der vorherigen Schritte (blass)
|
||||
this.liveDrafts = []; // Striche anderer, die gerade entstehen (Live-Ansicht): {shape, name, color}
|
||||
this.draft = null; // Form, die gerade gezeichnet wird
|
||||
this.hoverId = null; // Form unter dem Radierer
|
||||
this.hoverId = null; // Form unter dem Radierer bzw. dem Verschieben-Werkzeug
|
||||
this.selectedId = null; // mit dem Verschieben-Werkzeug ausgewaehlte Form
|
||||
|
||||
this.resize();
|
||||
// Klassen-Wappen der Figuren laden nach - dann noch einmal zeichnen
|
||||
TokenIcons.onImageLoad(() => this.draw());
|
||||
}
|
||||
|
||||
resize() {
|
||||
|
|
@ -48,7 +51,12 @@ class TacticLayer {
|
|||
this.ghostShapes.forEach(shape => this.drawShape(shape));
|
||||
ctx.restore();
|
||||
|
||||
this.shapes.forEach(shape => this.drawShape(shape, shape.id === this.hoverId));
|
||||
this.stacked(this.shapes).forEach(shape => {
|
||||
ctx.save();
|
||||
if (shape._alpha !== undefined) ctx.globalAlpha = Math.max(0, Math.min(1, shape._alpha));
|
||||
this.drawShape(shape, shape.id === this.hoverId || shape.id === this.selectedId);
|
||||
ctx.restore();
|
||||
});
|
||||
this.liveDrafts.forEach(live => {
|
||||
this.drawShape(live.shape);
|
||||
this.drawDrawerName(live);
|
||||
|
|
@ -140,11 +148,32 @@ class TacticLayer {
|
|||
case 'text':
|
||||
this.drawLabel(shape.label, pts[0], shape.color, 12 + width * 2);
|
||||
break;
|
||||
|
||||
case 'token': {
|
||||
const r = this.tokenRadius(shape);
|
||||
TokenIcons.draw(ctx, shape.icon || 'num-1', pts[0].x, pts[0].y, r, shape.color);
|
||||
if (shape.label) {
|
||||
const size = Math.max(11, Math.min(15, r * 0.7));
|
||||
this.drawLabel(shape.label, { x: pts[0].x, y: pts[0].y + r + size * 0.75 }, '#ffffff', size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Radius einer Figur in Bildschirmpixeln. Sie waechst mit der Karte (10 Welteinheiten bei mittlerer
|
||||
* Groesse) - so behaelt eine Aufstellung ihr Verhaeltnis zum Raum, auch auf dem Handy -, bleibt aber
|
||||
* herausgezoomt noch erkennbar und wird hineingezoomt nicht riesig. Die Strichstaerke waehlt die Groesse.
|
||||
*/
|
||||
tokenRadius(shape) {
|
||||
const size = 0.55 + (shape.width || 4) * 0.12;
|
||||
const r = Math.max(8, Math.min(40, 10 * size * this.scale()));
|
||||
return r * TokenIcons.scale(shape.icon);
|
||||
}
|
||||
|
||||
polyline(pts) {
|
||||
const ctx = this.ctx;
|
||||
ctx.beginPath();
|
||||
|
|
@ -202,14 +231,22 @@ class TacticLayer {
|
|||
* Radierer), oder null.
|
||||
*/
|
||||
hitTest(screenX, screenY) {
|
||||
for (let i = this.shapes.length - 1; i >= 0; i--) {
|
||||
if (this.hitsShape(this.shapes[i], screenX, screenY)) {
|
||||
return this.shapes[i];
|
||||
const shapes = this.stacked(this.shapes);
|
||||
for (let i = shapes.length - 1; i >= 0; i--) {
|
||||
// Beim Blaettern ausblendende Zeichnungen des vorigen Schritts zaehlen nicht
|
||||
if (shapes[i]._leaving) continue;
|
||||
if (this.hitsShape(shapes[i], screenX, screenY)) {
|
||||
return shapes[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Reihenfolge beim Zeichnen: Figuren liegen immer oben (auch auf spaeter gezeichneten Flaechen). */
|
||||
stacked(shapes) {
|
||||
return shapes.filter(s => s.type !== 'token').concat(shapes.filter(s => s.type === 'token'));
|
||||
}
|
||||
|
||||
hitsShape(shape, x, y) {
|
||||
const pts = shape.points.map(p => this.toScreen(p));
|
||||
const tolerance = 8 + (shape.width || 4) / 2;
|
||||
|
|
@ -231,6 +268,8 @@ class TacticLayer {
|
|||
const half = this.ctx.measureText(shape.label || '').width / 2;
|
||||
return Math.abs(x - pts[0].x) <= half + 4 && Math.abs(y - pts[0].y) <= size / 2 + 4;
|
||||
}
|
||||
case 'token':
|
||||
return Math.hypot(x - pts[0].x, y - pts[0].y) <= this.tokenRadius(shape) + 4;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
386
assets/map/js/views/TokenIcons.js
Normal file
|
|
@ -0,0 +1,386 @@
|
|||
/**
|
||||
* TokenIcons - die Figuren des Raidplaners (Form 'token'): Klassen, Rollen, Spielernummern,
|
||||
* Markierungen, Gegner und Mechaniken. Gezeichnet wird alles hier - auf der Karte (TacticLayer)
|
||||
* und in der Auswahl im Taktik-Panel -, damit beide gleich aussehen.
|
||||
*
|
||||
* Die Kennungen muessen zu TACTIC_TOKEN_ICONS in includes/tactics.php passen.
|
||||
*/
|
||||
|
||||
const TOKEN_ICONS = [
|
||||
{
|
||||
group: 'Klassen',
|
||||
items: [
|
||||
{ id: 'class-templar', label: 'Templer', image: 'Templar' },
|
||||
{ id: 'class-gladiator', label: 'Gladiator', image: 'Gladiator' },
|
||||
{ id: 'class-assassin', label: 'Assassine', image: 'Assassin' },
|
||||
{ id: 'class-ranger', label: 'Jäger', image: 'Ranger' },
|
||||
{ id: 'class-sorcerer', label: 'Magier', image: 'Sorcerer' },
|
||||
{ id: 'class-spiritmaster', label: 'Beschwörer', image: 'Spiritmaster' },
|
||||
{ id: 'class-cleric', label: 'Kleriker', image: 'Cleric' },
|
||||
{ id: 'class-chanter', label: 'Kantor', image: 'Chanter' }
|
||||
]
|
||||
},
|
||||
{
|
||||
group: 'Rollen',
|
||||
items: [
|
||||
{ id: 'role-tank', label: 'Tank' },
|
||||
{ id: 'role-heal', label: 'Heiler' },
|
||||
{ id: 'role-dps', label: 'Schaden' }
|
||||
]
|
||||
},
|
||||
{
|
||||
group: 'Spieler',
|
||||
items: [1, 2, 3, 4, 5, 6, 7, 8].map(n => ({ id: `num-${n}`, label: `Spieler ${n}`, next: n < 8 ? `num-${n + 1}` : null }))
|
||||
},
|
||||
{
|
||||
group: 'Markierungen',
|
||||
items: [
|
||||
{ id: 'mark-a', label: 'Markierung A', next: 'mark-b' },
|
||||
{ id: 'mark-b', label: 'Markierung B', next: 'mark-c' },
|
||||
{ id: 'mark-c', label: 'Markierung C', next: 'mark-d' },
|
||||
{ id: 'mark-d', label: 'Markierung D' },
|
||||
{ id: 'mark-star', label: 'Stern' },
|
||||
{ id: 'mark-circle', label: 'Kreis' },
|
||||
{ id: 'mark-triangle', label: 'Dreieck' },
|
||||
{ id: 'mark-square', label: 'Quadrat' },
|
||||
{ id: 'mark-cross', label: 'Kreuz' }
|
||||
]
|
||||
},
|
||||
{
|
||||
group: 'Gegner & Mechaniken',
|
||||
items: [
|
||||
{ id: 'boss', label: 'Boss', scale: 1.45 },
|
||||
{ id: 'add', label: 'Gegner', scale: 0.8 },
|
||||
{ id: 'danger', label: 'Gefahr' },
|
||||
{ id: 'stack', label: 'Sammeln' },
|
||||
{ id: 'spread', label: 'Verteilen' },
|
||||
{ id: 'tower', label: 'Turm' },
|
||||
{ id: 'orb', label: 'Kugel' },
|
||||
{ id: 'bomb', label: 'Bombe' }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
class TokenIcons {
|
||||
static find(id) {
|
||||
for (const group of TOKEN_ICONS) {
|
||||
const item = group.items.find(i => i.id === id);
|
||||
if (item) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Eigene Groesse der Figur (Boss groesser, Gegner kleiner). */
|
||||
static scale(id) {
|
||||
const item = TokenIcons.find(id);
|
||||
return item && item.scale ? item.scale : 1;
|
||||
}
|
||||
|
||||
/** Klassen-Wappen laden; ist eines fertig, zeichnen alle Angemeldeten neu (onImageLoad). */
|
||||
static image(name) {
|
||||
if (!TokenIcons.images) TokenIcons.images = new Map();
|
||||
let img = TokenIcons.images.get(name);
|
||||
if (!img) {
|
||||
img = new Image();
|
||||
img.onload = () => TokenIcons.listeners.forEach(fn => fn());
|
||||
img.src = `/assets/images/Classes/normalized/${name}_ICO.png`;
|
||||
TokenIcons.images.set(name, img);
|
||||
}
|
||||
return img.complete && img.naturalWidth ? img : null;
|
||||
}
|
||||
|
||||
static onImageLoad(fn) {
|
||||
TokenIcons.listeners.push(fn);
|
||||
}
|
||||
|
||||
/** Figur id mit Mittelpunkt x/y und Radius r (Bildschirmpixel) zeichnen; color = gewaehlte Farbe. */
|
||||
static draw(ctx, id, x, y, r, color) {
|
||||
ctx.save();
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.lineCap = 'round';
|
||||
const item = TokenIcons.find(id);
|
||||
|
||||
if (id.startsWith('class-')) {
|
||||
TokenIcons.badge(ctx, x, y, r, color);
|
||||
const img = item ? TokenIcons.image(item.image) : null;
|
||||
ctx.shadowBlur = 0;
|
||||
if (img) {
|
||||
ctx.drawImage(img, x - r * 0.82, y - r * 0.82, r * 1.64, r * 1.64);
|
||||
} else {
|
||||
TokenIcons.text(ctx, item ? item.label.charAt(0) : '?', x, y, r, '#ffffff');
|
||||
}
|
||||
} else if (id.startsWith('role-')) {
|
||||
TokenIcons.badge(ctx, x, y, r, color);
|
||||
ctx.shadowBlur = 0;
|
||||
TokenIcons.role(ctx, id, x, y, r);
|
||||
} else if (id.startsWith('num-')) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, Math.PI * 2);
|
||||
ctx.fillStyle = color;
|
||||
ctx.fill();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.13);
|
||||
ctx.strokeStyle = '#ffffff';
|
||||
ctx.stroke();
|
||||
TokenIcons.text(ctx, id.slice(4), x, y + r * 0.04, r * 1.05, '#ffffff');
|
||||
} else if (/^mark-[abcd]$/.test(id)) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y - r * 1.12);
|
||||
ctx.lineTo(x + r * 1.12, y);
|
||||
ctx.lineTo(x, y + r * 1.12);
|
||||
ctx.lineTo(x - r * 1.12, y);
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = color;
|
||||
ctx.fill();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.13);
|
||||
ctx.strokeStyle = '#ffffff';
|
||||
ctx.stroke();
|
||||
TokenIcons.text(ctx, id.slice(5).toUpperCase(), x, y + r * 0.04, r * 0.95, '#ffffff');
|
||||
} else if (id.startsWith('mark-')) {
|
||||
TokenIcons.badge(ctx, x, y, r, color);
|
||||
ctx.shadowBlur = 0;
|
||||
TokenIcons.symbol(ctx, id.slice(5), x, y, r, color);
|
||||
} else if (id === 'danger') {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y - r * 1.05);
|
||||
ctx.lineTo(x + r * 1.05, y + r * 0.8);
|
||||
ctx.lineTo(x - r * 1.05, y + r * 0.8);
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = '#ffcc33';
|
||||
ctx.fill();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.12);
|
||||
ctx.strokeStyle = '#1b1406';
|
||||
ctx.stroke();
|
||||
TokenIcons.text(ctx, '!', x, y + r * 0.18, r * 1.05, '#1b1406', false);
|
||||
} else if (id === 'orb') {
|
||||
const gradient = ctx.createRadialGradient(x - r * 0.3, y - r * 0.3, r * 0.1, x, y, r);
|
||||
gradient.addColorStop(0, '#ffffff');
|
||||
gradient.addColorStop(0.35, color);
|
||||
gradient.addColorStop(1, 'rgba(0, 0, 0, 0.35)');
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, Math.PI * 2);
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.lineWidth = Math.max(1, r * 0.08);
|
||||
ctx.strokeStyle = color;
|
||||
ctx.stroke();
|
||||
} else if (id === 'bomb') {
|
||||
TokenIcons.bomb(ctx, x, y, r, color);
|
||||
} else {
|
||||
// boss, add, stack, spread, tower
|
||||
TokenIcons.badge(ctx, x, y, r, color);
|
||||
ctx.shadowBlur = 0;
|
||||
if (id === 'boss' || id === 'add') TokenIcons.skull(ctx, x, y, r, id === 'boss' ? '#ffffff' : '#e8e8e8');
|
||||
else if (id === 'stack') TokenIcons.arrows(ctx, x, y, r, true);
|
||||
else if (id === 'spread') TokenIcons.arrows(ctx, x, y, r, false);
|
||||
else if (id === 'tower') TokenIcons.tower(ctx, x, y, r, color);
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/** Runde Plakette: dunkle Flaeche, Rand in der gewaehlten Farbe. */
|
||||
static badge(ctx, x, y, r, color) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, Math.PI * 2);
|
||||
ctx.fillStyle = 'rgba(12, 14, 28, 0.92)';
|
||||
ctx.fill();
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.16);
|
||||
ctx.strokeStyle = color;
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
static text(ctx, text, x, y, size, color, outline = true) {
|
||||
ctx.font = `bold ${Math.round(size)}px 'Segoe UI', sans-serif`;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
if (outline) {
|
||||
ctx.lineWidth = Math.max(2, size / 6);
|
||||
ctx.strokeStyle = 'rgba(0, 0, 0, 0.75)';
|
||||
ctx.strokeText(text, x, y);
|
||||
}
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillText(text, x, y);
|
||||
}
|
||||
|
||||
static role(ctx, id, x, y, r) {
|
||||
ctx.beginPath();
|
||||
if (id === 'role-tank') {
|
||||
// Schild
|
||||
ctx.moveTo(x - r * 0.5, y - r * 0.52);
|
||||
ctx.lineTo(x + r * 0.5, y - r * 0.52);
|
||||
ctx.lineTo(x + r * 0.5, y - r * 0.02);
|
||||
ctx.quadraticCurveTo(x + r * 0.45, y + r * 0.42, x, y + r * 0.62);
|
||||
ctx.quadraticCurveTo(x - r * 0.45, y + r * 0.42, x - r * 0.5, y - r * 0.02);
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = '#4da3ff';
|
||||
ctx.fill();
|
||||
} else if (id === 'role-heal') {
|
||||
// Kreuz
|
||||
const t = r * 0.19;
|
||||
const l = r * 0.56;
|
||||
ctx.rect(x - t, y - l, t * 2, l * 2);
|
||||
ctx.rect(x - l, y - t, l * 2, t * 2);
|
||||
ctx.fillStyle = '#5ddc7a';
|
||||
ctx.fill();
|
||||
} else {
|
||||
// Schwert, schraeg
|
||||
ctx.translate(x, y);
|
||||
ctx.rotate(Math.PI / 4);
|
||||
ctx.moveTo(0, -r * 0.68);
|
||||
ctx.lineTo(r * 0.11, -r * 0.5);
|
||||
ctx.lineTo(r * 0.11, r * 0.24);
|
||||
ctx.lineTo(-r * 0.11, r * 0.24);
|
||||
ctx.lineTo(-r * 0.11, -r * 0.5);
|
||||
ctx.closePath();
|
||||
ctx.rect(-r * 0.36, r * 0.24, r * 0.72, r * 0.13);
|
||||
ctx.rect(-r * 0.08, r * 0.37, r * 0.16, r * 0.3);
|
||||
ctx.fillStyle = '#ff6b6b';
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
static symbol(ctx, kind, x, y, r, color) {
|
||||
ctx.fillStyle = color;
|
||||
ctx.strokeStyle = color;
|
||||
ctx.beginPath();
|
||||
switch (kind) {
|
||||
case 'star':
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const radius = i % 2 === 0 ? r * 0.64 : r * 0.27;
|
||||
const angle = -Math.PI / 2 + i * Math.PI / 5;
|
||||
const px = x + Math.cos(angle) * radius;
|
||||
const py = y + Math.sin(angle) * radius;
|
||||
if (i === 0) ctx.moveTo(px, py); else ctx.lineTo(px, py);
|
||||
}
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
break;
|
||||
case 'circle':
|
||||
ctx.arc(x, y, r * 0.48, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
break;
|
||||
case 'triangle':
|
||||
ctx.moveTo(x, y - r * 0.6);
|
||||
ctx.lineTo(x + r * 0.55, y + r * 0.42);
|
||||
ctx.lineTo(x - r * 0.55, y + r * 0.42);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
break;
|
||||
case 'square':
|
||||
ctx.rect(x - r * 0.44, y - r * 0.44, r * 0.88, r * 0.88);
|
||||
ctx.fill();
|
||||
break;
|
||||
case 'cross':
|
||||
ctx.lineWidth = r * 0.24;
|
||||
ctx.moveTo(x - r * 0.42, y - r * 0.42);
|
||||
ctx.lineTo(x + r * 0.42, y + r * 0.42);
|
||||
ctx.moveTo(x + r * 0.42, y - r * 0.42);
|
||||
ctx.lineTo(x - r * 0.42, y + r * 0.42);
|
||||
ctx.stroke();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static skull(ctx, x, y, r, color) {
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y - r * 0.12, r * 0.5, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.rect(x - r * 0.3, y + r * 0.18, r * 0.6, r * 0.34);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = '#12141f';
|
||||
ctx.beginPath();
|
||||
ctx.arc(x - r * 0.2, y - r * 0.12, r * 0.14, 0, Math.PI * 2);
|
||||
ctx.arc(x + r * 0.2, y - r * 0.12, r * 0.14, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y + r * 0.02);
|
||||
ctx.lineTo(x + r * 0.08, y + r * 0.16);
|
||||
ctx.lineTo(x - r * 0.08, y + r * 0.16);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
// Zaehne
|
||||
ctx.fillRect(x - r * 0.1 - r * 0.02, y + r * 0.34, r * 0.04, r * 0.18);
|
||||
ctx.fillRect(x + r * 0.1 - r * 0.02, y + r * 0.34, r * 0.04, r * 0.18);
|
||||
}
|
||||
|
||||
/** Vier Pfeile: nach innen (Sammeln) oder nach aussen (Verteilen). */
|
||||
static arrows(ctx, x, y, r, inward) {
|
||||
ctx.strokeStyle = '#ffffff';
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.12);
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const angle = i * Math.PI / 2 + Math.PI / 4;
|
||||
const cos = Math.cos(angle);
|
||||
const sin = Math.sin(angle);
|
||||
const from = inward ? r * 0.78 : r * 0.2;
|
||||
const to = inward ? r * 0.28 : r * 0.72;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + cos * from, y + sin * from);
|
||||
ctx.lineTo(x + cos * to, y + sin * to);
|
||||
ctx.stroke();
|
||||
const dir = inward ? -1 : 1;
|
||||
const tipX = x + cos * to;
|
||||
const tipY = y + sin * to;
|
||||
const head = r * 0.2;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tipX + cos * head * 0.6 * dir, tipY + sin * head * 0.6 * dir);
|
||||
ctx.lineTo(tipX - sin * head * 0.7, tipY + cos * head * 0.7);
|
||||
ctx.lineTo(tipX + sin * head * 0.7, tipY - cos * head * 0.7);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
if (inward) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r * 0.14, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
static tower(ctx, x, y, r, color) {
|
||||
ctx.fillStyle = color;
|
||||
const w = r * 0.62;
|
||||
const top = y - r * 0.3;
|
||||
ctx.fillRect(x - w / 2, top, w, r * 0.84);
|
||||
// Zinnen
|
||||
const tooth = w / 5;
|
||||
for (let i = 0; i < 3; i++) {
|
||||
ctx.fillRect(x - w / 2 + i * tooth * 2, top - r * 0.2, tooth, r * 0.2);
|
||||
}
|
||||
ctx.fillStyle = '#12141f';
|
||||
ctx.fillRect(x - r * 0.1, y + r * 0.22, r * 0.2, r * 0.32);
|
||||
}
|
||||
|
||||
static bomb(ctx, x, y, r, color) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y + r * 0.1, r * 0.78, 0, Math.PI * 2);
|
||||
ctx.fillStyle = '#1b1d26';
|
||||
ctx.fill();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.12);
|
||||
ctx.strokeStyle = color;
|
||||
ctx.stroke();
|
||||
// Glanz
|
||||
ctx.beginPath();
|
||||
ctx.arc(x - r * 0.28, y - r * 0.18, r * 0.16, 0, Math.PI * 2);
|
||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.45)';
|
||||
ctx.fill();
|
||||
// Lunte mit Funke
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + r * 0.42, y - r * 0.5);
|
||||
ctx.quadraticCurveTo(x + r * 0.7, y - r * 0.95, x + r * 0.95, y - r * 0.78);
|
||||
ctx.lineWidth = Math.max(1.5, r * 0.1);
|
||||
ctx.strokeStyle = '#c8a064';
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.arc(x + r * 0.98, y - r * 0.8, r * 0.18, 0, Math.PI * 2);
|
||||
ctx.fillStyle = '#ffb02e';
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
TokenIcons.listeners = [];
|
||||
BIN
assets/map/previews/arkanis.webp
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/map/previews/awaken-1.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
assets/map/previews/awaken-2.webp
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/map/previews/awaken-3.webp
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
assets/map/previews/awaken-4.webp
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/map/previews/awaken-5.webp
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/map/previews/awaken-6.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
assets/map/previews/bakron-island.webp
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
assets/map/previews/blasphemy-lab.webp
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
assets/map/previews/blue-breath-isle.webp
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
assets/map/previews/cradle-nihility.webp
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
assets/map/previews/daeva-citadel.webp
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
assets/map/previews/dead-dramata-nest.webp
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
assets/map/previews/deus-center.webp
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
assets/map/previews/draconic-2.webp
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
assets/map/previews/draconic-4.webp
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
assets/map/previews/draconic-5.webp
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/map/previews/draupnir.webp
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/map/previews/erosion-purifier.webp
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
assets/map/previews/fafnite-gully.webp
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/map/previews/fire-temple.webp
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
assets/map/previews/horn-cave.webp
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
assets/map/previews/krao-cave.webp
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
assets/map/previews/legacy-noiran.webp
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/map/previews/mirror-heart.webp
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
assets/map/previews/muspel-grail.webp
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/map/previews/phantoms-hall.webp
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/map/previews/reforged-abyss.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/map/previews/sunken-temple.webp
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/map/previews/urugugu-canyon.webp
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
180
assets/map/scripts/download_dungeon_maps.py
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Download the Aion 2 dungeon and raid maps for the Raidplaner.
|
||||
|
||||
The map images come from the game client; the DPS meter repository
|
||||
Waffle-ens/waffle_meter publishes them (dotnet/Assets/Maps, 2048x2048 PNG).
|
||||
Which maps we use, their slugs and German names are maintained by hand in
|
||||
dungeons/dungeons.json - this script only fetches the images listed there:
|
||||
|
||||
- dungeons/<slug>.webp the map itself (WebP, same size as the original)
|
||||
- previews/<slug>.webp a small square preview for the map picker
|
||||
- size / bounds written back into dungeons.json: image size and the
|
||||
part of the map with the dungeon on it (world
|
||||
coordinates 0..4096, like the tactics) - the viewer
|
||||
zooms there when the map is opened
|
||||
|
||||
The bounds are found by comparing each map with the shared background of all
|
||||
maps (every map texture has the same clouds and rings, only the dungeon differs).
|
||||
|
||||
Usage:
|
||||
python download_dungeon_maps.py # all maps from dungeons.json
|
||||
python download_dungeon_maps.py --slug fire-temple
|
||||
python download_dungeon_maps.py --commit <sha> # other version of the repository
|
||||
|
||||
Requires Pillow and numpy.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image, ImageFilter
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
MAP_DIR = os.path.dirname(HERE)
|
||||
LIST_FILE = os.path.join(MAP_DIR, "dungeons", "dungeons.json")
|
||||
OUT_DIR = os.path.join(MAP_DIR, "dungeons")
|
||||
PREVIEW_DIR = os.path.join(MAP_DIR, "previews")
|
||||
|
||||
RAW_URL = "https://raw.githubusercontent.com/{repo}/{commit}/{path}/{key}.png"
|
||||
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) aion2-dungeon-maps/1.0"
|
||||
|
||||
WORLD_SIZE = 4096 # world coordinates of the viewer (CONFIG.WORLD_MAX_X)
|
||||
PREVIEW_SIZE = 320
|
||||
BOUNDS_MARGIN = 0.04 # share of the image added around the dungeon
|
||||
DIFF_THRESHOLD = 30 # colour difference to the shared background that counts as "dungeon"
|
||||
|
||||
|
||||
def http_get(url: str, retries: int = 3) -> bytes:
|
||||
last_err = None
|
||||
for attempt in range(1, retries + 1):
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
return resp.read()
|
||||
except (urllib.error.URLError, TimeoutError) as exc:
|
||||
last_err = exc
|
||||
if attempt < retries:
|
||||
time.sleep(1.5 * attempt)
|
||||
raise RuntimeError(f"GET {url} failed after {retries} attempts: {last_err}")
|
||||
|
||||
|
||||
def world_bounds(box, size):
|
||||
"""Pixel box (x0, y0, x1, y1) of an image -> world coordinates. The viewer draws the image as
|
||||
large as possible into the square 0..4096 world, centered (MapView.imageRect)."""
|
||||
width, height = size
|
||||
scale = WORLD_SIZE / max(width, height)
|
||||
off_x = (WORLD_SIZE - width * scale) / 2
|
||||
off_y = (WORLD_SIZE - height * scale) / 2
|
||||
x0, y0, x1, y1 = box
|
||||
return [round(off_x + x0 * scale), round(off_y + y0 * scale),
|
||||
round(off_x + x1 * scale), round(off_y + y1 * scale)]
|
||||
|
||||
|
||||
def content_box(image, background):
|
||||
"""Part of the image that differs from the shared background (with a margin), as a pixel box."""
|
||||
width, height = image.size
|
||||
if background is None or (width, height) != (2048, 2048):
|
||||
return (0, 0, width, height)
|
||||
small = np.asarray(image.resize((512, 512), Image.BILINEAR)).astype(np.int16)
|
||||
diff = np.abs(small - background).sum(axis=2) >= DIFF_THRESHOLD
|
||||
# single stray pixels (e.g. slightly different clouds) do not count
|
||||
mask = Image.fromarray((diff * 255).astype("uint8")).filter(ImageFilter.MinFilter(3)).filter(ImageFilter.MaxFilter(3))
|
||||
ys, xs = np.nonzero(np.asarray(mask) > 0)
|
||||
if len(xs) == 0:
|
||||
return (0, 0, width, height)
|
||||
factor = width / 512
|
||||
margin = BOUNDS_MARGIN * width
|
||||
return (max(0, int(xs.min() * factor - margin)), max(0, int(ys.min() * factor - margin)),
|
||||
min(width, int((xs.max() + 1) * factor + margin)), min(height, int((ys.max() + 1) * factor + margin)))
|
||||
|
||||
|
||||
def square_box(box, size):
|
||||
"""Enlarge a box to a square (for the preview), kept inside the image."""
|
||||
width, height = size
|
||||
x0, y0, x1, y1 = box
|
||||
side = min(max(x1 - x0, y1 - y0), width, height)
|
||||
cx, cy = (x0 + x1) / 2, (y0 + y1) / 2
|
||||
left = int(min(max(0, cx - side / 2), width - side))
|
||||
top = int(min(max(0, cy - side / 2), height - side))
|
||||
return (left, top, left + side, top + side)
|
||||
|
||||
|
||||
def dump_list(data) -> str:
|
||||
"""dungeons.json in its hand-written layout: one map per line, so it stays easy to edit."""
|
||||
compact = lambda value: json.dumps(value, ensure_ascii=False, separators=(", ", ": "))
|
||||
lines = ["{"]
|
||||
for key in [k for k in data if k != "groups"]:
|
||||
lines.append(f' {compact(key)}: {json.dumps(data[key], ensure_ascii=False, indent=2).replace(chr(10), chr(10) + " ")},')
|
||||
lines.append(' "groups": [')
|
||||
for g_index, group in enumerate(data["groups"]):
|
||||
lines.append(" {")
|
||||
for key in [k for k in group if k != "maps"]:
|
||||
lines.append(f" {compact(key)}: {compact(group[key])},")
|
||||
lines.append(' "maps": [')
|
||||
for m_index, entry in enumerate(group["maps"]):
|
||||
text = compact(entry)
|
||||
lines.append(" { " + text[1:-1] + " }" + ("," if m_index < len(group["maps"]) - 1 else ""))
|
||||
lines.append(" ]")
|
||||
lines.append(" }" + ("," if g_index < len(data["groups"]) - 1 else ""))
|
||||
lines.append(" ]")
|
||||
lines.append("}")
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Download the dungeon maps listed in dungeons/dungeons.json")
|
||||
parser.add_argument("--slug", help="only this map (all are still downloaded for the shared background)")
|
||||
parser.add_argument("--commit", help="commit of the source repository (default: dungeons.json source.commit)")
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(LIST_FILE, encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
source = data["source"]
|
||||
if args.commit:
|
||||
source["commit"] = args.commit
|
||||
|
||||
entries = [m for group in data["groups"] for m in group["maps"] if m.get("key")]
|
||||
selected = [m for m in entries if not args.slug or m["slug"] == args.slug]
|
||||
if not selected:
|
||||
sys.exit(f"Unknown slug {args.slug}")
|
||||
|
||||
images = {}
|
||||
for entry in entries:
|
||||
url = RAW_URL.format(repo=source["repo"], commit=source["commit"], path=source["path"], key=entry["key"])
|
||||
print(f" {entry['slug']:<20} {entry['key']}")
|
||||
images[entry["slug"]] = Image.open(io.BytesIO(http_get(url))).convert("RGB")
|
||||
|
||||
# Shared background: per-pixel median of all square maps
|
||||
squares = [np.asarray(img.resize((512, 512), Image.BILINEAR)).astype(np.int16)
|
||||
for img in images.values() if img.size == (2048, 2048)]
|
||||
background = np.median(np.stack(squares), axis=0).astype(np.int16) if len(squares) >= 5 else None
|
||||
if background is None:
|
||||
print("Too few maps for the shared background - bounds = whole image")
|
||||
|
||||
os.makedirs(OUT_DIR, exist_ok=True)
|
||||
os.makedirs(PREVIEW_DIR, exist_ok=True)
|
||||
for entry in selected:
|
||||
image = images[entry["slug"]]
|
||||
image.save(os.path.join(OUT_DIR, entry["slug"] + ".webp"), "WEBP", quality=85, method=6)
|
||||
|
||||
box = content_box(image, background)
|
||||
entry["size"] = list(image.size)
|
||||
entry["bounds"] = world_bounds(box, image.size)
|
||||
|
||||
preview = image.crop(square_box(box, image.size)).resize((PREVIEW_SIZE, PREVIEW_SIZE), Image.LANCZOS)
|
||||
preview.save(os.path.join(PREVIEW_DIR, entry["slug"] + ".webp"), "WEBP", quality=80, method=6)
|
||||
|
||||
with open(LIST_FILE, "w", encoding="utf-8", newline="\n") as fh:
|
||||
fh.write(dump_list(data))
|
||||
print(f"{len(selected)} maps written to {OUT_DIR}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -167,6 +167,42 @@ canvas:active {
|
|||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* Reiter der Kartenauswahl: Welt / Dungeons & Raids */
|
||||
#map-picker-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
margin: 0 auto 0 16px;
|
||||
padding: 3px;
|
||||
border-radius: 8px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
#map-picker-tabs.hidden { display: none; }
|
||||
|
||||
.map-picker-tab {
|
||||
padding: 5px 12px;
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.map-picker-tab.active {
|
||||
background: rgba(255, 215, 0, 0.18);
|
||||
border-color: rgba(255, 215, 0, 0.55);
|
||||
color: var(--accent-gold);
|
||||
}
|
||||
|
||||
.map-picker-zone.hidden + .map-picker-zone { margin-top: 0; }
|
||||
|
||||
/* Kleiner Hinweis unter dem Namen (z.B. Boss der Erwachen-Karten) */
|
||||
.map-card-hint {
|
||||
margin-top: -6px;
|
||||
padding: 0 10px 8px;
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
#map-picker-list {
|
||||
overflow-y: auto;
|
||||
min-height: 0;
|
||||
|
|
@ -510,6 +546,10 @@ button:hover {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
#tactic-canvas.moving {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
#tactic-panel {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
|
|
@ -984,8 +1024,8 @@ button.tp-live-user small {
|
|||
}
|
||||
|
||||
/* Werkzeugleiste im Taktik-Panel - bleibt auch beim Einklappen sichtbar. Raster mit 7 gleich
|
||||
grossen Feldern: oben die 7 Zeichenwerkzeuge, unten Text, Radierer, Rueckgaengig, Farbe und
|
||||
Strichstaerke (3 Felder breit). Passt ohne Umbruch-Luecken aufs Panel und aufs Handy. */
|
||||
grossen Feldern: zwei Reihen mit den 14 Werkzeugen, darunter Farbe, Strichstaerke/Groesse und beim
|
||||
Kegel dessen Winkel (je 3 Felder breit). Passt ohne Umbruch-Luecken aufs Panel und aufs Handy. */
|
||||
#tactic-toolbar {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||
|
|
@ -1044,7 +1084,8 @@ button.tp-live-user small {
|
|||
border-radius: 2px;
|
||||
}
|
||||
|
||||
#tool-width {
|
||||
#tool-width,
|
||||
#tool-angle {
|
||||
grid-column: span 3;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
|
@ -1057,6 +1098,76 @@ button.tp-live-user small {
|
|||
font-size: 13px;
|
||||
}
|
||||
|
||||
#tool-angle.hidden { display: none; }
|
||||
|
||||
/* Figuren des Raidplaners (Werkzeug ♟): Gruppen mit kleinen Knoepfen */
|
||||
#token-palette {
|
||||
margin-top: 6px;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
max-height: 190px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#token-palette.hidden { display: none; }
|
||||
|
||||
.tk-group + .tk-group { margin-top: 5px; }
|
||||
|
||||
.tk-group-title {
|
||||
margin-bottom: 3px;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.tk-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
button.tk-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 36px;
|
||||
padding: 0;
|
||||
background: rgba(30, 30, 55, 0.8);
|
||||
}
|
||||
|
||||
button.tk-item canvas {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
cursor: pointer;
|
||||
touch-action: auto;
|
||||
}
|
||||
|
||||
button.tk-item.active {
|
||||
border-color: var(--accent-gold);
|
||||
background: rgba(255, 215, 0, 0.22);
|
||||
}
|
||||
|
||||
/* Aktionen an der mit ✥ ausgewaehlten Zeichnung - sitzt ueber ihr */
|
||||
#shape-actions {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
transform: translate(-50%, -100%);
|
||||
}
|
||||
|
||||
#shape-actions.hidden { display: none; }
|
||||
|
||||
#shape-actions button {
|
||||
padding: 3px 9px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#shape-actions button.hidden { display: none; }
|
||||
|
||||
/* Schritt-Leiste unten mittig zwischen Kategorien-Panel (links, 300px) und
|
||||
Zoom-Anzeige (rechts) - left/right plus margin auto zentriert sie in diesem Streifen. */
|
||||
#step-bar {
|
||||
|
|
@ -1079,6 +1190,23 @@ button.tp-live-user small {
|
|||
cursor: default;
|
||||
}
|
||||
|
||||
#sb-play {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#sb-play[aria-pressed="true"] {
|
||||
border-color: var(--accent-gold);
|
||||
background: rgba(255, 215, 0, 0.25);
|
||||
}
|
||||
|
||||
/* Dungeon-Karten und Arenen haben kein Kategorien-Panel - Schritt-Leiste und Hinweise mittig */
|
||||
body:not(.map-kind-tiles) #step-bar,
|
||||
body:not(.map-kind-tiles) #toast {
|
||||
left: 100px;
|
||||
}
|
||||
|
||||
.sb-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
|
@ -1243,6 +1371,9 @@ button.tp-live-user small {
|
|||
#map-picker { padding: 10px; }
|
||||
.map-picker-panel { padding: 14px; }
|
||||
.map-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
||||
.map-picker-head { flex-wrap: wrap; gap: 8px; }
|
||||
#map-picker-tabs { order: 3; width: 100%; margin: 0; }
|
||||
.map-picker-tab { flex: 1; }
|
||||
|
||||
#zoom-controls {
|
||||
top: 8px;
|
||||
|
|
@ -1294,6 +1425,13 @@ button.tp-live-user small {
|
|||
right: 8px;
|
||||
bottom: 120px;
|
||||
}
|
||||
|
||||
body:not(.map-kind-tiles) #step-bar,
|
||||
body:not(.map-kind-tiles) #toast {
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
#token-palette { max-height: 120px; }
|
||||
}
|
||||
|
||||
/* ---- Orte teilen / auswaehlen (LocationController) ---- */
|
||||
|
|
|
|||
|
|
@ -475,6 +475,7 @@ if (empty($user['tour_completed_at'])):
|
|||
}
|
||||
if (user_has_permission('map.view')) {
|
||||
$tourSteps[] = ['target' => $link('/map.php'), 'title' => 'Karte', 'text' => 'Die interaktive Karte von Aion 2 mit allen Fundorten - und mit den Taktiken der Legion, Schritt für Schritt eingezeichnet.'];
|
||||
$tourSteps[] = ['target' => $link('/raidplan.php'), 'title' => 'Raidplaner', 'text' => 'Die Karten aller Dungeons und Raids: stell Figuren für Klassen, Rollen und Bosse auf und plane die Mechaniken Schritt für Schritt - beim Durchblättern laufen die Figuren an ihre neue Stelle.'];
|
||||
}
|
||||
if (user_has_permission('gear.view')) {
|
||||
$tourSteps[] = ['target' => $link('/gear.php'), 'title' => 'Gear-Planer', 'text' => 'Stell deine Ausrüstung zusammen, plane Skills und Stigmen und vergleiche deine Sets. Ein Set kannst du auch auf deiner Profilseite zeigen.'];
|
||||
|
|
|
|||
41
includes/dungeon_maps.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Dungeon- und Raid-Karten des Raidplaners (assets/map/dungeons/dungeons.json). Der Viewer liest die
|
||||
* Liste selbst; hier braucht die Website nur Slugs und Namen - fuer die Taktiken (gueltige Karte)
|
||||
* und fuer Links auf einen Ort der Karte.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alle Dungeon-Karten, Slug => Eintrag aus dungeons.json (dazu 'group' = Name der Gruppe).
|
||||
* Fehlt die Datei, ist die Liste leer.
|
||||
*
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
function dungeon_maps(): array
|
||||
{
|
||||
static $maps = null;
|
||||
if ($maps !== null) {
|
||||
return $maps;
|
||||
}
|
||||
|
||||
$maps = [];
|
||||
$path = __DIR__ . '/../assets/map/dungeons/dungeons.json';
|
||||
$data = is_file($path) ? json_decode((string) file_get_contents($path), true) : null;
|
||||
foreach ((is_array($data) ? ($data['groups'] ?? []) : []) as $group) {
|
||||
foreach ((is_array($group['maps'] ?? null) ? $group['maps'] : []) as $map) {
|
||||
$slug = (string) ($map['slug'] ?? '');
|
||||
if (preg_match('/^[a-z0-9-]{1,60}$/', $slug) === 1) {
|
||||
$maps[$slug] = $map + ['group' => (string) ($group['name'] ?? '')];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $maps;
|
||||
}
|
||||
|
||||
/** Slug => Anzeigename der Dungeon-Karten. @return array<string, string> */
|
||||
function dungeon_map_names(): array
|
||||
{
|
||||
return array_map(static fn (array $map): string => (string) ($map['name'] ?? ''), dungeon_maps());
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||
const SIDEBAR_NAV_MAIN = [
|
||||
'/dashboard.php', '/profile.php', '/members.php', '/gallery.php', '/contributions.php', '/shop.php', 'gap',
|
||||
'/wiki.php', '/raids.php', '/premades.php', '/calendar.php', '/events.php',
|
||||
'/map.php', '/gear.php', '/professions.php', '/warehouse.php',
|
||||
'/map.php', '/raidplan.php', '/gear.php', '/professions.php', '/warehouse.php',
|
||||
];
|
||||
// So viele zusaetzliche Trennlinien darf jedes Mitglied einfuegen
|
||||
const SIDEBAR_MAX_EXTRA_GAPS = 10;
|
||||
|
|
@ -167,6 +167,8 @@ function icon(string $name): string
|
|||
'bug' => '<rect x="8" y="6" width="8" height="14" rx="4"/><path d="M19 7l-3 2"/><path d="M5 7l3 2"/><path d="M19 19l-3-2"/><path d="M5 19l3-2"/><path d="M20 13h-4"/><path d="M4 13h4"/><path d="M10 4l1 2"/><path d="M14 4l-1 2"/>',
|
||||
'shield-check' => '<path d="M12 21c4.5-1.8 7-5.2 7-9.5V6l-7-3-7 3v5.5c0 4.3 2.5 7.7 7 9.5z"/><polyline points="9 12 11.2 14.2 15.5 9.8"/>',
|
||||
'hammer' => '<path d="m14.5 9.5-10 10"/><path d="M11 6l4-4 7 7-4 4z"/>',
|
||||
// Raidplaner: Aufstellung mit Figuren und Laufweg
|
||||
'tactic' => '<circle cx="6" cy="6" r="2.5"/><circle cx="18" cy="18" r="2.5"/><path d="M8.5 7.5 15.5 16.5"/><path d="M15 12.5v4h-4"/><path d="M16 3l4 4"/><path d="M20 3l-4 4"/>',
|
||||
];
|
||||
|
||||
$path = $paths[$name] ?? '';
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ $isEventsActive = $currentScript === 'events.php';
|
|||
$isCalendarActive = $currentScript === 'calendar.php';
|
||||
$isActivityActive = $currentScript === 'activity.php';
|
||||
$isMapActive = $currentScript === 'map.php';
|
||||
$isRaidplanActive = $currentScript === 'raidplan.php';
|
||||
$isWarehouseActive = $currentScript === 'warehouse.php';
|
||||
$isGearActive = in_array($currentScript, ['gear.php', 'gear_items.php', 'gear_skills.php'], true);
|
||||
$isProfessionsActive = $currentScript === 'professions.php';
|
||||
|
|
@ -80,6 +81,7 @@ $pageBackgrounds = [
|
|||
'calendar.php' => 'bg-events',
|
||||
'activity.php' => 'bg-events',
|
||||
'map.php' => 'bg-map',
|
||||
'raidplan.php' => 'bg-map',
|
||||
'warehouse.php' => 'bg-warehouse',
|
||||
'gear.php' => 'bg-warehouse',
|
||||
'professions.php' => 'bg-warehouse',
|
||||
|
|
@ -290,6 +292,9 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => !i
|
|||
<a href="/map.php" data-nav="/map.php"<?= $navOrder('/map.php') ?> class="sidebar-link<?= $isMapActive ? ' active' : '' ?>" title="Karte">
|
||||
<?= icon('map') ?><span class="label">Karte</span>
|
||||
</a>
|
||||
<a href="/raidplan.php" data-nav="/raidplan.php"<?= $navOrder('/raidplan.php') ?> class="sidebar-link<?= $isRaidplanActive ? ' active' : '' ?>" title="Raidplaner: Taktiken für Dungeons und Raids">
|
||||
<?= icon('tactic') ?><span class="label">Raidplaner</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewGear): ?>
|
||||
<a href="/gear.php" data-nav="/gear.php"<?= $navOrder('/gear.php') ?> class="sidebar-link<?= $isGearActive ? ' active' : '' ?>" title="Gear-Planer">
|
||||
|
|
|
|||
|
|
@ -2,12 +2,16 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Links auf Orte der Karte (/map.php?karte=verteron&x=1234&y=2345&zoom=5&ort=Treffpunkt),
|
||||
* erzeugt ueber "Ort teilen" bzw. "Ort auswaehlen" (assets/map/js/controllers/LocationController.js).
|
||||
* Links auf Orte der Karte (/map.php?karte=verteron&x=1234&y=2345&zoom=5&ort=Treffpunkt, bei
|
||||
* Dungeon-Karten /raidplan.php?...), erzeugt ueber "Ort teilen" bzw. "Ort auswaehlen"
|
||||
* (assets/map/js/controllers/LocationController.js).
|
||||
* Hier: erkennen, pruefen und als "📍 Verteron – Treffpunkt" anzeigen.
|
||||
*/
|
||||
|
||||
// Anzeigenamen der Karten (wie data/maps.json + CONFIG.MAP_NAMES im Viewer)
|
||||
require_once __DIR__ . '/dungeon_maps.php';
|
||||
|
||||
// Anzeigenamen der Weltkarten (wie data/maps.json + CONFIG.MAP_NAMES im Viewer) - die Dungeon-Karten
|
||||
// des Raidplaners kommen aus assets/map/dungeons/dungeons.json dazu (map_link_names)
|
||||
const MAP_LINK_NAMES = [
|
||||
'verteron' => 'Verteron',
|
||||
'elthen' => 'Eltnen',
|
||||
|
|
@ -21,11 +25,23 @@ const MAP_LINK_NAMES = [
|
|||
'chaotic-upper-reshanta' => 'Chaotic Upper Reshanta',
|
||||
];
|
||||
|
||||
/** Slug => Anzeigename aller Karten, auf die ein Ort-Link zeigen kann. @return array<string, string> */
|
||||
function map_link_names(): array
|
||||
{
|
||||
return MAP_LINK_NAMES + dungeon_map_names();
|
||||
}
|
||||
|
||||
/** Seite, die eine Karte oeffnet: Dungeon-Karten der Raidplaner, alle anderen die Karte. */
|
||||
function map_link_page(string $slug): string
|
||||
{
|
||||
return isset(dungeon_map_names()[$slug]) ? '/raidplan.php' : '/map.php';
|
||||
}
|
||||
|
||||
/** Regex fuer Karten-Links dieser Website (absolut mit unserer Domain oder relativ). */
|
||||
function map_link_pattern(): string
|
||||
{
|
||||
$host = preg_quote((string) ($_SERVER['HTTP_HOST'] ?? 'lumina-ascendens.de'), '~');
|
||||
return '~(?:https?://(?:www\.)?' . $host . ')?/map\.php\?[^\s<>"\']+~i';
|
||||
return '~(?:https?://(?:www\.)?' . $host . ')?/(?:map|raidplan)\.php\?[^\s<>"\']+~i';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -41,7 +57,7 @@ function map_link_parse(string $url): ?array
|
|||
}
|
||||
parse_str((string) parse_url($url, PHP_URL_QUERY), $query);
|
||||
$slug = (string) ($query['karte'] ?? '');
|
||||
if (!isset(MAP_LINK_NAMES[$slug]) || !is_numeric($query['x'] ?? null) || !is_numeric($query['y'] ?? null)) {
|
||||
if (!isset(map_link_names()[$slug]) || !is_numeric($query['x'] ?? null) || !is_numeric($query['y'] ?? null)) {
|
||||
return null;
|
||||
}
|
||||
$link = [
|
||||
|
|
@ -55,14 +71,14 @@ function map_link_parse(string $url): ?array
|
|||
if ($link['ort'] !== '') {
|
||||
$params['ort'] = $link['ort'];
|
||||
}
|
||||
$link['path'] = '/map.php?' . http_build_query($params);
|
||||
$link['path'] = map_link_page($slug) . '?' . http_build_query($params);
|
||||
return $link;
|
||||
}
|
||||
|
||||
/** "Verteron – Treffpunkt Brücke" */
|
||||
function map_link_label(array $link): string
|
||||
{
|
||||
return MAP_LINK_NAMES[$link['slug']] . ($link['ort'] !== '' ? ' – ' . $link['ort'] : '');
|
||||
return map_link_names()[$link['slug']] . ($link['ort'] !== '' ? ' – ' . $link['ort'] : '');
|
||||
}
|
||||
|
||||
/** Huebscher Link mit Pin fuer Texte (Kommentare, Termine). */
|
||||
|
|
|
|||
|
|
@ -19,6 +19,20 @@ const PATCHNOTE_TYPES = [
|
|||
];
|
||||
|
||||
const PATCHNOTES = [
|
||||
[
|
||||
'id' => '2026-09-26-f',
|
||||
'date' => '2026-09-26',
|
||||
'title' => 'Raidplaner für Dungeons und Raids',
|
||||
'summary' => 'Neu im Menü: der Raidplaner – Taktiken wie bei raidplan.io auf den Karten aller Dungeons und Raids, mit Figuren, die von Schritt zu Schritt laufen.',
|
||||
'changes' => [
|
||||
['type' => 'neu', 'area' => 'Raidplaner', 'text' => 'Die Karten aus dem Spiel für alle Expeditionen, Transzendenz-Dungeons, Refugien (Raids), Erwachen und Unterwerfungen, dazu eine leere runde und eckige Arena für Bossmechaniken. Dungeons, die es bisher nur in Korea/Taiwan gibt, sind gekennzeichnet.'],
|
||||
['type' => 'neu', 'area' => 'Raidplaner', 'text' => 'Figuren setzen (♟): Klassen, Rollen, Spielernummern, Markierungen, Boss, Gegner und Mechaniken wie Sammeln, Verteilen, Turm oder Bombe. Nummern und Markierungen zählen beim Setzen von selbst weiter.'],
|
||||
['type' => 'neu', 'area' => 'Raidplaner', 'text' => 'So plant ihr eine Mechanik: Aufstellung setzen, „+ Kopie dieses Schritts“, Figuren mit ✥ an die neue Stelle ziehen. Beim Durchblättern und beim Abspielen laufen die Figuren von selbst an ihre neue Position.'],
|
||||
['type' => 'neu', 'area' => 'Karte', 'text' => 'Neue Werkzeuge auch auf den Weltkarten: Verschieben (✥) mit Beschriften und Löschen, Rechteck und Kegel (z.B. für Frontalangriffe). Strg+Z nimmt auch ein Verschieben zurück.'],
|
||||
['type' => 'neu', 'area' => 'Karte', 'text' => '🔗 kopiert einen Link zur Taktik beim aktuellen Schritt – zum Einfügen in Discord, Termine oder Kommentare.'],
|
||||
['type' => 'verbessert', 'area' => 'Karte', 'text' => 'Das Mausrad zoomt jetzt dorthin, wo der Mauszeiger steht.'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => '2026-09-26-e',
|
||||
'date' => '2026-09-26',
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 59;
|
||||
const SCHEMA_VERSION = 60;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -748,6 +748,15 @@ function schema_column_upgrades(): array
|
|||
],
|
||||
'highlighted_at' => "ALTER TABLE tactics ADD COLUMN highlighted_at DATETIME NULL AFTER highlighted_by",
|
||||
],
|
||||
// Raidplaner: Figuren (icon) und eine Kennung, die beim Kopieren von Schritten mitgeht (ref) -
|
||||
// bisherige Zeichnungen bekommen jede eine eigene
|
||||
'tactic_shapes' => [
|
||||
'icon' => "ALTER TABLE tactic_shapes ADD COLUMN icon VARCHAR(32) NOT NULL DEFAULT '' AFTER label",
|
||||
'ref' => [
|
||||
"ALTER TABLE tactic_shapes ADD COLUMN ref VARCHAR(16) NOT NULL DEFAULT '' AFTER points",
|
||||
"UPDATE tactic_shapes SET ref = CONCAT('s', id) WHERE ref = ''",
|
||||
],
|
||||
],
|
||||
'users' => [
|
||||
// Zuletzt in der Galerie (gallery.php) - neuere Bilder zaehlen in der Seitenleiste als neu
|
||||
'gallery_seen_at' => "ALTER TABLE users ADD COLUMN gallery_seen_at DATETIME NULL AFTER patchnotes_seen",
|
||||
|
|
@ -938,6 +947,15 @@ function ensure_schema(): void
|
|||
$statements[] = "ALTER TABLE users MODIFY status ENUM('active', 'disabled', 'pending') NOT NULL DEFAULT 'active'";
|
||||
}
|
||||
|
||||
// Die Figuren des Raidplaners (Form 'token') kamen am 26.09.2026 dazu.
|
||||
$shapeEnum = $pdo->query(
|
||||
"SELECT column_type FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = 'tactic_shapes' AND column_name = 'shape_type'"
|
||||
)->fetchColumn();
|
||||
if (is_string($shapeEnum) && strpos($shapeEnum, "'token'") === false) {
|
||||
$statements[] = "ALTER TABLE tactic_shapes MODIFY shape_type ENUM('pen', 'line', 'arrow', 'area', 'circle', 'point', 'text', 'token') NOT NULL";
|
||||
}
|
||||
|
||||
// Spalten, deren Typ nachtraeglich korrigiert wurde: [Tabelle, Spalte, erwarteter Typ-Anfang, Befehl].
|
||||
// raid_id sind Discord-Nachrichten-IDs (19-stellig) - ein INT war dafuer zu klein.
|
||||
$typeFixes = [
|
||||
|
|
|
|||
|
|
@ -11,7 +11,33 @@ declare(strict_types=1);
|
|||
// fehlt bewusst: sie legt die automatische Schema-Pruefung an (includes/schema.php).
|
||||
const TACTIC_TABLES = ['tactics', 'tactic_steps', 'tactic_shapes'];
|
||||
|
||||
const TACTIC_SHAPE_TYPES = ['pen', 'line', 'arrow', 'area', 'circle', 'point', 'text'];
|
||||
const TACTIC_SHAPE_TYPES = ['pen', 'line', 'arrow', 'area', 'circle', 'point', 'text', 'token'];
|
||||
|
||||
// Figuren (Form 'token') des Raidplaners - wie TOKEN_ICONS in assets/map/js/views/TokenIcons.js
|
||||
const TACTIC_TOKEN_ICONS = [
|
||||
'class-templar', 'class-gladiator', 'class-assassin', 'class-ranger',
|
||||
'class-sorcerer', 'class-spiritmaster', 'class-cleric', 'class-chanter',
|
||||
'role-tank', 'role-heal', 'role-dps',
|
||||
'num-1', 'num-2', 'num-3', 'num-4', 'num-5', 'num-6', 'num-7', 'num-8',
|
||||
'mark-a', 'mark-b', 'mark-c', 'mark-d', 'mark-star', 'mark-circle', 'mark-triangle', 'mark-square', 'mark-cross',
|
||||
'boss', 'add', 'danger', 'stack', 'spread', 'tower', 'orb', 'bomb',
|
||||
];
|
||||
|
||||
/**
|
||||
* Kennung einer Zeichnung ueber die Schritte hinweg: "+ Kopie dieses Schritts" und das Kopieren
|
||||
* einer Taktik uebernehmen sie, so erkennt die Karte beim Blaettern dieselbe Figur und laesst sie
|
||||
* an ihre neue Stelle laufen.
|
||||
*/
|
||||
function tactic_new_ref(): string
|
||||
{
|
||||
return bin2hex(random_bytes(5));
|
||||
}
|
||||
|
||||
/** Kennung aus einem gesicherten Stand o.ae. - ungueltige werden neu vergeben. */
|
||||
function tactic_clean_ref(mixed $ref): string
|
||||
{
|
||||
return is_string($ref) && preg_match('/^[A-Za-z0-9]{1,16}$/', $ref) === 1 ? $ref : tactic_new_ref();
|
||||
}
|
||||
|
||||
// Die Weltkoordinaten der Karte laufen von 0 bis 4096. Etwas Luft rundherum, damit ein
|
||||
// Pfeil auch knapp ueber den Kartenrand hinaus zeigen darf.
|
||||
|
|
@ -77,15 +103,20 @@ function tactics_create_tables(): void
|
|||
}
|
||||
|
||||
/**
|
||||
* Die Regionen der Karte, wie sie der Viewer kennt (assets/map/data/maps.json).
|
||||
* Fehlt die Datei - etwa weil der Datenordner noch nicht hochgeladen ist - wird nur
|
||||
* das Format des Kartennamens geprueft.
|
||||
* Die Karten, wie sie der Viewer kennt: die Regionen (assets/map/data/maps.json) und die Dungeon-
|
||||
* und Raid-Karten des Raidplaners (assets/map/dungeons/dungeons.json). Fehlt maps.json - etwa weil
|
||||
* der Datenordner noch nicht hochgeladen ist -, wird bei allen anderen Karten nur das Format des
|
||||
* Kartennamens geprueft.
|
||||
*/
|
||||
function tactics_valid_map(string $slug): bool
|
||||
{
|
||||
if (preg_match('/^[a-z0-9-]{1,60}$/', $slug) !== 1) {
|
||||
return false;
|
||||
}
|
||||
require_once __DIR__ . '/dungeon_maps.php';
|
||||
if (isset(dungeon_maps()[$slug])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static $slugs = null;
|
||||
if ($slugs === null) {
|
||||
|
|
@ -221,7 +252,7 @@ function tactics_for_map(string $slug, int $userId): array
|
|||
$stepIds = array_keys($steps);
|
||||
$stepPlaceholders = implode(',', array_fill(0, count($stepIds), '?'));
|
||||
$shapeStmt = db()->prepare(
|
||||
"SELECT id, step_id, shape_type, label, color, width, points FROM tactic_shapes
|
||||
"SELECT id, step_id, shape_type, label, icon, color, width, points, ref FROM tactic_shapes
|
||||
WHERE step_id IN ($stepPlaceholders) ORDER BY id"
|
||||
);
|
||||
$shapeStmt->execute($stepIds);
|
||||
|
|
@ -249,12 +280,26 @@ function tactic_shape_row(array $row): array
|
|||
'id' => (int) $row['id'],
|
||||
'type' => (string) $row['shape_type'],
|
||||
'label' => (string) $row['label'],
|
||||
'icon' => (string) ($row['icon'] ?? ''),
|
||||
'color' => (string) $row['color'],
|
||||
'width' => (int) $row['width'],
|
||||
'points' => is_array($points) ? $points : [],
|
||||
'ref' => (string) ($row['ref'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Figur einer Zeichnung pruefen: bei 'token' eine der bekannten, sonst keine. null, wenn eine
|
||||
* Figur fehlt oder unbekannt ist.
|
||||
*/
|
||||
function tactic_clean_icon(string $type, mixed $icon): ?string
|
||||
{
|
||||
if ($type !== 'token') {
|
||||
return '';
|
||||
}
|
||||
return is_string($icon) && in_array($icon, TACTIC_TOKEN_ICONS, true) ? $icon : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft die Stuetzpunkte einer Zeichnung und gibt sie gerundet zurueck, oder null, wenn
|
||||
* sie nicht zur Form passen.
|
||||
|
|
@ -284,7 +329,7 @@ function tactic_clean_points($points, string $type): ?array
|
|||
|
||||
$count = count($clean);
|
||||
$valid = match ($type) {
|
||||
'point', 'text' => $count === 1,
|
||||
'point', 'text', 'token' => $count === 1,
|
||||
'line', 'arrow', 'circle' => $count === 2,
|
||||
'pen' => $count >= 2 && $count <= TACTIC_MAX_POINTS,
|
||||
'area' => $count >= 3 && $count <= TACTIC_MAX_POINTS,
|
||||
|
|
@ -420,7 +465,7 @@ function tactic_export(int $tacticId): ?array
|
|||
}
|
||||
|
||||
$shapeStmt = db()->prepare(
|
||||
'SELECT sh.step_id, sh.shape_type, sh.label, sh.color, sh.width, sh.points, sh.created_by, sh.created_at
|
||||
'SELECT sh.step_id, sh.shape_type, sh.label, sh.icon, sh.color, sh.width, sh.points, sh.ref, sh.created_by, sh.created_at
|
||||
FROM tactic_shapes sh JOIN tactic_steps s ON s.id = sh.step_id
|
||||
WHERE s.tactic_id = ? ORDER BY sh.id'
|
||||
);
|
||||
|
|
@ -433,9 +478,11 @@ function tactic_export(int $tacticId): ?array
|
|||
$steps[(int) $row['step_id']]['shapes'][] = [
|
||||
'type' => (string) $row['shape_type'],
|
||||
'label' => (string) $row['label'],
|
||||
'icon' => (string) $row['icon'],
|
||||
'color' => (string) $row['color'],
|
||||
'width' => (int) $row['width'],
|
||||
'points' => is_array($points) ? $points : [],
|
||||
'ref' => (string) $row['ref'],
|
||||
'created_by' => $row['created_by'] !== null ? (int) $row['created_by'] : null,
|
||||
'created_at' => (string) $row['created_at'],
|
||||
];
|
||||
|
|
@ -753,8 +800,8 @@ function tactic_import_steps(int $tacticId, array $steps): int
|
|||
$users = tactic_existing_users($userIds);
|
||||
|
||||
$insert = db()->prepare(
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, color, width, points, created_by, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, icon, color, width, points, ref, created_by, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
);
|
||||
$count = 0;
|
||||
foreach ($steps as $step) {
|
||||
|
|
@ -773,8 +820,9 @@ function tactic_import_steps(int $tacticId, array $steps): int
|
|||
if (!in_array($type, TACTIC_SHAPE_TYPES, true) || !is_array($shape['points'] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
$icon = tactic_clean_icon($type, $shape['icon'] ?? null);
|
||||
$points = json_encode($shape['points']);
|
||||
if ($points === false) {
|
||||
if ($icon === null || $points === false) {
|
||||
continue;
|
||||
}
|
||||
$color = (string) ($shape['color'] ?? '');
|
||||
|
|
@ -783,9 +831,12 @@ function tactic_import_steps(int $tacticId, array $steps): int
|
|||
$stepId,
|
||||
$type,
|
||||
mb_substr((string) ($shape['label'] ?? ''), 0, 200),
|
||||
$icon,
|
||||
preg_match('/^#[0-9a-fA-F]{6}$/', $color) === 1 ? strtolower($color) : '#ffd700',
|
||||
max(1, min(30, (int) ($shape['width'] ?? 4))),
|
||||
$points,
|
||||
// Staende von vor dem Raidplaner haben keine Kennung - dann eine neue
|
||||
tactic_clean_ref($shape['ref'] ?? null),
|
||||
isset($users[$creator]) ? $creator : null,
|
||||
tactic_datetime($shape['created_at'] ?? null),
|
||||
]);
|
||||
|
|
|
|||
14
map.php
|
|
@ -11,21 +11,29 @@ try {
|
|||
$missingTables = TACTIC_TABLES;
|
||||
}
|
||||
|
||||
// Dieselbe Seite ist auch der Raidplaner (raidplan.php setzt $mapArea): der Viewer startet dann bei
|
||||
// den Dungeon- und Raid-Karten statt bei den Weltkarten.
|
||||
$mapArea = ($mapArea ?? 'welt') === 'dungeons' ? 'dungeons' : 'welt';
|
||||
|
||||
// Die Karte ist ein eigenstaendiger Viewer (assets/map/) mit eigenem Stylesheet, das
|
||||
// global auf body/button/* greift. Im iframe bleibt er vom Seitenlayout getrennt.
|
||||
// Die Taktiken laedt und speichert er selbst ueber tactics_api.php.
|
||||
// Geteilter Ort (/map.php?karte=verteron&x=1234&y=2345&zoom=5&ort=Treffpunkt): an den Viewer weiterreichen.
|
||||
// Geteilter Ort (/map.php?karte=verteron&x=1234&y=2345&zoom=5&ort=Treffpunkt) bzw. geteilte Taktik
|
||||
// (/raidplan.php?karte=reforged-abyss&taktik=12&schritt=3): an den Viewer weiterreichen.
|
||||
$linkParams = array_filter([
|
||||
'bereich' => $mapArea === 'dungeons' ? 'dungeons' : '',
|
||||
'karte' => preg_match('/^[a-z0-9-]{1,40}$/', (string) ($_GET['karte'] ?? '')) ? (string) $_GET['karte'] : '',
|
||||
'x' => is_numeric($_GET['x'] ?? null) ? (string) (int) $_GET['x'] : '',
|
||||
'y' => is_numeric($_GET['y'] ?? null) ? (string) (int) $_GET['y'] : '',
|
||||
'zoom' => is_numeric($_GET['zoom'] ?? null) ? (string) (int) $_GET['zoom'] : '',
|
||||
'ort' => mb_substr(trim((string) ($_GET['ort'] ?? '')), 0, 60),
|
||||
'taktik' => (int) ($_GET['taktik'] ?? 0) > 0 ? (string) (int) $_GET['taktik'] : '',
|
||||
'schritt' => (int) ($_GET['schritt'] ?? 0) > 0 ? (string) (int) $_GET['schritt'] : '',
|
||||
], static fn (string $v): bool => $v !== '');
|
||||
// map_frame.php haengt Versionskennungen an die Skripte (sonst alte Dateien aus dem Browser-Cache)
|
||||
$frameSrc = '/map_frame.php' . ($linkParams ? '?' . http_build_query($linkParams) : '');
|
||||
|
||||
$pageTitle = 'Karte';
|
||||
$pageTitle = $mapArea === 'dungeons' ? 'Raidplaner' : 'Karte';
|
||||
$containerWide = true;
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
|
@ -46,5 +54,5 @@ include __DIR__ . '/includes/header.php';
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<iframe class="map-frame" src="<?= e($frameSrc) ?>" title="Interaktive Karte"></iframe>
|
||||
<iframe class="map-frame" src="<?= e($frameSrc) ?>" title="<?= $mapArea === 'dungeons' ? 'Raidplaner: Taktiken für Dungeons und Raids' : 'Interaktive Karte' ?>"></iframe>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
|
|||
7
raidplan.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Raidplaner: dieselbe Karte mit den Taktiken wie map.php, nur beginnt sie bei den Dungeon- und
|
||||
* Raid-Karten (assets/map/dungeons/). Figuren, Schritte und Live-Ansicht sind die der Taktiken.
|
||||
*/
|
||||
$mapArea = 'dungeons';
|
||||
require __DIR__ . '/map.php';
|
||||
|
|
@ -413,14 +413,19 @@ CREATE TABLE IF NOT EXISTS tactic_steps (
|
|||
-- points enthaelt die Stuetzpunkte als JSON-Array [[x,y], ...] in Weltkoordinaten der
|
||||
-- Karte (0..4096, dieselben wie die Marker). TEXT statt JSON, damit auch aeltere
|
||||
-- MySQL-/MariaDB-Versionen ohne JSON-Typ funktionieren.
|
||||
-- token = Figur des Raidplaners (Klasse, Rolle, Nummer, Markierung ...), welche steht in icon.
|
||||
-- ref ist ueber die Schritte gleich, wenn eine Zeichnung mit "+ Kopie dieses Schritts" entstanden
|
||||
-- ist - daran erkennt die Karte dieselbe Figur und laesst sie beim Blaettern an ihre neue Stelle laufen.
|
||||
CREATE TABLE IF NOT EXISTS tactic_shapes (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
step_id INT UNSIGNED NOT NULL,
|
||||
shape_type ENUM('pen', 'line', 'arrow', 'area', 'circle', 'point', 'text') NOT NULL,
|
||||
shape_type ENUM('pen', 'line', 'arrow', 'area', 'circle', 'point', 'text', 'token') NOT NULL,
|
||||
label VARCHAR(200) NOT NULL DEFAULT '',
|
||||
icon VARCHAR(32) NOT NULL DEFAULT '',
|
||||
color VARCHAR(7) NOT NULL DEFAULT '#ffd700',
|
||||
width TINYINT UNSIGNED NOT NULL DEFAULT 4,
|
||||
points MEDIUMTEXT NOT NULL,
|
||||
ref VARCHAR(16) NOT NULL DEFAULT '',
|
||||
created_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (step_id) REFERENCES tactic_steps(id) ON DELETE CASCADE,
|
||||
|
|
|
|||
|
|
@ -165,9 +165,10 @@ try {
|
|||
// Schritt fuer Schritt in derselben Reihenfolge, die Zeichnungen wie bei "+ Kopie dieses Schritts"
|
||||
$sourceSteps = $pdo->prepare('SELECT id, title, description FROM tactic_steps WHERE tactic_id = ? ORDER BY sort_order, id');
|
||||
$sourceSteps->execute([(int) $source['id']]);
|
||||
// Mit derselben Kennung (ref) je Zeichnung - die Figuren laufen in der Kopie ebenso von Schritt zu Schritt.
|
||||
$copyShapes = $pdo->prepare(
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, color, width, points, created_by)
|
||||
SELECT ?, shape_type, label, color, width, points, ? FROM tactic_shapes WHERE step_id = ? ORDER BY id'
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, icon, color, width, points, ref, created_by)
|
||||
SELECT ?, shape_type, label, icon, color, width, points, ref, ? FROM tactic_shapes WHERE step_id = ? ORDER BY id'
|
||||
);
|
||||
$stepCount = 0;
|
||||
foreach ($sourceSteps->fetchAll() as $sourceStep) {
|
||||
|
|
@ -310,6 +311,7 @@ try {
|
|||
|
||||
// "Als Kopie": der neue Schritt startet mit den Zeichnungen des alten, damit
|
||||
// man nur noch einzeichnen muss, was sich von einem Schritt zum naechsten aendert.
|
||||
// Die Kennung (ref) bleibt gleich - verschobene Figuren laufen beim Blaettern an ihre neue Stelle.
|
||||
if ($copyFrom > 0) {
|
||||
$source = tactic_step_owner($copyFrom, $userId);
|
||||
if ((int) $source['tactic_id'] !== $tacticId) {
|
||||
|
|
@ -317,8 +319,8 @@ try {
|
|||
json_response(false, 'Der Schritt gehört zu einer anderen Taktik.');
|
||||
}
|
||||
$pdo->prepare(
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, color, width, points, created_by)
|
||||
SELECT ?, shape_type, label, color, width, points, ? FROM tactic_shapes WHERE step_id = ? ORDER BY id'
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, icon, color, width, points, ref, created_by)
|
||||
SELECT ?, shape_type, label, icon, color, width, points, ref, ? FROM tactic_shapes WHERE step_id = ? ORDER BY id'
|
||||
)->execute([$stepId, $userId, $copyFrom]);
|
||||
}
|
||||
tactic_touch($tacticId);
|
||||
|
|
@ -410,18 +412,23 @@ try {
|
|||
if ($points === null) {
|
||||
json_response(false, 'Die Zeichnung ist ungültig oder liegt außerhalb der Karte.');
|
||||
}
|
||||
$icon = tactic_clean_icon($type, $input['icon'] ?? null);
|
||||
if ($icon === null) {
|
||||
json_response(false, 'Unbekannte Figur - bitte die Seite neu laden.');
|
||||
}
|
||||
$color = (string) ($input['color'] ?? '');
|
||||
if (preg_match('/^#[0-9a-fA-F]{6}$/', $color) !== 1) {
|
||||
$color = '#ffd700';
|
||||
}
|
||||
$width = max(1, min(30, (int) ($input['width'] ?? 4)));
|
||||
$label = tactic_text($input, 'label', 200, 'die Beschriftung', $type === 'text');
|
||||
$ref = tactic_new_ref();
|
||||
|
||||
tactic_snapshot_if_due((int) $step['tactic_id'], $userId);
|
||||
db()->prepare(
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, color, width, points, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)'
|
||||
)->execute([(int) $step['id'], $type, $label, strtolower($color), $width, json_encode($points), $userId]);
|
||||
'INSERT INTO tactic_shapes (step_id, shape_type, label, icon, color, width, points, ref, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
)->execute([(int) $step['id'], $type, $label, $icon, strtolower($color), $width, json_encode($points), $ref, $userId]);
|
||||
$shapeId = (int) db()->lastInsertId();
|
||||
tactic_touch((int) $step['tactic_id']);
|
||||
|
||||
|
|
@ -429,11 +436,48 @@ try {
|
|||
'id' => $shapeId,
|
||||
'type' => $type,
|
||||
'label' => $label,
|
||||
'icon' => $icon,
|
||||
'color' => strtolower($color),
|
||||
'width' => $width,
|
||||
'points' => $points,
|
||||
'ref' => $ref,
|
||||
]]);
|
||||
|
||||
case 'shape_update':
|
||||
// Verschieben (neue Stuetzpunkte, gleiche Form) und Beschriften - Art, Farbe und Figur bleiben.
|
||||
$stmt = db()->prepare(
|
||||
'SELECT sh.id, sh.step_id, sh.shape_type, sh.label, sh.icon, sh.color, sh.width, sh.points, sh.ref, s.tactic_id
|
||||
FROM tactic_shapes sh JOIN tactic_steps s ON s.id = sh.step_id WHERE sh.id = ?'
|
||||
);
|
||||
$stmt->execute([(int) ($input['shape_id'] ?? 0)]);
|
||||
$shape = $stmt->fetch();
|
||||
if (!$shape) {
|
||||
json_response(false, 'Diese Zeichnung gibt es nicht mehr - bitte die Seite neu laden.');
|
||||
}
|
||||
tactic_load((int) $shape['tactic_id'], $userId);
|
||||
|
||||
$type = (string) $shape['shape_type'];
|
||||
$points = json_decode((string) $shape['points'], true);
|
||||
if (array_key_exists('points', $input)) {
|
||||
$points = tactic_clean_points($input['points'], $type);
|
||||
if ($points === null) {
|
||||
json_response(false, 'Die Zeichnung ist ungültig oder liegt außerhalb der Karte.');
|
||||
}
|
||||
}
|
||||
$label = (string) $shape['label'];
|
||||
if (array_key_exists('label', $input)) {
|
||||
$label = tactic_text($input, 'label', 200, 'die Beschriftung', $type === 'text');
|
||||
}
|
||||
|
||||
tactic_snapshot_if_due((int) $shape['tactic_id'], $userId);
|
||||
db()->prepare('UPDATE tactic_shapes SET points = ?, label = ? WHERE id = ?')
|
||||
->execute([json_encode($points), $label, (int) $shape['id']]);
|
||||
tactic_touch((int) $shape['tactic_id']);
|
||||
|
||||
$shape['points'] = json_encode($points);
|
||||
$shape['label'] = $label;
|
||||
json_response(true, '', ['shape' => tactic_shape_row($shape)]);
|
||||
|
||||
case 'shape_delete':
|
||||
$shapeId = (int) ($input['shape_id'] ?? 0);
|
||||
$stmt = db()->prepare(
|
||||
|
|
|
|||