Skip to content

Commit

Permalink
fix sign parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzo committed Nov 29, 2024
1 parent ed4dd3d commit 998812e
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions templating_unity.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ func NumSpellFormatterUnity(input string, lang string, gameData *JSONGameDataUni
var numSigned bool
var sideSigned bool
var ptSideSigned bool
_, ptSideSigned = ParseSigness(input)
_, ptSideSigned = ParseSignessUnity(input)
if *frNumSigned != 2 || *frSideSigned != 2 { // 2 is unset, 0 is false, 1 is true
numSigned = *frNumSigned == 1
sideSigned = *frSideSigned == 1
} else {
if lang == "fr" {
numSigned, sideSigned = ParseSigness(input)
numSigned, sideSigned = ParseSignessUnity(input)
if numSigned {
*frNumSigned = 1
} else {
Expand Down Expand Up @@ -283,3 +283,30 @@ func NumSpellFormatterUnity(input string, lang string, gameData *JSONGameDataUni

return input, onlyNoMinMax
}

func ParseSignessUnity(input string) (bool, bool) {
numSigness := false
sideSigness := false

regexNum := regexp.MustCompile("(([+,-])?#1)")
entriesNum := regexNum.FindAllStringSubmatch(input, -1)
for _, extracted := range entriesNum {
for _, entry := range extracted {
if entry == "-" {
numSigness = true
}
}
}

regexSide := regexp.MustCompile("([+,-])?(}})?#2")
entriesSide := regexSide.FindAllStringSubmatch(input, -1)
for _, extracted := range entriesSide {
for _, entry := range extracted {
if entry == "-" {
sideSigness = true
}
}
}

return numSigness, sideSigness
}

0 comments on commit 998812e

Please sign in to comment.