fix live sortie turn lifecycle parity
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { getNextTurnAt, type TurnSchedule } from '../src/turn/calendar.js';
|
||||
|
||||
describe('turn calendar', () => {
|
||||
it('adds the active turn interval without cutting a general timestamp to a global boundary', () => {
|
||||
const schedule: TurnSchedule = { entries: [{ startMinute: 0, tickMinutes: 10 }] };
|
||||
const current = new Date('2026-07-26T13:38:45.123Z');
|
||||
|
||||
expect(getNextTurnAt(current, schedule).toISOString()).toBe('2026-07-26T13:48:45.123Z');
|
||||
});
|
||||
|
||||
it('uses the interval active at the current timestamp when crossing a schedule segment', () => {
|
||||
const schedule: TurnSchedule = {
|
||||
entries: [
|
||||
{ startMinute: 0, tickMinutes: 10 },
|
||||
{ startMinute: 14 * 60, tickMinutes: 5 },
|
||||
],
|
||||
};
|
||||
const current = new Date('2026-07-26T13:58:45.000Z');
|
||||
|
||||
expect(getNextTurnAt(current, schedule).toISOString()).toBe('2026-07-26T14:08:45.000Z');
|
||||
});
|
||||
});
|
||||
@@ -230,11 +230,13 @@ describe('war triggers', () => {
|
||||
const crewType = new WarCrewType(buildUnitSet().crewTypes![0]!);
|
||||
const nation = buildNation();
|
||||
const city = buildCity();
|
||||
const attackerGeneral = buildGeneral(80);
|
||||
attackerGeneral.turnTime = new Date('2026-07-26T13:38:45.000Z');
|
||||
|
||||
const attacker = new WarUnitGeneral(
|
||||
rng,
|
||||
config,
|
||||
buildGeneral(80),
|
||||
attackerGeneral,
|
||||
city,
|
||||
nation,
|
||||
true,
|
||||
@@ -255,6 +257,8 @@ describe('war triggers', () => {
|
||||
|
||||
attacker.setOppose(defender);
|
||||
defender.setOppose(attacker);
|
||||
expect(attackerGeneral.recentWarTime?.toISOString()).toBe('2026-07-26T13:38:45.000Z');
|
||||
expect(attackerGeneral.meta.recent_war_phase).toBe(0);
|
||||
|
||||
attacker.beginPhase();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user