Files
WT-Offline/packages/local-service/src/research/research-rules.ts
T
N0VAN0M4LY 78f1857918 fix(research): keep a valid vehicle research target for each branch
The accelerated research dialog reads currUnit when it first opens.
Assign a valid target whenever an eligible vehicle exists and replace
stale selections when refreshing a profile.

Prefer an available direct successor when configured. Otherwise use
the configured rank or tech tree order. Type checking and profile
initialization passed. In-game acceptance is pending.
2026-11-25 13:41:29 +08:00

81 lines
4.5 KiB
TypeScript

/**
* The static facts research and purchase rules use, loaded once at start-up from the
* player's game files.
*/
import type { DatasetCache } from '../game-data/datasets/dataset-cache.ts';
import { crewSlotPrices, eraRequirements, type CrewSlotPrices, type EraRequirements } from '../game-data/datasets/rank-settings.ts';
import { researchPointsPerGoldenEagle } from '../game-data/datasets/research-point-rate.ts';
import { vehicleCatalogue } from '../game-data/datasets/vehicle-catalogue.ts';
import { decorCatalogue } from '../game-data/datasets/decor-catalogue.ts';
import { crewSkillData } from '../game-data/datasets/crew-skills.ts';
import { CrewSkillCatalogue } from '../crew/crew-skill-rules.ts';
import { vehicleEquipment } from '../game-data/datasets/vehicle-equipment.ts';
import { DecorShop } from '../decor/decor-purchase.ts';
import { vehicleUnlocks, type UnlockDefinition } from '../game-data/datasets/vehicle-unlocks.ts';
import { EquipmentCatalogue } from '../modifications/equipment-catalogue.ts';
import { unlockPrices } from '../game-data/datasets/unlock-prices.ts';
import { UnlockShop } from '../unlocks/unlock-purchase.ts';
import { clanEconomy, type ClanEconomy } from '../game-data/datasets/clan-economy.ts';
import { itemCatalogue } from '../game-data/datasets/item-catalogue.ts';
import { externalItemSources } from '../game-data/datasets/external-item-sources.ts';
import { storeBundles } from '../game-data/datasets/store-bundles.ts';
import { unitNames } from '../game-data/datasets/unit-names.ts';
import { InventoryCatalogue } from '../inventory/itemdef-catalogue.ts';
import { TrophyCatalogue } from '../inventory/trophy-catalogue.ts';
import { ItemCatalogue } from '../items/item-catalogue.ts';
import { StoreCatalogue } from '../store/store-catalogue.ts';
import type { Tuning } from '../tuning/tuning.ts';
import type { ResearchTuning } from './research-tuning.ts';
import { TechTree } from './tech-tree.ts';
export interface ResearchRules {
readonly techTree: TechTree;
readonly eraRequirements: EraRequirements;
readonly vehicleUnlocks: readonly UnlockDefinition[];
readonly crewSlotPrices: CrewSlotPrices;
readonly researchPointsPerGoldenEagle: number;
/** How a branch without a research target gets one (tuning/research.jsonc; implementation notes). */
readonly researchTuning: ResearchTuning;
/** Modifications, ammunition, weapon presets and spares of every vehicle. */
readonly equipment: EquipmentCatalogue;
/** Decorations for sale. */
readonly decor: DecorShop;
/** Crew skills, skill point packs, training prices. */
readonly crew: CrewSkillCatalogue;
/** Unlocks for sale: ship flags, profile icons and frames, awards. */
readonly unlocks: UnlockShop;
/** Classic items: boosters, personal discounts, contracts, universal spares. */
readonly items: ItemCatalogue;
/** Paid store catalogue: GE packs, SL packs, Premium Account, vehicle packs. */
readonly store: StoreCatalogue;
/** External inventory itemdefs, supply chests, recycle recipes, and marketplace coupons. */
readonly inventory: InventoryCatalogue;
/** Classic trophies: SL supply chests and GE vehicle prize-pool direct purchases. */
readonly trophies: TrophyCatalogue;
/** Squadron creation, upgrade and member-limit economy from warpoints.blk. */
readonly clanEconomy: ClanEconomy;
}
export function loadResearchRules(datasets: DatasetCache, tuning: Tuning): ResearchRules {
const vehicles = datasets.load(vehicleCatalogue);
const classicItemDefs = datasets.load(itemCatalogue);
const localizedUnitNames = datasets.load(unitNames);
return {
techTree: new TechTree(vehicles),
eraRequirements: datasets.load(eraRequirements),
vehicleUnlocks: datasets.load(vehicleUnlocks),
crewSlotPrices: datasets.load(crewSlotPrices),
researchPointsPerGoldenEagle: datasets.load(researchPointsPerGoldenEagle),
researchTuning: tuning.research,
equipment: new EquipmentCatalogue(datasets.load(vehicleEquipment)),
decor: new DecorShop(datasets.load(decorCatalogue)),
crew: new CrewSkillCatalogue(datasets.load(crewSkillData)),
unlocks: new UnlockShop(datasets.load(unlockPrices)),
items: new ItemCatalogue(classicItemDefs, tuning.limits.itemPiecesPerPurchase),
store: new StoreCatalogue(vehicles, datasets.load(storeBundles), localizedUnitNames, tuning.store),
inventory: new InventoryCatalogue(vehicles, localizedUnitNames, datasets.load(externalItemSources), classicItemDefs, tuning),
trophies: new TrophyCatalogue(vehicles, classicItemDefs, tuning.trophies),
clanEconomy: datasets.load(clanEconomy),
};
}