refactor: update test setup, introduce system environment for commands, and streamline frontend build configuration.

This commit is contained in:
2026-01-07 17:17:04 +00:00
parent 57e9bbb4ea
commit 38a8d33242
22 changed files with 518 additions and 432 deletions
+8
View File
@@ -3,6 +3,14 @@
"private": true,
"version": "0.0.0",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/game-api",
"dev": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/game-api --watch",
+5 -5
View File
@@ -217,7 +217,7 @@ const resolveCityRiceConsumption = (options: {
year: number;
startYear: number;
}): number => {
const cityReport = options.battle.reports.find((report) => report.type === 'city');
const cityReport = options.battle.reports.find((report: any) => report.type === 'city');
if (!cityReport) {
return 0;
}
@@ -225,7 +225,7 @@ const resolveCityRiceConsumption = (options: {
return 0;
}
const crewType = options.unitSet.crewTypes?.find((item) => item.id === options.castleCrewTypeId);
const crewType = options.unitSet.crewTypes?.find((item: any) => item.id === options.castleCrewTypeId);
const riceCoef = crewType?.rice ?? 1;
const tech = Number(options.defenderNation.meta.tech ?? 0);
const trainAtmos = resolveCityTrainAtmos(options.year, options.startYear);
@@ -333,7 +333,7 @@ export const processBattleSimJob = (payload: BattleSimJobPayload): BattleSimResu
});
lastBattle = outcome;
const attackerReport = outcome.reports.find((report) => report.type === 'general' && report.isAttacker);
const attackerReport = outcome.reports.find((report: any) => report.type === 'general' && report.isAttacker);
const killed = attackerReport?.killed ?? 0;
const dead = attackerReport?.dead ?? 0;
@@ -370,7 +370,7 @@ export const processBattleSimJob = (payload: BattleSimJobPayload): BattleSimResu
defenderAvgRice += (defenderRiceInit - defenderRiceAfter + cityRice) * weight;
const attackerActivated = outcome.metrics?.attackerActivatedSkills ?? {};
for (const [skillName, value] of Object.entries(attackerActivated)) {
for (const [skillName, value] of Object.entries(attackerActivated) as [string, number][]) {
attackerSkills[skillName] = (attackerSkills[skillName] ?? 0) + value * weight;
}
@@ -380,7 +380,7 @@ export const processBattleSimJob = (payload: BattleSimJobPayload): BattleSimResu
defendersSkills.push({});
}
const bucket = defendersSkills[defIdx]!;
for (const [skillName, value] of Object.entries(defenderActivated[defIdx]!)) {
for (const [skillName, value] of Object.entries(defenderActivated[defIdx]!) as [string, number][]) {
bucket[skillName] = (bucket[skillName] ?? 0) + value * weight;
}
}
+2
View File
@@ -35,6 +35,8 @@ export type NationRow = GamePrisma.NationGetPayload<Record<string, never>>;
export type TroopRow = GamePrisma.TroopGetPayload<Record<string, never>>;
export type JsonValue = GamePrisma.JsonValue;
export type JsonObject = GamePrisma.JsonObject;
export type JsonArray = GamePrisma.JsonArray;
export type InputJsonValue = GamePrisma.InputJsonValue;
export type DatabaseClient = InfraDatabaseClient;
+6
View File
@@ -22,6 +22,12 @@ export * from './battleSim/inMemoryTransport.js';
export * from './battleSim/keys.js';
export * from './battleSim/worker.js';
// Types for TRPC consumer
export type { MessageView } from './messages/store.js';
export type { TurnCommandTable } from './turns/commandTable.js';
export type { ReservedTurnView } from './turns/reservedTurns.js';
export type { JsonObject, JsonArray } from './context.js';
const isMain = (): boolean => {
if (!process.argv[1]) {
return false;
+1 -1
View File
@@ -328,7 +328,7 @@ const evaluateAvailability = (
reason: result.reason,
};
}
const missingKinds = new Set(result.missing.map((req) => req.kind));
const missingKinds = new Set(result.missing.map((req: any) => req.kind));
const inputOnlyMissing =
missingKinds.size === 0 ? reqArg : Array.from(missingKinds).every((kind) => INPUT_REQUIREMENT_KINDS.has(kind));
if (inputOnlyMissing) {
+32 -11
View File
@@ -3,20 +3,41 @@
"compilerOptions": {
"outDir": "dist",
"composite": true,
"rootDir": "src",
"baseUrl": ".",
"paths": {
"@sammo-ts/common": ["../../packages/common/src/index.ts"],
"@sammo-ts/common/*": ["../../packages/common/src/*"],
"@sammo-ts/infra": ["../../packages/infra/src/index.ts"],
"@sammo-ts/infra/*": ["../../packages/infra/src/*"],
"@sammo-ts/logic": ["../../packages/logic/src/index.ts"],
"@sammo-ts/logic/*": ["../../packages/logic/src/*"]
"@sammo-ts/common": [
"../../packages/common/src/index.ts"
],
"@sammo-ts/common/*": [
"../../packages/common/src/*"
],
"@sammo-ts/infra": [
"../../packages/infra/src/index.ts"
],
"@sammo-ts/infra/*": [
"../../packages/infra/src/*"
],
"@sammo-ts/logic": [
"../../packages/logic/src/index.ts"
],
"@sammo-ts/logic/*": [
"../../packages/logic/src/*"
]
}
},
"include": ["src", "test", "*.ts"],
"include": [
"src"
],
"references": [
{ "path": "../../packages/common" },
{ "path": "../../packages/infra" },
{ "path": "../../packages/logic" }
{
"path": "../../packages/common"
},
{
"path": "../../packages/infra"
},
{
"path": "../../packages/logic"
}
]
}
}
+15 -6
View File
@@ -2,12 +2,21 @@
"extends": "../../tsconfig.paths.json",
"compilerOptions": {
"outDir": "dist",
"composite": true
"composite": true,
"rootDir": "src"
},
"include": ["src", "test", "*.ts"],
"include": [
"src"
],
"references": [
{ "path": "../../packages/common" },
{ "path": "../../packages/infra" },
{ "path": "../../packages/logic" }
{
"path": "../../packages/common"
},
{
"path": "../../packages/infra"
},
{
"path": "../../packages/logic"
}
]
}
}
+8
View File
@@ -3,6 +3,14 @@
"private": true,
"version": "0.0.0",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/gateway-api",
"dev": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/gateway-api --watch",
+18 -7
View File
@@ -2,13 +2,24 @@
"extends": "../../tsconfig.paths.json",
"compilerOptions": {
"outDir": "dist",
"composite": true
"composite": true,
"rootDir": "src"
},
"include": ["src", "test", "*.ts"],
"include": [
"src"
],
"references": [
{ "path": "../../packages/common" },
{ "path": "../../packages/infra" },
{ "path": "../../packages/logic" },
{ "path": "../../app/game-engine" }
{
"path": "../../packages/common"
},
{
"path": "../../packages/infra"
},
{
"path": "../../packages/logic"
},
{
"path": "../../app/game-engine"
}
]
}
}
+2
View File
@@ -14,6 +14,8 @@
"dependencies": {
"@sammo-ts/common": "workspace:*",
"@sammo-ts/game-api": "workspace:*",
"@sammo-ts/gateway-api": "workspace:*",
"@sammo-ts/logic": "workspace:*",
"@trpc/client": "^11.8.1",
"@trpc/server": "^11.8.1",
"@vueuse/core": "^13.9.0",
+1 -1
View File
@@ -1,5 +1,5 @@
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { appRouter } from '../../../game-api/src/router';
import type { appRouter } from '@sammo-ts/game-api';
export type GameRouter = typeof appRouter;
+55 -28
View File
@@ -4,48 +4,75 @@
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"lib": [
"ESNext",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@sammo-ts/common": ["../../packages/common/src/index.ts"],
"@sammo-ts/common/*": ["../../packages/common/src/*"],
"@sammo-ts/infra": ["../../packages/infra/src/index.ts"],
"@sammo-ts/infra/*": ["../../packages/infra/src/*"],
"@sammo-ts/logic": ["../../packages/logic/src/index.ts"],
"@sammo-ts/logic/*": ["../../packages/logic/src/*"],
"@sammo-ts/game-engine": ["../../app/game-engine/src/index.ts"],
"@sammo-ts/game-engine/*": ["../../app/game-engine/src/*"],
"@sammo-ts/game-api": ["../../app/game-api/src/index.ts"],
"@sammo-ts/game-api/*": ["../../app/game-api/src/*"],
"@sammo-ts/gateway-api": ["../../app/gateway-api/src/index.ts"],
"@sammo-ts/gateway-api/*": ["../../app/gateway-api/src/*"]
"@/*": [
"./src/*"
],
"@sammo-ts/common": [
"../../packages/common/src/index.ts"
],
"@sammo-ts/common/*": [
"../../packages/common/src/*"
],
"@sammo-ts/infra": [
"../../packages/infra/src/index.ts"
],
"@sammo-ts/infra/*": [
"../../packages/infra/src/*"
],
"@sammo-ts/logic": [
"../../packages/logic/src/index.ts"
],
"@sammo-ts/logic/*": [
"../../packages/logic/src/*"
],
"@sammo-ts/game-engine": [
"../../app/game-engine/src/index.ts"
],
"@sammo-ts/game-engine/*": [
"../../app/game-engine/src/*"
],
"@sammo-ts/game-api": [
"../../app/game-api/src/index.ts"
],
"@sammo-ts/game-api/*": [
"../../app/game-api/src/*"
],
"@sammo-ts/gateway-api": [
"../../app/gateway-api/src/index.ts"
],
"@sammo-ts/gateway-api/*": [
"../../app/gateway-api/src/*"
]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "test/**/*.ts", "*.ts"],
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"test/**/*.ts"
],
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "../../packages/common" },
{ "path": "../../packages/infra" },
{ "path": "../../packages/logic" },
{ "path": "../../app/game-engine" },
{ "path": "../../app/game-api" },
{ "path": "../../app/gateway-api" }
{
"path": "./tsconfig.node.json"
}
]
}
}
-2
View File
@@ -1,2 +0,0 @@
declare const _default: import('vite').UserConfig;
export default _default;
-16
View File
@@ -1,16 +0,0 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), tailwindcss()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 3000,
},
});