diff --git a/src/main/java/dice/sinanya/dice/roll/Dx.java b/src/main/java/dice/sinanya/dice/roll/Dx.java index 6943b993b74b27dc4473c0555693115507e3b6cf..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) { @@ -26,20 +26,25 @@ public class Dx implements MakeNickToSender { public void dx() throws DxTimesException, DxSuccessException { String tag = TAG_DX; - String msg = entityTypeMessages.getMessage().trim().replaceFirst(tag.substring(0, tag.length() - 2), "").trim(); + String msg = entityTypeMessages.getMsgGet().getMsg().trim().replaceFirst(tag.substring(0, tag.length() - 2), "").trim(); int time = 1; 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; } diff --git a/src/main/java/dice/sinanya/exceptions/DxSuccessException.java b/src/main/java/dice/sinanya/exceptions/DxSuccessException.java index 57bd2e9a312e89cb6b6a7462b6fd5a2c5633aba7..2fc7ae34d544aa660ddabb147358d8bbc4a229be 100644 --- a/src/main/java/dice/sinanya/exceptions/DxSuccessException.java +++ b/src/main/java/dice/sinanya/exceptions/DxSuccessException.java @@ -16,7 +16,7 @@ import static dice.sinanya.tools.makedata.Sender.sender; */ public class DxSuccessException extends Exception { public DxSuccessException(EntityTypeMessages entityTypeMessages) { - super("加骰必须大于1"); - sender(entityTypeMessages, "加骰必须大于1"); + super("暴击值(加骰阈值)必须大于1"); + sender(entityTypeMessages, "暴击值(加骰阈值)必须大于1"); } } diff --git a/src/main/java/dice/sinanya/exceptions/DxTimesException.java b/src/main/java/dice/sinanya/exceptions/DxTimesException.java index 93ae6148d87a08e7f96a3b5d4f05388eb83c9428..8034efc6829789e3b4fcc6026bf7da4fd86a3b0e 100644 --- a/src/main/java/dice/sinanya/exceptions/DxTimesException.java +++ b/src/main/java/dice/sinanya/exceptions/DxTimesException.java @@ -15,7 +15,7 @@ import static dice.sinanya.tools.makedata.Sender.sender; */ public class DxTimesException extends Exception { public DxTimesException(EntityTypeMessages entityTypeMessages) { - super("次数必须大于等于1,且小于"); - sender(entityTypeMessages, "次数必须大于等于1,且小于"); + super("骰子数必须大于等于1,且小于50"); + sender(entityTypeMessages, "骰子数必须大于等于1,且小于50"); } }