From d9569f699d3c546a7eb5dbbf059fbfcab0057ef7 Mon Sep 17 00:00:00 2001 From: isuke Date: Tue, 5 Dec 2023 22:43:02 +0900 Subject: [PATCH] feat: support 'A' and 'D' of SocketType closes #28 --- lib/parser.d.ts | 4 +-- src/advanced-poe-filter.pegjs | 8 ++--- test/parser.test.js | 58 +++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/lib/parser.d.ts b/lib/parser.d.ts index 22af4f0..acbae31 100644 --- a/lib/parser.d.ts +++ b/lib/parser.d.ts @@ -97,8 +97,8 @@ type AdvancedBlock = { MapTier?: `${NumOperator} ${number}` Quality?: `${NumOperator} ${number}` LinkedSockets?: `${NumOperator} ${number}` - Sockets?: `${NumOperator} ${number}` - SocketGroup?: `${NumOperator} ${string}` | string + Sockets?: `${NumOperator} ${number}${string}` + SocketGroup?: `${NumOperator} ${number}${string}` FracturedItem?: boolean SynthesisedItem?: boolean Corrupted?: boolean diff --git a/src/advanced-poe-filter.pegjs b/src/advanced-poe-filter.pegjs index 2ee3666..3ad6b3b 100644 --- a/src/advanced-poe-filter.pegjs +++ b/src/advanced-poe-filter.pegjs @@ -139,8 +139,8 @@ conditionStackSize = attr:'StackSize' __ val:condition conditionMapTier = attr:'MapTier' __ val:conditionValueNumber { return { lineType: 'condition', attr, val} } conditionQuality = attr:'Quality' __ val:conditionValueNumber { return { lineType: 'condition', attr, val} } conditionLinkedSockets = attr:'LinkedSockets' __ val:conditionValueNumber { return { lineType: 'condition', attr, val} } -conditionSockets = attr:'Sockets' __ val:conditionValueNumber { return { lineType: 'condition', attr, val} } -conditionSocketGroup = attr:'SocketGroup' __ val:conditionValueSocketRGBW { return { lineType: 'condition', attr, val} } +conditionSockets = attr:'Sockets' __ val:conditionValueSocketType { return { lineType: 'condition', attr, val} } +conditionSocketGroup = attr:'SocketGroup' __ val:conditionValueSocketType { return { lineType: 'condition', attr, val} } conditionRarity = attr:'Rarity' __ val:conditionValueRarity { return { lineType: 'condition', attr, val} } conditionBaseDefencePercentile = attr:'BaseDefencePercentile' __ val:conditionValueNumber { return { lineType: 'condition', attr, val} } conditionBaseArmour = attr:'BaseArmour' __ val:conditionValueNumber { return { lineType: 'condition', attr, val} } @@ -180,7 +180,7 @@ conditionValueArray = operator:(matchOperator __)? names:names { return operator conditionValueArrayOrNone = conditionValueArray / val:'None' { return val ? { ope: undefined, val: 'None' } : { ope, vals } } conditionValueNumericAndArray = pre:((numOperator __ num __) / (matchOperator __))? names:names { return pre ? (pre.length === 4 ? { numeric: { ope: pre[0], val: pre[2] }, vals: names } : { ope: pre[0], vals: names } ) : { ope: '=', vals: names } } conditionValueNumber = operator:numOperator __ num:num { return `${operator} ${num}` } -conditionValueSocketRGBW = socketRGBW +conditionValueSocketType = operator:(numOperator __)? num:(num)? socketType:socketType { return operator ? `${operator[0]} ${num ? num : ''}${socketType}` : `= ${num ? num : ''}${socketType}` } conditionValueRarity = operator:(numOperator __)? rarity:rarity { return operator ? `${operator[0]} ${rarity}` : rarity } conditionValueBoolean = boolean @@ -263,7 +263,7 @@ color = r:rgbaNum __ g:rgbaNum __ b:rgbaNum alpha:(__ rgbaNum)? { return { rgb: numOperator = '<=' / '>=' / '<' / '>' / '=' matchOperator = '==' / '=' rarity = 'Normal' / 'Magic' / 'Rare' / 'Unique' -socketRGBW = $('R'* 'G'* 'B'* 'W'*) +socketType = $('R'* 'G'* 'B'* 'W'* 'A'* 'D'*) rgbaNum = num:num &{ return 0 <= num && num <= 255 } { return num } fontSize = num:num &{ return 18 <= num && num <= 45 } { return num } minimapIconSize = val:('0' / '1' / '2' / 'Largest' / 'Medium' / 'Small') { diff --git a/test/parser.test.js b/test/parser.test.js index 389793e..ed0763c 100644 --- a/test/parser.test.js +++ b/test/parser.test.js @@ -112,8 +112,8 @@ Show "Section1" MapTier <= 12 Quality = 15 LinkedSockets = 6 - Sockets = 5 - SocketGroup RGB + Sockets >= 5RGBWAD + SocketGroup >= 5RGBWAD Rarity = Rare BaseDefencePercentile > 50 BaseArmour > 40 @@ -158,7 +158,8 @@ Show "Section1" Show "Section2" Class "Life Flasks" "Mana Flasks" "Hybrid Flasks" BaseType "Two-Toned Boots" "Spiked Gloves" "Gripped Gloves" "Fingerless Silk Gloves" "Bone Helmet" - SocketGroup W + Sockets 5RGBWAD + SocketGroup 5RGBWAD Rarity Rare HasExplicitMod == "Foo" "Bar" HasEnchantment == "Foo" "Bar" @@ -172,6 +173,8 @@ Show "Section2" MinimapIcon Medium Red Circle PlayEffect Blue Temp Show "Section3" + Sockets RGBWAD + SocketGroup RGBWAD HasExplicitMod >= 2 "Foo" "Bar" HasEnchantment >= 2 "Foo" "Bar" HasInfluence None @@ -213,8 +216,8 @@ Unset "Section6" MapTier: "<= 12", Quality: "= 15", LinkedSockets: "= 6", - Sockets: "= 5", - SocketGroup: "RGB", + Sockets: ">= 5RGBWAD", + SocketGroup: ">= 5RGBWAD", Rarity: "= Rare", BaseDefencePercentile: "> 50", BaseArmour: "> 40", @@ -272,7 +275,7 @@ Unset "Section6" end: { line: 56, column: 1, - offset: 1600, + offset: 1614, }, }, }, @@ -289,7 +292,8 @@ Unset "Section6" ope: "=", vals: ["Two-Toned Boots", "Spiked Gloves", "Gripped Gloves", "Fingerless Silk Gloves", "Bone Helmet"], }, - SocketGroup: "W", + Sockets: "= 5RGBWAD", + SocketGroup: "= 5RGBWAD", Rarity: "Rare", HasExplicitMod: { ope: "==", vals: ["Foo", "Bar"] }, HasEnchantment: { ope: "==", vals: ["Foo", "Bar"] }, @@ -313,12 +317,12 @@ Unset "Section6" start: { line: 56, column: 1, - offset: 1600, + offset: 1614, }, end: { - line: 72, + line: 73, column: 1, - offset: 2263, + offset: 2310, }, }, }, @@ -327,6 +331,8 @@ Unset "Section6" name: "Section3", activity: "Show", conditions: { + Sockets: "= RGBWAD", + SocketGroup: "= RGBWAD", HasExplicitMod: { numeric: { ope: ">=", val: 2 }, vals: ["Foo", "Bar"], @@ -347,14 +353,14 @@ Unset "Section6" branches: [], location: { start: { - line: 72, + line: 73, column: 1, - offset: 2263, + offset: 2310, }, end: { - line: 81, + line: 84, column: 1, - offset: 2574, + offset: 2673, }, }, }, @@ -373,14 +379,14 @@ Unset "Section6" branches: [], location: { start: { - line: 81, + line: 84, column: 1, - offset: 2574, + offset: 2673, }, end: { - line: 87, + line: 90, column: 1, - offset: 2794, + offset: 2893, }, }, }, @@ -397,14 +403,14 @@ Unset "Section6" branches: [], location: { start: { - line: 87, + line: 90, column: 1, - offset: 2794, + offset: 2893, }, end: { - line: 91, + line: 94, column: 1, - offset: 2936, + offset: 3035, }, }, }, @@ -420,14 +426,14 @@ Unset "Section6" branches: [], location: { start: { - line: 91, + line: 94, column: 1, - offset: 2936, + offset: 3035, }, end: { - line: 94, + line: 97, column: 1, - offset: 3042, + offset: 3141, }, }, },