@@ -151,7 +151,7 @@ static unordered_map<int, string>RollDiceErr{
151
151
};
152
152
void DiceEvent::replyRollDiceErr (int err, const RD& rd) {
153
153
switch (err) {
154
- case 0 : break ;
154
+ case 0 : return ;
155
155
case Value_Err:
156
156
break ;
157
157
case Input_Err:
@@ -1558,7 +1558,7 @@ int DiceEvent::BasicOrder()
1558
1558
}
1559
1559
else if (action == " rou" ) {
1560
1560
readSkipSpace ();
1561
- if (isdigit ( static_cast < unsigned char >( strMsg[intMsgCnt]) )) {
1561
+ if (is_digit ( strMsg[intMsgCnt])) {
1562
1562
if (game->is_gm (fromChat.uid )) {
1563
1563
if (int nFace = 100 ; !readNum (nFace) && nFace <= 100 ) {
1564
1564
set (" face" , nFace);
@@ -2219,7 +2219,7 @@ int DiceEvent::InnerOrder() {
2219
2219
}
2220
2220
long long llMemberQQ = stoll (QQNum);
2221
2221
set (" member" ,getName (llMemberQQ, llGroup));
2222
- string strMainDice = readDice ();
2222
+ string strMainDice = readXDY ();
2223
2223
if (strMainDice.empty ()) {
2224
2224
replyMsg (" strValueErr" );
2225
2225
return -1 ;
@@ -2340,7 +2340,7 @@ int DiceEvent::InnerOrder() {
2340
2340
while (isspace (static_cast <unsigned char >(strLowerMessage[intMsgCnt])))
2341
2341
intMsgCnt++;
2342
2342
string strNum;
2343
- while (isdigit ( static_cast < unsigned char >( strLowerMessage[intMsgCnt]) )) {
2343
+ while (is_digit ( strLowerMessage[intMsgCnt])) {
2344
2344
strNum += strLowerMessage[intMsgCnt];
2345
2345
intMsgCnt++;
2346
2346
}
@@ -2495,13 +2495,16 @@ int DiceEvent::InnerOrder() {
2495
2495
set (" table_item" ,readRest ());
2496
2496
if (is_empty (" table_item" ))
2497
2497
replyMsg (" strGMTableItemEmpty" );
2498
- else if (auto game{ thisGame () }; game->table_del (" 先攻" , get_str (" table_item" )))
2498
+ else if (game->table_del (" 先攻" , get_str (" table_item" ))) {
2499
+ game->table_del (" init_exp" , get_str (" table_item" ));
2499
2500
replyMsg (" strGMTableItemDel" );
2501
+ }
2500
2502
else
2501
2503
replyMsg (" strGMTableItemNotFound" );
2502
2504
}
2503
2505
else if (strCmd == " clr" ) {
2504
2506
game->reset (" 先攻" );
2507
+ game->reset (" init_exp" );
2505
2508
replyMsg (" strGMTableClr" );
2506
2509
}
2507
2510
return 1 ;
@@ -2798,7 +2801,7 @@ int DiceEvent::InnerOrder() {
2798
2801
while (isspace (static_cast <unsigned char >(strLowerMessage[intMsgCnt])))
2799
2802
intMsgCnt++;
2800
2803
string strNum;
2801
- while (isdigit ( static_cast < unsigned char >( strLowerMessage[intMsgCnt]) )) {
2804
+ while (is_digit ( strLowerMessage[intMsgCnt])) {
2802
2805
strNum += strLowerMessage[intMsgCnt];
2803
2806
intMsgCnt++;
2804
2807
}
@@ -2820,7 +2823,7 @@ int DiceEvent::InnerOrder() {
2820
2823
while (isspace (static_cast <unsigned char >(strLowerMessage[intMsgCnt])))
2821
2824
intMsgCnt++;
2822
2825
string strNum;
2823
- while (isdigit ( static_cast < unsigned char >( strLowerMessage[intMsgCnt]) )) {
2826
+ while (is_digit ( strLowerMessage[intMsgCnt])) {
2824
2827
strNum += strLowerMessage[intMsgCnt];
2825
2828
intMsgCnt++;
2826
2829
}
@@ -3539,7 +3542,7 @@ int DiceEvent::InnerOrder() {
3539
3542
string strTurnCnt = strMsg.substr (intMsgCnt, strMsg.find (' #' ) - intMsgCnt);
3540
3543
// #能否识别有效
3541
3544
if (strTurnCnt.empty ())intMsgCnt++;
3542
- else if ((strTurnCnt.length () == 1 && isdigit ( static_cast < unsigned char >( strTurnCnt[0 ]) )) || strTurnCnt ==
3545
+ else if ((strTurnCnt.length () == 1 && is_digit ( strTurnCnt[0 ])) || strTurnCnt ==
3543
3546
" 10" ) {
3544
3547
intMsgCnt += strTurnCnt.length () + 1 ;
3545
3548
intTurnCnt = stoi (strTurnCnt);
@@ -3766,19 +3769,51 @@ int DiceEvent::InnerOrder() {
3766
3769
strinit += readDice ();
3767
3770
}
3768
3771
else if (isRollDice ()) {
3769
- strinit = readDice ();
3770
- }
3771
- set (" char" ,strip (readRest ()));
3772
- if (is_empty (" char" )) {
3773
- set (" char" ,idx_pc (*this ));
3772
+ if ((strinit = readXDY ()).empty ())strinit = " D20" ;
3774
3773
}
3774
+ string name{ strip (readRest ()) };
3775
3775
RD initdice (strinit, 20 );
3776
3776
if (const auto intFirstTimeRes = initdice.Roll ()) {
3777
3777
replyRollDiceErr (intFirstTimeRes, initdice);
3778
3778
return 1 ;
3779
3779
}
3780
- sessions.get (fromChat)->table_add (" 先攻" , initdice.intTotal , get_str (" char" ));
3781
- set (" res" ,initdice.FormCompleteString ());
3780
+ auto game{ sessions.get (fromChat) };
3781
+ if (size_t pos{ name.find (' #' ) }; pos == string::npos) {
3782
+ set (" char" , name.empty () ? name = idx_pc (*this ) : name);
3783
+ game->table_add (" 先攻" , initdice.intTotal , name);
3784
+ game->table_add (" init_exp" , initdice.strDice , name);
3785
+ set (" res" , initdice.FormCompleteString ());
3786
+ }
3787
+ else {
3788
+ string strTurnCnt = name.substr (0 , pos);
3789
+ set (" char" , name = name.substr (pos + 1 ));
3790
+ int cntInit = 1 ;
3791
+ ShowList res;
3792
+ if (!strTurnCnt.empty ()) {
3793
+ RD rdTurnCnt (strTurnCnt, 20 );
3794
+ if (const int intRdTurnCntRes = rdTurnCnt.Roll (); intRdTurnCntRes != 0 ) {
3795
+ replyRollDiceErr (intRdTurnCntRes, rdTurnCnt);
3796
+ return 1 ;
3797
+ }
3798
+ else if (rdTurnCnt.intTotal > 10 ) {
3799
+ replyMsg (" strRollTimeExceeded" );
3800
+ return 1 ;
3801
+ }
3802
+ else if (rdTurnCnt.intTotal <= 0 ) {
3803
+ replyMsg (" strRollTimeErr" );
3804
+ return 1 ;
3805
+ }
3806
+ cntInit = rdTurnCnt.intTotal ;
3807
+ }
3808
+ game->table_add (" init_exp" , initdice.strDice , name);
3809
+ int no = 0 ;
3810
+ do {
3811
+ res << to_string (++no) + " . " + initdice.FormCompleteString ();
3812
+ game->table_add (" 先攻" , initdice.intTotal , name + to_string (no));
3813
+ initdice.Roll ();
3814
+ } while (no < cntInit);
3815
+ set (" res" , " \n " + res.show (" \n " ));
3816
+ }
3782
3817
replyMsg (" strRollInit" );
3783
3818
return 1 ;
3784
3819
}
@@ -3811,14 +3846,14 @@ int DiceEvent::InnerOrder() {
3811
3846
string strSanCostSuc = SanCost.substr (0 , SanCost.find (' /' ));
3812
3847
string strSanCostFail = SanCost.substr (SanCost.find (' /' ) + 1 );
3813
3848
for (const auto & character : strSanCostSuc) {
3814
- if (!isdigit ( static_cast < unsigned char >( character) ) && character != ' D' && character != ' d' && character !=
3849
+ if (!is_digit ( character) && character != ' D' && character != ' d' && character !=
3815
3850
' +' && character != ' -' ) {
3816
3851
replyMsg (" strSanCostInvalid" );
3817
3852
return 1 ;
3818
3853
}
3819
3854
}
3820
3855
for (const auto & character : strSanCostFail) {
3821
- if (!isdigit ( static_cast < unsigned char >( character) ) && character != ' D' && character != ' d' && character !=
3856
+ if (!is_digit ( character) && character != ' D' && character != ' d' && character !=
3822
3857
' +' && character != ' -' ) {
3823
3858
replyMsg (" strSanCostInvalid" );
3824
3859
return 1 ;
@@ -4088,7 +4123,7 @@ int DiceEvent::InnerOrder() {
4088
4123
}
4089
4124
// 判定录入文本
4090
4125
else if (strLowerMessage.length () != intMsgCnt
4091
- && !isdigit ( static_cast < unsigned char >( strLowerMessage[intMsgCnt]) )
4126
+ && !is_digit ( strLowerMessage[intMsgCnt])
4092
4127
&& !isspace (static_cast <unsigned char >(strLowerMessage[intMsgCnt]))) {
4093
4128
if (string strVal{ trustedQQ (fromChat.uid ) > 0 ? readUntilSpace () : filter_CQcode (readUntilSpace ()) };
4094
4129
!pc->set (attr_name, strVal)) {
@@ -4158,6 +4193,7 @@ int DiceEvent::InnerOrder() {
4158
4193
res << attr + " ≠ " + tx->get_str (" reason" );
4159
4194
}
4160
4195
}
4196
+ if (!is (" cnt" ))set (" cnt" , 0 );
4161
4197
set (" detail" , res.show (" \n " ));
4162
4198
replyMsg (" strStDetail" );
4163
4199
}
@@ -4237,12 +4273,13 @@ int DiceEvent::InnerOrder() {
4237
4273
RD rdTurnCnt (strTurnCnt, intDefaultDice);
4238
4274
if (const int intRdTurnCntRes = rdTurnCnt.Roll (); intRdTurnCntRes != 0 ) {
4239
4275
replyRollDiceErr (intRdTurnCntRes, rdTurnCnt);
4276
+ return 1 ;
4240
4277
}
4241
- if (rdTurnCnt.intTotal > 10 ) {
4278
+ else if (rdTurnCnt.intTotal > 10 ) {
4242
4279
replyMsg (" strRollTimeExceeded" );
4243
4280
return 1 ;
4244
4281
}
4245
- if (rdTurnCnt.intTotal <= 0 ) {
4282
+ else if (rdTurnCnt.intTotal <= 0 ) {
4246
4283
replyMsg (" strRollTimeErr" );
4247
4284
return 1 ;
4248
4285
}
@@ -4264,7 +4301,7 @@ int DiceEvent::InnerOrder() {
4264
4301
: strFirstDice.find (' *' ));
4265
4302
bool boolAdda10 = true ;
4266
4303
for (auto i : strFirstDice) {
4267
- if (!isdigit ( static_cast < unsigned char >(i) )) {
4304
+ if (!is_digit (i )) {
4268
4305
boolAdda10 = false ;
4269
4306
break ;
4270
4307
}
@@ -4675,6 +4712,42 @@ int DiceEvent::readNum(int& num)
4675
4712
num = stoi (strNum);
4676
4713
return 0 ;
4677
4714
}
4715
+ string DiceEvent::readXDY ()
4716
+ {
4717
+ string strDice;
4718
+ while (isspace (static_cast <unsigned char >(strLowerMessage[intMsgCnt])))intMsgCnt++;
4719
+ while (is_digit (strLowerMessage[intMsgCnt])
4720
+ || strLowerMessage[intMsgCnt] == ' d' || strLowerMessage[intMsgCnt] == ' k'
4721
+ || strLowerMessage[intMsgCnt] == ' p' || strLowerMessage[intMsgCnt] == ' b'
4722
+ || strLowerMessage[intMsgCnt] == ' +' || strLowerMessage[intMsgCnt] == ' -'
4723
+ || strLowerMessage[intMsgCnt] == ' x' || strLowerMessage[intMsgCnt] == ' *' || strMsg[intMsgCnt] == ' /' )
4724
+ {
4725
+ strDice += strMsg[intMsgCnt];
4726
+ intMsgCnt++;
4727
+ }
4728
+ if (!isNumeric (strDice))return strDice;
4729
+ else intMsgCnt -= strDice.length ();
4730
+ return {};
4731
+ }
4732
+ string DiceEvent::readDice ()
4733
+ {
4734
+ string strDice;
4735
+ while (isspace (static_cast <unsigned char >(strLowerMessage[intMsgCnt])) || strLowerMessage[intMsgCnt] == ' =' ||
4736
+ strLowerMessage[intMsgCnt] == ' :' )intMsgCnt++;
4737
+ while (is_digit (strLowerMessage[intMsgCnt])
4738
+ || strLowerMessage[intMsgCnt] == ' d' || strLowerMessage[intMsgCnt] == ' k'
4739
+ || strLowerMessage[intMsgCnt] == ' p' || strLowerMessage[intMsgCnt] == ' b'
4740
+ || strLowerMessage[intMsgCnt] == ' f'
4741
+ || strLowerMessage[intMsgCnt] == ' +' || strLowerMessage[intMsgCnt] == ' -'
4742
+ || strLowerMessage[intMsgCnt] == ' a'
4743
+ || strLowerMessage[intMsgCnt] == ' x' || strLowerMessage[intMsgCnt] == ' *' || strMsg[intMsgCnt] == ' /'
4744
+ || strLowerMessage[intMsgCnt] == ' #' )
4745
+ {
4746
+ strDice += strMsg[intMsgCnt];
4747
+ intMsgCnt++;
4748
+ }
4749
+ return strDice;
4750
+ }
4678
4751
string DiceEvent::readAttrName ()
4679
4752
{
4680
4753
while (isspace (static_cast <unsigned char >(strMsg[intMsgCnt])))intMsgCnt++;
0 commit comments