Skip to content

Commit e803a91

Browse files
committed
feat(rc): BRP roll
支持BRP成功等级规则 rc支持简单难度 setcoc优先设置给game
1 parent e4e0d63 commit e803a91

File tree

7 files changed

+114
-116
lines changed

7 files changed

+114
-116
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141

4242
# Initializes the CodeQL tools for scanning.
4343
- name: Initialize CodeQL
44-
uses: github/codeql-action/init@v2
44+
uses: github/codeql-action/init@v3
4545
with:
4646
languages: ${{ matrix.language }}
4747
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -52,7 +52,7 @@ jobs:
5252
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5353
# If this step fails, then you should remove it and run the build manually (see below)
5454
- name: Autobuild
55-
uses: github/codeql-action/autobuild@v2
55+
uses: github/codeql-action/autobuild@v3
5656

5757
# ℹ️ Command-line programs to run using the OS shell.
5858
# 📚 https://git.io/JvXDl
@@ -66,4 +66,4 @@ jobs:
6666
# make release
6767

6868
- name: Perform CodeQL Analysis
69-
uses: github/codeql-action/analyze@v2
69+
uses: github/codeql-action/analyze@v3

Dice/DiceEvent.cpp

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,13 +1762,19 @@ int DiceEvent::InnerOrder() {
17621762
reply(getMsg("strDefaultCOCSet") + "5\n出1-2且<五分之一大成功\n不满50出96-100大失败,满50出99-100大失败");
17631763
break;
17641764
case 6:
1765-
reply(getMsg("strDefaultCOCSet") + "6\n绿色三角洲\n出1或出个位十位相同且<=成功率大成功\n出100或出个位十位相同且>成功率大失败");
1765+
reply(getMsg("strDefaultCOCSet") + "6-绿色三角洲\n出1或出个位十位相同且<=成功率大成功\n出100或出个位十位相同且>成功率大失败");
1766+
break;
1767+
case 7:
1768+
reply(getMsg("strDefaultCOCSet") + "7-BRP\n简单难度成功率翻倍,五分之一成功率特殊成功\n出96-100必定失败且视成功率判大失败");
17661769
break;
17671770
default:
17681771
replyMsg("strDefaultCOCNotFound");
17691772
return 1;
17701773
}
17711774
if (isPrivate())getUser(fromChat.uid).setConf("rc房规", intRule);
1775+
else if (auto game{ thisGame() }) {
1776+
game->set("rr_rc", intRule);
1777+
}
17721778
else chat(fromChat.gid).set("rc房规", intRule);
17731779
return 1;
17741780
}
@@ -3535,8 +3541,9 @@ int DiceEvent::InnerOrder() {
35353541
replyHelp("rc");
35363542
return 1;
35373543
}
3538-
int intRule = isPrivate()
3539-
? getUser(fromChat.uid).getConf("rc房规", console["DefaultCOCRoomRule"])
3544+
auto game{ thisGame() };
3545+
int intRule = isPrivate() ? getUser(fromChat.uid).getConf("rc房规", console["DefaultCOCRoomRule"])
3546+
: (game && game->has("rr_rc")) ? game->get_int("rr_rc")
35403547
: chat(fromChat.gid).getConf("rc房规", console["DefaultCOCRoomRule"]);
35413548
int intTurnCnt = 1;
35423549
if (strMsg[intMsgCnt] == 'h' && isspace(static_cast<unsigned char>(strMsg[intMsgCnt + 1]))) {
@@ -3563,6 +3570,7 @@ int DiceEvent::InnerOrder() {
35633570
//困难等级
35643571
string strDifficulty;
35653572
int intDifficulty = 1;
3573+
int multiSuccess = 1;
35663574
int intSkillModify = 0;
35673575
//乘数
35683576
int intSkillMultiple = 1;
@@ -3572,7 +3580,6 @@ int DiceEvent::InnerOrder() {
35723580
bool isAutomatic = false;
35733581
//D100且有角色卡时计入统计
35743582
bool isStatic = PList.count(fromChat.uid);
3575-
auto game{ thisGame() };
35763583
bool isRoulette = game && game->is_part(fromChat.uid) && game->roulette.count(100);
35773584
PC pc{ isStatic ? PList[fromChat.uid][fromChat.gid] : std::make_shared<CharaCard>(0)};
35783585
if ((strLowerMessage[intMsgCnt] == 'p' || strLowerMessage[intMsgCnt] == 'b') && strLowerMessage[intMsgCnt - 1] != ' ') {
@@ -3618,9 +3625,16 @@ int DiceEvent::InnerOrder() {
36183625
attr = attr.substr(12);
36193626
isAutomatic = true;
36203627
}
3621-
if (attr.find("困难") == 0 || attr.find("极难") == 0 || attr.find("极限") == 0) {
3622-
strDifficulty += attr.substr(0, 6);
3623-
intDifficulty = (attr.substr(0, 6) == "困难") ? 2 : 5;
3628+
if (attr.find("困难") == 0 || attr.find("极难") == 0 || attr.find("极限") == 0
3629+
|| attr.find("简单") == 0) {
3630+
string adj{ attr.substr(0, 6) };
3631+
strDifficulty += adj;
3632+
if (adj != "简单") {
3633+
intDifficulty = (adj == "困难") ? 2 : 5;
3634+
}
3635+
else {
3636+
multiSuccess = 2;
3637+
}
36243638
attr = attr.substr(6);
36253639
}
36263640
if (pc) {
@@ -3675,7 +3689,7 @@ int DiceEvent::InnerOrder() {
36753689
intSkillVal = stoi(strSkillVal);
36763690
}
36773691
//最终成功率计入检定统计
3678-
int intFianlSkillVal = (intSkillVal * intSkillMultiple + intSkillModify) / intSkillDivisor / intDifficulty;
3692+
int intFianlSkillVal = (intSkillVal * intSkillMultiple + intSkillModify) * multiSuccess / intSkillDivisor / intDifficulty;
36793693
if (intFianlSkillVal < 0 || intFianlSkillVal > 1000) {
36803694
replyMsg("strSuccessRateErr");
36813695
return 1;
@@ -3707,23 +3721,22 @@ int DiceEvent::InnerOrder() {
37073721
pc->cntRcStat(rdMainDice.intTotal, intFianlSkillVal);
37083722
}
37093723
strAns = rdMainDice.FormCompleteString() + "/" + std::to_string(intFianlSkillVal) + " ";
3710-
int intRes = RollSuccessLevel(rdMainDice.intTotal, intFianlSkillVal, intRule);
3724+
auto intRes = RollSuccessLevel(rdMainDice.intTotal, intFianlSkillVal, intRule);
37113725
switch (intRes) {
3712-
case 0: strAns += getMsg("strRollFumble");
3726+
case SuccessLevel::Fumble: strAns += getMsg("strRollFumble");
37133727
break;
3714-
case 1: strAns += isAutomatic ? getMsg("strRollRegularSuccess") : getMsg("strRollFailure");
3728+
case SuccessLevel::Failure: strAns += isAutomatic ? getMsg("strRollRegularSuccess") : getMsg("strRollFailure");
37153729
break;
3716-
case 5: strAns += getMsg("strRollCriticalSuccess");
3730+
case SuccessLevel::Critical: strAns += getMsg("strRollCriticalSuccess");
37173731
break;
3718-
case 4: if (intDifficulty == 1) {
3732+
case SuccessLevel::ExtremeSuccess:
37193733
strAns += getMsg("strRollExtremeSuccess");
37203734
break;
3721-
}
3722-
case 3: if (intDifficulty == 1) {
3735+
case SuccessLevel::HardSuccess: if (multiSuccess == 1) {
37233736
strAns += getMsg("strRollHardSuccess");
37243737
break;
37253738
}
3726-
case 2: strAns += getMsg("strRollRegularSuccess");
3739+
case SuccessLevel::RegularSuccess: strAns += getMsg("strRollRegularSuccess");
37273740
break;
37283741
}
37293742
strReply += strAns;
@@ -3737,23 +3750,23 @@ int DiceEvent::InnerOrder() {
37373750
pc->cntRcStat(rdMainDice.intTotal, intFianlSkillVal);
37383751
}
37393752
strAns = rdMainDice.FormCompleteString() + "/" + std::to_string(intFianlSkillVal) + " ";
3740-
int intRes = RollSuccessLevel(rdMainDice.intTotal, intFianlSkillVal, intRule);
3753+
auto intRes = RollSuccessLevel(rdMainDice.intTotal, intFianlSkillVal, intRule);
37413754
switch (intRes) {
3742-
case 0: strAns += getMsg("strFumble");
3755+
case SuccessLevel::Fumble: strAns += getMsg("strFumble");
37433756
break;
3744-
case 1: strAns += isAutomatic ? getMsg("strSuccess") : getMsg("strFailure");
3757+
case SuccessLevel::Failure: strAns += isAutomatic ? getMsg("strSuccess") : getMsg("strFailure");
37453758
break;
3746-
case 5: strAns += getMsg("strCriticalSuccess");
3759+
case SuccessLevel::Critical: strAns += getMsg("strCriticalSuccess");
37473760
break;
3748-
case 4: if (intDifficulty == 1) {
3761+
case SuccessLevel::ExtremeSuccess: if (intDifficulty == 1) {
37493762
strAns += getMsg("strExtremeSuccess");
37503763
break;
37513764
}
3752-
case 3: if (intDifficulty == 1) {
3765+
case SuccessLevel::HardSuccess: if (intDifficulty == 1) {
37533766
strAns += getMsg("strHardSuccess");
37543767
break;
37553768
}
3756-
case 2: strAns += getMsg("strSuccess");
3769+
case SuccessLevel::RegularSuccess: strAns += getMsg("strSuccess");
37573770
break;
37583771
}
37593772
Res << strAns;
@@ -3887,34 +3900,31 @@ int DiceEvent::InnerOrder() {
38873900
int intRule = fromChat.gid
38883901
? chat(fromChat.gid).getConf("rc房规", console["DefaultCOCRoomRule"])
38893902
: getUser(fromChat.uid).getConf("rc房规", console["DefaultCOCRoomRule"]);
3890-
int res = RollSuccessLevel(intTmpRollRes, intSan, intRule);
3903+
auto res = RollSuccessLevel(intTmpRollRes, intSan, intRule);
38913904
switch (res) {
3892-
case 5:
3893-
case 4:
3894-
case 3:
3895-
case 2:
3896-
rdLoss = RD(strSanCostSuc);
3905+
case SuccessLevel::Failure:
3906+
rdLoss = RD(strSanCostFail);
38973907
if (rdLoss->Roll() != 0) {
38983908
replyMsg("strSanCostInvalid");
38993909
return 1;
39003910
}
39013911
set("change", rdLoss->FormShortString());
39023912
break;
3903-
case 1:
3913+
case SuccessLevel::Fumble:
39043914
rdLoss = RD(strSanCostFail);
3905-
if (rdLoss->Roll() != 0) {
3915+
if (rdLoss->Max() != 0) {
39063916
replyMsg("strSanCostInvalid");
39073917
return 1;
39083918
}
3909-
set("change", rdLoss->FormShortString());
3919+
set("change","Max{" + rdLoss->strDice + "}=" + std::to_string(rdLoss->intTotal));
39103920
break;
3911-
case 0:
3912-
rdLoss = RD(strSanCostFail);
3913-
if (rdLoss->Max() != 0) {
3921+
default:
3922+
rdLoss = RD(strSanCostSuc);
3923+
if (rdLoss->Roll() != 0) {
39143924
replyMsg("strSanCostInvalid");
39153925
return 1;
39163926
}
3917-
set("change","Max{" + rdLoss->strDice + "}=" + std::to_string(rdLoss->intTotal));
3927+
set("change", rdLoss->FormShortString());
39183928
break;
39193929
}
39203930
AttrObject trans{ AnysTable{{
@@ -3926,7 +3936,7 @@ int DiceEvent::InnerOrder() {
39263936
intSan = max(0, intSan - sanLoss);
39273937
trans->set("new", intSan);
39283938
set("final",intSan);
3929-
set("rank", res);
3939+
set("rank", int(res));
39303940
if (pc && sanLoss){
39313941
pc->set(attr, intSan);
39323942
set("trans", AnysTable{ AttrVars{

Dice/GlobalVar.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ const dict_ci<string> GlobalComment{
536536
};
537537
const dict_ci<> HelpDoc = {
538538
{"更新",R"(
539+
668:支持BRP检定
539540
667:format新增len&expired
540541
666:变更内部字符编码
541542
665:webui依赖本地化
@@ -838,6 +839,9 @@ pl默认所有群使用同一张卡,如需多开请使用.pc指令切卡
838839
6 绿色三角洲
839840
出1或出个位十位相同且<=成功率大成功
840841
出100或出个位十位相同且>成功率大失败
842+
7 BRP
843+
简单难度双倍成功率,五分之一特殊成功率
844+
出96-100必定失败且视成功率判大失败
841845
842846
如需其他房规可向开发者反馈
843847
无论如何,群内检定只会调用群内设置,以免团内成员不对等

Dice/GlobalVar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Please Do not modify Dice_Build, Dice_Ver_Without_Build, DiceRequestHeader or Dice_Ver
3838
* To costum version info, please modify const Dice_Short_Ver or Dice_Full_Ver
3939
*/
40-
constexpr unsigned short Dice_Build = 667u;
40+
constexpr unsigned short Dice_Build = 668u;
4141
inline const std::string Dice_Ver_Without_Build = "2.7.1beta1";
4242
constexpr auto DiceRequestHeader = "Dice/2.7.1";
4343
inline const std::string Dice_Ver = Dice_Ver_Without_Build + "(" + std::to_string(Dice_Build) + ")";

Dice/Jsonio.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
#include "filesystem.hpp"
2-
#include <fstream>
3-
#include <iomanip>
4-
#include "StrExtern.hpp"
51
#include "Jsonio.h"
62

7-
[[deprecated]] fifo_json freadJson(const std::string& strPath)
8-
{
9-
std::ifstream fin(strPath);
10-
if (!fin)return fifo_json();
11-
fifo_json j;
12-
try
13-
{
14-
fin >> j;
15-
}
16-
catch (...)
17-
{
18-
return fifo_json();
19-
}
20-
return j;
21-
}
22-
233
fifo_json freadJson(const std::filesystem::path& path){
244
fifo_json j;
255
std::ifstream fin(path);
@@ -31,15 +11,8 @@ fifo_json freadJson(const std::filesystem::path& path){
3111
return j;
3212
}
3313

34-
[[deprecated]] void fwriteJson(const std::string& strPath, const fifo_json& j)
35-
{
36-
std::ofstream fout(strPath);
37-
fout << std::setw(2) << j;
38-
}
39-
4014
void fwriteJson(const std::filesystem::path& fpPath, const fifo_json& j, const int indent)
4115
{
4216
std::ofstream fout(fpPath);
4317
fout << std::setw(2) << j.dump(indent);
4418
}
45-

0 commit comments

Comments
 (0)