From 998812e8534466801e3693a36297059feeb5527d Mon Sep 17 00:00:00 2001 From: stelzo Date: Fri, 29 Nov 2024 22:42:26 +0100 Subject: [PATCH] fix sign parsing --- templating_unity.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/templating_unity.go b/templating_unity.go index e09aa2d..dc26231 100644 --- a/templating_unity.go +++ b/templating_unity.go @@ -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 { @@ -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 +}