From 8dac928cd2c12a197462c545052e6a19c1451cc4 Mon Sep 17 00:00:00 2001 From: w4123 <34530484+w4123@users.noreply.github.com> Date: Mon, 18 Jun 2018 22:49:34 +0800 Subject: [PATCH] 1. .ri .init DnD initiative 2. Bug fixes --- Dice/Dice.cpp | Bin 339348 -> 352502 bytes Dice/Dice.vcxproj | 2 ++ Dice/Dice.vcxproj.filters | 6 ++++ Dice/InitList.cpp | 69 ++++++++++++++++++++++++++++++++++++++ Dice/InitList.h | 41 ++++++++++++++++++++++ Dice/RDConstant.h | 22 ++++++------ 6 files changed, 129 insertions(+), 11 deletions(-) create mode 100644 Dice/InitList.cpp create mode 100644 Dice/InitList.h diff --git a/Dice/Dice.cpp b/Dice/Dice.cpp index 71bf58edd6797e27b167190e211e3682d694a98a..0045828a43a1a039267059ddff5f2e46fbd8214d 100644 GIT binary patch delta 1711 zcmeHIT}YE*6n@Y9ecGIBe48_WvhDLLwakW^NvK6dP|6Y$^P&i|G+bURom^T;8&UjD%?ZtpX_I5hBy;IVxUh+Iko}~a zxJf0MPqZ`kId8G`h3WpN)b|o;FZ7~5hvu{3L@BG72qr0HC$Hec#Fobx&4zNYGq_xh zeTP9}(t~n58>R}%DPYR5Pn9l{HAE%~*+@!BF;OtAh*>DFht;qghweZ%tUyBuve0{5 z&WdW9~gd;K2bcjwS z?=|7a4r;{Vh0w_45e=?=N~_T7rrTMhCK)5`REY&la*<}@L_-r;FzTaP?6E=q=T~s~ZeM%QGo86o;n3ygNm~;*x;e8)S~HXh>HzAO2gtdnvA|= z$i&DP$03f25=wrmTQdtL20$Sv4{Y9A+3LG=+nxRWCs;FBRHy|Ud;x|VsU<1a@fL)3 z$O~A9Xc@3|VLexJ8!>sTuWcrz>iEdbo{+T^5w@ zfg5iO(IO^|*XJcPk<4y_mCvV*Z^c1uJ_@KrSxynzIZ_BLZ4AAWxGOk%Mxk7k*{ + + diff --git a/Dice/Dice.vcxproj.filters b/Dice/Dice.vcxproj.filters index 413caca8..7b82978a 100644 --- a/Dice/Dice.vcxproj.filters +++ b/Dice/Dice.vcxproj.filters @@ -24,6 +24,9 @@ 源文件 + + 源文件 + @@ -35,5 +38,8 @@ 头文件 + + 头文件 + \ No newline at end of file diff --git a/Dice/InitList.cpp b/Dice/InitList.cpp new file mode 100644 index 00000000..7d7e482d --- /dev/null +++ b/Dice/InitList.cpp @@ -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 . + */ +#include "InitList.h" +#include +#include +#include +#include +using namespace std; + + +void Initlist::insert(long long group, int value, string nickname) +{ + if (!mpInitlist.count(group)) + { + mpInitlist[group] = vector{ 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; +} diff --git a/Dice/InitList.h b/Dice/InitList.h new file mode 100644 index 00000000..79ce0b73 --- /dev/null +++ b/Dice/InitList.h @@ -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 . + */ +#pragma once +#ifndef __INIT__ +#define __INIT__ +#include +#include +#include + +struct INIT { + std::string strNickName; + int intValue; + bool operator()(INIT first, INIT second) const { + return first.intValue>second.intValue; + } +}; + +class Initlist +{ + std::map> 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__*/ \ No newline at end of file diff --git a/Dice/RDConstant.h b/Dice/RDConstant.h index fc33d66c..db3a12d8 100644 --- a/Dice/RDConstant.h +++ b/Dice/RDConstant.h @@ -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 @@ -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 [] üɾdz -.h/rh/dh/oh [ʽ] [ԭ] ,˽ķ +.ri [ֵ] [dz] DnDȹ +.init [clr] DnDȹ鿴/ +.nn [] /ɾdz +.rh [ʽ*] [ԭ] ,˽ķ .bot [on/off] [QQ] ˿ر .ob [exit/list/clr/on/off] Թģʽ .me on/off/ Եӽ