| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- if (!interface_exists('MapTemplateInterface')) {
- interface MapTemplateInterface
- {
- public static function id(): string;
- public static function applyTemplate($map): void;
- public static function tileDefinitions(): array;
- }
- }
- class UrbanTemplate implements MapTemplateInterface
- {
- public static function id(): string
- {
- return 'urban';
- }
- public static function applyTemplate($map): void
- {
- // Exemple simple : marquer quelques tuiles centrales comme buildings
- if (!method_exists($map, 'getHexes')) return;
- $hexes = $map->getHexes();
- $count = count($hexes);
- $i = 0;
- foreach ($hexes as $k => $h) {
- if ($i++ % 7 === 0) {
- if (method_exists($h, 'setTile')) $h->setTile('building');
- }
- if ($i > 30) break;
- }
- }
- public static function tileDefinitions(): array
- {
- return [
- ['id' => 'building', 'name' => 'Bâtiment', 'color' => '#b0b0b0'],
- ['id' => 'road', 'name' => 'Route', 'color' => '#d2b48c'],
- ['id' => 'park', 'name' => 'Parc', 'color' => '#7fc97f']
- ];
- }
- }
|