mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-26 06:35:45 +00:00
more data files refactoring
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
const dict = {
|
||||
'channel.system': /^: (?<body>.+)$/,
|
||||
'channel.trade': /^\$(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.global': /^#(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.party': /^%(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.guild': /^&(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.whisper.to': /^@To (?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.whisper.from': /^@From (?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'trade.gem': /^level (?<gem_lvl>\d+) (?<gem_qual>\d+)% (?<gem_name>.+)$/
|
||||
}
|
||||
|
||||
export default dict
|
||||
|
||||
export type ClientLogDict = typeof dict
|
||||
@@ -82,7 +82,16 @@ const dict = { /* eslint-disable quote-props */
|
||||
'CORRUPTED_IMPLICIT': 'Corruption Implicit Modifier',
|
||||
'MODIFIER_INCREASED': /^(.+?)% Increased$/,
|
||||
'INCURSION_OPEN': 'Open Rooms:',
|
||||
'INCURSION_OBSTRUCTED': 'Obstructed Rooms:'
|
||||
'INCURSION_OBSTRUCTED': 'Obstructed Rooms:',
|
||||
// ---
|
||||
'CHAT_SYSTEM': /^: (?<body>.+)$/,
|
||||
'CHAT_TRADE': /^\$(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_GLOBAL': /^#(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_PARTY': /^%(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_GUILD': /^&(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_WHISPER_TO': /^@To (?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_WHISPER_FROM': /^@From (?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_WEBTRADE_GEM': /^level (?<gem_lvl>\d+) (?<gem_qual>\d+)% (?<gem_name>.+)$/
|
||||
}
|
||||
|
||||
export default dict
|
||||
|
||||
+15
-43
@@ -1,8 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import fnv1a from '@sindresorhus/fnv1a'
|
||||
import type { TranslationDict } from '@/assets/data/en/client_strings'
|
||||
import type { ClientLogDict } from '@/assets/data/en/client_log'
|
||||
import type { BaseType, DropEntry, Stat, StatMatcher, UniqueItem } from './interfaces'
|
||||
import type { BaseType, DropEntry, Stat, StatMatcher } from './interfaces'
|
||||
import { AppConfig } from '@/web/Config'
|
||||
import { nameToDetailsId } from '@/web/price-check/trends/getDetailsId'
|
||||
|
||||
@@ -55,28 +55,19 @@ class MapNDJSON<K, V> {
|
||||
export let STAT_BY_MATCH_STR: MapNDJSON<string, { matcher: StatMatcher, stat: Stat }>
|
||||
export let STAT_BY_REF: MapNDJSON<string, Stat>
|
||||
|
||||
export let BASE_TYPES: Map<string, BaseType>
|
||||
|
||||
export let TRADE_TAGS: Array<[string, string]>
|
||||
export let TRADE_TAG_BY_NAME: Map<string, string>
|
||||
|
||||
export let UNIQUES_LIST: UniqueItem[]
|
||||
export let UNIQUES: Map<string, UniqueItem>
|
||||
|
||||
export let MAP_IMGS: Map<string, { img: string }>
|
||||
const DELAYED_STAT_VALIDATION = new Set<string>()
|
||||
|
||||
export const ITEM_DROP = new Map<string, DropEntry>()
|
||||
|
||||
;(function initData () { /* eslint-disable no-lone-blocks */
|
||||
;(async function initData () { /* eslint-disable no-lone-blocks */
|
||||
const { language } = AppConfig()
|
||||
|
||||
{
|
||||
CLIENT_STRINGS = (require(`./${language}/client_strings`).default)
|
||||
CLIENTLOG_STRINGS = (require(`./${language}/client_log`).default)
|
||||
await loadItems(language)
|
||||
}
|
||||
|
||||
const itemNames: Array<[string, string]> = (require(`./${language}/item-names.json`))
|
||||
TRANSLATED_ITEM_NAME_BY_REF = new Map(itemNames)
|
||||
ITEM_NAME_REF_BY_TRANSLATED = new Map(itemNames.map(_ => [_[1], _[0]]))
|
||||
{
|
||||
CLIENT_STRINGS = (await import(`./${language}/client_strings.ts`)).default
|
||||
}
|
||||
|
||||
{
|
||||
@@ -106,25 +97,13 @@ export const ITEM_DROP = new Map<string, DropEntry>()
|
||||
|
||||
start = end + 1
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const baseTypes: Array<[string, BaseType]> = (require('./base-types.json'))
|
||||
BASE_TYPES = new Map(baseTypes)
|
||||
}
|
||||
|
||||
{
|
||||
const tradeTags: Array<[string, string]> = (require('./trade-tags.json'))
|
||||
TRADE_TAGS = tradeTags
|
||||
TRADE_TAG_BY_NAME = new Map(tradeTags)
|
||||
}
|
||||
|
||||
{
|
||||
const uniques: UniqueItem[] = (require('./uniques.json'))
|
||||
UNIQUES_LIST = uniques
|
||||
UNIQUES = new Map(
|
||||
uniques.map(item => [`${item.name} ${item.basetype}`, item])
|
||||
)
|
||||
for (const text of DELAYED_STAT_VALIDATION) {
|
||||
if (!STAT_BY_REF.has(text)) {
|
||||
throw new Error(`Cannot find stat: ${text}`)
|
||||
}
|
||||
}
|
||||
DELAYED_STAT_VALIDATION.clear()
|
||||
}
|
||||
|
||||
{
|
||||
@@ -138,17 +117,10 @@ export const ITEM_DROP = new Map<string, DropEntry>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const maps: Array<[string, { img: string }]> = (require('./maps.json'))
|
||||
MAP_IMGS = new Map(maps)
|
||||
}
|
||||
})()
|
||||
|
||||
// assertion, to avoid regressions in stats.json
|
||||
export function stat (text: string) {
|
||||
if (!STAT_BY_REF.has(text)) {
|
||||
throw new Error(`Cannot find stat: ${text}`)
|
||||
}
|
||||
DELAYED_STAT_VALIDATION.add(text)
|
||||
return text
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { ClientLogDict } from '../en/client_log'
|
||||
|
||||
const dict: ClientLogDict = {
|
||||
'channel.system': /^: (?<body>.+)$/,
|
||||
'channel.trade': /^\$(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.global': /^#(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.party': /^%(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.guild': /^&(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.whisper.to': /^@Кому (?<char_name>.+?): (?<body>.+)$/,
|
||||
'channel.whisper.from': /^@От кого (?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'trade.gem': /^уровень (?<gem_lvl>\d+) (?<gem_qual>\d+)% (?<gem_name>.+)$/
|
||||
}
|
||||
|
||||
export default dict
|
||||
@@ -84,7 +84,16 @@ const dict: TranslationDict = { /* eslint-disable quote-props */
|
||||
'CORRUPTED_IMPLICIT': 'Осквернённое собственное свойство',
|
||||
'MODIFIER_INCREASED': /^(.+?)% увеличение$/,
|
||||
'INCURSION_OPEN': 'Открытые комнаты:',
|
||||
'INCURSION_OBSTRUCTED': 'Отделённые комнаты:'
|
||||
'INCURSION_OBSTRUCTED': 'Отделённые комнаты:',
|
||||
// ---
|
||||
'CHAT_SYSTEM': /^: (?<body>.+)$/,
|
||||
'CHAT_TRADE': /^\$(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_GLOBAL': /^#(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_PARTY': /^%(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_GUILD': /^&(?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_WHISPER_TO': /^@Кому (?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_WHISPER_FROM': /^@От кого (?:<(?<guild_tag>.+?)> )?(?<char_name>.+?): (?<body>.+)$/,
|
||||
'CHAT_WEBTRADE_GEM': /^уровень (?<gem_lvl>\d+) (?<gem_qual>\d+)% (?<gem_name>.+)$/
|
||||
}
|
||||
|
||||
export default dict
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { CLIENTLOG_STRINGS as _$ } from '@/assets/data'
|
||||
import { CLIENT_STRINGS as _$ } from '@/assets/data'
|
||||
import { AppConfig } from '@/web/Config'
|
||||
|
||||
const enum MessageChannel {
|
||||
@@ -41,19 +41,19 @@ export function handleLine (line: string) {
|
||||
|
||||
const entry = {} as LogEntry
|
||||
let match: RegExpMatchArray | null
|
||||
if ((match = text.match(_$['channel.global']))) {
|
||||
if ((match = text.match(_$.CHAT_GLOBAL))) {
|
||||
entry.сhannel = MessageChannel.GLOBAL
|
||||
} else if ((match = text.match(_$['channel.trade']))) {
|
||||
} else if ((match = text.match(_$.CHAT_TRADE))) {
|
||||
entry.сhannel = MessageChannel.TRADE
|
||||
} else if ((match = text.match(_$['channel.system']))) {
|
||||
} else if ((match = text.match(_$.CHAT_SYSTEM))) {
|
||||
entry.сhannel = MessageChannel.SYSTEM
|
||||
} else if ((match = text.match(_$['channel.whisper.to']))) {
|
||||
} else if ((match = text.match(_$.CHAT_WHISPER_TO))) {
|
||||
entry.сhannel = MessageChannel.WHISPER_TO
|
||||
} else if ((match = text.match(_$['channel.whisper.from']))) {
|
||||
} else if ((match = text.match(_$.CHAT_WHISPER_FROM))) {
|
||||
entry.сhannel = MessageChannel.WHISPER_FROM
|
||||
} else if ((match = text.match(_$['channel.party']))) {
|
||||
} else if ((match = text.match(_$.CHAT_PARTY))) {
|
||||
entry.сhannel = MessageChannel.PARTY
|
||||
} else if ((match = text.match(_$['channel.guild']))) {
|
||||
} else if ((match = text.match(_$.CHAT_GUILD))) {
|
||||
entry.сhannel = MessageChannel.GUILD
|
||||
} else {
|
||||
return
|
||||
@@ -69,7 +69,7 @@ export function handleLine (line: string) {
|
||||
match.groups!.price.split(' ', 1).toString(),
|
||||
match.groups!.price.split(' ').slice(1).join(' ')
|
||||
]
|
||||
const gemMatch = match.groups!.item.match(_$['trade.gem'])
|
||||
const gemMatch = match.groups!.item.match(_$.CHAT_WEBTRADE_GEM)
|
||||
if (gemMatch) {
|
||||
match.groups!.item = gemMatch.groups!.gem_name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user