Skip to content

Commit

Permalink
feat: make strict socketType value
Browse files Browse the repository at this point in the history
  • Loading branch information
isuke committed Jan 8, 2024
1 parent deeff49 commit 5402d26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/advanced-poe-filter.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ conditionValueNumericAndArray = pre:((numOperator __ num __) / (matchOperator __
}
}
conditionValueNumber = operator:numOperator __ num:num { return { ope: operator, val: num } }
conditionValueSocketType = operator:(numOperator __)? num:(num)? socketType:socketType { return operator ? { ope: operator[0], val: `${num ? num : ''}${socketType}` } : { ope: '=', val: `${num ? num : ''}${socketType}` } }
conditionValueSocketType = operator:(numOperator __)? num:(num)? socketTypes:socketTypes { return operator ? { ope: operator[0], val: `${num ? num : ''}${socketTypes}` } : { ope: '=', val: `${num ? num : ''}${socketTypes}` } }
conditionValueRarity = operator:(numOperator __)? rarity:rarity { return operator ? { ope: operator[0], val: rarity } : { ope: '=', val: rarity } }
conditionValueBoolean = boolean
conditionValueImplicitModTier = operator:numOperator __ modTier:implicitModTier { return { ope: operator, val: modTier } }
Expand Down Expand Up @@ -278,7 +278,12 @@ color = r:rgbaNum __ g:rgbaNum __ b:rgbaNum alpha:(__ rgbaNum)? { return { rgb:
numOperator = '<=' / '>=' / '<' / '>' / '='
matchOperator = '==' / '='
rarity = 'Normal' / 'Magic' / 'Rare' / 'Unique'
socketType = $('R'* 'G'* 'B'* 'W'* 'A'* 'D'*)
socketType = 'R' / 'G' / 'B' / 'W' / 'A' / 'D'
socketTypes = vals:socketType|1..6| {
const order = ['R', 'G', 'B', 'W', 'A', 'D']
return vals.sort((left, right) => order.indexOf(left) - order.indexOf(right)).join('')
}

rgbaNum = num:num &{ return 0 <= num && num <= 255 } { return num }
implicitModTier = val:('1' / '2' / '3' / '4' / '5' / '6' / 'Lesser' / 'Greater' / 'Grand' / 'Exceptional' / 'Exquisite' / 'Perfect') {
switch (val) {
Expand Down
6 changes: 3 additions & 3 deletions test/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Show "Section1"
Quality = 15
LinkedSockets = 6
Sockets >= 5RGBWAD
SocketGroup >= 5RGBWAD
SocketGroup >= 5ADRGBW
Rarity = Rare
BaseDefencePercentile > 50
BaseArmour > 40
Expand Down Expand Up @@ -161,7 +161,7 @@ Show "Section2"
Class "Life Flasks" "Mana Flasks" "Hybrid Flasks"
BaseType "Two-Toned Boots" "Spiked Gloves" "Gripped Gloves" "Fingerless Silk Gloves" "Bone Helmet"
Sockets 5RGBWAD
SocketGroup 5RGBWAD
SocketGroup 5ADRGBW
Rarity Rare
HasExplicitMod == "Foo" "Bar"
HasEaterOfWorldsImplicit >= Greater
Expand All @@ -178,7 +178,7 @@ Show "Section2"
PlayEffect Blue Temp
Show "Section3"
Sockets RGBWAD
SocketGroup RGBWAD
SocketGroup ADRGBW
HasExplicitMod >= 2 "Foo" "Bar"
HasEnchantment >= 2 "Foo" "Bar"
HasInfluence None
Expand Down

0 comments on commit 5402d26

Please sign in to comment.