diff --git a/src/parser/ParsedItem.ts b/src/parser/ParsedItem.ts index 277bf9a1..6e2cd11c 100644 --- a/src/parser/ParsedItem.ts +++ b/src/parser/ParsedItem.ts @@ -46,6 +46,7 @@ export interface ParsedItem { category?: ItemCategory icon?: string rawText: string + isAdvancedDesc: boolean } export type HeistJob = diff --git a/src/parser/Parser.ts b/src/parser/Parser.ts index 287c3be5..655bf966 100644 --- a/src/parser/Parser.ts +++ b/src/parser/Parser.ts @@ -75,7 +75,10 @@ export function parseClipboard (clipboard: string) { if (!parsed) { return null } + sections.shift() + parsed.rawText = clipboard + parsed.isAdvancedDesc = isAdvancedDescription(lines) // each section can be parsed at most by one parser for (const parser of parsers) { @@ -90,8 +93,6 @@ export function parseClipboard (clipboard: string) { } } - parsed.rawText = clipboard - return Object.freeze(parsed) } @@ -200,7 +201,8 @@ function parseNamePlate (section: string[]) { influences: [], sockets: {}, extra: {}, - rawText: undefined! + rawText: undefined!, + isAdvancedDesc: false } return item } @@ -683,3 +685,7 @@ function markupConditionParser (text: string) { return text } + +function isAdvancedDescription (lines: string[]): boolean { + return lines.some(line => line.startsWith('{') && line.endsWith('}')) +} diff --git a/src/web/background/Prices.ts b/src/web/background/Prices.ts index 044dd1c3..985e620b 100644 --- a/src/web/background/Prices.ts +++ b/src/web/background/Prices.ts @@ -6,12 +6,12 @@ import { nameToDetailsId } from '../price-check/trends/getDetailsId' interface NinjaCurrencyInfo { /* eslint-disable camelcase */ currencyTypeName: string receive?: { - league_id: number - pay_currency_id: number get_currency_id: number - count: number value: number - includes_secondary: boolean + } + pay?: { + get_currency_id: number + value: number } receiveSparkLine: { data: Array @@ -142,7 +142,12 @@ async function load (force: boolean = false) { if (currency.receive.value >= 15) { chaosExaRate.value = currency.receive.value } else { - chaosExaRate.value = undefined + // fallback to sell price + if (currency.pay?.value && (1 / currency.pay.value) >= 15) { + chaosExaRate.value = (1 / currency.pay.value) + } else { + chaosExaRate.value = undefined + } } } }