Skip to content

Commit

Permalink
1. .ri .init DnD initiative
Browse files Browse the repository at this point in the history
2. Bug fixes
  • Loading branch information
w4123 committed Jun 18, 2018
1 parent b791005 commit 8dac928
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 11 deletions.
Binary file modified Dice/Dice.cpp
Binary file not shown.
2 changes: 2 additions & 0 deletions Dice/Dice.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@
<ItemGroup>
<ClCompile Include="Dice.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="InitList.cpp" />
<ClCompile Include="RD.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="APPINFO.h" />
<ClInclude Include="InitList.h" />
<ClInclude Include="RD.h" />
<ClInclude Include="RDConstant.h" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Dice/Dice.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<ClCompile Include="RD.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="InitList.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="APPINFO.h">
Expand All @@ -35,5 +38,8 @@
<ClInclude Include="RDConstant.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="InitList.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
69 changes: 69 additions & 0 deletions Dice/InitList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
*Dice! QQ dice robot for TRPG game
*Copyright (C) 2018 w4123溯洄
*
*This program is free software: you can redistribute it and/or modify it under the terms
*of the GNU Affero General Public License as published by the Free Software Foundation,
*either version 3 of the License, or (at your option) any later version.
*
*This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
*without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*See the GNU Affero General Public License for more details.
*
*You should have received a copy of the GNU Affero General Public License along with this
*program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "InitList.h"
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;


void Initlist::insert(long long group, int value, string nickname)
{
if (!mpInitlist.count(group))
{
mpInitlist[group] = vector<INIT>{ INIT{ nickname,value } };
}
else
{
for(auto it = mpInitlist[group].begin();it != mpInitlist[group].end();++it)
{
if (it->strNickName == nickname)
{
it->intValue = value;
return;
}
}
mpInitlist[group].push_back(INIT{ nickname,value });
}
}

void Initlist::show(long long group, std::string &strMAns)
{
if (!mpInitlist.count(group)||mpInitlist[group].empty())
{
strMAns = "错误:请先使用.ri指令投掷先攻值";
return;
}
strMAns = "先攻顺序:";
sort(mpInitlist[group].begin(), mpInitlist[group].end(), INIT());
int i = 1;
for (auto it = mpInitlist[group].begin(); it != mpInitlist[group].end(); ++it)
{
strMAns += '\n' + to_string(i) + "." + it->strNickName + " " + to_string(it->intValue);
++i;
}
}

bool Initlist::clear(long long group)
{
if (mpInitlist.count(group))
{
mpInitlist.erase(group);
return true;
}
return false;
}
41 changes: 41 additions & 0 deletions Dice/InitList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
*Dice! QQ dice robot for TRPG game
*Copyright (C) 2018 w4123ËÝä§
*
*This program is free software: you can redistribute it and/or modify it under the terms
*of the GNU Affero General Public License as published by the Free Software Foundation,
*either version 3 of the License, or (at your option) any later version.
*
*This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
*without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*See the GNU Affero General Public License for more details.
*
*You should have received a copy of the GNU Affero General Public License along with this
*program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef __INIT__
#define __INIT__
#include <string>
#include <map>
#include <vector>

struct INIT {
std::string strNickName;
int intValue;
bool operator()(INIT first, INIT second) const {
return first.intValue>second.intValue;
}
};

class Initlist
{
std::map<long long, std::vector<INIT>> mpInitlist;
public:
void insert(long long group, int value, std::string nickname);
void show(long long group, std::string &strMAns);
bool clear(long long group);
};


#endif /*__INIT__*/
22 changes: 11 additions & 11 deletions Dice/RDConstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#error 请使用Win32 Release模式进行编译
#endif
//Version
static const std::string Dice_Ver = "2.2.4(426)";
static const std::string Dice_Ver = "2.2.5(428)";
static const std::string Dice_Short_Ver = "Dice! by 溯洄 Version " + Dice_Ver;
static const std::string Dice_Full_Ver = Dice_Short_Ver + " [MSVC " + std::to_string(_MSC_FULL_VER) + " " + __DATE__ + " " + __TIME__ + "]";
//Error Handle
Expand Down Expand Up @@ -287,26 +287,26 @@ static std::string LongInsanity[11]{ "",
static std::string strHlpMsg = Dice_Short_Ver + R"(
请使用!dismiss [机器人QQ号]命令让机器人自动退群或讨论组!
<通用命令>
.r/d/o [掷骰表达式*] [原因] 普通掷骰
.r [掷骰表达式*] [原因] 普通掷骰
.rs [掷骰表达式*] [原因] 简化输出
.w/ww XaY 骰池
.set [1-99999之间的整数] 设置默认骰
.sc SC表达式** [理智值] 自动Sancheck
.sc SC表达式** [San值] 自动Sancheck
.en [技能名] [技能值] 增强检定/幕间成长
.coc7 [个数] COC7人物作成
.coc6 [个数] COC6人物作成
.coc7/6 [个数] COC7/6人物作成
.dnd [个数] DND人物作成
.coc7d 详细版COC7人物作成
.coc6d 详细版COC6人物作成
.ti 疯狂发作-临时症状
.li 疯狂发作-总结症状
.coc7/6d 详细版COC7/6人物作成
.ti/li 疯狂发作-临时/总结症状
.st [del/clr/show] [属性名] [属性值] 人物卡导入
.rc/ra [技能名] [技能值] 技能检定(规则书/房规)
.jrrp [on/off] 今日人品检定
.rules 关键字 COC7规则查询
.help 显示帮助
<仅限群/多人聊天>
.nn [名称] 设置及删除昵称
.h/rh/dh/oh [掷骰表达式] [原因] 暗骰,结果私聊发送
.ri [加值] [昵称] DnD先攻掷骰
.init [clr] DnD先攻查看/清空
.nn [名称] 设置/删除昵称
.rh [掷骰表达式*] [原因] 暗骰,结果私聊发送
.bot [on/off] [机器人QQ号] 机器人开启或关闭
.ob [exit/list/clr/on/off] 旁观模式
.me on/off/动作 以第三方视角做出动作
Expand Down

0 comments on commit 8dac928

Please sign in to comment.