feat(saves): merge bulk research and purchase into one launcher action

In the launcher's Saves -> Vehicles & Research page, "Research all" only
filled vehicle RP without purchasing them, requiring players to buy each
vehicle manually in-game while a separate "Grant regular vehicles" button
already added them to the hangar.

Merge the two actions into a single "Research and buy all" (`purchase`) action
alongside "Unlock modifications" (`equipment`), and switch bulk modification
unlocking in save-research.ts to ProfileEquipmentIndex so large saves stay
O(N) and write cleanly across chunked modification blocks.

Verified with root and launcher npm run typecheck, launcher electron-vite
build, and en/zh-CN locale key parity (631 keys).
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 01:19:20 +08:00
1 parent 4e72bf3746
commit deffcd6dde
5 files changed
+11 -15

No files matched your search

@@ -341,8 +341,7 @@
"country": "Country",
"type": "Vehicle type",
"actions": "Bulk actions",
"research": "Research all",
"purchase": "Grant regular vehicles",
"purchase": "Research and buy all",
"equipment": "Unlock modifications",
"empty": "This client has no eligible research branches.",
"rank": "Rank {{rank}}",
@@ -341,8 +341,7 @@
"country": "国家",
"type": "兵种",
"actions": "批量操作",
"research": "全部研发",
"purchase": "获得常规载具",
"purchase": "全部研发并购买",
"equipment": "解锁改装件",
"empty": "此客户端没有可编辑的研发分支。",
"rank": "等级 {{rank}}",
@@ -11,7 +11,7 @@ interface Props {
readonly onError: (error: unknown) => void;
}
const ACTIONS = ['research', 'purchase', 'equipment'] as const;
const ACTIONS = ['purchase', 'equipment'] as const;
export function SaveResearch({ copyId, userId, readOnly, onError }: Props) {
const { t, i18n } = useTranslation();
+1 -1
View File
@@ -94,7 +94,7 @@ export const OfficialPreviewSchema = z.object({
omitted: z.array(z.string()),
});
export const ResearchBranchSchema = z.object({ country: z.string().min(1), type: z.string().min(1) });
export const ResearchOperationSchema = z.enum(['research', 'purchase', 'equipment']);
export const ResearchOperationSchema = z.enum(['purchase', 'equipment']);
export const SaveResearchSchema = z.object({
branches: z.array(ResearchBranchSchema),
selected: ResearchBranchSchema.nullable(),
+7 -9
View File
@@ -3,9 +3,9 @@ import { ClanStore } from '../clans/clan-store.ts';
import { DatasetCache } from '../game-data/datasets/dataset-cache.ts';
import { vehicleCatalogue } from '../game-data/datasets/vehicle-catalogue.ts';
import { GameFiles } from '../game-data/game-files.ts';
import { ProfileEquipmentIndex } from '../modifications/profile-equipment-index.ts';
import { addOwnedVehicle, ownedVehicles } from '../profile/profile-hangar.ts';
import { ownsModification, writeModificationRecord } from '../profile/profile-modifications.ts';
import { researchPointsOf, setResearchPoints } from '../profile/profile-vehicle-research.ts';
import { researchPointsOf } from '../profile/profile-vehicle-research.ts';
import { setUpProfiles } from '../profiles-setup.ts';
import { TechTree } from '../research/tech-tree.ts';
import { loadTuning } from '../tuning/tuning.ts';
@@ -15,7 +15,7 @@ export interface ResearchBranch {
readonly country: string;
readonly type: string;
}
export type ResearchOperation = 'research' | 'purchase' | 'equipment';
export type ResearchOperation = 'purchase' | 'equipment';
function tree(location: SaveLocation) {
const gameFiles = new GameFiles(location.gameFolder);
@@ -52,21 +52,19 @@ export function editSaveResearch(location: SaveLocation, userId: string, branch:
const { profiles, equipment } = setUpProfiles(location.dataFolder, gameFiles, datasets, tuning, { accounts, clans }, vehicles);
profiles.update(userId, (profile) => {
const owned = ownedVehicles(profile);
const index = operation === 'equipment' ? new ProfileEquipmentIndex(profile) : undefined;
for (const unit of units) {
if (operation === 'research' && unit.kind === 'research' && !owned.has(unit.name)) {
setResearchPoints(profile, unit.name, Math.max(researchPointsOf(profile, unit.name), unit.researchPoints));
}
if (operation === 'purchase' && (unit.kind === 'research' || unit.kind === 'purchase')) {
addOwnedVehicle(profile, unit.name);
for (const part of unit.parts) addOwnedVehicle(profile, part);
}
if (operation === 'equipment' && owned.has(unit.name)) {
if (index && owned.has(unit.name)) {
const enabledGroups = new Set<string>();
for (const mod of equipment.vehicle(unit.name)?.modifications ?? []) {
if (mod.name === 'premExpMul' || mod.goldenEagles > 0 || ownsModification(profile, unit.name, mod.name)) continue;
if (mod.name === 'premExpMul' || mod.goldenEagles > 0 || index.ownsModification(unit.name, mod.name)) continue;
const enable = mod.defaultEnabled && (!mod.exclusiveGroup || !enabledGroups.has(mod.exclusiveGroup));
if (enable && mod.exclusiveGroup) enabledGroups.add(mod.exclusiveGroup);
writeModificationRecord(profile, unit.name, mod.name, {
index.writeModificationRecord(unit.name, mod.name, {
silverLionsSpent: 0, goldenEaglesSpent: 0, enabled: enable, count: Math.max(1, mod.maxCount),
});
}