Compare commits
5
Commits
v0.1.2
..
7bd17c4f74
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bd17c4f74 | ||
|
|
be772c0cea | ||
|
|
fa7f68b942 | ||
|
|
899fb5d91b | ||
|
|
3f0e08c5b7 |
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
<a id="zh-cn"></a>
|
||||
|
||||
简体中文 · [English](#english)
|
||||
简体中文 · [English](#english) · [Discord](https://discord.gg/P566xWNpEs)
|
||||
|
||||
------
|
||||
|
||||
@@ -21,6 +21,10 @@ WTOffline 是《战争雷霆》(War Thunder)Windows 客户端的单机离线
|
||||
|
||||
`patches/versions/` 中每份核对记录对应一个检查通过并在游戏中验证过的客户端版本。补丁和 native 模块按特征码、字符串引用和从代码中读出的值定位,不依赖固定地址,小版本更新后通常仍能命中,但没有核对记录的版本不保证功能正确。
|
||||
|
||||
## 开发讨论、交流与求助
|
||||
|
||||
欢迎加入 [WTOffline Discord 服务器](https://discord.gg/P566xWNpEs),用于日常交流、使用求助、问题反馈、调参分享以及开发和版本适配讨论。
|
||||
|
||||
## 功能
|
||||
|
||||
| 领域 | 已实现 |
|
||||
@@ -151,7 +155,7 @@ AI 的驾驶、寻路和战术使用游戏自带的 AI,目前仍有明显不
|
||||
|
||||
## 开发
|
||||
|
||||
开发规范、补丁指南和 PR 自查清单见 [Dev Docs](dev-docs/README.md#zh-cn)。
|
||||
开发规范、补丁指南和 PR 自查清单见 [Dev Docs](dev-docs/README.md#zh-cn),开发与版本适配讨论欢迎前往 [Discord](https://discord.gg/P566xWNpEs)。
|
||||
|
||||
### 环境要求
|
||||
|
||||
@@ -265,7 +269,7 @@ tools/ wtotools,补丁检查工具(Python)
|
||||
|
||||
# WTOffline (English)
|
||||
|
||||
[简体中文](#zh-cn) · English
|
||||
[简体中文](#zh-cn) · English · [Discord](https://discord.gg/P566xWNpEs)
|
||||
|
||||
WTOffline is a single-player offline project for the Windows client of War Thunder. A local server emulates Gaijin's online services, and the client sends all of its requests to the local machine. The client logs in, loads its profile, enters the hangar, and submits player actions as usual. Game rules, saves, and battle settlement run on the local server, and all allies and opponents are AI.
|
||||
|
||||
@@ -282,6 +286,10 @@ The repository contains source code and patch definitions only. It does not cont
|
||||
|
||||
Each check record in `patches/versions/` stands for a client version that passed the checks and was verified in game. Patches and native modules are located by signatures, string references and values read from the code rather than fixed addresses, so they usually still match after a minor update, but correct behavior is not guaranteed for a version without a check record.
|
||||
|
||||
## Community
|
||||
|
||||
Join the [WTOffline Discord server](https://discord.gg/P566xWNpEs) for general discussion, troubleshooting, bug reports, and development or patch adaptation discussions.
|
||||
|
||||
## Features
|
||||
|
||||
| Area | Implemented |
|
||||
@@ -412,7 +420,7 @@ To override defaults, create `tuning/<same file name>.jsonc` in the data folder
|
||||
|
||||
## Development
|
||||
|
||||
See [Dev Docs](dev-docs/README.md#english) for development rules, patch templates, and the PR checklist.
|
||||
See [Dev Docs](dev-docs/README.md#english) for development rules, patch templates, and the PR checklist, or join [Discord](https://discord.gg/P566xWNpEs) for development and patch adaptation discussions.
|
||||
|
||||
### Requirements
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { appUpdatesSupported, checkAppUpdate, downloadAppUpdate, installAppUpdat
|
||||
import { listBackgroundPictures } from '../services/background-art/art-catalog.ts';
|
||||
import { getCopyTuning, updateCopyTuning } from '../services/config/copy-tuning.ts';
|
||||
import { getSettings, updateSettings } from '../services/config/settings-store.ts';
|
||||
import { cancelMaintenance, maintainCopy, maintenanceInfo, maintenanceInProgress } from '../services/copies/copy-maintenance.ts';
|
||||
import { cancelMaintenance, maintainCopy, maintenanceInfo, maintenanceInProgress, maintenanceState } from '../services/copies/copy-maintenance.ts';
|
||||
import { relocateCopy } from '../services/copies/relocate-copy.ts';
|
||||
import { exportDiagnostics, openLogsFolder } from '../services/diagnostics/diagnostics.ts';
|
||||
import { measureFolder } from '../services/game-folder/folder-size.ts';
|
||||
@@ -135,6 +135,7 @@ export function registerIpcHandlers(): void {
|
||||
return updated;
|
||||
});
|
||||
handle('copies:maintenanceInfo', ({ id }) => maintenanceInfo(id));
|
||||
handle('copies:maintenanceState', () => maintenanceState());
|
||||
handle('copies:maintain', async (request) => {
|
||||
if (saveWriteInProgress() || decalImportInProgress()) throw new AppError('maintenance_busy');
|
||||
const updated = await hydrateCopiesStatus(await maintainCopy(request, (progress) => broadcast('event:copy-maintenance', progress)));
|
||||
|
||||
@@ -15,12 +15,20 @@ import { localServerReady } from '../launch/local-server.ts';
|
||||
import { fileInfo } from './change-copy-files.ts';
|
||||
import { compactCopy, convertibleCopy, isNewer, readSource, repair, updateFromSource, updatePreservesSpaceSaving, type Report } from './copy-file-maintenance.ts';
|
||||
|
||||
let current: { stop: AbortController; interruptible: boolean } | null = null;
|
||||
let current: {
|
||||
stop: AbortController;
|
||||
interruptible: boolean;
|
||||
progress: MaintenanceProgress;
|
||||
} | null = null;
|
||||
|
||||
export function maintenanceInProgress(): boolean {
|
||||
return current !== null;
|
||||
}
|
||||
|
||||
export function maintenanceState(): MaintenanceProgress | null {
|
||||
return current ? { ...current.progress } : null;
|
||||
}
|
||||
|
||||
export function cancelMaintenance(): void {
|
||||
if (current?.interruptible) current.stop.abort();
|
||||
}
|
||||
@@ -43,18 +51,28 @@ export async function maintenanceInfo(id: string): Promise<MaintenanceInfo> {
|
||||
|
||||
export async function maintainCopy(
|
||||
request: MaintenanceRequest,
|
||||
publish: (progress: MaintenanceProgress) => void,
|
||||
publish: (progress: MaintenanceProgress | null) => void,
|
||||
): Promise<Copies> {
|
||||
if (current || launchInProgress() || installationInProgress()) throw new AppError('maintenance_busy');
|
||||
const initial: MaintenanceProgress = {
|
||||
id: request.id,
|
||||
operation: request.operation,
|
||||
phase: 'checking',
|
||||
doneBytes: 0,
|
||||
totalBytes: 0,
|
||||
};
|
||||
const job = {
|
||||
stop: new AbortController(),
|
||||
interruptible: request.operation === 'update' || request.operation === 'compact',
|
||||
progress: initial,
|
||||
};
|
||||
current = job;
|
||||
const signal = job.stop.signal;
|
||||
const report: Report = (phase, doneBytes = 0, totalBytes = 0) => {
|
||||
if (phase === 'applying') job.interruptible = false;
|
||||
publish({ id: request.id, operation: request.operation, phase, doneBytes, totalBytes });
|
||||
const next: MaintenanceProgress = { id: request.id, operation: request.operation, phase, doneBytes, totalBytes };
|
||||
job.progress = next;
|
||||
publish(next);
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -67,6 +85,7 @@ export async function maintainCopy(
|
||||
throw new AppError('maintenance_failed');
|
||||
} finally {
|
||||
current = null;
|
||||
publish(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { applyLanguage, resolveLanguage } from './i18n/index.ts';
|
||||
import { ipcInvoke, ipcOn } from './ipc.ts';
|
||||
import { AboutPage } from './pages/about/AboutPage.tsx';
|
||||
import { CopyMaintenance } from './pages/copies/CopyMaintenance.tsx';
|
||||
import { useCopyMaintenance } from './pages/copies/useCopyMaintenance.ts';
|
||||
import { CopyList } from './pages/copies/CopyList.tsx';
|
||||
import { CopySummary } from './pages/copies/CopySummary.tsx';
|
||||
import { FeatureStatus } from './pages/copies/FeatureStatus.tsx';
|
||||
@@ -68,6 +69,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
// The setting as the window opened: turning it on later does not check right away.
|
||||
const patchPack = usePatchPack(initialSettings.checkPatchPacksOnStart, report);
|
||||
const appUpdate = useAppUpdate(info.appUpdatesSupported, initialSettings.checkLauncherUpdatesOnStart, report);
|
||||
const maintenance = useCopyMaintenance(report);
|
||||
const supported = patchPack.active?.gameVersions ?? info.supportedGameVersions;
|
||||
|
||||
const wizard = useInstallWizard({ onInstalled: () => setRoute(START_ROUTE) });
|
||||
@@ -223,7 +225,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
};
|
||||
}
|
||||
if (route.copies === 'maintain') {
|
||||
return { side, main: <CopyMaintenance key={record.id} record={record} onError={report} />, bar: home };
|
||||
return { side, main: <CopyMaintenance key={record.id} record={record} maintenance={maintenance} onError={report} />, bar: home };
|
||||
}
|
||||
const main = route.copies === 'features'
|
||||
? <FeatureStatus record={record} supportedVersions={supported} onError={report} />
|
||||
|
||||
@@ -638,7 +638,12 @@
|
||||
}
|
||||
},
|
||||
"statement": "Project information",
|
||||
"statementBody": "WTOffline is a noncommercial hobby project independent of Gaijin. Running it requires your own War Thunder base game files."
|
||||
"statementBody": "WTOffline is a noncommercial hobby project independent of Gaijin. Running it requires your own War Thunder base game files.",
|
||||
"community": {
|
||||
"discord": "Discord",
|
||||
"discordHint": "Development discussion, general chat, troubleshooting, and bug reports.",
|
||||
"openDiscord": "Open Discord"
|
||||
}
|
||||
},
|
||||
"features": {
|
||||
"A-Offline startup": "Offline startup",
|
||||
|
||||
@@ -638,7 +638,12 @@
|
||||
}
|
||||
},
|
||||
"statement": "项目信息",
|
||||
"statementBody": "WTOffline 是一个独立于 Gaijin 的非商业兴趣项目。运行需要自备战争雷霆游戏本体文件。"
|
||||
"statementBody": "WTOffline 是一个独立于 Gaijin 的非商业兴趣项目。运行需要自备战争雷霆游戏本体文件。",
|
||||
"community": {
|
||||
"discord": "Discord",
|
||||
"discordHint": "开发讨论、日常交流、使用求助与问题反馈。",
|
||||
"openDiscord": "打开 Discord"
|
||||
}
|
||||
},
|
||||
"features": {
|
||||
"A-Offline startup": "离线启动",
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Notice } from '../../components/Notice.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
import { Sheet } from '../../components/Sheet.tsx';
|
||||
import { ipcInvoke } from '../../ipc.ts';
|
||||
import type { AppUpdateState } from '../../shell/useAppUpdate.ts';
|
||||
import { AppUpdateSection } from './AppUpdateSection.tsx';
|
||||
import type { PatchPackState } from '../../shell/usePatchPack.ts';
|
||||
|
||||
const DISCORD_INVITE_URL = 'https://discord.gg/P566xWNpEs';
|
||||
|
||||
interface AboutPageProps {
|
||||
readonly launcherVersion: string;
|
||||
readonly supportedVersions: readonly string[];
|
||||
@@ -17,7 +18,7 @@ interface AboutPageProps {
|
||||
readonly onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
/** The launcher's version, the game versions it supports, adaptation pack updates, log export, and the project statement. */
|
||||
/** The launcher's version, the game versions it supports, updates, community links, log export, and the project statement. */
|
||||
export function AboutPage({ launcherVersion, supportedVersions, patchPack, appUpdate, loggingEnabled, onError }: AboutPageProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
@@ -30,15 +31,41 @@ export function AboutPage({ launcherVersion, supportedVersions, patchPack, appUp
|
||||
{t('about.supported', { versions: supportedVersions.join(', ') })}
|
||||
</div>
|
||||
</div>
|
||||
<AppUpdateSection state={appUpdate} />
|
||||
<PatchPackSection state={patchPack} />
|
||||
<FeedbackLogsSection loggingEnabled={loggingEnabled} onError={onError} />
|
||||
<h3 className="section-title section-title-spaced">{t('about.statement')}</h3>
|
||||
<p className="lead">{t('about.statementBody')}</p>
|
||||
<div className="about-columns">
|
||||
<div className="about-column">
|
||||
<AppUpdateSection state={appUpdate} />
|
||||
<PatchPackSection state={patchPack} />
|
||||
</div>
|
||||
<div className="about-column">
|
||||
<CommunitySection />
|
||||
<FeedbackLogsSection loggingEnabled={loggingEnabled} onError={onError} />
|
||||
<section className="about-card">
|
||||
<h3 className="about-card-title">{t('about.statement')}</h3>
|
||||
<p className="about-card-meta">{t('about.statementBody')}</p>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
|
||||
function CommunitySection() {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<section className="about-card">
|
||||
<div className="about-card-head">
|
||||
<h3 className="about-card-title">{t('about.community.discord')}</h3>
|
||||
<div className="about-card-actions">
|
||||
<a className="button" href={DISCORD_INVITE_URL} target="_blank" rel="noreferrer">
|
||||
{t('about.community.openDiscord')}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<p className="about-card-meta">{t('about.community.discordHint')}</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function FeedbackLogsSection({ loggingEnabled, onError }: {
|
||||
readonly loggingEnabled: boolean;
|
||||
readonly onError: (error: unknown) => void;
|
||||
@@ -61,16 +88,19 @@ function FeedbackLogsSection({ loggingEnabled, onError }: {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<h3 className="section-title section-title-spaced">{t('about.feedback.title')}</h3>
|
||||
<Row label={t('about.feedback.export')} hint={t('about.feedback.exportHint')}>
|
||||
<button type="button" className="button" disabled={exporting} onClick={() => { void save(); }}>
|
||||
{t('about.feedback.exportButton')}
|
||||
</button>
|
||||
</Row>
|
||||
<section className="about-card">
|
||||
<div className="about-card-head">
|
||||
<h3 className="about-card-title">{t('about.feedback.title')}</h3>
|
||||
<div className="about-card-actions">
|
||||
<button type="button" className="button" disabled={exporting} onClick={() => { void save(); }}>
|
||||
{t('about.feedback.exportButton')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="about-card-meta">{t('about.feedback.exportHint')}</p>
|
||||
{!loggingEnabled && <p className="small">{t('settings.diagnostics.loggingDisabledNotice')}</p>}
|
||||
{savedPath && <p className="small" role="status">{t('settings.diagnostics.saved', { path: savedPath })}</p>}
|
||||
</>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,25 +115,30 @@ function PatchPackSection({ state }: { readonly state: PatchPackState }) {
|
||||
? t('about.pack.bundledVersion', { version: active.version })
|
||||
: t('about.pack.bundled');
|
||||
return (
|
||||
<>
|
||||
<h3 className="section-title">{t('about.pack.title')}</h3>
|
||||
<Row label={t('about.pack.current')} hint={t('about.pack.currentHint')}>
|
||||
<span>{current}</span>
|
||||
{active?.source === 'downloaded' && (
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.useBundled}>
|
||||
{t('about.pack.useBundled')}
|
||||
<section className="about-card">
|
||||
<div className="about-card-head">
|
||||
<h3 className="about-card-title">{t('about.pack.title')}</h3>
|
||||
<div className="about-card-actions">
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.checkNow}>
|
||||
{busy === 'checking' ? t('about.pack.checking') : t('about.pack.checkButton')}
|
||||
</button>
|
||||
)}
|
||||
</Row>
|
||||
<Row label={t('about.pack.check')} hint={t('about.pack.checkHint')}>
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.checkNow}>
|
||||
{busy === 'checking' ? t('about.pack.checking') : t('about.pack.checkButton')}
|
||||
</button>
|
||||
</Row>
|
||||
{active?.source === 'downloaded' && (
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.useBundled}>
|
||||
{t('about.pack.useBundled')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<p className="about-card-meta">
|
||||
<span className="about-card-label">{t('about.pack.current')}</span>
|
||||
{' · '}
|
||||
{current}
|
||||
</p>
|
||||
<p className="small">{t('about.pack.currentHint')}</p>
|
||||
{busy === 'applying' && <p className="small">{t('about.pack.applying')}</p>}
|
||||
{state.applyFailure && <Notice tone="error"><p>{t(`about.pack.applyFailed.${state.applyFailure}`)}</p></Notice>}
|
||||
{check && busy !== 'checking' && <CheckResult state={state} />}
|
||||
</>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Notice } from '../../components/Notice.tsx';
|
||||
import { ProgressBar } from '../../components/ProgressBar.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
import { formatBytes } from '../../format.ts';
|
||||
import type { AppUpdateState } from '../../shell/useAppUpdate.ts';
|
||||
|
||||
@@ -10,13 +9,16 @@ export function AppUpdateSection({ state }: { readonly state: AppUpdateState })
|
||||
if (!state.supported) return null;
|
||||
const { check, busy, progress } = state;
|
||||
return (
|
||||
<>
|
||||
<h3 className="section-title">{t('about.update.title')}</h3>
|
||||
<Row label={t('about.update.check')}>
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.checkNow}>
|
||||
{t(busy === 'checking' ? 'about.update.checking' : 'about.pack.checkButton')}
|
||||
</button>
|
||||
</Row>
|
||||
<section className="about-card">
|
||||
<div className="about-card-head">
|
||||
<h3 className="about-card-title">{t('about.update.title')}</h3>
|
||||
<div className="about-card-actions">
|
||||
<button type="button" className="button" disabled={busy !== null} onClick={state.checkNow}>
|
||||
{t(busy === 'checking' ? 'about.update.checking' : 'about.pack.checkButton')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="about-card-meta">{t('about.update.check')}</p>
|
||||
{check?.status === 'current' && busy !== 'checking' && <Notice tone="info"><p>{t('about.update.current')}</p></Notice>}
|
||||
{check?.status === 'failed' && busy !== 'checking' && <Notice tone="error"><p>{t(`about.update.errors.${check.problem}`)}</p></Notice>}
|
||||
{check?.status === 'available' && busy !== 'checking' && (
|
||||
@@ -43,6 +45,6 @@ export function AppUpdateSection({ state }: { readonly state: AppUpdateState })
|
||||
)}
|
||||
</Notice>
|
||||
)}
|
||||
</>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,29 +1,24 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { IpcInput } from '@shared/ipc/contract.ts';
|
||||
import type { InstallRecord } from '@shared/schemas/install.ts';
|
||||
import type { MaintenanceInfo, MaintenanceProgress, MaintenanceRequest } from '@shared/schemas/maintenance.ts';
|
||||
import type { MaintenanceInfo, MaintenanceProgress } from '@shared/schemas/maintenance.ts';
|
||||
import { ProgressBar } from '../../components/ProgressBar.tsx';
|
||||
import { Sheet } from '../../components/Sheet.tsx';
|
||||
import { formatBytes } from '../../format.ts';
|
||||
import { AppIpcError, ipcInvoke, ipcOn } from '../../ipc.ts';
|
||||
import { ipcInvoke } from '../../ipc.ts';
|
||||
import { CopyMaintenanceActions, CopyRemoval, type CopyRemovalOptions } from './CopyMaintenanceControls.tsx';
|
||||
import type { CopyMaintenanceState, MaintenanceOperation, MaintenanceOptions } from './useCopyMaintenance.ts';
|
||||
|
||||
interface CopyMaintenanceProps {
|
||||
readonly record: InstallRecord;
|
||||
readonly maintenance: CopyMaintenanceState;
|
||||
readonly onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
type Operation = MaintenanceRequest['operation'];
|
||||
type OperationOptions = Pick<IpcInput<'copies:maintain'>, 'deleteData' | 'steamLocations'>;
|
||||
|
||||
export function CopyMaintenance({ record, onError }: CopyMaintenanceProps) {
|
||||
export function CopyMaintenance({ record, maintenance, onError }: CopyMaintenanceProps) {
|
||||
const { t } = useTranslation();
|
||||
const [info, setInfo] = useState<MaintenanceInfo | null>(null);
|
||||
const [working, setWorking] = useState<Operation | null>(null);
|
||||
const [progress, setProgress] = useState<MaintenanceProgress | null>(null);
|
||||
const [removal, setRemoval] = useState<CopyRemovalOptions | null>(null);
|
||||
const [result, setResult] = useState<Operation | 'cancelled' | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
@@ -31,29 +26,17 @@ export function CopyMaintenance({ record, onError }: CopyMaintenanceProps) {
|
||||
if (mounted) setInfo(value);
|
||||
}).catch(onError);
|
||||
return () => { mounted = false; };
|
||||
}, [record.id, record.gameVersion, record.steamLibraryConfirmation, onError]);
|
||||
}, [record.id, record.gameVersion, record.steamLibraryConfirmation, maintenance.revision, onError]);
|
||||
|
||||
useEffect(() => ipcOn('event:copy-maintenance', (event) => {
|
||||
if (event.id === record.id) setProgress(event);
|
||||
}), [record.id]);
|
||||
|
||||
const run = (operation: Operation, options: OperationOptions = {}): void => {
|
||||
setResult(null);
|
||||
setWorking(operation);
|
||||
setProgress(null);
|
||||
ipcInvoke('copies:maintain', { id: record.id, operation, ...options })
|
||||
.then(() => {
|
||||
setResult(operation);
|
||||
setRemoval(null);
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
if (error instanceof AppIpcError && error.code === 'maintenance_cancelled') setResult('cancelled');
|
||||
else onError(error);
|
||||
})
|
||||
.finally(() => setWorking(null));
|
||||
const run = (operation: MaintenanceOperation, options: MaintenanceOptions = {}): void => {
|
||||
if (operation === 'delete') setRemoval(null);
|
||||
maintenance.run(record.id, operation, options);
|
||||
};
|
||||
|
||||
const busy = working !== null;
|
||||
const active = maintenance.active;
|
||||
const busy = active !== null;
|
||||
const result = maintenance.lastResult?.copyId === record.id ? maintenance.lastResult.outcome : null;
|
||||
|
||||
return (
|
||||
<Sheet title={t('copies.sections.maintain')} aside={record.name}>
|
||||
<CopyMaintenanceActions
|
||||
@@ -71,32 +54,25 @@ export function CopyMaintenance({ record, onError }: CopyMaintenanceProps) {
|
||||
onOptionsChange={setRemoval}
|
||||
onRemove={(deleteData) => run('delete', { deleteData })}
|
||||
/>
|
||||
{working && (
|
||||
<MaintenanceStatus
|
||||
operation={working}
|
||||
progress={progress}
|
||||
onCancel={() => ipcInvoke('copies:cancelMaintenance').catch(onError)}
|
||||
/>
|
||||
)}
|
||||
{active && <MaintenanceStatus progress={active} onCancel={maintenance.cancel} />}
|
||||
{result && <p className="small" role="status">{t(`copies.maintenance.result.${result}`)}</p>}
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
|
||||
interface MaintenanceStatusProps {
|
||||
readonly operation: Operation;
|
||||
readonly progress: MaintenanceProgress | null;
|
||||
readonly progress: MaintenanceProgress;
|
||||
readonly onCancel: () => void;
|
||||
}
|
||||
|
||||
function MaintenanceStatus({ operation, progress, onCancel }: MaintenanceStatusProps) {
|
||||
function MaintenanceStatus({ progress, onCancel }: MaintenanceStatusProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="maintenance-progress" role="status">
|
||||
<p>{t(`copies.maintenance.phase.${progress?.phase ?? 'checking'}`)}</p>
|
||||
<ProgressBar value={progress?.doneBytes ?? 0} max={progress?.totalBytes || null} />
|
||||
{progress?.totalBytes ? <p className="small">{formatBytes(progress.doneBytes)} / {formatBytes(progress.totalBytes)}</p> : null}
|
||||
{(operation === 'update' || operation === 'compact') && progress?.phase !== 'applying' && (
|
||||
<p>{t(`copies.maintenance.phase.${progress.phase}`)}</p>
|
||||
<ProgressBar value={progress.doneBytes} max={progress.totalBytes || null} />
|
||||
{progress.totalBytes ? <p className="small">{formatBytes(progress.doneBytes)} / {formatBytes(progress.totalBytes)}</p> : null}
|
||||
{(progress.operation === 'update' || progress.operation === 'compact') && progress.phase !== 'applying' && (
|
||||
<button type="button" className="button" onClick={onCancel}>
|
||||
{t('wizard.cancel')}
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import type { IpcInput } from '@shared/ipc/contract.ts';
|
||||
import type { MaintenanceProgress, MaintenanceRequest } from '@shared/schemas/maintenance.ts';
|
||||
import { AppIpcError, ipcInvoke, ipcOn } from '../../ipc.ts';
|
||||
|
||||
export type MaintenanceOperation = MaintenanceRequest['operation'];
|
||||
export type MaintenanceOptions = Pick<IpcInput<'copies:maintain'>, 'deleteData' | 'steamLocations'>;
|
||||
|
||||
export interface MaintenanceOutcome {
|
||||
readonly copyId: string;
|
||||
readonly outcome: MaintenanceOperation | 'cancelled';
|
||||
}
|
||||
|
||||
/** Tracks copy maintenance across tab switches so progress and busy state survive unmounting the maintenance page. */
|
||||
export function useCopyMaintenance(onError: (error: unknown) => void) {
|
||||
const [active, setActive] = useState<MaintenanceProgress | null>(null);
|
||||
const [lastResult, setLastResult] = useState<MaintenanceOutcome | null>(null);
|
||||
const [revision, setRevision] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
let receivedEvent = false;
|
||||
const dispose = ipcOn('event:copy-maintenance', (event) => {
|
||||
receivedEvent = true;
|
||||
setActive(event);
|
||||
if (event === null) setRevision((value) => value + 1);
|
||||
});
|
||||
ipcInvoke('copies:maintenanceState').then((state) => {
|
||||
if (mounted && !receivedEvent) setActive(state);
|
||||
}).catch(onError);
|
||||
return () => { mounted = false; dispose(); };
|
||||
}, [onError]);
|
||||
|
||||
const run = useCallback((id: string, operation: MaintenanceOperation, options: MaintenanceOptions = {}): void => {
|
||||
setLastResult(null);
|
||||
setActive({ id, operation, phase: 'checking', doneBytes: 0, totalBytes: 0 });
|
||||
ipcInvoke('copies:maintain', { id, operation, ...options })
|
||||
.then(() => {
|
||||
setLastResult({ copyId: id, outcome: operation });
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
if (error instanceof AppIpcError && error.code === 'maintenance_cancelled') {
|
||||
setLastResult({ copyId: id, outcome: 'cancelled' });
|
||||
} else {
|
||||
onError(error);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
setActive((current) => (current?.id === id && current.operation === operation ? null : current));
|
||||
});
|
||||
}, [onError]);
|
||||
|
||||
const cancel = useCallback((): void => {
|
||||
ipcInvoke('copies:cancelMaintenance').catch(onError);
|
||||
}, [onError]);
|
||||
|
||||
return { active, lastResult, revision, run, cancel };
|
||||
}
|
||||
|
||||
export type CopyMaintenanceState = ReturnType<typeof useCopyMaintenance>;
|
||||
@@ -215,9 +215,13 @@
|
||||
|
||||
/* ===== Buttons and links ===== */
|
||||
.button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font: 500 14px var(--font-display);
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
padding: 7px 16px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -371,3 +371,67 @@
|
||||
line-height: 1.6;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.about-columns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.about-column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.about-card {
|
||||
min-width: 0;
|
||||
padding: 14px 16px;
|
||||
background: rgba(0, 0, 0, 0.14);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.about-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.about-card-title {
|
||||
margin: 0;
|
||||
font: 500 14px var(--font-display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.about-card-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.about-card-meta {
|
||||
margin: 8px 0 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.about-card-label {
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.about-card .notice {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.about-card .notice .button {
|
||||
margin-top: 8px;
|
||||
}
|
||||
@@ -154,6 +154,10 @@ export const ipcContract = {
|
||||
input: z.object({ id: CopyIdSchema }),
|
||||
output: MaintenanceInfoSchema,
|
||||
},
|
||||
'copies:maintenanceState': {
|
||||
input: z.void(),
|
||||
output: MaintenanceProgressSchema.nullable(),
|
||||
},
|
||||
'copies:maintain': {
|
||||
input: MaintenanceRequestSchema,
|
||||
output: CopiesSchema,
|
||||
@@ -334,7 +338,7 @@ export const ipcEvents = {
|
||||
'event:app-update-progress': AppUpdateProgressSchema,
|
||||
'event:launch-state': LaunchStateSchema,
|
||||
'event:copies-changed': CopiesSchema,
|
||||
'event:copy-maintenance': MaintenanceProgressSchema,
|
||||
'event:copy-maintenance': MaintenanceProgressSchema.nullable(),
|
||||
/** Another patch set became active (a pack was installed, or the bundled set restored). */
|
||||
'event:patch-set-changed': ActivePatchSetSchema,
|
||||
} as const;
|
||||
|
||||
@@ -37,6 +37,7 @@ export interface EnqueueBattleInput {
|
||||
readonly modes?: readonly OfferedGameMode[];
|
||||
readonly country: string;
|
||||
readonly slotVehicles: readonly string[];
|
||||
readonly mrankDeltas: ReadonlyMap<string, number>;
|
||||
readonly selectedSlot?: BattleCrewSlot;
|
||||
readonly bannedMissions: ReadonlySet<string>;
|
||||
readonly dislikedMissions: ReadonlySet<string>;
|
||||
@@ -117,13 +118,14 @@ export class BattleMatchmaker {
|
||||
(mode) => mode.declaration.displayType !== 'pve_battle' && twoSidedMissionsOf(mode).length > 0,
|
||||
);
|
||||
if (pvpModes.length === 0) return { ok: false, error: 'PVE_NOT_SUPPORTED' };
|
||||
const chosenMode = this.#pickQueuedMode(pvpModes, input.slotVehicles, input.selectedSlot?.unitName);
|
||||
const chosenMode = this.#pickQueuedMode(pvpModes, input);
|
||||
if (!chosenMode) return { ok: false, error: 'BAD_PARAMS' };
|
||||
|
||||
const { declaration } = chosenMode;
|
||||
const activeVehicles = activeVehiclesForMode(declaration, input.slotVehicles, input.selectedSlot?.unitName, this.#vehiclesByName);
|
||||
const playerMrank = lineupMrank(
|
||||
activeVehicles, this.#vehiclesByName, declaration.difficulty, declaration.requiredClass, declaration.allowedClasses,
|
||||
input.mrankDeltas,
|
||||
);
|
||||
const minMrank = Math.max(declaration.minQueueMrank ?? 0, playerMrank - this.#tuning.brSpreadMrank);
|
||||
const roomCeiling = chosenMode.missionRanks?.maxMrank ?? Infinity;
|
||||
@@ -158,13 +160,10 @@ export class BattleMatchmaker {
|
||||
};
|
||||
}
|
||||
|
||||
#pickQueuedMode(
|
||||
candidates: readonly OfferedGameMode[],
|
||||
slotVehicles: readonly string[],
|
||||
selectedSlotVehicle: string | undefined,
|
||||
): OfferedGameMode | undefined {
|
||||
const pool = candidates.filter((mode) =>
|
||||
isModeEligibleForLineup(mode.declaration, slotVehicles, selectedSlotVehicle, this.#vehiclesByName));
|
||||
#pickQueuedMode(candidates: readonly OfferedGameMode[], input: EnqueueBattleInput): OfferedGameMode | undefined {
|
||||
const pool = candidates.filter((mode) => isModeEligibleForLineup(
|
||||
mode.declaration, input.slotVehicles, input.selectedSlot?.unitName, this.#vehiclesByName, input.mrankDeltas,
|
||||
));
|
||||
if (pool.length === 0) return candidates.find((mode) => mode.declaration.multiSlot !== false);
|
||||
const classics = pool.filter((mode) => !mode.declaration.tag);
|
||||
const subModes = pool.filter((mode) => Boolean(mode.declaration.tag));
|
||||
|
||||
@@ -28,7 +28,7 @@ const RULE_KEYS: readonly string[] = [
|
||||
/** Game type switches of a versus battle with tickets, capture zones and session rewards. */
|
||||
const VERSUS_SWITCHES: readonly string[] = [
|
||||
'gt_versus', 'gt_mp_tickets', 'gt_mp_capture', 'gt_use_wp', 'gt_use_xp', 'gt_use_stats', 'gt_use_unlocks',
|
||||
'isLimitedAmmo', 'allowUseArtillerySupport', 'isBotsAllowed', 'autoBalance',
|
||||
'allowUseArtillerySupport', 'isBotsAllowed', 'autoBalance',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -60,6 +60,8 @@ export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<R
|
||||
setParam(settings, 'symmetricTeams', flag(plan.symmetricTeams));
|
||||
setParam(settings, 'gt_mp_solo', flag(false));
|
||||
for (const name of VERSUS_SWITCHES) setParam(settings, name, flag(true));
|
||||
// The native in-flight rearm request and its receiver both require unlimited reserve ammunition.
|
||||
setParam(settings, 'isLimitedAmmo', flag(plan.modeName !== 'air_arcade'));
|
||||
setParam(settings, 'allowSpare', flag(!plan.selectedSlot));
|
||||
if (plan.selectedSlot) {
|
||||
setParam(settings, 'maxRespawns', integer(SINGLE_SPAWN));
|
||||
|
||||
@@ -95,18 +95,28 @@ export function lineupMrank(
|
||||
difficulty: ModeDifficulty,
|
||||
requiredClass: UnitClass,
|
||||
allowedClasses: readonly UnitClass[],
|
||||
mrankDeltas: ReadonlyMap<string, number>,
|
||||
): number {
|
||||
const crafts: CraftRankEntry[] = vehicleNames.flatMap((name) => {
|
||||
const vehicle = byName.get(name);
|
||||
if (!vehicle) return [];
|
||||
return [{
|
||||
unitClass: unitClassOfExpClass(vehicle.unitClass),
|
||||
mrank: vehicleMrank(vehicle, difficulty, requiredClass),
|
||||
mrank: lineupVehicleMrank(vehicle, difficulty, requiredClass, mrankDeltas),
|
||||
}];
|
||||
});
|
||||
return maxModeMrank(crafts, requiredClass, allowedClasses);
|
||||
}
|
||||
|
||||
function lineupVehicleMrank(
|
||||
vehicle: CatalogueVehicle,
|
||||
difficulty: ModeDifficulty,
|
||||
requiredClass: UnitClass,
|
||||
mrankDeltas: ReadonlyMap<string, number>,
|
||||
): number {
|
||||
return vehicleMrank(vehicle, difficulty, requiredClass) + (mrankDeltas.get(vehicle.name) ?? 0);
|
||||
}
|
||||
|
||||
export function selectCustomBots(
|
||||
vehicles: readonly CatalogueVehicle[], query: BotPoolQuery, aircraftLoadouts?: ReadonlyMap<string, BotAircraftLoadout>,
|
||||
): CustomBotsPool {
|
||||
@@ -203,6 +213,7 @@ export function isModeEligibleForLineup(
|
||||
slotVehicles: readonly string[],
|
||||
selectedSlotVehicle: string | undefined,
|
||||
byName: ReadonlyMap<string, CatalogueVehicle>,
|
||||
mrankDeltas: ReadonlyMap<string, number>,
|
||||
): boolean {
|
||||
if (!declaration.tag && declaration.multiSlot !== false) return true;
|
||||
const active = activeVehiclesForMode(declaration, slotVehicles, selectedSlotVehicle, byName);
|
||||
@@ -211,7 +222,7 @@ export function isModeEligibleForLineup(
|
||||
const matchingCount = active.filter((name) => {
|
||||
const vehicle = byName.get(name);
|
||||
if (!vehicle || unitClassOfExpClass(vehicle.unitClass) !== declaration.requiredClass) return false;
|
||||
return vehicleMrank(vehicle, declaration.difficulty, declaration.requiredClass) >= minMrank;
|
||||
return lineupVehicleMrank(vehicle, declaration.difficulty, declaration.requiredClass, mrankDeltas) >= minMrank;
|
||||
}).length;
|
||||
return matchingCount >= minCrafts;
|
||||
}
|
||||
@@ -61,6 +61,7 @@ import {
|
||||
buyWeaponsAction,
|
||||
enableModificationsAction,
|
||||
saveWeaponPresetsAction,
|
||||
setUnitSelectedMrankAction,
|
||||
} from './modification-actions.ts';
|
||||
import { entitlementsFull, initialMeta, legacyUserData } from './online-init-actions.ts';
|
||||
import { savePilotAppearanceAction, saveShowcaseAction, selectTitleAction, showcasesAction, usersTerseInfoAction } from './player-card-actions.ts';
|
||||
@@ -137,6 +138,7 @@ function coreActionEntries(deps: ActionDependencies): Array<[string, CharActionH
|
||||
['cln_buy_weapon', buyWeaponsAction(deps.profiles, deps.accounts, deps.equipment)],
|
||||
['cln_save_weapon_presets', saveWeaponPresetsAction(deps.profiles, deps.accounts, deps.equipment)],
|
||||
['cln_enable_modifications', enableModificationsAction(deps.profiles, deps.accounts, deps.equipment)],
|
||||
['cln_set_unit_selected_mrank', setUnitSelectedMrankAction(deps.profiles, deps.accounts, deps.equipment)],
|
||||
['cln_upgrade_crew', upgradeCrewAction(deps.profiles, deps.accounts, deps.crew)],
|
||||
['cln_purchase_skill_points', purchaseSkillPointsAction(deps.profiles, deps.accounts, deps.crew)],
|
||||
['cln_specialize_crew', specializeCrewAction(deps.profiles, deps.accounts, deps.crew)],
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* cln_buy_all_modification: unit:t forceOpen:b cost:i costGold:i
|
||||
* cln_buy_spare_aircrafts: aircraft:t count:i cost:i costGold:i
|
||||
* cln_buy_weapon: aircraft:t weapon:t count:i cost:i costGold:i
|
||||
* cln_set_unit_selected_mrank (scripts/unit/unitmrankselectionstate.nut): unit:t addMrank:i
|
||||
* cln_enable_modifications (shop_enable_modifications, 0x17a5020 -> 0x29a890; lab round 18):
|
||||
* <vehicle>{ <modification>:b=yes ... } ...
|
||||
*/
|
||||
@@ -16,6 +17,7 @@ import type { AccountStore } from '../../accounts/account-store.ts';
|
||||
import type { EquipmentCatalogue } from '../../modifications/equipment-catalogue.ts';
|
||||
import { buyAllModifications, buyModification, enableModifications } from '../../modifications/modification-purchase.ts';
|
||||
import { buySpares } from '../../modifications/spare-purchase.ts';
|
||||
import { selectVehicleMrankDelta } from '../../modifications/vehicle-mrank-selection.ts';
|
||||
import { saveWeaponPresets } from '../../modifications/weapon-presets.ts';
|
||||
import { buyWeapons } from '../../modifications/weapon-purchase.ts';
|
||||
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
|
||||
@@ -81,6 +83,15 @@ export function saveWeaponPresetsAction(profiles: PlayerProfiles, accounts: Acco
|
||||
return ruleAction(profiles, accounts, (payload) => (profile) => saveWeaponPresets(profile, equipment, payload));
|
||||
}
|
||||
|
||||
export function setUnitSelectedMrankAction(profiles: PlayerProfiles, accounts: AccountStore, equipment: EquipmentCatalogue): CharActionHandler {
|
||||
return ruleAction(profiles, accounts, (payload) => {
|
||||
const vehicle = stringParam(payload, 'unit');
|
||||
const delta = intParam(payload, 'addMrank');
|
||||
if (!vehicle || delta === undefined) return undefined;
|
||||
return (profile) => selectVehicleMrankDelta(profile, equipment, vehicle, delta);
|
||||
});
|
||||
}
|
||||
|
||||
function offeredPrice(payload: BlkBlock) {
|
||||
return { silverLions: intParam(payload, 'cost') ?? 0, goldenEagles: intParam(payload, 'costGold') ?? 0 };
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* char.vromfs.bin config/wpcost.blk, per vehicle:
|
||||
* needBuyToOpenNextInTier<N>:i researched modifications of tier N needed to open tier N+1
|
||||
* modifications{ <name>{ tier:i reqExp:i value:i costGold:i openCostGold:i
|
||||
* reqModification:t (repeated) maxCount:i ammoCount:i ... } }
|
||||
* reqModification:t (repeated) maxCount:i ammoCount:i addMrank:i ... } }
|
||||
* Ammunition and expendables are modifications too (tier 0, maxCount, ammoCount).
|
||||
* weapons{ <preset>{ value:i costGold:i maxCount:i reqModification:t ... } }
|
||||
* Paid presets (bombs, rockets) are bought by the piece, up to maxCount; the rest are free,
|
||||
@@ -39,6 +39,8 @@ export interface ModificationFacts {
|
||||
readonly maxCount: number;
|
||||
/** ammoCount present: an ammunition belt or shell type. */
|
||||
readonly ammunition: boolean;
|
||||
/** addMrank: selectable matchmaking rank increase unlocked by owning this modification. */
|
||||
readonly addMrank?: number;
|
||||
/** Initial enabled state when acquired (`turn_it_off` / `isEnabledByDefaultForAddMrank`). */
|
||||
readonly defaultEnabled: boolean;
|
||||
/** Non-bullet `group` name when modifications in the same group are mutually exclusive. */
|
||||
@@ -78,7 +80,7 @@ interface GlobalModificationMeta {
|
||||
|
||||
export const vehicleEquipment: Dataset<readonly VehicleEquipment[]> = {
|
||||
id: 'vehicle-equipment',
|
||||
version: 4,
|
||||
version: 5,
|
||||
extract: (source) => {
|
||||
const modMeta = readGlobalModificationMeta(source.readBlk('char.vromfs.bin', MODIFICATIONS_CONFIG));
|
||||
return source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks.map((vehicle) => equipmentOf(vehicle, modMeta));
|
||||
@@ -119,6 +121,7 @@ function equipmentOf(vehicle: BlkBlock, modMeta: ReadonlyMap<string, GlobalModif
|
||||
|
||||
function modificationOf(modification: BlkBlock, meta: GlobalModificationMeta | undefined): ModificationFacts {
|
||||
const ammunition = numberField(modification, 'ammoCount') !== undefined;
|
||||
const addMrank = numberField(modification, 'addMrank');
|
||||
const defaultEnabled = !(meta?.turnOffByDefault ?? false) && (boolField(modification, 'isEnabledByDefaultForAddMrank') ?? true);
|
||||
const group = stringField(modification, 'group') ?? meta?.group;
|
||||
const exclusiveGroup = !ammunition && !(meta?.bulletGroup ?? false) ? group : undefined;
|
||||
@@ -132,6 +135,7 @@ function modificationOf(modification: BlkBlock, meta: GlobalModificationMeta | u
|
||||
requires: stringList(modification, 'reqModification'),
|
||||
maxCount: numberField(modification, 'maxCount') ?? 0,
|
||||
ammunition,
|
||||
...(addMrank !== undefined ? { addMrank } : {}),
|
||||
defaultEnabled,
|
||||
...(exclusiveGroup !== undefined ? { exclusiveGroup } : {}),
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ import { maxModeMrank, unitClassOfExpClass, unitClassOfTypeCode, type CraftRankE
|
||||
import type { BattleSessionStore } from '../battle/battle-session-store.ts';
|
||||
import type { GameModes, OfferedGameMode } from '../game-modes/game-modes.ts';
|
||||
import { crewSlotVehicleOfCountry, crewVehiclesOfCountry } from '../profile/profile-crews.ts';
|
||||
import { vehicleMrankDelta } from '../profile/profile-hangar.ts';
|
||||
import type { PlayerProfiles } from '../profile/player-profiles.ts';
|
||||
import { battleLaunchNotify, type BattleLaunchNotify } from './battle-launch-notify.ts';
|
||||
import type { MatchingRequestHandler } from './matching-requests.ts';
|
||||
@@ -90,6 +91,7 @@ function handleEnqueue(
|
||||
modes,
|
||||
country: playerEntry.country,
|
||||
slotVehicles,
|
||||
mrankDeltas: new Map(slotVehicles.map((vehicle) => [vehicle, vehicleMrankDelta(profile, vehicle)])),
|
||||
...(idInCountry !== undefined && selectedSlotVehicle ? { selectedSlot: { idInCountry, unitName: selectedSlotVehicle } } : {}),
|
||||
bannedMissions: playerEntry.bannedMissions,
|
||||
dislikedMissions: playerEntry.dislikedMissions,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import { ownsVehicle, setVehicleMrankDelta } from '../profile/profile-hangar.ts';
|
||||
import { modificationRecord } from '../profile/profile-modifications.ts';
|
||||
import { ACCEPTED, refused, type RuleOutcome } from '../research/rule-outcome.ts';
|
||||
import type { EquipmentCatalogue } from './equipment-catalogue.ts';
|
||||
|
||||
export function selectVehicleMrankDelta(
|
||||
profile: BlkBlock, catalogue: EquipmentCatalogue, vehicle: string, delta: number,
|
||||
): RuleOutcome {
|
||||
const equipment = catalogue.vehicle(vehicle);
|
||||
if (!equipment || !ownsVehicle(profile, vehicle) || !Number.isInteger(delta) || delta < 0) return refused('BAD_PARAMS');
|
||||
|
||||
// Stock getSelectableAddMranks offers zero and each positive addMrank on an owned modification.
|
||||
if (delta > 0 && !equipment.modifications.some((modification) =>
|
||||
modification.addMrank === delta && (modificationRecord(profile, vehicle, modification.name)?.count ?? 0) > 0)) {
|
||||
return refused('NOT_AVAILABLE');
|
||||
}
|
||||
|
||||
setVehicleMrankDelta(profile, vehicle, delta);
|
||||
return ACCEPTED;
|
||||
}
|
||||
@@ -1,19 +1,24 @@
|
||||
/**
|
||||
* Owned vehicles in the profile, as in Gaijin's
|
||||
* config/default_user.blk: one empty sub-block per vehicle the player owns.
|
||||
* The profile's hangar has one sub-block per owned vehicle, as in config/default_user.blk.
|
||||
*
|
||||
* hangar{
|
||||
* bf2c_1{
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
import { ensureBlock, findBlock, type BlkBlock } from '@wto/blk';
|
||||
import { ensureBlock, findBlock, setParam, type BlkBlock } from '@wto/blk';
|
||||
import { intField } from './blk-fields.ts';
|
||||
|
||||
const HANGAR = 'hangar';
|
||||
const MRANK_DELTA = 'mrankDelta';
|
||||
|
||||
function ownedVehicle(profile: BlkBlock, vehicle: string): BlkBlock | undefined {
|
||||
const hangar = findBlock(profile, HANGAR);
|
||||
return hangar && findBlock(hangar, vehicle);
|
||||
}
|
||||
|
||||
export function ownsVehicle(profile: BlkBlock, vehicle: string): boolean {
|
||||
const hangar = findBlock(profile, HANGAR);
|
||||
return hangar !== undefined && findBlock(hangar, vehicle) !== undefined;
|
||||
return ownedVehicle(profile, vehicle) !== undefined;
|
||||
}
|
||||
|
||||
export function ownedVehicles(profile: BlkBlock): Set<string> {
|
||||
@@ -25,3 +30,13 @@ export function addOwnedVehicle(profile: BlkBlock, vehicle: string): void {
|
||||
const hangar = ensureBlock(profile, HANGAR);
|
||||
if (!hangar.blocks.some((owned) => owned.name === vehicle)) hangar.blocks.push({ name: vehicle, params: [], blocks: [] });
|
||||
}
|
||||
|
||||
/** The stock client uses the base rank until it has a non-negative selection. */
|
||||
export function vehicleMrankDelta(profile: BlkBlock, vehicle: string): number {
|
||||
return Math.max(0, intField(ownedVehicle(profile, vehicle), MRANK_DELTA));
|
||||
}
|
||||
|
||||
export function setVehicleMrankDelta(profile: BlkBlock, vehicle: string, delta: number): void {
|
||||
const entry = ownedVehicle(profile, vehicle);
|
||||
if (entry) setParam(entry, MRANK_DELTA, { type: 'int', value: delta });
|
||||
}
|
||||
Reference in new issue
Block a user