diff --git a/database/migrations/2026_11_03_210000_world_one_at_speed_four.php b/database/migrations/2026_11_03_210000_world_one_at_speed_four.php index 721313a..ac66861 100644 --- a/database/migrations/2026_11_03_210000_world_one_at_speed_four.php +++ b/database/migrations/2026_11_03_210000_world_one_at_speed_four.php @@ -18,9 +18,8 @@ return new class extends Migration // // Lazy values are worth world speed times the time passed, so every w1 village is // settled first, at the old speed: its stock and loyalty, so what speed 1 earned isn't - // counted again at speed 4. Then its food timer follows the new rates. The world's own - // clock moves the same way: started_at moves up so the world days already played stay - // played, and the crowns still come after 30 world days, not at once. Timers already + // counted again at speed 4. Then its food timer follows the new rates. started_at stays: + // a season counts real days, so the crowns come when they would have. Timers already // set keep their times: build orders under way, recruits, movements, levies, waves and // events. Only new ones run at the new speed. // @@ -60,12 +59,7 @@ return new class extends Migration foreach (self::PACE as $key => $value) { Arr::set($config, $key, $value); } - $world->config = $config; - if ($world->started_at?->lessThan($now)) { - $played = $now->getTimestampMs() - $world->started_at->getTimestampMs(); - $world->started_at = $now->subMilliseconds((int) round($played * $before->speed() / self::PACE['world.speed'])); - } - $world->save(); + $world->update(['config' => $config]); // Read again, so the village sees its world at the new pace. foreach ($ids as $id) { diff --git a/tests/Feature/WorldOnePaceTest.php b/tests/Feature/WorldOnePaceTest.php index 0c22928..46ecef3 100644 --- a/tests/Feature/WorldOnePaceTest.php +++ b/tests/Feature/WorldOnePaceTest.php @@ -100,16 +100,15 @@ it('keeps the timers already set and runs only new ones at speed 4', function () expect(collect(shown($village)['queue'])->sole()['finishes_at'])->toBe('2026-11-03T12:23:46.000Z'); }); -it('moves the world clock so the days played stay played and the crowns do not come at once', function () { +it('keeps the start, so the crowns still come 30 real days after it', function () { startVillage(); worldOne()->update(['started_at' => now()->subDays(8)]); paceMigration()->speedUp(now()->toImmutable()); - // Eight world days played: 22 to go, 5.5 real days at speed 4. $world = worldOne(); - expect($world->started_at->toDateTimeString())->toBe('2026-11-01 12:00:00') - ->and((new Season($world->gameConfig()))->crownsAt($world->started_at)->toDateTimeString())->toBe('2026-11-09 00:00:00'); + expect($world->started_at->toDateTimeString())->toBe('2026-10-26 12:00:00') + ->and((new Season($world->gameConfig()))->crownsAt($world->started_at)->toDateTimeString())->toBe('2026-11-25 12:00:00'); }); it('changes nothing on a second run, and nothing without a World 1', function () {