fix: fix parsing of hextech gunblade and mejais on dragon-item-parser
This commit is contained in:
@@ -506,54 +506,99 @@ function parseEffects(description: string): ItemEffect[] {
|
|||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (!line) continue
|
if (!line) continue
|
||||||
|
|
||||||
// Check for passive tag
|
// Check for passive tag at the START of the line (effect header)
|
||||||
const passiveMatch = line.match(/<passive>([^<]*)<\/passive>/i)
|
// Only treat as a new effect if the line starts with the tag or the tag is the only content
|
||||||
|
const passiveMatch = line.match(/^<passive>([^<]*)<\/passive>(.*)$/i)
|
||||||
if (passiveMatch) {
|
if (passiveMatch) {
|
||||||
|
const remainingContent = passiveMatch[2].trim()
|
||||||
|
// If there's content after the tag on the same line, it's part of description
|
||||||
|
// If the tag is the only content, this is just an effect header
|
||||||
|
if (!remainingContent) {
|
||||||
|
// This is an effect header line - start a new effect
|
||||||
if (currentEffect) {
|
if (currentEffect) {
|
||||||
effects.push(currentEffect)
|
effects.push(currentEffect)
|
||||||
}
|
}
|
||||||
// Remove the passive tag from the line before parsing description
|
|
||||||
const lineWithoutTag = line.replace(/<passive>[^<]*<\/passive>/i, '').trim()
|
|
||||||
currentEffect = {
|
currentEffect = {
|
||||||
type: 'passive',
|
type: 'passive',
|
||||||
name: passiveMatch[1].trim(),
|
name: passiveMatch[1].trim(),
|
||||||
description: parseTextSegments(lineWithoutTag),
|
description: [],
|
||||||
|
isUnique: false
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// If there's content after, check if it looks like a description (not just a label)
|
||||||
|
// For now, treat lines starting with passive tag as new effects
|
||||||
|
if (currentEffect) {
|
||||||
|
effects.push(currentEffect)
|
||||||
|
}
|
||||||
|
currentEffect = {
|
||||||
|
type: 'passive',
|
||||||
|
name: passiveMatch[1].trim(),
|
||||||
|
description: parseTextSegments(remainingContent),
|
||||||
isUnique: false
|
isUnique: false
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for active tag
|
// Check for active tag at the START of the line
|
||||||
const activeMatch = line.match(/<active>([^<]*)<\/active>/i)
|
const activeMatch = line.match(/^<active>([^<]*)<\/active>(.*)$/i)
|
||||||
if (activeMatch) {
|
if (activeMatch) {
|
||||||
|
const remainingContent = activeMatch[2].trim()
|
||||||
|
// Skip lines that are just "ACTIVE" labels (like "(0s)" cooldown indicators)
|
||||||
|
const effectName = activeMatch[1].trim()
|
||||||
|
if (effectName.toUpperCase() === 'ACTIVE' && remainingContent.match(/^\([^)]*\)\s*$/)) {
|
||||||
|
// This is just a cooldown label, skip it
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!remainingContent) {
|
||||||
|
// This is an effect header line - start a new effect
|
||||||
if (currentEffect) {
|
if (currentEffect) {
|
||||||
effects.push(currentEffect)
|
effects.push(currentEffect)
|
||||||
}
|
}
|
||||||
// Remove the active tag from the line before parsing description
|
|
||||||
const lineWithoutTag = line.replace(/<active>[^<]*<\/active>/i, '').trim()
|
|
||||||
currentEffect = {
|
currentEffect = {
|
||||||
type: 'active',
|
type: 'active',
|
||||||
name: activeMatch[1].trim(),
|
name: effectName,
|
||||||
description: parseTextSegments(lineWithoutTag),
|
description: [],
|
||||||
|
isUnique: false
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// If there's content after, it's the description
|
||||||
|
if (currentEffect) {
|
||||||
|
effects.push(currentEffect)
|
||||||
|
}
|
||||||
|
currentEffect = {
|
||||||
|
type: 'active',
|
||||||
|
name: effectName,
|
||||||
|
description: parseTextSegments(remainingContent),
|
||||||
isUnique: false
|
isUnique: false
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for unique tag
|
// Check for unique tag at the START of the line
|
||||||
const uniqueMatch = line.match(/<unique>([^<]*)<\/unique>/i)
|
const uniqueMatch = line.match(/^<unique>([^<]*)<\/unique>(.*)$/i)
|
||||||
if (uniqueMatch) {
|
if (uniqueMatch) {
|
||||||
|
const remainingContent = uniqueMatch[2].trim()
|
||||||
if (currentEffect) {
|
if (currentEffect) {
|
||||||
effects.push(currentEffect)
|
effects.push(currentEffect)
|
||||||
}
|
}
|
||||||
// Remove the unique tag from the line before parsing description
|
if (!remainingContent) {
|
||||||
const lineWithoutTag = line.replace(/<unique>[^<]*<\/unique>/i, '').trim()
|
|
||||||
currentEffect = {
|
currentEffect = {
|
||||||
type: 'unique',
|
type: 'unique',
|
||||||
name: uniqueMatch[1].trim() || undefined,
|
name: uniqueMatch[1].trim() || undefined,
|
||||||
description: parseTextSegments(lineWithoutTag),
|
description: [],
|
||||||
isUnique: true
|
isUnique: true
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
currentEffect = {
|
||||||
|
type: 'unique',
|
||||||
|
name: uniqueMatch[1].trim() || undefined,
|
||||||
|
description: parseTextSegments(remainingContent),
|
||||||
|
isUnique: true
|
||||||
|
}
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user