Skip to content

Commit

Permalink
feat: support 'A' and 'D' of SocketType
Browse files Browse the repository at this point in the history
closes #28
  • Loading branch information
isuke committed Dec 5, 2023
1 parent b2ff892 commit 0f86fa7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions lib/parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/advanced-poe-filter.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -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} }
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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') {
Expand Down
58 changes: 32 additions & 26 deletions test/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -272,7 +275,7 @@ Unset "Section6"
end: {
line: 56,
column: 1,
offset: 1600,
offset: 1612,
},
},
},
Expand All @@ -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"] },
Expand All @@ -313,12 +317,12 @@ Unset "Section6"
start: {
line: 56,
column: 1,
offset: 1600,
offset: 1612,
},
end: {
line: 72,
line: 73,
column: 1,
offset: 2263,
offset: 2308,
},
},
},
Expand All @@ -327,6 +331,8 @@ Unset "Section6"
name: "Section3",
activity: "Show",
conditions: {
Sockets: "RGBWAD",
SocketGroup: "RGBWAD",
HasExplicitMod: {
numeric: { ope: ">=", val: 2 },
vals: ["Foo", "Bar"],
Expand All @@ -347,14 +353,14 @@ Unset "Section6"
branches: [],
location: {
start: {
line: 72,
line: 73,
column: 1,
offset: 2263,
offset: 2308,
},
end: {
line: 81,
line: 84,
column: 1,
offset: 2574,
offset: 2671,
},
},
},
Expand All @@ -373,14 +379,14 @@ Unset "Section6"
branches: [],
location: {
start: {
line: 81,
line: 84,
column: 1,
offset: 2574,
offset: 2671,
},
end: {
line: 87,
line: 90,
column: 1,
offset: 2794,
offset: 2891,
},
},
},
Expand All @@ -397,14 +403,14 @@ Unset "Section6"
branches: [],
location: {
start: {
line: 87,
line: 90,
column: 1,
offset: 2794,
offset: 2891,
},
end: {
line: 91,
line: 94,
column: 1,
offset: 2936,
offset: 3033,
},
},
},
Expand All @@ -420,14 +426,14 @@ Unset "Section6"
branches: [],
location: {
start: {
line: 91,
line: 94,
column: 1,
offset: 2936,
offset: 3033,
},
end: {
line: 94,
line: 97,
column: 1,
offset: 3042,
offset: 3139,
},
},
},
Expand Down

0 comments on commit 0f86fa7

Please sign in to comment.