mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2025-10-30 14:17:55 +00:00
@@ -3,7 +3,6 @@ import type {
|
||||
BaseType,
|
||||
DropEntry,
|
||||
ItemCategoryToEmptyPrefix,
|
||||
PseudoIdToTradeRequest,
|
||||
RuneDataByRune,
|
||||
RuneDataByTradeId,
|
||||
RuneSingleValue,
|
||||
@@ -19,7 +18,6 @@ export let ITEM_DROP: DropEntry[];
|
||||
export let CLIENT_STRINGS: TranslationDict;
|
||||
export let CLIENT_STRINGS_REF: TranslationDict;
|
||||
export let APP_PATRONS: Array<{ from: string; months: number; style: number }>;
|
||||
export let PSEUDO_ID_TO_TRADE_REQUEST: PseudoIdToTradeRequest;
|
||||
export let RUNE_SINGLE_VALUE: RuneSingleValue;
|
||||
export let RUNE_DATA_BY_RUNE: RuneDataByRune;
|
||||
export let RUNE_DATA_BY_TRADE_ID: RuneDataByTradeId;
|
||||
@@ -259,10 +257,6 @@ export async function init(lang: string, isTest = false) {
|
||||
await fetch(`${import.meta.env.BASE_URL}data/patrons.json`)
|
||||
).json();
|
||||
|
||||
PSEUDO_ID_TO_TRADE_REQUEST = await (
|
||||
await fetch(`${import.meta.env.BASE_URL}data/pseudo-pseudo.json`)
|
||||
).json();
|
||||
|
||||
ITEM_CATEGORY_TO_EMPTY_PREFIX = await (
|
||||
await fetch(`${import.meta.env.BASE_URL}data/pseudo-empty-prefix.json`)
|
||||
).json();
|
||||
|
||||
@@ -243,18 +243,6 @@ export interface Filter {
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
export interface PseudoIdToTradeRequest {
|
||||
[id: string]: {
|
||||
filters: Filter[];
|
||||
type: "weight";
|
||||
value: {
|
||||
min?: number;
|
||||
max?: number;
|
||||
};
|
||||
disabled?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ItemCategoryToEmptyPrefix {
|
||||
[id: string]: {
|
||||
filters: Filter[];
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
:stats="itemStats"
|
||||
:item="item"
|
||||
:presets="presets"
|
||||
:weightFilters="weightFilters"
|
||||
@preset="selectPreset"
|
||||
@submit="doSearch = true"
|
||||
:rebuild-key="rebuildKey"
|
||||
@@ -21,7 +20,6 @@
|
||||
:filters="itemFilters"
|
||||
:stats="itemStats"
|
||||
:item="item"
|
||||
:weightFilters="weightFilters"
|
||||
/>
|
||||
<trade-bulk
|
||||
v-if="tradeAPI === 'bulk' && doSearch"
|
||||
@@ -150,12 +148,6 @@ export default defineComponent({
|
||||
(preset) => preset.id === presets.value.active,
|
||||
)!.stats,
|
||||
);
|
||||
const weightFilters = computed(
|
||||
() =>
|
||||
presets.value.presets.find(
|
||||
(preset) => preset.id === presets.value.active,
|
||||
)!.weightFilters,
|
||||
);
|
||||
const doSearch = ref(false);
|
||||
const tradeAPI = ref<"trade" | "bulk">("bulk");
|
||||
|
||||
@@ -365,7 +357,6 @@ export default defineComponent({
|
||||
t,
|
||||
itemFilters,
|
||||
itemStats,
|
||||
weightFilters,
|
||||
doSearch,
|
||||
tradeAPI,
|
||||
tradeService,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { createFilters } from "./create-item-filters";
|
||||
import {
|
||||
createExactStatFilters,
|
||||
createResistanceWeightFilter,
|
||||
initUiModFilters,
|
||||
initWeightFilters,
|
||||
} from "./create-stat-filters";
|
||||
import { sumStatsByModType } from "@/parser/modifiers";
|
||||
import { ItemCategory, ItemRarity, ParsedItem } from "@/parser";
|
||||
@@ -34,11 +32,6 @@ export function createPresets(
|
||||
id: ROMAN_NUMERALS[idx],
|
||||
filters: createFilters(item, { ...opts, exact: true }),
|
||||
stats: createExactStatFilters(item, sumStatsByModType(area), opts),
|
||||
weightFilters: createResistanceWeightFilter(
|
||||
item,
|
||||
sumStatsByModType(area),
|
||||
opts,
|
||||
),
|
||||
})),
|
||||
};
|
||||
}
|
||||
@@ -66,11 +59,6 @@ export function createPresets(
|
||||
id: "filters.preset_exact",
|
||||
filters: createFilters(item, { ...opts, exact: true }),
|
||||
stats: createExactStatFilters(item, item.statsByType, opts),
|
||||
weightFilters: createResistanceWeightFilter(
|
||||
item,
|
||||
item.statsByType,
|
||||
opts,
|
||||
),
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -81,7 +69,6 @@ export function createPresets(
|
||||
id: "filters.preset_pseudo",
|
||||
filters: createFilters(item, { ...opts, exact: false }),
|
||||
stats: initUiModFilters(item, opts),
|
||||
weightFilters: initWeightFilters(item, opts),
|
||||
};
|
||||
|
||||
// Apply runes if we should
|
||||
@@ -107,7 +94,6 @@ export function createPresets(
|
||||
id: "filters.preset_base_item",
|
||||
filters: createFilters(item, { ...opts, exact: true }),
|
||||
stats: createExactStatFilters(item, item.statsByType, opts),
|
||||
weightFilters: createResistanceWeightFilter(item, item.statsByType, opts),
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -15,17 +15,15 @@ import { percentRoll, percentRollDelta, roundRoll } from "./util";
|
||||
import {
|
||||
FilterTag,
|
||||
ItemHasEmptyModifier,
|
||||
RESISTANCE_WEIGHT_GROUP,
|
||||
StatFilter,
|
||||
StatFilterRoll,
|
||||
WeightStatGroup,
|
||||
} from "./interfaces";
|
||||
import { filterPseudo } from "./pseudo";
|
||||
import { applyRules as applyAtzoatlRules } from "./pseudo/atzoatl-rules";
|
||||
import { applyRules as applyMirroredTabletRules } from "./pseudo/reflection-rules";
|
||||
import { filterItemProp, filterBasePercentile } from "./pseudo/item-property";
|
||||
import { decodeOils, applyAnointmentRules } from "./pseudo/anointments";
|
||||
import { StatBetter, CLIENT_STRINGS, STAT_BY_REF } from "@/assets/data";
|
||||
import { StatBetter, CLIENT_STRINGS } from "@/assets/data";
|
||||
import { maxUsefulItemLevel } from "./common";
|
||||
|
||||
export interface FiltersCreationContext {
|
||||
@@ -35,88 +33,6 @@ export interface FiltersCreationContext {
|
||||
statsByType: StatCalculated[];
|
||||
}
|
||||
|
||||
export function initWeightFilters(
|
||||
item: ParsedItem,
|
||||
opts: {
|
||||
searchStatRange: number;
|
||||
},
|
||||
): WeightStatGroup[] {
|
||||
const statsByType = item.statsByType.map((calc) => {
|
||||
if (
|
||||
calc.type === ModifierType.Fractured &&
|
||||
calc.stat.trade.ids[ModifierType.Explicit]
|
||||
) {
|
||||
return { ...calc, type: ModifierType.Explicit };
|
||||
} else {
|
||||
return calc;
|
||||
}
|
||||
});
|
||||
|
||||
return createResistanceWeightFilter(item, statsByType, opts);
|
||||
}
|
||||
|
||||
export function createResistanceWeightFilter(
|
||||
item: ParsedItem,
|
||||
statsByType: StatCalculated[],
|
||||
opts: {
|
||||
searchStatRange: number;
|
||||
},
|
||||
): WeightStatGroup[] {
|
||||
const weightFilter: WeightStatGroup = {
|
||||
stats: [],
|
||||
value: {},
|
||||
disabled: true,
|
||||
name: RESISTANCE_WEIGHT_GROUP,
|
||||
};
|
||||
|
||||
const searchInRange = Math.min(2, opts.searchStatRange);
|
||||
|
||||
const resistanceWeights: any = {
|
||||
"#% to Lightning Resistance": 1,
|
||||
"#% to Fire Resistance": 1,
|
||||
"#% to Cold Resistance": 1,
|
||||
"#% to all Elemental Resistances": 3,
|
||||
};
|
||||
|
||||
let min = 0;
|
||||
for (const stat of statsByType) {
|
||||
if (!resistanceWeights[stat.stat.ref]) continue;
|
||||
|
||||
const modWeight = resistanceWeights[stat.stat.ref];
|
||||
const statValue = stat.sources
|
||||
.map((source) => source.contributes?.value)
|
||||
.map((value) => value || 0)
|
||||
.reduce((acc: number, v: number) => acc + v, 0);
|
||||
min += statValue * modWeight;
|
||||
}
|
||||
|
||||
if (min === 0) return [];
|
||||
|
||||
for (const ref of Object.keys(resistanceWeights)) {
|
||||
const stat = STAT_BY_REF(ref)!;
|
||||
const modWeight = resistanceWeights[ref];
|
||||
const calcStat: StatCalculated = {
|
||||
stat,
|
||||
type: ModifierType.Pseudo,
|
||||
sources: [],
|
||||
};
|
||||
|
||||
const statFilter = calculatedStatToFilter(calcStat, searchInRange, item);
|
||||
statFilter.disabled = false;
|
||||
statFilter.weight = modWeight;
|
||||
statFilter.tradeId = Object.values(stat.trade.ids).flat();
|
||||
weightFilter.stats.push(statFilter);
|
||||
}
|
||||
|
||||
weightFilter.value.min = percentRoll(
|
||||
min,
|
||||
-opts.searchStatRange,
|
||||
Math.floor,
|
||||
false,
|
||||
);
|
||||
return [weightFilter];
|
||||
}
|
||||
|
||||
export function createExactStatFilters(
|
||||
item: ParsedItem,
|
||||
statsByType: StatCalculated[],
|
||||
|
||||
@@ -7,7 +7,6 @@ export interface FilterPreset {
|
||||
id: string;
|
||||
filters: ItemFilters;
|
||||
stats: StatFilter[];
|
||||
weightFilters: WeightStatGroup[];
|
||||
}
|
||||
|
||||
interface SearchFilter {
|
||||
@@ -128,26 +127,12 @@ export interface StatFilter {
|
||||
};
|
||||
hidden?: string;
|
||||
disabled: boolean; // NOTE: mutable in UI
|
||||
weight?: number;
|
||||
additionalInfo?: {
|
||||
[key: string]: StatFilterRoll;
|
||||
};
|
||||
editorAdded?: BaseType;
|
||||
}
|
||||
|
||||
export interface WeightStatGroup {
|
||||
stats: StatFilter[];
|
||||
name: string;
|
||||
value: {
|
||||
min?: number;
|
||||
max?: number;
|
||||
};
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
export const RESISTANCE_WEIGHT_GROUP: string =
|
||||
"RESISTANCE_WEIGHT_GROUP" as const;
|
||||
|
||||
export const INTERNAL_TRADE_IDS = [
|
||||
"item.base_percentile",
|
||||
"item.armour",
|
||||
|
||||
@@ -327,12 +327,6 @@ const PSEUDO_RULES: PseudoRule[] = [
|
||||
// },
|
||||
];
|
||||
|
||||
export function filterInPseudo(filter: StatFilter) {
|
||||
return PSEUDO_RULES.some((rule) =>
|
||||
rule.stats.some((stat) => stat.ref === filter.statRef),
|
||||
);
|
||||
}
|
||||
|
||||
export function filterPseudo(ctx: FiltersCreationContext) {
|
||||
const filterByGroup = new Map<string, StatFilter[]>();
|
||||
|
||||
|
||||
@@ -115,11 +115,7 @@ import { createTradeRequest } from "./pathofexile-trade";
|
||||
import { getTradeEndpoint } from "./common";
|
||||
import { AppConfig } from "@/web/Config";
|
||||
import { PriceCheckWidget } from "@/web/overlay/interfaces";
|
||||
import {
|
||||
ItemFilters,
|
||||
StatFilter,
|
||||
WeightStatGroup,
|
||||
} from "../filters/interfaces";
|
||||
import { ItemFilters, StatFilter } from "../filters/interfaces";
|
||||
import { ItemCategory, ParsedItem } from "@/parser";
|
||||
import { artificialSlowdown } from "./artificial-slowdown";
|
||||
import OnlineFilter from "./OnlineFilter.vue";
|
||||
@@ -146,10 +142,6 @@ export default defineComponent({
|
||||
type: Object as PropType<ParsedItem>,
|
||||
required: true,
|
||||
},
|
||||
weightFilters: {
|
||||
type: Array as PropType<WeightStatGroup[]>,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const widget = computed(() => AppConfig<PriceCheckWidget>("price-check")!);
|
||||
@@ -173,10 +165,6 @@ export default defineComponent({
|
||||
: `https://${getTradeEndpoint()}/trade2/search/poe2/${props.filters.trade.league}?q=${JSON.stringify(createTradeRequest(props.filters, props.stats, props.item))}`;
|
||||
}
|
||||
|
||||
function makeTradeLinkPseudo() {
|
||||
return `https://${getTradeEndpoint()}/trade2/search/poe2/${props.filters.trade.league}?q=${JSON.stringify(createTradeRequest(props.filters, props.stats, props.item, props.weightFilters))}`;
|
||||
}
|
||||
|
||||
// Shift Key Detection
|
||||
const isShiftPressed = ref(false);
|
||||
|
||||
@@ -231,7 +219,6 @@ export default defineComponent({
|
||||
}),
|
||||
showSeller: computed(() => widget.value.showSeller),
|
||||
makeTradeLink,
|
||||
makeTradeLinkPseudo,
|
||||
openTradeLink() {
|
||||
showBrowser(makeTradeLink());
|
||||
},
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
StatFilter,
|
||||
INTERNAL_TRADE_IDS,
|
||||
InternalTradeId,
|
||||
WeightStatGroup,
|
||||
ItemIsElementalModifier,
|
||||
} from "../filters/interfaces";
|
||||
import { setProperty as propSet } from "dot-prop";
|
||||
@@ -18,11 +17,10 @@ import {
|
||||
RATE_LIMIT_RULES,
|
||||
preventQueueCreation,
|
||||
} from "./common";
|
||||
import { PSEUDO_ID_TO_TRADE_REQUEST, STAT_BY_REF } from "@/assets/data";
|
||||
import { STAT_BY_REF } from "@/assets/data";
|
||||
import { RateLimiter } from "./RateLimiter";
|
||||
import { ModifierType } from "@/parser/modifiers";
|
||||
import { Cache } from "./Cache";
|
||||
import { filterInPseudo } from "../filters/pseudo";
|
||||
import { parseAffixStrings } from "@/parser/Parser";
|
||||
|
||||
export const CATEGORY_TO_TRADE_ID = new Map([
|
||||
@@ -121,7 +119,7 @@ interface TradeRequest {
|
||||
name?: string | { discriminator: string; option: string };
|
||||
type?: string | { discriminator: string; option: string };
|
||||
stats: Array<{
|
||||
type: "and" | "if" | "count" | "not" | "weight";
|
||||
type: "and" | "if" | "count" | "not";
|
||||
value?: FilterRange;
|
||||
filters: Array<{
|
||||
id: string;
|
||||
@@ -129,7 +127,6 @@ interface TradeRequest {
|
||||
min?: number;
|
||||
max?: number;
|
||||
option?: number | string;
|
||||
weight?: number;
|
||||
};
|
||||
disabled?: boolean;
|
||||
}>;
|
||||
@@ -310,7 +307,6 @@ export function createTradeRequest(
|
||||
filters: ItemFilters,
|
||||
stats: StatFilter[],
|
||||
item: ParsedItem,
|
||||
weightGroups?: WeightStatGroup[],
|
||||
) {
|
||||
const body: TradeRequest = {
|
||||
query: {
|
||||
@@ -794,11 +790,6 @@ export function createTradeRequest(
|
||||
|
||||
const qAnd = query.stats[0];
|
||||
for (const stat of stats) {
|
||||
let overrideDisabled = false;
|
||||
if (weightGroups && filterInPseudo(stat)) {
|
||||
overrideDisabled = true;
|
||||
}
|
||||
|
||||
if (stat.statRef === "Only affects Passives in # Ring") {
|
||||
const metaSource = stat.roll!;
|
||||
const metamorphosisCount = metaSource.bounds!.max;
|
||||
@@ -819,54 +810,21 @@ export function createTradeRequest(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stat.tradeId[0].startsWith("pseudo.")) {
|
||||
query.stats.push(pseudoPseudoToQuery(stat.tradeId[0], stat));
|
||||
} else if (stat.tradeId.length === 1) {
|
||||
qAnd.filters.push(
|
||||
tradeIdToQuery(stat.tradeId[0], stat, overrideDisabled),
|
||||
);
|
||||
if (stat.tradeId.length === 1) {
|
||||
qAnd.filters.push(tradeIdToQuery(stat.tradeId[0], stat));
|
||||
} else {
|
||||
query.stats.push({
|
||||
type: "count",
|
||||
value: { min: 1 },
|
||||
disabled: stat.disabled || overrideDisabled,
|
||||
disabled: stat.disabled,
|
||||
filters: stat.tradeId.map((id) => tradeIdToQuery(id, stat)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (weightGroups) {
|
||||
for (const weightGroup of weightGroups) {
|
||||
query.stats.push({
|
||||
type: "weight",
|
||||
value: weightGroup.value,
|
||||
disabled: false,
|
||||
filters: weightStatsToFilters(weightGroup.stats),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
function weightStatsToFilters(weightStats: StatFilter[]) {
|
||||
const filters: any[] = [];
|
||||
|
||||
for (const stat of weightStats) {
|
||||
for (const tradeId of stat.tradeId) {
|
||||
filters.push({
|
||||
disabled: false,
|
||||
id: tradeId,
|
||||
value: {
|
||||
weight: stat.weight,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
const cache = new Cache();
|
||||
|
||||
export async function requestTradeResultList(
|
||||
@@ -1062,11 +1020,7 @@ function getMinMax(roll: StatFilter["roll"]) {
|
||||
return !roll.tradeInvert ? { min: a, max: b } : { min: b, max: a };
|
||||
}
|
||||
|
||||
function tradeIdToQuery(
|
||||
id: string,
|
||||
stat: StatFilter,
|
||||
overrideDisabled: boolean = false,
|
||||
) {
|
||||
function tradeIdToQuery(id: string, stat: StatFilter) {
|
||||
// NOTE: if there will be too many overrides in the future,
|
||||
// consider moving them to stats.ndjson
|
||||
|
||||
@@ -1103,7 +1057,7 @@ function tradeIdToQuery(
|
||||
...getMinMax(roll),
|
||||
// option: stat.option != null ? stat.option.value : undefined,
|
||||
},
|
||||
disabled: stat.disabled || overrideDisabled,
|
||||
disabled: stat.disabled,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1117,10 +1071,3 @@ function nameToQuery(name: string, filters: ItemFilters) {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function pseudoPseudoToQuery(id: string, stat: StatFilter) {
|
||||
const filter = PSEUDO_ID_TO_TRADE_REQUEST[id];
|
||||
filter.value = { ...getMinMax(stat.roll) };
|
||||
filter.disabled = stat.disabled;
|
||||
return filter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user