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:
1 parent
4e72bf3746
commit
deffcd6dde
5 files changed
+11
-15
No files matched your search
@@ -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),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user