Skip to content

Commit

Permalink
fix non-en parsing for PoE 3.17
Browse files Browse the repository at this point in the history
  • Loading branch information
SnosMe committed Feb 5, 2022
1 parent 4cbed61 commit b2cc9fb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "awakened-poe-trade",
"version": "2.15.0",
"version": "2.15.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
5 changes: 3 additions & 2 deletions src/assets/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './interfaces'
export let ITEM_DROP: DropEntry[]
export let BLIGHT_RECIPES: BlightRecipes
export let CLIENT_STRINGS: TranslationDict
export let CLIENT_STRINGS_REF: TranslationDict

export let ITEM_BY_TRANSLATED = (ns: BaseType['namespace'], name: string): BaseType[] | undefined => undefined
export let ITEM_BY_REF = (ns: BaseType['namespace'], name: string): BaseType[] | undefined => undefined
Expand Down Expand Up @@ -131,9 +132,9 @@ export function stat (text: string) {
DELAYED_STAT_VALIDATION.clear()
}

{
// eslint-disable-next-line no-eval
{ /* eslint-disable no-eval */
CLIENT_STRINGS = (await eval(`import('${process.env.BASE_URL}data/${language}/client_strings.js')`)).default
CLIENT_STRINGS_REF = (await eval(`import('${process.env.BASE_URL}data/en/client_strings.js')`)).default
BLIGHT_RECIPES = await (await fetch(`${process.env.BASE_URL}data/blight-recipes.json`)).json()
ITEM_DROP = await (await fetch(`${process.env.BASE_URL}data/item-drop.json`)).json()
}
Expand Down
53 changes: 27 additions & 26 deletions src/parser/Parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
CLIENT_STRINGS as _$,
CLIENT_STRINGS_REF as _$REF,
ITEM_BY_TRANSLATED,
ITEM_BY_REF,
STAT_BY_MATCH_STR,
Expand Down Expand Up @@ -133,30 +134,30 @@ function normalizeName (item: ParserState) {
item.rarity === ItemRarity.Rare
) {
if (item.baseType) {
if (_$.MAP_BLIGHTED.test(item.baseType)) {
item.baseType = _$.MAP_BLIGHTED.exec(item.baseType)![1]
} else if (_$.MAP_BLIGHT_RAVAGED.test(item.baseType)) {
item.baseType = _$.MAP_BLIGHT_RAVAGED.exec(item.baseType)![1]
if (_$REF.MAP_BLIGHTED.test(item.baseType)) {
item.baseType = _$REF.MAP_BLIGHTED.exec(item.baseType)![1]
} else if (_$REF.MAP_BLIGHT_RAVAGED.test(item.baseType)) {
item.baseType = _$REF.MAP_BLIGHT_RAVAGED.exec(item.baseType)![1]
}
} else {
if (_$.MAP_BLIGHTED.test(item.name)) {
item.name = _$.MAP_BLIGHTED.exec(item.name)![1]
} else if (_$.MAP_BLIGHT_RAVAGED.test(item.name)) {
item.name = _$.MAP_BLIGHT_RAVAGED.exec(item.name)![1]
if (_$REF.MAP_BLIGHTED.test(item.name)) {
item.name = _$REF.MAP_BLIGHTED.exec(item.name)![1]
} else if (_$REF.MAP_BLIGHT_RAVAGED.test(item.name)) {
item.name = _$REF.MAP_BLIGHT_RAVAGED.exec(item.name)![1]
}
}
}

if (item.category === ItemCategory.MetamorphSample) {
if (_$.METAMORPH_BRAIN.test(item.name)) {
if (_$REF.METAMORPH_BRAIN.test(item.name)) {
item.name = 'Metamorph Brain'
} else if (_$.METAMORPH_EYE.test(item.name)) {
} else if (_$REF.METAMORPH_EYE.test(item.name)) {
item.name = 'Metamorph Eye'
} else if (_$.METAMORPH_LUNG.test(item.name)) {
} else if (_$REF.METAMORPH_LUNG.test(item.name)) {
item.name = 'Metamorph Lung'
} else if (_$.METAMORPH_HEART.test(item.name)) {
} else if (_$REF.METAMORPH_HEART.test(item.name)) {
item.name = 'Metamorph Heart'
} else if (_$.METAMORPH_LIVER.test(item.name)) {
} else if (_$REF.METAMORPH_LIVER.test(item.name)) {
item.name = 'Metamorph Liver'
}
}
Expand All @@ -165,17 +166,17 @@ function normalizeName (item: ParserState) {
function findInDatabase (item: ParserState) {
let info: BaseType[] | undefined
if (item.category === ItemCategory.DivinationCard) {
info = ITEM_BY_TRANSLATED('DIVINATION_CARD', item.name)
info = ITEM_BY_REF('DIVINATION_CARD', item.name)
} else if (item.category === ItemCategory.CapturedBeast) {
info = ITEM_BY_TRANSLATED('CAPTURED_BEAST', item.baseType ?? item.name)
info = ITEM_BY_REF('CAPTURED_BEAST', item.baseType ?? item.name)
} else if (item.category === ItemCategory.Gem) {
info = ITEM_BY_TRANSLATED('GEM', item.name)
info = ITEM_BY_REF('GEM', item.name)
} else if (item.category === ItemCategory.MetamorphSample) {
info = ITEM_BY_REF('ITEM', item.name)
} else if (item.rarity === ItemRarity.Unique && !item.isUnidentified) {
info = ITEM_BY_TRANSLATED('UNIQUE', item.name)
info = ITEM_BY_REF('UNIQUE', item.name)
} else {
info = ITEM_BY_TRANSLATED('ITEM', item.baseType ?? item.name)
info = ITEM_BY_REF('ITEM', item.baseType ?? item.name)
}
if (!info?.length) {
throw new Error('Unsupported item')
Expand Down Expand Up @@ -387,7 +388,7 @@ function parseVaalGemName (section: string[], item: ParserState) {
item.gemAltQuality = 'Superior'
}
if (gemName) {
item.name = gemName
item.name = ITEM_BY_TRANSLATED('GEM', gemName)![0].refName
return SECTION_PARSED
}
}
Expand All @@ -413,11 +414,11 @@ function parseGemAltQuality (item: ParserState) {
if (item.category !== ItemCategory.Gem) return

let gemName: string | undefined
if ((gemName = _$.QUALITY_ANOMALOUS.exec(item.name)?.[1])) {
if ((gemName = _$REF.QUALITY_ANOMALOUS.exec(item.name)?.[1])) {
item.gemAltQuality = 'Anomalous'
} else if ((gemName = _$.QUALITY_DIVERGENT.exec(item.name)?.[1])) {
} else if ((gemName = _$REF.QUALITY_DIVERGENT.exec(item.name)?.[1])) {
item.gemAltQuality = 'Divergent'
} else if ((gemName = _$.QUALITY_PHANTASMAL.exec(item.name)?.[1])) {
} else if ((gemName = _$REF.QUALITY_PHANTASMAL.exec(item.name)?.[1])) {
item.gemAltQuality = 'Phantasmal'
} else {
item.gemAltQuality = 'Superior'
Expand Down Expand Up @@ -619,9 +620,9 @@ function parseSynthesised (section: string[], item: ParserState) {
if (section[0] === _$.SECTION_SYNTHESISED) {
item.isSynthesised = true
if (item.baseType) {
item.baseType = _$.ITEM_SYNTHESISED.exec(item.baseType)![1]
item.baseType = _$REF.ITEM_SYNTHESISED.exec(item.baseType)![1]
} else {
item.name = _$.ITEM_SYNTHESISED.exec(item.name)![1]
item.name = _$REF.ITEM_SYNTHESISED.exec(item.name)![1]
}
return SECTION_PARSED
}
Expand All @@ -637,8 +638,8 @@ function parseSuperior (item: ParserState) {
(item.rarity === ItemRarity.Rare && item.isUnidentified) ||
(item.rarity === ItemRarity.Unique && item.isUnidentified)
) {
if (_$.ITEM_SUPERIOR.test(item.name)) {
item.name = _$.ITEM_SUPERIOR.exec(item.name)![1]
if (_$REF.ITEM_SUPERIOR.test(item.name)) {
item.name = _$REF.ITEM_SUPERIOR.exec(item.name)![1]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser/magic-name.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ITEM_BY_TRANSLATED } from '@/assets/data'
import { ITEM_BY_REF } from '@/assets/data'

export function magicBasetype (name: string) {
const words = name.split(' ')
Expand All @@ -13,7 +13,7 @@ export function magicBasetype (name: string) {

const result = perm
.map(name => {
const result = ITEM_BY_TRANSLATED('ITEM', name)
const result = ITEM_BY_REF('ITEM', name)
return { name, found: (result && result[0].craftable) }
})
.filter(res => res.found)
Expand Down

0 comments on commit b2cc9fb

Please sign in to comment.