diff --git a/src/main/java/dice/sinanya/dice/roll/Dx.java b/src/main/java/dice/sinanya/dice/roll/Dx.java index ed19c22b6fa35b14857b1b6ce4be3a4245fae874..b6a8c59f758da0be07fad5461b1dd5ee1cce1608 100644 --- a/src/main/java/dice/sinanya/dice/roll/Dx.java +++ b/src/main/java/dice/sinanya/dice/roll/Dx.java @@ -17,7 +17,7 @@ import static dice.sinanya.tools.makedata.RandomInt.random; import static dice.sinanya.tools.makedata.Sender.sender; public class Dx implements MakeNickToSender { - private final Pattern getParam = Pattern.compile("(\\d+)*[a]*(\\d+)*[+]*(\\d+)*"); + private final Pattern getParam = Pattern.compile("(\\d+)*[a]*(\\d+)*([+-])(\\d+)*"); private final EntityTypeMessages entityTypeMessages; public Dx(EntityTypeMessages entityTypeMessages) { @@ -32,14 +32,19 @@ public class Dx implements MakeNickToSender { int success = 10; int add = 0; int resultNum; + String addString = ""; ArrayList resultTmpStr; ArrayList resultStr = new ArrayList<>(); Matcher dxFind = getParam.matcher(msg); if (dxFind.find()) { time = getValue(dxFind.group(1), time); success = getValue(dxFind.group(2), success); - if (dxFind.groupCount() == 3) { - add = getValue(dxFind.group(3), add); + if (dxFind.groupCount() == 4) { + addString = dxFind.group(3) + dxFind.group(4); + add = getValue(dxFind.group(4), add); + if (addTag.equles("-")){ + add *= -1; + } } } if (success <= 1) { @@ -87,7 +92,7 @@ public class Dx implements MakeNickToSender { } String senderStr; if (add != 0) { - senderStr = StringUtils.join(resultStr, "\n+") + "\n+" + add + "\n=" + (resultNum + add); + senderStr = StringUtils.join(resultStr, "\n+") + "\n" + addString + "\n=" + (resultNum + add); } else { senderStr = StringUtils.join(resultStr, "\n+") + "\n=" + resultNum; }