mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-25 14:15:42 +00:00
Fix parse error on bonded mods
This commit is contained in:
@@ -196,6 +196,26 @@ describe("determineAugments", () => {
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].refName).toEqual("Greater Storm Rune");
|
||||
});
|
||||
|
||||
it("works for bonded augments", () => {
|
||||
const expectedRef = ["Fox Idol"];
|
||||
|
||||
const result = __testExports.determineAugments(
|
||||
{
|
||||
info: {
|
||||
type: ModifierType.Augment,
|
||||
},
|
||||
} as unknown as ParsedModifier,
|
||||
[
|
||||
makeCalcStat(
|
||||
"Idols socketed in this item gain the benefits of their Bonded modifiers",
|
||||
1,
|
||||
ModifierType.Augment,
|
||||
),
|
||||
],
|
||||
);
|
||||
expect(result.map((augment) => augment.refName)).toEqual(expectedRef);
|
||||
});
|
||||
});
|
||||
|
||||
describe("BFS", () => {
|
||||
@@ -460,4 +480,44 @@ describe("applyAugmentSockets", () => {
|
||||
),
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should handle bonded mods", () => {
|
||||
const item = createTestItem();
|
||||
item.category = ItemCategory.BodyArmour;
|
||||
item.augmentSockets = {
|
||||
empty: 1,
|
||||
current: 1,
|
||||
normal: 2,
|
||||
augments: [null, null],
|
||||
};
|
||||
|
||||
const Bonded = makeCalcStat(
|
||||
"Bonded: #% to Quality of all Skills",
|
||||
5,
|
||||
ModifierType.Augment,
|
||||
);
|
||||
const nonBonded = makeCalcStat(
|
||||
"Idols socketed in this item gain the benefits of their Bonded modifiers",
|
||||
1,
|
||||
ModifierType.Augment,
|
||||
);
|
||||
item.statsByType = [Bonded, nonBonded];
|
||||
item.newMods = [
|
||||
{
|
||||
info: {
|
||||
type: ModifierType.Augment,
|
||||
tags: [],
|
||||
},
|
||||
stats: [Bonded.sources[0].stat, nonBonded.sources[0].stat],
|
||||
},
|
||||
];
|
||||
|
||||
__testExports.applyAugmentSockets(item);
|
||||
expect(item.augmentSockets.empty).toEqual(1);
|
||||
expect(item.augmentSockets.current).toEqual(1);
|
||||
expect(item.augmentSockets.normal).toEqual(2);
|
||||
expect(item.augmentSockets.augments).toHaveLength(2);
|
||||
expect(item.augmentSockets.augments[0]?.refName).toBe("Fox Idol");
|
||||
expect(item.augmentSockets.augments[1]).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -398,7 +398,7 @@ function augmentsToLookup(augmentList: BaseType[]): AugmentDataByAugment {
|
||||
if (!augmentDataByAugment[augment.refName]) {
|
||||
augmentDataByAugment[augment.refName] = [];
|
||||
}
|
||||
augmentDataByAugment[augment.refName].push({
|
||||
augmentDataByAugment[augment.refName]!.push({
|
||||
augment: augment.name,
|
||||
refName: augment.refName,
|
||||
baseStat: text,
|
||||
@@ -426,7 +426,7 @@ function augmentsToLookupTradeId(
|
||||
if (!augmentDataByAugment[tradeId[0]]) {
|
||||
augmentDataByAugment[tradeId[0]] = [];
|
||||
}
|
||||
augmentDataByAugment[tradeId[0]].push({
|
||||
augmentDataByAugment[tradeId[0]]!.push({
|
||||
refName: augment.refName,
|
||||
augment: augment.name,
|
||||
baseStat: text,
|
||||
|
||||
@@ -312,18 +312,20 @@ export interface AugmentData {
|
||||
* Value is each option that the value could be for, ie stat for armour or weapon.
|
||||
*/
|
||||
export interface AugmentDataByAugment {
|
||||
[augment: string]: AugmentData[];
|
||||
[augment: string]: AugmentData[] | undefined;
|
||||
}
|
||||
export interface AugmentDataByTradeId {
|
||||
[tradeId: string]: Array<{
|
||||
refName: string;
|
||||
augment: string;
|
||||
baseStat: string;
|
||||
values: number[];
|
||||
id: string;
|
||||
categories: ItemCategory[];
|
||||
icon: string;
|
||||
}>;
|
||||
[tradeId: string]:
|
||||
| Array<{
|
||||
refName: string;
|
||||
augment: string;
|
||||
baseStat: string;
|
||||
values: number[];
|
||||
id: string;
|
||||
categories: ItemCategory[];
|
||||
icon: string;
|
||||
}>
|
||||
| undefined;
|
||||
}
|
||||
|
||||
export interface AugmentGroup<T> {
|
||||
|
||||
@@ -1325,9 +1325,9 @@ function applyAugmentSockets(item: ParsedItem) {
|
||||
const augmentMods = item.newMods.filter(
|
||||
(mod) => mod.info.type === ModifierType.Augment,
|
||||
);
|
||||
const augmentStats = item.statsByType.filter(
|
||||
(calc) => calc.type === ModifierType.Augment,
|
||||
);
|
||||
const augmentStats = item.statsByType
|
||||
.filter((calc) => calc.type === ModifierType.Augment)
|
||||
.filter((calc) => !calc.stat.ref.startsWith("Bonded"));
|
||||
|
||||
let statCombinations = combinations(augmentStats)
|
||||
.filter((f) => f.length)
|
||||
@@ -2168,9 +2168,10 @@ function determineAugments(
|
||||
const allTradeIds = statCalcs.map(
|
||||
(c) => c.stat.trade.ids[ModifierType.Augment][0],
|
||||
);
|
||||
const allPossibleAugments = allTradeIds.map(
|
||||
(id) => AUGMENT_DATA_BY_TRADE_ID[id],
|
||||
);
|
||||
const allPossibleAugments = allTradeIds
|
||||
.map((id) => AUGMENT_DATA_BY_TRADE_ID[id])
|
||||
.filter((v) => v !== undefined);
|
||||
|
||||
const augmentRefSets = allPossibleAugments.map(
|
||||
(augGroup) => new Set(augGroup.map((a) => a.refName)),
|
||||
);
|
||||
|
||||
@@ -77,7 +77,9 @@ function createNewStatFilter(
|
||||
): StatFilter[] | undefined {
|
||||
if (!item.category) return;
|
||||
const newItem = JSON.parse(JSON.stringify(item)) as ParsedItem;
|
||||
const augmentData = AUGMENT_DATA_BY_AUGMENT[newAugment].find((rune) =>
|
||||
const allCatAugData = AUGMENT_DATA_BY_AUGMENT[newAugment];
|
||||
if (!allCatAugData) return;
|
||||
const augmentData = allCatAugData.find((rune) =>
|
||||
rune.categories.includes(item.category!),
|
||||
);
|
||||
if (!augmentData) return;
|
||||
|
||||
@@ -7,6 +7,7 @@ export default defineConfig({
|
||||
build: {
|
||||
target: "esnext",
|
||||
assetsInlineLimit: 0,
|
||||
sourcemap: true,
|
||||
},
|
||||
optimizeDeps: {
|
||||
esbuildOptions: { target: "esnext" },
|
||||
|
||||
Reference in New Issue
Block a user