21 lines
568 B
PHP
21 lines
568 B
PHP
<?php
|
||
|
||
namespace App\Game\Map;
|
||
|
||
/**
|
||
* Continents are 100 × 100 blocks named by their row and column counted from the map's
|
||
* top-left corner, as in Die Stämme. The world starts at 0|0, the corner of K44, K45,
|
||
* K54 and K55; on a 1000-field map −500|−500 lies in K00 and 499|499 in K99.
|
||
*/
|
||
final class Continent
|
||
{
|
||
public const SIZE = 100;
|
||
|
||
public static function of(int $x, int $y, int $mapSize = 1000): string
|
||
{
|
||
$offset = intdiv($mapSize, 2);
|
||
|
||
return 'K'.intdiv($y + $offset, self::SIZE).intdiv($x + $offset, self::SIZE);
|
||
}
|
||
}
|