| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- if (!interface_exists('MapTemplateInterface')) {
- interface MapTemplateInterface
- {
- public static function id(): string;
- public static function applyTemplate($map): void;
- public static function tileDefinitions(): array;
- }
- }
- class RuralTemplate implements MapTemplateInterface
- {
- public static function id(): string
- {
- return 'rural';
- }
- public static function applyTemplate($map): void
- {
- if (!method_exists($map, 'getHexes')) return;
- $hexes = $map->getHexes();
- $i = 0;
- foreach ($hexes as $k => $h) {
- // marquer approximativement 10% comme forêt
- if ($i++ % 10 === 0) {
- if (method_exists($h, 'setTile')) $h->setTile('forest');
- }
- }
- }
- public static function tileDefinitions(): array
- {
- return [
- ['id' => 'forest', 'name' => 'Forêt', 'color' => '#228B22', 'asset' => '/assets/tiles/forest.svg'],
- ['id' => 'field', 'name' => 'Champ', 'color' => '#F4A460', 'asset' => '/assets/tiles/field.svg'],
- ['id' => 'road_straight', 'name' => 'Route droite', 'color' => '#D2B48C', 'asset' => '/assets/tiles/road-straight.svg'],
- ['id' => 'road_right', 'name' => 'Route tourne à droite', 'color' => '#D2B48C', 'asset' => '/assets/tiles/road-right.svg'],
- ['id' => 'road_left', 'name' => 'Route tourne à gauche', 'color' => '#D2B48C', 'asset' => '/assets/tiles/road-left.svg'],
- ['id' => 'villa', 'name' => 'Villa', 'color' => '#F5DEB3', 'asset' => '/assets/tiles/villa.svg']
- ];
- }
- }
|