Skip to content

KcdMp.mapInfo

A level’s map - its size, its towns and where the world lies on it.

Resolves with the map of level (the server’s level when it is left out), or null when that level has no map. Its width and height are the region map’s full size in pixels: every position it gives, and every point KcdMp.worldToMap gives, is in those pixels. For a picture shown at another size, scale by its shown width / width - or use x / width and y / height as fractions of the picture.

towns lists the towns with a detailed map of their own and the rectangle each covers on the region map, so a page can lay a town’s picture over the region’s at the right place, or open it on its own with KcdMp.mapImage({ town }). In a browser, in mock mode, it resolves with the Kuttenberg and Trosky regions’ sizes and no towns.

await KcdMp.mapInfo(level?)
Parameter Type
level string "kutnohorsko", "trosecko", "klaster", or "current" (the default): the server’s level (optional)

Promise<KcdMpMapInfo | null> - the level’s map, or null when it has none; rejects when level is not a level’s name

A level’s map, as KcdMp.mapInfo gives it.

Field Type
level string the level’s name
picture boolean false when the level has no region map (Sedletz): only its towns’ maps exist
width number the region map’s width in pixels at its full size - the size the positions below are given in; a picture of another width scales them by its width / width
height number the region map’s height in pixels at its full size
tileSize number the tiles’ size in pixels, 256
maxZoom number the largest zoom of the tiles, 5 - the full size; each zoom below it halves the map
transform number[] the world’s place on the map: [a, b, c, d, e, f] with x = a * worldX + b * worldY + c and y = d * worldX + e * worldY + f - what KcdMp.worldToMap uses
towns KcdMpMapTown[] the towns that have a detailed map of their own

A town’s detailed map and where it lies on its region’s map.

Field Type
name string the town map’s name, for KcdMp.mapImage({ town }) ("kutna_hora", "suchdol", "trosky" …)
x number the left edge of the town’s map on the region map, in the region map’s pixels at full size
y number the top edge, likewise
width number the width the town’s map covers on the region map
height number the height the town’s map covers on the region map
pictureWidth number the town map’s own width at its full size (it is drawn finer than the region’s)
pictureHeight number the town map’s own height at its full size
const info = await KcdMp.mapInfo();
if (info && info.picture) {
document.querySelector("#map").src = KcdMp.mapImage({ width: 1536 });
}
for (const town of info ? info.towns : []) {
console.log(town.name, "covers", town.width, "x", town.height, "pixels of the region map");
}

KcdMp.mapImage · KcdMp.mapTiles · KcdMp.worldToMap · the The game’s pictures and typefaces group of the index