Skip to content

Commit 5898590

Browse files
authored
Update to Ver 2.2.0
1 parent 0d742b0 commit 5898590

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
lines changed

vs/Dice/Dice.cpp

58 KB
Binary file not shown.

vs/Dice/RD.h

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@
99
#include "RDConstant.h"
1010
#include "CQTools.h"
1111
extern std::map<long long, int> DefaultDice;
12-
//This funtion template is used to convert a type into another type
13-
//Param:origin->Original Data
14-
//Usage:Convert<Converted Type> (Original Data)
15-
16-
template<typename typeTo, typename typeFrom>
17-
typeTo Convert(typeFrom origin)
18-
{
19-
std::stringstream ConvertStream;
20-
typeTo converted;
21-
ConvertStream << origin;
22-
ConvertStream >> converted;
23-
return converted;
24-
}
2512

2613
//This function is used to generate random integer
2714
inline int Randint(int lowest, int highest)
@@ -52,8 +39,8 @@ class RD
5239
return Input_Err;
5340
if (strAddVal.length() > 2)
5441
return AddDiceVal_Err;
55-
int intDiceCnt = Convert<int>(strDiceCnt);
56-
int AddDiceVal = Convert<int>(strAddVal);
42+
int intDiceCnt = stoi(strDiceCnt);
43+
int AddDiceVal = stoi(strAddVal);
5744
if (intDiceCnt == 0)
5845
return ZeroDice_Err;
5946
if (AddDiceVal < 5 || AddDiceVal > 10)
@@ -100,7 +87,7 @@ class RD
10087
}
10188
if (strDiceNum.length() > 2)
10289
return DiceTooBig_Err;
103-
int intDiceNum = Convert<int>(strDiceNum);
90+
int intDiceNum = stoi(strDiceNum);
10491
if (intDiceNum == 0)
10592
return ZeroDice_Err;
10693
std::vector<int> vintTmpRes;
@@ -127,7 +114,7 @@ class RD
127114
for (int i = 1; i != dice.length(); i++)
128115
if (!isdigit(dice[i]))
129116
return Input_Err;
130-
int intPNum = Convert<int>(dice.substr(1));
117+
int intPNum = stoi(dice.substr(1).empty() ? "1" : dice.substr(1));
131118
if (dice.length() == 1)
132119
intPNum = 1;
133120
if (intPNum == 0)
@@ -164,7 +151,7 @@ class RD
164151
for (int i = 1; i != dice.length(); i++)
165152
if (!isdigit(dice[i]))
166153
return Input_Err;
167-
int intBNum = Convert<int>(dice.substr(1));
154+
int intBNum = stoi(dice.substr(1).empty() ? "1" : dice.substr(1));
168155
if (dice.length() == 1)
169156
intBNum = 1;
170157
if (intBNum == 0)
@@ -222,7 +209,7 @@ class RD
222209
{
223210
if (dice.length() > 5 || dice.length() == 0)
224211
return Value_Err;
225-
int intTmpRes = Convert<int>(dice);
212+
int intTmpRes = stoi(dice);
226213
if (boolNegative)
227214
intTotal -= intTmpRes;
228215
else
@@ -237,8 +224,8 @@ class RD
237224
return DiceTooBig_Err;
238225
if (dice.substr(dice.find("D") + 1).length() > 5)
239226
return TypeTooBig_Err;
240-
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : Convert<int>(dice.substr(0, dice.find("D")));
241-
int intDiceType = Convert<int>(dice.substr(dice.find("D") + 1));
227+
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : stoi(dice.substr(0, dice.find("D")));
228+
int intDiceType = stoi(dice.substr(dice.find("D") + 1));
242229
if (intDiceCnt == 0)
243230
return ZeroDice_Err;
244231
if (intDiceType == 0)
@@ -263,12 +250,12 @@ class RD
263250
{
264251
if (dice.substr(dice.find("K") + 1).length() > 3)
265252
return Value_Err;
266-
int intKNum = Convert<int>(dice.substr(dice.find("K") + 1));
253+
int intKNum = stoi(dice.substr(dice.find("K") + 1));
267254
dice = dice.substr(0, dice.find("K"));
268255
if (dice.substr(0, dice.find("D")).length() > 3 || dice.substr(dice.find("D") + 1).length() > 5)
269256
return Value_Err;
270-
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : Convert<int>(dice.substr(0, dice.find("D")));
271-
int intDiceType = Convert<int>(dice.substr(dice.find("D") + 1));
257+
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : stoi(dice.substr(0, dice.find("D")));
258+
int intDiceType = stoi(dice.substr(dice.find("D") + 1));
272259
if (intKNum <= 0 || intDiceCnt == 0)
273260
return ZeroDice_Err;
274261
if (intKNum > intDiceCnt)

vs/Dice/RDConstant.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
#pragma once
2+
23
#ifndef _RDCONSTANT_
34
#define _RDCONSTANT_
45
#include <string>
6+
//Error Handle
57
#define Value_Err -1
68
#define Input_Err -2
79
#define ZeroDice_Err -3
810
#define ZeroType_Err -4
911
#define DiceTooBig_Err -5
1012
#define TypeTooBig_Err -6
1113
#define AddDiceVal_Err -7
14+
//Dice Type
1215
#define Normal_Dice 0
1316
#define B_Dice 1
1417
#define P_Dice 2
1518
#define Fudge_Dice 3
1619
#define WW_Dice 4
20+
//Message Type
1721
#define PrivateMsg 0
1822
#define GroupMsg 1
1923
#define DiscussMsg 2
20-
24+
//Source type
25+
#define PrivateT 0
26+
#define GroupT 1
27+
#define DiscussT 2
2128
typedef int int_errno;
2229
struct RP {
2330
int RPVal;
2431
std::string Date;
2532
};
33+
//static std::map<std::string, std::string> SkillNameReplace = {make_pair("str","力量"),make_pair("dex","敏捷")}
2634
static std::string TempInsanity[11]{ "",
2735
"失忆:在{1}轮之内,调查员会发现自己只记得最后身处的安全地点,却没有任何来到这里的记忆。",
2836
"假性残疾:调查员陷入了心理性的失明,失聪以及躯体缺失感中,持续{1}轮。",
@@ -58,7 +66,7 @@ static std::string LongInsanity[11]{ "",
5866
static std::string strEnValInvalid = "技能值或属性输入不正确,请输入1-99范围内的整数!";
5967
static std::string strGroupIDInvalid = "无效的群号!";
6068
static std::string strSendErr = "消息发送失败!";
61-
static std::string strDisabledErr = "在此群中,机器人已被关闭!";
69+
static std::string strDisabledErr = "命令无法执行: 机器人已在此群中被关闭!";
6270
static std::string strMEDisabledErr = "管理员已在此群中禁用.me命令!";
6371
static std::string strNameDelErr = "没有设置名称,无法删除!";
6472
static std::string strValueErr = "掷骰表达式输入错误!";
@@ -76,22 +84,31 @@ static std::string LongInsanity[11]{ "",
7684
static std::string strWelcomeMsgUpdateNotice = "已更新本群的入群欢迎词";
7785
static std::string strPermissionDeniedErr = "错误:此操作需要群主或管理员权限";
7886
static std::string strNameTooLongErr = "错误:名称过长(最多为50英文字符)";
87+
static std::string strUnknownPropErr = "错误:属性不存在";
7988
static std::string strEmptyWWDiceErr = "格式错误:正确格式为.w(w) XaY!";
80-
static std::string strHlpMsg = R"(Dice! Version 2.1.1Pre-release2
89+
static std::string strPropErr = "请认真的输入你的属性哦~";
90+
static std::string strSetPropSuccess = "属性设置成功";
91+
static std::string strPropCleared = "已清除所有属性";
92+
static std::string strPropDeleted = "属性删除成功";
93+
static std::string strPropNotFound = "错误:属性不存在";
94+
static std::string strProp = "{0}的{1}属性值为{2}";
95+
static std::string strHlpMsg = R"(Dice! Version 2.2.0
8196
注:[ ]中的命令为可选命令
8297
<通用命令>
8398
.r/d/o [掷骰表达式*] [原因] 普通掷骰
8499
.w/ww XaY 骰池
85100
.set [1-99999之间的整数] 设置默认骰
86-
.sc SC表达式** 当前San值 自动Sancheck
87-
.en [技能或属性名称] 值 增强检定/幕间成长
101+
.sc SC表达式** [理智值] 自动Sancheck
102+
.en [技能名] [技能值] 增强检定/幕间成长
88103
.coc7 [个数] COC7人物作成
89104
.coc6 [个数] COC6人物作成
90105
.dnd [个数] DND人物作成
91106
.coc7d 详细版COC7人物作成
92107
.coc6d 详细版COC6人物作成
93108
.ti 疯狂发作-临时症状
94109
.li 疯狂发作-总结症状
110+
.st [del/clr/show] [属性名] [属性值] 人物卡导入
111+
.rc/ra [技能名] [技能值] 技能检定(规则书/房规)
95112
.jrrp [on/off] 今日人品检定
96113
.rules 关键字 COC7规则查询
97114
.help 显示帮助
@@ -101,7 +118,7 @@ static std::string strHlpMsg = R"(Dice! Version 2.1.1Pre-release2
101118
.bot [on/off] [机器人QQ号] 机器人开启或关闭
102119
.ob [exit/list/clr/on/off] 旁观模式
103120
.me on/off/动作 以第三方视角做出动作
104-
.welcome 欢迎消息 群欢迎提示
121+
.welcome 欢迎消息 群欢迎提示
105122
<仅限私聊>
106123
.me 群号 动作 以第三方视角做出动作
107124
*COC7惩罚骰为P+个数,奖励骰为B+个数

0 commit comments

Comments
 (0)