Maps
Generate a self-contained HTML map from world config data. Output to stuff/world-map.html.
Design
- Squares = regions, circles = locations
- No text on map - hover tooltips show name, coordinates, radius, description
Data Sources
const settings = JSON.parse(fs.readFileSync('tabs/settings.json'))
const realms = JSON.parse(fs.readFileSync('tabs/realms.json'))
const regions = JSON.parse(fs.readFileSync('tabs/regions.json'))
const locations = JSON.parse(fs.readFileSync('tabs/locations.json'))
const regionSize = settings.locationSettings.regionSize // e.g., 100
const coordRange = regionSize / 2 // e.g., 50
Coordinate System
- Region coordinates (in regions.json): Position within the realm grid (e.g., x:0, y:1)
- Location coordinates (in locations.json): Position within the region, where 0,0 is center
regionSize: 100 means location coordinates span -50 to 50
- Y-axis: Positive y goes UP (invert for CSS:
top = centerY - (loc.y * scale))
Data Grouping
// Group regions by realm
const realmRegions = {};
Object.entries(regions.regions).forEach(([key, r]) => {
if (!realmRegions[r.realm]) realmRegions[r.realm] = [];
realmRegions[r.realm].push({ key, ...r });
});
// Group locations by region
const locsByRegion = {};
Object.entries(locations.locations).forEach(([key, loc]) => {
if (!locsByRegion[loc.region]) locsByRegion[loc.region] = [];
locsByRegion[loc.region].push({ key, ...loc });
});
Region Grid Layout
For each realm, build a grid from region x,y coordinates:
function getGridBounds(regionList) {
let minX = Infinity, maxX = -Infinity;
let minY = Infinity, maxY = -Infinity;
regionList.forEach(r => {
if (r.x !== undefined && r.y !== undefined) {
minX = Math.min(minX, r.x); maxX = Math.max(maxX, r.x);
minY = Math.min(minY, r.y); maxY = Math.max(maxY, r.y);
}
});
return { minX, maxX, minY, maxY };
}
// Grid dimensions: (maxX - minX + 1) columns, (maxY - minY + 1) rows
Location Positioning
Plot locations within their region cell using x,y coordinates relative to center:
const coordRange = regionSize / 2; // e.g., 50
const scale = cellSize / (coordRange * 2);
// For each location:
const scaledDiameter = Math.max(6, loc.radius * 2 * scale);
const centerX = cellWidth / 2;
const centerY = cellHeight / 2;
const left = centerX + (loc.x * scale) - scaledDiameter / 2;
const top = centerY - (loc.y * scale) - scaledDiameter / 2; // NEGATIVE for y inversion
Steps
- Read config files (settings, realms, regions, locations)
- Group regions by realm, locations by region
- For each realm, determine grid bounds from region coordinates
- Render realm as CSS grid, place regions at their x,y positions
- Within each region cell, plot locations using the positioning formula
- Add hover tooltips for regions (name, description) and locations (name, x, y, radius, description)
- Write to
stuff/world-map.html, open in browser
1---2name: maps3description: Generate visual maps of the world showing realms, regions, and locations. Use when the user wants to see a map or visualize the world layout.4---56# Maps78Generate a self-contained HTML map from world config data. Output to `stuff/world-map.html`.910## Design1112- Squares = regions, circles = locations13- No text on map - hover tooltips show name, coordinates, radius, description1415## Data Sources1617```javascript18const settings = JSON.parse(fs.readFileSync('tabs/settings.json'))19const realms = JSON.parse(fs.readFileSync('tabs/realms.json'))20const regions = JSON.parse(fs.readFileSync('tabs/regions.json'))21const locations = JSON.parse(fs.readFileSync('tabs/locations.json'))2223const regionSize = settings.locationSettings.regionSize // e.g., 10024const coordRange = regionSize / 2 // e.g., 5025```2627## Coordinate System2829- **Region coordinates** (in regions.json): Position within the realm grid (e.g., x:0, y:1)30- **Location coordinates** (in locations.json): Position within the region, where 0,0 is center31- `regionSize: 100` means location coordinates span -50 to 5032- **Y-axis**: Positive y goes UP (invert for CSS: `top = centerY - (loc.y * scale)`)3334## Data Grouping3536```javascript37// Group regions by realm38const realmRegions = {};39Object.entries(regions.regions).forEach(([key, r]) => {40 if (!realmRegions[r.realm]) realmRegions[r.realm] = [];41 realmRegions[r.realm].push({ key, ...r });42});4344// Group locations by region45const locsByRegion = {};46Object.entries(locations.locations).forEach(([key, loc]) => {47 if (!locsByRegion[loc.region]) locsByRegion[loc.region] = [];48 locsByRegion[loc.region].push({ key, ...loc });49});50```5152## Region Grid Layout5354For each realm, build a grid from region x,y coordinates:5556```javascript57function getGridBounds(regionList) {58 let minX = Infinity, maxX = -Infinity;59 let minY = Infinity, maxY = -Infinity;60 regionList.forEach(r => {61 if (r.x !== undefined && r.y !== undefined) {62 minX = Math.min(minX, r.x); maxX = Math.max(maxX, r.x);63 minY = Math.min(minY, r.y); maxY = Math.max(maxY, r.y);64 }65 });66 return { minX, maxX, minY, maxY };67}68// Grid dimensions: (maxX - minX + 1) columns, (maxY - minY + 1) rows69```7071## Location Positioning7273Plot locations within their region cell using x,y coordinates relative to center:7475```javascript76const coordRange = regionSize / 2; // e.g., 5077const scale = cellSize / (coordRange * 2);7879// For each location:80const scaledDiameter = Math.max(6, loc.radius * 2 * scale);81const centerX = cellWidth / 2;82const centerY = cellHeight / 2;83const left = centerX + (loc.x * scale) - scaledDiameter / 2;84const top = centerY - (loc.y * scale) - scaledDiameter / 2; // NEGATIVE for y inversion85```8687## Steps88891. Read config files (settings, realms, regions, locations)902. Group regions by realm, locations by region913. For each realm, determine grid bounds from region coordinates924. Render realm as CSS grid, place regions at their x,y positions935. Within each region cell, plot locations using the positioning formula946. Add hover tooltips for regions (name, description) and locations (name, x, y, radius, description)957. Write to `stuff/world-map.html`, open in browser