From 8528623bccf702b0463fe31b6bef2a0a0185cefe Mon Sep 17 00:00:00 2001 From: Alexander Drozdov Date: Sat, 11 Jul 2020 20:43:21 +0300 Subject: [PATCH] fix: parse any rarity Blighted map --- src/assets/data/en/client_strings.ts | 3 ++- src/assets/data/ru/client_strings.ts | 3 ++- src/parser/Parser.ts | 16 ++++++++++------ src/parser/magic-name.ts | 16 ++++++++++++---- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/assets/data/en/client_strings.ts b/src/assets/data/en/client_strings.ts index c4484e94..14542386 100644 --- a/src/assets/data/en/client_strings.ts +++ b/src/assets/data/en/client_strings.ts @@ -52,7 +52,8 @@ const dict = { 'You will find Einhar and complete his mission.': 'You will find Einhar and complete his mission.', 'You will find Niko and complete his mission.': 'You will find Niko and complete his mission.', 'You will find Jun and complete her mission.': 'You will find Jun and complete her mission.', - 'You will find Zana and complete her mission.': 'You will find Zana and complete her mission.' + 'You will find Zana and complete her mission.': 'You will find Zana and complete her mission.', + 'Blighted {0}': 'Blighted {0}' } export default dict diff --git a/src/assets/data/ru/client_strings.ts b/src/assets/data/ru/client_strings.ts index fa4f413c..7489cab0 100644 --- a/src/assets/data/ru/client_strings.ts +++ b/src/assets/data/ru/client_strings.ts @@ -54,7 +54,8 @@ const dict: TranslationDict = { 'You will find Einhar and complete his mission.': 'Ты встретишь Эйнара и выполнишь его задание.', 'You will find Niko and complete his mission.': 'Ты встретишь Нико и выполнишь его задание.', 'You will find Jun and complete her mission.': 'Ты встретишь Джун и выполнишь её задание.', - 'You will find Zana and complete her mission.': 'Ты встретишь Зану и выполнишь её задание.' + 'You will find Zana and complete her mission.': 'Ты встретишь Зану и выполнишь её задание.', + 'Blighted {0}': 'Заражённая {0}' } export default dict diff --git a/src/parser/Parser.ts b/src/parser/Parser.ts index c4387161..3c596a41 100644 --- a/src/parser/Parser.ts +++ b/src/parser/Parser.ts @@ -139,13 +139,17 @@ function parseMap (section: string[], item: ParsedItem) { if (section[0].startsWith(_$[C.TAG_MAP_TIER])) { item.props.mapTier = Number(section[0].substr(_$[C.TAG_MAP_TIER].length)) - if (item.rarity === ItemRarity.Normal) { - if (_$[C.MAP_BLIGHTED].test(item.name)) { - const name = _$[C.MAP_BLIGHTED].exec(item.name)![1] - item.name = ITEM_NAME_REF_BY_TRANSLATED.get(name) || name - item.category = ItemCategory.Map - item.props.mapBlighted = true + let name = item.baseType || item.name + if (_$[C.MAP_BLIGHTED].test(name)) { + name = _$[C.MAP_BLIGHTED].exec(name)![1] + name = ITEM_NAME_REF_BY_TRANSLATED.get(name) || name + if (item.baseType) { + item.baseType = name + } else { + item.name = name } + item.category = ItemCategory.Map + item.props.mapBlighted = true } return SECTION_PARSED diff --git a/src/parser/magic-name.ts b/src/parser/magic-name.ts index 6089dea9..eadbfdfb 100644 --- a/src/parser/magic-name.ts +++ b/src/parser/magic-name.ts @@ -1,12 +1,20 @@ -import { BASE_TYPES, TRANSLATED_ITEM_NAME_BY_REF } from '@/assets/data' +import { BASE_TYPES, TRANSLATED_ITEM_NAME_BY_REF, CLIENT_STRINGS } from '@/assets/data' +import { ItemCategory } from './meta' let baseTypes: Set export function magicBasetype (name: string) { if (!baseTypes) { - baseTypes = new Set( - Array.from(BASE_TYPES.keys()).map(b => TRANSLATED_ITEM_NAME_BY_REF.get(b)!) - ) + baseTypes = new Set() + for (let [name, info] of BASE_TYPES.entries()) { + name = TRANSLATED_ITEM_NAME_BY_REF.get(name)! + baseTypes.add(name) + if (info.category === ItemCategory.Map) { + baseTypes.add( + CLIENT_STRINGS['Blighted {0}'].replace('{0}', name) + ) + } + } } const words = name.split(' ')