fix(modifications): emit RESEARCHED status and align buy-all pricing
Add ModuleStatus.RESEARCHED (0x40, ES_ITEM_STATUS_RESEARCHED) for modifications that have reached their RP requirement while a reqModification prerequisite is not yet owned, and keep unresearched modifications locked until their prerequisites are researched. Update buyAllModifications / buyAllEntry to accept both CAN_BUY and RESEARCHED so the server matches client getAllModsCost (canBuyMod || isModStatusResearched) instead of rejecting cln_buy_all_modification with PRICE_CHANGED (shown as Internal character server error). Verified: root and launcher typecheck, and runtime check against 2.61.0.58 wpcost.blk chained modifications. Pending in-game acceptance.
This commit is contained in:
1 parent
638bc75724
commit
f6b00bc787
2 files changed
+41
-9
No files matched your search
@@ -10,11 +10,12 @@ import { moduleResearchPoints } from '../profile/profile-module-research.ts';
|
||||
import { countsForTier, isResearchable } from './equipment-catalogue.ts';
|
||||
import type { ProfileEquipmentIndex } from './profile-equipment-index.ts';
|
||||
|
||||
/** shopItemConsts ES_ITEM_STATUS_*; the same values as the vehicle statuses. */
|
||||
/** shopItemConsts ES_ITEM_STATUS_* (aces.exe 2.61.0.58 0x17e2894..0x17e294b); same values as VehicleStatus. */
|
||||
export const ModuleStatus = {
|
||||
LOCKED: 1,
|
||||
CAN_RESEARCH: 2,
|
||||
CAN_BUY: 8,
|
||||
RESEARCHED: 0x40,
|
||||
} as const;
|
||||
|
||||
export type ModuleStatus = (typeof ModuleStatus)[keyof typeof ModuleStatus];
|
||||
@@ -32,10 +33,11 @@ export function vehicleModuleState(
|
||||
index?: ProfileEquipmentIndex,
|
||||
): VehicleModuleState {
|
||||
const openTier = openTierOf(profile, equipment, index);
|
||||
const byName = new Map(equipment.modifications.map((mod) => [mod.name, mod]));
|
||||
const statuses = new Map<string, ModuleStatus>();
|
||||
for (const modification of equipment.modifications) {
|
||||
if (isOwned(profile, equipment.vehicle, modification.name, index)) continue;
|
||||
statuses.set(modification.name, statusOf(profile, equipment.vehicle, modification, openTier, index));
|
||||
statuses.set(modification.name, statusOf(profile, equipment.vehicle, modification, openTier, byName, index));
|
||||
}
|
||||
return { openTier, statuses };
|
||||
}
|
||||
@@ -80,16 +82,38 @@ function openTierOf(profile: BlkBlock, equipment: VehicleEquipment, index?: Prof
|
||||
return tier;
|
||||
}
|
||||
|
||||
function arePrerequisitesResearched(
|
||||
profile: BlkBlock,
|
||||
vehicle: string,
|
||||
requires: readonly string[],
|
||||
byName: ReadonlyMap<string, ModificationFacts>,
|
||||
index?: ProfileEquipmentIndex,
|
||||
): boolean {
|
||||
return requires.every((required) => {
|
||||
if (isOwned(profile, vehicle, required, index)) return true;
|
||||
const mod = byName.get(required);
|
||||
return mod !== undefined && isResearchable(mod) && isModuleResearched(profile, vehicle, mod, index);
|
||||
});
|
||||
}
|
||||
|
||||
function statusOf(
|
||||
profile: BlkBlock,
|
||||
vehicle: string,
|
||||
modification: ModificationFacts,
|
||||
openTier: number,
|
||||
byName: ReadonlyMap<string, ModificationFacts>,
|
||||
index?: ProfileEquipmentIndex,
|
||||
): ModuleStatus {
|
||||
if (isResearchable(modification)) {
|
||||
if (modification.tier > openTier) return ModuleStatus.LOCKED;
|
||||
return isModuleResearched(profile, vehicle, modification, index) ? ModuleStatus.CAN_BUY : ModuleStatus.CAN_RESEARCH;
|
||||
if (isModuleResearched(profile, vehicle, modification, index)) {
|
||||
return arePrerequisitesOwned(profile, vehicle, modification.requires, index)
|
||||
? ModuleStatus.CAN_BUY
|
||||
: ModuleStatus.RESEARCHED;
|
||||
}
|
||||
return arePrerequisitesResearched(profile, vehicle, modification.requires, byName, index)
|
||||
? ModuleStatus.CAN_RESEARCH
|
||||
: ModuleStatus.LOCKED;
|
||||
}
|
||||
return arePrerequisitesOwned(profile, vehicle, modification.requires, index) ? ModuleStatus.CAN_BUY : ModuleStatus.LOCKED;
|
||||
}
|
||||
Reference in new issue
Block a user