13 lines
605 B
TypeScript
13 lines
605 B
TypeScript
// The world starts at 0|0: coordinates run from −size/2 to size/2 − 1 on both axes,
|
||
// negative included, so a 1000-field map spans −500 to 499.
|
||
|
||
export const mapMin = (size: number) => -Math.floor(size / 2)
|
||
export const mapMax = (size: number) => mapMin(size) + size - 1
|
||
|
||
/**
|
||
* The continent of a field, named like Die Stämme by its 100 × 100 block's row and column
|
||
* counted from the top-left: 0|0 is the corner of K44, K45, K54 and K55.
|
||
*/
|
||
export const continentOf = (x: number, y: number, size = 1000) =>
|
||
`K${Math.floor((y - mapMin(size)) / 100)}${Math.floor((x - mapMin(size)) / 100)}`
|