fix: the World 1 pace migration keeps started_at, since a season now counts real days
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ea593d932b
commit
7157364a0d
|
|
@ -18,9 +18,8 @@ return new class extends Migration
|
||||||
//
|
//
|
||||||
// Lazy values are worth world speed times the time passed, so every w1 village is
|
// 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
|
// 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
|
// counted again at speed 4. Then its food timer follows the new rates. started_at stays:
|
||||||
// clock moves the same way: started_at moves up so the world days already played stay
|
// a season counts real days, so the crowns come when they would have. Timers already
|
||||||
// played, and the crowns still come after 30 world days, not at once. Timers already
|
|
||||||
// set keep their times: build orders under way, recruits, movements, levies, waves and
|
// set keep their times: build orders under way, recruits, movements, levies, waves and
|
||||||
// events. Only new ones run at the new speed.
|
// events. Only new ones run at the new speed.
|
||||||
//
|
//
|
||||||
|
|
@ -60,12 +59,7 @@ return new class extends Migration
|
||||||
foreach (self::PACE as $key => $value) {
|
foreach (self::PACE as $key => $value) {
|
||||||
Arr::set($config, $key, $value);
|
Arr::set($config, $key, $value);
|
||||||
}
|
}
|
||||||
$world->config = $config;
|
$world->update(['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();
|
|
||||||
|
|
||||||
// Read again, so the village sees its world at the new pace.
|
// Read again, so the village sees its world at the new pace.
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
|
|
|
||||||
|
|
@ -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');
|
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();
|
startVillage();
|
||||||
worldOne()->update(['started_at' => now()->subDays(8)]);
|
worldOne()->update(['started_at' => now()->subDays(8)]);
|
||||||
|
|
||||||
paceMigration()->speedUp(now()->toImmutable());
|
paceMigration()->speedUp(now()->toImmutable());
|
||||||
|
|
||||||
// Eight world days played: 22 to go, 5.5 real days at speed 4.
|
|
||||||
$world = worldOne();
|
$world = worldOne();
|
||||||
expect($world->started_at->toDateTimeString())->toBe('2026-11-01 12: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-09 00: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 () {
|
it('changes nothing on a second run, and nothing without a World 1', function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue