Implement crew type execution model

This commit is contained in:
2026-07-25 05:16:11 +00:00
parent 2824e5af13
commit c5da507df9
24 changed files with 1165 additions and 48 deletions
+9 -8
View File
@@ -1,13 +1,6 @@
import type { City, General, Nation } from '@sammo-ts/logic/domain/entities.js';
import type { CrewTypeDefinition, CrewTypeRequirement, MapDefinition, UnitSetDefinition } from './types.js';
import {
asNullableStringArray,
asNumber,
asRecord,
asString,
asStringArray,
isRecord,
} from '@sammo-ts/common';
import { asNullableStringArray, asNumber, asRecord, asString, asStringArray, isRecord } from '@sammo-ts/common';
import { UnitSetDefinitionInputSchema } from '../resources/unitSetSchema.js';
const DEFAULT_REGION_MAP: Record<string, number> = {
@@ -181,6 +174,14 @@ export const getTechAbility = (tech: number): number => getTechLevel(tech) * 25;
export const getTechCost = (tech: number): number => 1 + getTechLevel(tech) * 0.15;
export const getCrewTypePickScore = (crewType: CrewTypeDefinition, tech: number, armPerPhase: number): number => {
let score = armPerPhase + crewType.attack + crewType.defence + getTechAbility(tech) * 2;
score *= 1 + crewType.speed / 2;
score /= Math.max(1 - crewType.avoid / 100, 0.1);
score *= 1 + crewType.magicCoef / 2;
return score;
};
export interface CrewTypeAvailabilityContext {
general: General;
nation: Nation | null;