Skip to content

Commit

Permalink
Update to Ver 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
w4123 authored Apr 16, 2018
1 parent 0d742b0 commit 5898590
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
Binary file modified vs/Dice/Dice.cpp
Binary file not shown.
35 changes: 11 additions & 24 deletions vs/Dice/RD.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
#include "RDConstant.h"
#include "CQTools.h"
extern std::map<long long, int> DefaultDice;
//This funtion template is used to convert a type into another type
//Param:origin->Original Data
//Usage:Convert<Converted Type> (Original Data)

template<typename typeTo, typename typeFrom>
typeTo Convert(typeFrom origin)
{
std::stringstream ConvertStream;
typeTo converted;
ConvertStream << origin;
ConvertStream >> converted;
return converted;
}

//This function is used to generate random integer
inline int Randint(int lowest, int highest)
Expand Down Expand Up @@ -52,8 +39,8 @@ class RD
return Input_Err;
if (strAddVal.length() > 2)
return AddDiceVal_Err;
int intDiceCnt = Convert<int>(strDiceCnt);
int AddDiceVal = Convert<int>(strAddVal);
int intDiceCnt = stoi(strDiceCnt);
int AddDiceVal = stoi(strAddVal);
if (intDiceCnt == 0)
return ZeroDice_Err;
if (AddDiceVal < 5 || AddDiceVal > 10)
Expand Down Expand Up @@ -100,7 +87,7 @@ class RD
}
if (strDiceNum.length() > 2)
return DiceTooBig_Err;
int intDiceNum = Convert<int>(strDiceNum);
int intDiceNum = stoi(strDiceNum);
if (intDiceNum == 0)
return ZeroDice_Err;
std::vector<int> vintTmpRes;
Expand All @@ -127,7 +114,7 @@ class RD
for (int i = 1; i != dice.length(); i++)
if (!isdigit(dice[i]))
return Input_Err;
int intPNum = Convert<int>(dice.substr(1));
int intPNum = stoi(dice.substr(1).empty() ? "1" : dice.substr(1));
if (dice.length() == 1)
intPNum = 1;
if (intPNum == 0)
Expand Down Expand Up @@ -164,7 +151,7 @@ class RD
for (int i = 1; i != dice.length(); i++)
if (!isdigit(dice[i]))
return Input_Err;
int intBNum = Convert<int>(dice.substr(1));
int intBNum = stoi(dice.substr(1).empty() ? "1" : dice.substr(1));
if (dice.length() == 1)
intBNum = 1;
if (intBNum == 0)
Expand Down Expand Up @@ -222,7 +209,7 @@ class RD
{
if (dice.length() > 5 || dice.length() == 0)
return Value_Err;
int intTmpRes = Convert<int>(dice);
int intTmpRes = stoi(dice);
if (boolNegative)
intTotal -= intTmpRes;
else
Expand All @@ -237,8 +224,8 @@ class RD
return DiceTooBig_Err;
if (dice.substr(dice.find("D") + 1).length() > 5)
return TypeTooBig_Err;
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : Convert<int>(dice.substr(0, dice.find("D")));
int intDiceType = Convert<int>(dice.substr(dice.find("D") + 1));
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : stoi(dice.substr(0, dice.find("D")));
int intDiceType = stoi(dice.substr(dice.find("D") + 1));
if (intDiceCnt == 0)
return ZeroDice_Err;
if (intDiceType == 0)
Expand All @@ -263,12 +250,12 @@ class RD
{
if (dice.substr(dice.find("K") + 1).length() > 3)
return Value_Err;
int intKNum = Convert<int>(dice.substr(dice.find("K") + 1));
int intKNum = stoi(dice.substr(dice.find("K") + 1));
dice = dice.substr(0, dice.find("K"));
if (dice.substr(0, dice.find("D")).length() > 3 || dice.substr(dice.find("D") + 1).length() > 5)
return Value_Err;
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : Convert<int>(dice.substr(0, dice.find("D")));
int intDiceType = Convert<int>(dice.substr(dice.find("D") + 1));
int intDiceCnt = dice.substr(0, dice.find("D")).length() == 0 ? 1 : stoi(dice.substr(0, dice.find("D")));
int intDiceType = stoi(dice.substr(dice.find("D") + 1));
if (intKNum <= 0 || intDiceCnt == 0)
return ZeroDice_Err;
if (intKNum > intDiceCnt)
Expand Down
29 changes: 23 additions & 6 deletions vs/Dice/RDConstant.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
#pragma once

#ifndef _RDCONSTANT_
#define _RDCONSTANT_
#include <string>
//Error Handle
#define Value_Err -1
#define Input_Err -2
#define ZeroDice_Err -3
#define ZeroType_Err -4
#define DiceTooBig_Err -5
#define TypeTooBig_Err -6
#define AddDiceVal_Err -7
//Dice Type
#define Normal_Dice 0
#define B_Dice 1
#define P_Dice 2
#define Fudge_Dice 3
#define WW_Dice 4
//Message Type
#define PrivateMsg 0
#define GroupMsg 1
#define DiscussMsg 2

//Source type
#define PrivateT 0
#define GroupT 1
#define DiscussT 2
typedef int int_errno;
struct RP {
int RPVal;
std::string Date;
};
//static std::map<std::string, std::string> SkillNameReplace = {make_pair("str","力量"),make_pair("dex","敏捷")}
static std::string TempInsanity[11]{ "",
"失忆:在{1}轮之内,调查员会发现自己只记得最后身处的安全地点,却没有任何来到这里的记忆。",
"假性残疾:调查员陷入了心理性的失明,失聪以及躯体缺失感中,持续{1}轮。",
Expand Down Expand Up @@ -58,7 +66,7 @@ static std::string LongInsanity[11]{ "",
static std::string strEnValInvalid = "技能值或属性输入不正确,请输入1-99范围内的整数!";
static std::string strGroupIDInvalid = "无效的群号!";
static std::string strSendErr = "消息发送失败!";
static std::string strDisabledErr = "在此群中,机器人已被关闭!";
static std::string strDisabledErr = "命令无法执行: 机器人已在此群中被关闭!";
static std::string strMEDisabledErr = "管理员已在此群中禁用.me命令!";
static std::string strNameDelErr = "没有设置名称,无法删除!";
static std::string strValueErr = "掷骰表达式输入错误!";
Expand All @@ -76,22 +84,31 @@ static std::string LongInsanity[11]{ "",
static std::string strWelcomeMsgUpdateNotice = "已更新本群的入群欢迎词";
static std::string strPermissionDeniedErr = "错误:此操作需要群主或管理员权限";
static std::string strNameTooLongErr = "错误:名称过长(最多为50英文字符)";
static std::string strUnknownPropErr = "错误:属性不存在";
static std::string strEmptyWWDiceErr = "格式错误:正确格式为.w(w) XaY!";
static std::string strHlpMsg = R"(Dice! Version 2.1.1Pre-release2
static std::string strPropErr = "请认真的输入你的属性哦~";
static std::string strSetPropSuccess = "属性设置成功";
static std::string strPropCleared = "已清除所有属性";
static std::string strPropDeleted = "属性删除成功";
static std::string strPropNotFound = "错误:属性不存在";
static std::string strProp = "{0}的{1}属性值为{2}";
static std::string strHlpMsg = R"(Dice! Version 2.2.0
注:[ ]中的命令为可选命令
<通用命令>
.r/d/o [掷骰表达式*] [原因] 普通掷骰
.w/ww XaY 骰池
.set [1-99999之间的整数] 设置默认骰
.sc SC表达式** 当前San值 自动Sancheck
.en [技能或属性名称] 值 增强检定/幕间成长
.sc SC表达式** [理智值] 自动Sancheck
.en [技能名] [技能值] 增强检定/幕间成长
.coc7 [个数] COC7人物作成
.coc6 [个数] COC6人物作成
.dnd [个数] DND人物作成
.coc7d 详细版COC7人物作成
.coc6d 详细版COC6人物作成
.ti 疯狂发作-临时症状
.li 疯狂发作-总结症状
.st [del/clr/show] [属性名] [属性值] 人物卡导入
.rc/ra [技能名] [技能值] 技能检定(规则书/房规)
.jrrp [on/off] 今日人品检定
.rules 关键字 COC7规则查询
.help 显示帮助
Expand All @@ -101,7 +118,7 @@ static std::string strHlpMsg = R"(Dice! Version 2.1.1Pre-release2
.bot [on/off] [机器人QQ号] 机器人开启或关闭
.ob [exit/list/clr/on/off] 旁观模式
.me on/off/动作 以第三方视角做出动作
.welcome 欢迎消息 群欢迎提示
.welcome 欢迎消息 群欢迎提示
<仅限私聊>
.me 群号 动作 以第三方视角做出动作
*COC7惩罚骰为P+个数,奖励骰为B+个数
Expand Down

0 comments on commit 5898590

Please sign in to comment.