feat: createNoopDaemonTransport 함수 추가 및 토너먼트 상태 처리 개선, 캘린더 핸들러 반환 타입 수정
This commit is contained in:
@@ -28,6 +28,12 @@ class MemoryRedis {
|
||||
|
||||
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null;
|
||||
|
||||
const createNoopDaemonTransport = (): TurnDaemonTransport => ({
|
||||
sendCommand: async () => 'ok',
|
||||
requestCommand: async () => null,
|
||||
requestStatus: async () => null,
|
||||
});
|
||||
|
||||
const createTournamentState = (overrides: Partial<TournamentState> = {}): TournamentState => {
|
||||
const now = new Date().toISOString();
|
||||
return {
|
||||
@@ -174,6 +180,8 @@ const runTournamentToCompletion = async (options: {
|
||||
throw new Error('토너먼트 상태가 없습니다.');
|
||||
}
|
||||
|
||||
const daemonTransport = createNoopDaemonTransport();
|
||||
|
||||
for (let i = 0; i < 2000; i += 1) {
|
||||
if (state.stage === 0) {
|
||||
return state;
|
||||
@@ -184,7 +192,7 @@ const runTournamentToCompletion = async (options: {
|
||||
await options.store.setState(state);
|
||||
}
|
||||
if (state.stage >= 1 && state.stage <= 6) {
|
||||
state = await applyPreBattleStage(options.store, options.prisma, state, options.baseSeed);
|
||||
state = await applyPreBattleStage(options.store, options.prisma, state, options.baseSeed, daemonTransport);
|
||||
continue;
|
||||
}
|
||||
if (state.stage >= 7 && state.stage <= 10) {
|
||||
@@ -337,7 +345,7 @@ describe('tournament worker (in-memory)', () => {
|
||||
|
||||
const initialState = state ?? createTournamentState({ stage: 1 });
|
||||
await store.setState(initialState);
|
||||
const afterJoin = await applyPreBattleStage(store, prisma, initialState, 'seed');
|
||||
const afterJoin = await applyPreBattleStage(store, prisma, initialState, 'seed', createNoopDaemonTransport());
|
||||
const participants = await store.getParticipants();
|
||||
|
||||
expect(afterJoin.stage).toBe(2);
|
||||
|
||||
@@ -2,10 +2,10 @@ import type { TurnCalendarHandler } from './inMemoryWorld.js';
|
||||
|
||||
export const composeCalendarHandlers = (
|
||||
...handlers: Array<TurnCalendarHandler | null | undefined>
|
||||
): TurnCalendarHandler | null => {
|
||||
): TurnCalendarHandler | undefined => {
|
||||
const resolved = handlers.filter(Boolean) as TurnCalendarHandler[];
|
||||
if (resolved.length === 0) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
onMonthChanged: (context) => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
ScenarioMeta,
|
||||
Troop,
|
||||
TurnCommandProfile,
|
||||
TurnCommandEnv,
|
||||
UnitSetDefinition,
|
||||
} from '@sammo-ts/logic';
|
||||
import {
|
||||
@@ -353,32 +354,6 @@ const resolveDefinition = (
|
||||
fallback: GeneralActionDefinition
|
||||
): GeneralActionDefinition => definitions.get(actionKey) ?? fallback;
|
||||
|
||||
const resolveNpcTaxRate = (cities: City[]): number => {
|
||||
if (cities.length === 0) {
|
||||
return 15;
|
||||
}
|
||||
let pop = 0;
|
||||
let all = 0;
|
||||
for (const city of cities) {
|
||||
const popRatio = city.populationMax > 0 ? city.population / city.populationMax : 0;
|
||||
pop += popRatio;
|
||||
all += calcCityDevRatio(city);
|
||||
}
|
||||
pop /= cities.length;
|
||||
all /= cities.length;
|
||||
const avg = (pop + all) / 2;
|
||||
if (avg > 0.95) {
|
||||
return 25;
|
||||
}
|
||||
if (avg > 0.7) {
|
||||
return 20;
|
||||
}
|
||||
if (avg > 0.5) {
|
||||
return 15;
|
||||
}
|
||||
return 10;
|
||||
};
|
||||
|
||||
export const createReservedTurnHandler = async (options: {
|
||||
reservedTurns: InMemoryReservedTurnStore;
|
||||
scenarioConfig: ScenarioConfig;
|
||||
|
||||
@@ -13,7 +13,13 @@ export interface StatBlock {
|
||||
intelligence: number;
|
||||
}
|
||||
|
||||
export type TriggerValue = boolean | number | string;
|
||||
export type TriggerValuePrimitive = boolean | number | string;
|
||||
|
||||
export interface TriggerValueObject {
|
||||
[key: string]: TriggerValuePrimitive | TriggerValueObject;
|
||||
}
|
||||
|
||||
export type TriggerValue = TriggerValuePrimitive | TriggerValueObject;
|
||||
|
||||
export interface GeneralTriggerState {
|
||||
// Trigger 시스템에서 사용하는 확장 슬롯.
|
||||
|
||||
Reference in New Issue
Block a user