From 5390c7a5957ae9656f9dcacfae873366c51fe18d Mon Sep 17 00:00:00 2001 From: SadlyWish <806891709@qq.com> Date: Tue, 27 Oct 2020 02:03:11 +0800 Subject: [PATCH] =?UTF-8?q?DX=E9=AA=B0=E5=AD=90=E6=9C=AB=E5=B0=BE=E5=8A=A0?= =?UTF-8?q?=E5=80=BC=E6=94=AF=E6=8C=81+-=E8=BF=90=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/dice/sinanya/dice/roll/Dx.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/dice/sinanya/dice/roll/Dx.java b/src/main/java/dice/sinanya/dice/roll/Dx.java index ed19c22b..b6a8c59f 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; } -- Gitee