Everything sat in packages/: two programs next to the small libraries
they use, and the patch data loose at the root. The programs now live in
apps/ and the shared libraries in packages/:
apps/server the local server (was packages/local-service),
package @wto/server
packages/patcher builds the game copy (was packages/build),
package @wto/patcher
patches/exe exe patch definitions (was exe-patches)
patches/gui GUI script patches (was gui-patches)
Inside the server, the network layer folder becomes transport/ so it is
not server/server/, the entry module is server.ts, and startLocalService
and its types become startServer, ServerOptions and RunningServer. The
health answer names the app wto-server, and the TLS files in the data
folder are server.key and server.crt (made again on the next start).
Comments, logs and tool texts say "local server".
The patcher no longer reaches into the server's folder. It read the
default tuning/store.jsonc by a relative path to register bundle GUIDs
for the multi-vehicle packs, which also ignored the player's overrides
in <data>/tuning/. It now takes the pack ids from its caller; the
server exports multiVehiclePackIds(dataFolder), which reads them the way
the running server does. rebuildGuiPack takes the patch folder from its
caller as well.
The development build moves out of the patcher to
scripts/build-game-copy.ts, since it uses both the server and the
patcher. It needs --data (the folder the server will run with) and
defaults the patch folders and the hook library to this repository.
Checked with the root typecheck, check-patches, check-gui,
check-offsets, the native build, a run of build-game-copy.ts into a
scratch folder (12 exe patches, 35 GUI patches, 496 bundle GUIDs as
before) and a server start from apps/server answering wto-server.
BREAKING CHANGE: Use @wto/server and @wto/patcher from the new workspace paths. Run the development build with scripts/build-game-copy.ts and pass --data.
133 lines
5.3 KiB
TypeScript
133 lines
5.3 KiB
TypeScript
/** Typed content of tuning/clans.jsonc. */
|
|
import { TuningError, type TuningReader } from '../tuning/tuning-reader.ts';
|
|
import { roleCodeFromString, type ClanStats } from './clan-types.ts';
|
|
|
|
/** The clan statistics a preset clan starts with; the per-mode ratings (dr_era5_*) come from each clan's rating. */
|
|
export type PresetClanStats = Omit<ClanStats, 'dr_era5_arc' | 'dr_era5_hist' | 'dr_era5_sim'>;
|
|
|
|
const STAT_KEYS: readonly (keyof PresetClanStats)[] = [
|
|
'akills_arc', 'akills_hist', 'akills_sim', 'gkills_arc', 'gkills_hist', 'gkills_sim',
|
|
'deaths_arc', 'deaths_hist', 'deaths_sim', 'ftime_arc', 'ftime_hist', 'ftime_sim',
|
|
];
|
|
|
|
export interface ModeTriple {
|
|
readonly arc: number;
|
|
readonly hist: number;
|
|
readonly sim: number;
|
|
}
|
|
|
|
export interface PresetMember {
|
|
readonly uid: string;
|
|
readonly nick: string;
|
|
readonly role: number;
|
|
readonly title: string;
|
|
readonly icon: string;
|
|
readonly unit: string;
|
|
readonly activity: number;
|
|
}
|
|
|
|
export interface PresetClan {
|
|
readonly id: string;
|
|
readonly tag: string;
|
|
readonly name: string;
|
|
readonly type: 'normal' | 'battalion';
|
|
readonly slogan: string;
|
|
readonly desc: string;
|
|
readonly announcement: string;
|
|
readonly region: string;
|
|
readonly autoAccept: boolean;
|
|
readonly createdAfterDays: number;
|
|
readonly rating: ModeTriple;
|
|
readonly members: readonly PresetMember[];
|
|
}
|
|
|
|
export interface ClanTuning {
|
|
readonly activity: {
|
|
readonly maxPerPeriod: number;
|
|
readonly squadronRpPerFullPeriod: number;
|
|
readonly rewardPeriodDays: number;
|
|
readonly historyDepthDays: number;
|
|
readonly startingPeriods: number;
|
|
};
|
|
readonly memberLimits: { readonly normal: number; readonly battalionInitial: number };
|
|
readonly leaderboard: { readonly activityMultiplier: number; readonly maxActivity: number };
|
|
readonly firstNewClanId: number;
|
|
readonly playerRating: { readonly founder: ModeTriple; readonly joiner: ModeTriple };
|
|
readonly presetClans: {
|
|
readonly createdDaysAgo: number;
|
|
readonly memberJoinSpacingMinutes: number;
|
|
readonly stats: PresetClanStats;
|
|
readonly memberRating: { readonly step: ModeTriple; readonly floor: ModeTriple };
|
|
readonly clans: readonly PresetClan[];
|
|
};
|
|
}
|
|
|
|
export function readClanTuning(file: TuningReader): ClanTuning {
|
|
const activity = file.object('activity');
|
|
const limits = file.object('memberLimits');
|
|
const leaderboard = file.object('leaderboard');
|
|
const preset = file.object('presetClans');
|
|
const stats = preset.object('stats');
|
|
const rating = preset.object('memberRating');
|
|
return {
|
|
activity: {
|
|
maxPerPeriod: activity.int('maxPerPeriod', { min: 1 }),
|
|
squadronRpPerFullPeriod: activity.int('squadronRpPerFullPeriod', { min: 0 }),
|
|
rewardPeriodDays: activity.int('rewardPeriodDays', { min: 1 }),
|
|
historyDepthDays: activity.int('historyDepthDays', { min: 1 }),
|
|
startingPeriods: activity.int('startingPeriods', { min: 0 }),
|
|
},
|
|
memberLimits: { normal: limits.int('normal', { min: 1 }), battalionInitial: limits.int('battalionInitial', { min: 1 }) },
|
|
leaderboard: { activityMultiplier: leaderboard.number('activityMultiplier', { min: 0 }), maxActivity: leaderboard.int('maxActivity', { min: 0 }) },
|
|
firstNewClanId: file.int('firstNewClanId', { min: 1 }),
|
|
playerRating: { founder: triple(file.object('playerRating').object('founder')), joiner: triple(file.object('playerRating').object('joiner')) },
|
|
presetClans: {
|
|
createdDaysAgo: preset.int('createdDaysAgo', { min: 0 }),
|
|
memberJoinSpacingMinutes: preset.int('memberJoinSpacingMinutes', { min: 0 }),
|
|
stats: Object.fromEntries(STAT_KEYS.map((key) => [key, stats.int(key, { min: 0 })])) as unknown as PresetClanStats,
|
|
memberRating: { step: triple(rating.object('step')), floor: triple(rating.object('floor')) },
|
|
clans: preset.list('clans', readPresetClan),
|
|
},
|
|
};
|
|
}
|
|
|
|
function readPresetClan(entry: TuningReader): PresetClan {
|
|
const type = entry.string('type');
|
|
if (type !== 'normal' && type !== 'battalion') throw new TuningError(`tuning file clans.jsonc: clan type must be normal or battalion (found "${type}")`);
|
|
const members = entry.list('members', readPresetMember);
|
|
if (members.length === 0) throw new TuningError(`tuning file clans.jsonc: preset clan ${entry.string('id')} needs at least one member (the first is its leader)`);
|
|
return {
|
|
id: entry.string('id'),
|
|
tag: entry.string('tag'),
|
|
name: entry.string('name'),
|
|
type,
|
|
slogan: entry.string('slogan'),
|
|
desc: entry.string('desc'),
|
|
announcement: entry.string('announcement'),
|
|
region: entry.string('region'),
|
|
autoAccept: entry.bool('autoAccept'),
|
|
createdAfterDays: entry.int('createdAfterDays', { min: 0 }),
|
|
rating: triple(entry.object('rating')),
|
|
members,
|
|
};
|
|
}
|
|
|
|
function readPresetMember(member: TuningReader): PresetMember {
|
|
const roleName = member.string('role');
|
|
const role = roleCodeFromString(roleName);
|
|
if (role === undefined) throw new TuningError(`tuning file clans.jsonc: unknown member role "${roleName}"`);
|
|
return {
|
|
uid: member.string('uid'),
|
|
nick: member.string('nick'),
|
|
role,
|
|
title: member.string('title'),
|
|
icon: member.string('icon'),
|
|
unit: member.string('unit'),
|
|
activity: member.int('activity', { min: 0 }),
|
|
};
|
|
}
|
|
|
|
function triple(entry: TuningReader): ModeTriple {
|
|
return { arc: entry.int('arc'), hist: entry.int('hist'), sim: entry.int('sim') };
|
|
}
|