| 12345678910111213141516171819202122232425262728293031323334 |
- <?php
- require_once __DIR__ . '/MapTemplateInterface.php';
- if (!class_exists('RuralTemplate')) {
- class RuralTemplate implements MapTemplateInterface
- {
- public static function id(): string { return 'rural'; }
- public static function applyTemplate(Map $map): void
- {
- // Simple rural: placer des zones de forêts dispersées
- $w = $map->getWidth();
- $h = $map->getHeight();
- for ($i = 0; $i < max(3, (int)floor(($w*$h)/50)); $i++) {
- $q = rand(0, max(0, $w-1));
- $r = rand(0, max(0, $h-1));
- if ($map->isValidCoordinate($q, $r)) {
- $map->setTile($q, $r, new Tile(['type' => 'forest']));
- }
- }
- }
- public static function tileDefinitions(): array
- {
- return [
- 'empty' => ['label' => 'Vide', 'walkable' => true],
- 'forest' => ['label' => 'Forêt', 'walkable' => false],
- 'field' => ['label' => 'Champ', 'walkable' => true]
- ];
- }
- }
- }
|