Skip to content

Commit

Permalink
.ri允许自定义表达式
Browse files Browse the repository at this point in the history
现在先攻允许多骰取大
  • Loading branch information
mystringEmpty committed Jul 23, 2019
1 parent b436fe2 commit b60910a
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions Dice/DiceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -2435,31 +2435,24 @@ class FromMsg {
else if (strLowerMessage.substr(intMsgCnt, 2) == "ri"&&intT)
{
intMsgCnt += 2;
while (isspace(static_cast<unsigned char>(strLowerMessage[intMsgCnt])))intMsgCnt++;
readSkipSpace();
string strinit = "D20";
if (strLowerMessage[intMsgCnt] == '+' || strLowerMessage[intMsgCnt] == '-')
{
strinit += strLowerMessage[intMsgCnt];
intMsgCnt++;
while (isspace(static_cast<unsigned char>(strLowerMessage[intMsgCnt])))intMsgCnt++;
}
else if (isdigit(static_cast<unsigned char>(strLowerMessage[intMsgCnt])))
strinit += '+';
while (isdigit(static_cast<unsigned char>(strLowerMessage[intMsgCnt])))
{
strinit += strLowerMessage[intMsgCnt];
intMsgCnt++;
}
while (isspace(static_cast<unsigned char>(strLowerMessage[intMsgCnt])))
{
intMsgCnt++;
else if (isRollDice()){
strinit = readDice();
}
readSkipSpace();
string strname = strMsg.substr(intMsgCnt);
if (strname.empty())
strname = strNickName;
else
strname = strip(strname);
RD initdice(strinit);
RD initdice(strinit, 20);
const int intFirstTimeRes = initdice.Roll();
if (intFirstTimeRes == Value_Err)
{
Expand Down Expand Up @@ -3414,6 +3407,20 @@ class FromMsg {
if (strGroup.empty()) return 0;
return stoll(strGroup);
}
//是否可看做掷骰表达式
bool isRollDice() {
readSkipSpace();
if (isdigit(static_cast<unsigned char>(strLowerMessage[intMsgCnt]))
|| strLowerMessage[intMsgCnt] == 'd' || strLowerMessage[intMsgCnt] == 'k'
|| strLowerMessage[intMsgCnt] == 'p' || strLowerMessage[intMsgCnt] == 'b'
|| strLowerMessage[intMsgCnt] == 'f'
|| strLowerMessage[intMsgCnt] == '+' || strLowerMessage[intMsgCnt] == '-'
|| strLowerMessage[intMsgCnt] == 'a'
|| strLowerMessage[intMsgCnt] == 'x' || strLowerMessage[intMsgCnt] == '*') {
return true;
}
else return false;
}
//读取掷骰表达式
string readDice(){
string strDice;
Expand All @@ -3426,7 +3433,7 @@ class FromMsg {
|| strLowerMessage[intMsgCnt] == 'a'
|| strLowerMessage[intMsgCnt] == 'x' || strLowerMessage[intMsgCnt] == '*')
{
strDice += strLowerMessage[intMsgCnt];
strDice += strMsg[intMsgCnt];
intMsgCnt++;
}
return strDice;
Expand Down

0 comments on commit b60910a

Please sign in to comment.