Separate research rules from character price encoding
Keep ResearchRules focused on vehicle research and purchases. Move cln_get_price_ex encoding into the character protocol layer and inject its catalogue dependencies explicitly. Load only the catalogues needed by each service and save editing command. Type checking and isolated service and save CLI checks passed. In-game acceptance is pending.
This commit is contained in:
1 parent
2b123194e1
commit
f4bb5ccf46
18 files changed
+310
-232
No files matched your search
@@ -9,10 +9,13 @@ import type { ClanStore } from './clans/clan-store.ts';
|
||||
import type { DatasetCache } from './game-data/datasets/dataset-cache.ts';
|
||||
import { reserveVehicles } from './game-data/datasets/reserve-vehicles.ts';
|
||||
import { shopBranches } from './game-data/datasets/shop-branches.ts';
|
||||
import { vehicleCatalogue, type CatalogueVehicle } from './game-data/datasets/vehicle-catalogue.ts';
|
||||
import { vehicleEquipment } from './game-data/datasets/vehicle-equipment.ts';
|
||||
import type { GameFiles } from './game-data/game-files.ts';
|
||||
import { removeExpiredItems } from './items/item-expiry.ts';
|
||||
import { trimUserLogs } from './profile/profile-trophies-log.ts';
|
||||
import { EquipmentCatalogue } from './modifications/equipment-catalogue.ts';
|
||||
import { refreshModuleState } from './modifications/module-state.ts';
|
||||
import { trimUserLogs } from './profile/profile-trophies-log.ts';
|
||||
import { PlayerProfiles } from './profile/player-profiles.ts';
|
||||
import { profileUpgrades } from './profile/profile-upgrades.ts';
|
||||
import { serverTimeNow } from './profile/server-time.ts';
|
||||
@@ -25,6 +28,7 @@ import type { Tuning } from './tuning/tuning.ts';
|
||||
export interface ProfileServices {
|
||||
readonly profiles: PlayerProfiles;
|
||||
readonly research: ResearchRules;
|
||||
readonly equipment: EquipmentCatalogue;
|
||||
}
|
||||
|
||||
export interface ProfileSyncContext {
|
||||
@@ -38,21 +42,23 @@ export function setUpProfiles(
|
||||
datasets: DatasetCache,
|
||||
tuning: Tuning,
|
||||
sync?: ProfileSyncContext,
|
||||
vehicles: readonly CatalogueVehicle[] = datasets.load(vehicleCatalogue),
|
||||
): ProfileServices {
|
||||
const startingContent: StartingContent = {
|
||||
reserveVehicles: datasets.load(reserveVehicles),
|
||||
branches: datasets.load(shopBranches),
|
||||
startingBalance: tuning.newProfile.startingBalance,
|
||||
};
|
||||
const research = loadResearchRules(datasets, tuning);
|
||||
const research = loadResearchRules(datasets, tuning.research, vehicles);
|
||||
const equipment = new EquipmentCatalogue(datasets.load(vehicleEquipment));
|
||||
const saves = new SaveStore(dataFolder, profileUpgrades(startingContent));
|
||||
const profiles = new PlayerProfiles(saves, gameFiles, startingContent, (profile, userId) => {
|
||||
const account = sync?.accounts.byUserId(userId);
|
||||
if (account && sync) sync.clans.syncProfile(profile, account);
|
||||
refreshResearchState(profile, research);
|
||||
refreshModuleState(profile, research.equipment);
|
||||
refreshModuleState(profile, equipment);
|
||||
removeExpiredItems(profile, serverTimeNow());
|
||||
trimUserLogs(profile, tuning.limits.userLogsKept);
|
||||
});
|
||||
return { profiles, research };
|
||||
return { profiles, research, equipment };
|
||||
}
|
||||
Reference in new issue
Block a user