| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?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' => '#2b7a2b'],
- ['id' => 'field', 'name' => 'Champ', 'color' => '#f4ecb0']
- ];
- }
- }
|