2026-07-07 23:05:22 +02:00
|
|
|
// Leaflet is loaded via CDN in index.html
|
|
|
|
|
// @ts-expect-error - Leaflet global
|
|
|
|
|
const L = window.L;
|
|
|
|
|
|
|
|
|
|
export interface MapMarker {
|
|
|
|
|
id: string;
|
|
|
|
|
lat: number;
|
|
|
|
|
lng: number;
|
|
|
|
|
label: string;
|
|
|
|
|
dreadLevel: number; // 0-3
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const LOCATIONS: Omit<MapMarker, 'dreadLevel'>[] = [
|
|
|
|
|
{ id: 'rosengard', lat: 55.5894, lng: 13.0414, label: 'Källaren i Rosengård' },
|
|
|
|
|
{ id: 'varnhem', lat: 55.5982, lng: 13.0058, label: 'Värnhemstorget' },
|
|
|
|
|
{ id: 'torso', lat: 55.6130, lng: 12.9758, label: 'Turning Torso' },
|
|
|
|
|
{ id: 'oresund', lat: 55.5789, lng: 12.9200, label: 'Øresundsbron' },
|
|
|
|
|
{ id: 'ribersborg',lat: 55.6063, lng: 12.9652, label: 'Ribersborgsstranden' },
|
|
|
|
|
{ id: 'davidshall',lat: 55.5963, lng: 13.0021, label: 'Davidshallsgatan' },
|
|
|
|
|
{ id: 'stortorget',lat: 55.6047, lng: 13.0038, label: 'Stortorget' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
type LeafletMap = ReturnType<typeof L.map>;
|
|
|
|
|
type LeafletMarker = ReturnType<typeof L.circleMarker>;
|
|
|
|
|
|
|
|
|
|
let map: LeafletMap | null = null;
|
|
|
|
|
const markers = new Map<string, LeafletMarker>();
|
|
|
|
|
|
|
|
|
|
function dreadColor(level: number): string {
|
|
|
|
|
return ['#1a1a2e', '#4a1a4a', '#8b0a8b', '#cc00cc'][Math.min(level, 3)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dreadRadius(level: number): number {
|
|
|
|
|
return [6, 10, 16, 24][Math.min(level, 3)];
|
|
|
|
|
}
|
|
|
|
|
|
Add help modal, changelog, map visits, Dockerfile, CI
- Help modal (? button or keyboard shortcut): how-to-play in Swedish,
flavor text, full changelog sourced from src/data/version.ts
- src/data/version.ts: versioned changelog entries, in-universe Malmö voice
- Map zone clicks: each location on the Leaflet map is now clickable.
Unlocked cult areas give resources + log entries. Locked locations show
lore hints. 30s cooldown per location so it's a decision, not a spam button.
- Dockerfile + nginx.conf + docker-compose.yml (port 5684)
- Gitea CI workflow (identical to 2048 — derives image from repo path, needs
TKNTKN secret, pushes :latest and :sha tags)
- README.md with mechanics summary and docker instructions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 23:31:37 +02:00
|
|
|
export function initMap(containerId: string, onClick: (id: string) => void): void {
|
2026-07-07 23:05:22 +02:00
|
|
|
if (!L) return;
|
|
|
|
|
map = L.map(containerId, {
|
|
|
|
|
center: [55.597, 13.002],
|
|
|
|
|
zoom: 12,
|
|
|
|
|
zoomControl: false,
|
|
|
|
|
attributionControl: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
|
|
|
|
|
maxZoom: 18,
|
|
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
|
|
for (const loc of LOCATIONS) {
|
|
|
|
|
const m = L.circleMarker([loc.lat, loc.lng], {
|
|
|
|
|
radius: 6,
|
|
|
|
|
color: '#1a1a2e',
|
|
|
|
|
fillColor: '#1a1a2e',
|
|
|
|
|
fillOpacity: 0.3,
|
|
|
|
|
weight: 1,
|
|
|
|
|
}).addTo(map).bindTooltip(loc.label, { className: 'map-tooltip', permanent: false });
|
Add help modal, changelog, map visits, Dockerfile, CI
- Help modal (? button or keyboard shortcut): how-to-play in Swedish,
flavor text, full changelog sourced from src/data/version.ts
- src/data/version.ts: versioned changelog entries, in-universe Malmö voice
- Map zone clicks: each location on the Leaflet map is now clickable.
Unlocked cult areas give resources + log entries. Locked locations show
lore hints. 30s cooldown per location so it's a decision, not a spam button.
- Dockerfile + nginx.conf + docker-compose.yml (port 5684)
- Gitea CI workflow (identical to 2048 — derives image from repo path, needs
TKNTKN secret, pushes :latest and :sha tags)
- README.md with mechanics summary and docker instructions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 23:31:37 +02:00
|
|
|
m.on('click', () => onClick(loc.id));
|
2026-07-07 23:05:22 +02:00
|
|
|
markers.set(loc.id, m);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function updateMap(dread: number, areas: { rosengard: boolean; varnhem: boolean; torso: boolean }): void {
|
|
|
|
|
if (!map) return;
|
|
|
|
|
|
|
|
|
|
const levels: Record<string, number> = {
|
|
|
|
|
rosengard: areas.rosengard ? Math.min(3, Math.floor(dread / 40) + 1) : Math.min(1, Math.floor(dread / 60)),
|
|
|
|
|
varnhem: areas.varnhem ? Math.min(3, Math.floor(dread / 35) + 1) : 0,
|
|
|
|
|
torso: areas.torso ? 3 : Math.min(1, Math.floor(dread / 80)),
|
|
|
|
|
oresund: Math.min(2, Math.floor(dread / 50)),
|
|
|
|
|
ribersborg: Math.min(2, Math.floor(dread / 45)),
|
|
|
|
|
davidshall: Math.min(1, Math.floor(dread / 70)),
|
|
|
|
|
stortorget: Math.min(2, Math.floor(dread / 55)),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const [id, marker] of markers) {
|
|
|
|
|
const level = levels[id] ?? 0;
|
|
|
|
|
marker.setStyle({
|
|
|
|
|
radius: dreadRadius(level),
|
|
|
|
|
color: dreadColor(level),
|
|
|
|
|
fillColor: dreadColor(level),
|
|
|
|
|
fillOpacity: 0.15 + level * 0.2,
|
|
|
|
|
weight: level > 0 ? 2 : 1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|