game-village-politics-backend/tests/Unit/Game/SeasonTest.php

32 lines
1.2 KiB
PHP
Raw Normal View History

<?php
use App\Game\Map\Season;
use Carbon\CarbonImmutable;
it('brings the crowns after 30 days and lets a holder win after 7, at world speed', function () {
$start = CarbonImmutable::parse('2026-11-01 00:00:00');
expect((new Season(gameConfig()))->crownsAt($start)->toDateTimeString())->toBe('2026-12-01 00:00:00')
->and((new Season(gameConfig(['world' => ['speed' => 100]])))->crownsAt($start)->toDateTimeString())->toBe('2026-11-01 07:12:00')
->and((new Season(gameConfig()))->holdSeconds())->toBe(7 * 86400);
});
it('places five crowns evenly round 0|0', function () {
expect((new Season(gameConfig()))->spots())->toBe([[0, -10], [10, -3], [6, 8], [-6, 8], [-10, -3]]);
});
it('needs more than half of the crowns to hold them', function () {
$season = new Season(gameConfig());
expect($season->needed())->toBe(3)
->and($season->holder([4, 4, 4, null, 9]))->toBe(4)
->and($season->holder([4, 4, 9, 9, null]))->toBeNull()
->and($season->holder([null, null, null, null, null]))->toBeNull();
});
it('names the next world', function () {
expect(Season::next('w1'))->toBe('w2')
->and(Season::next('World 9'))->toBe('World 10')
->and(Season::next('dev'))->toBe('dev2');
});