From 31f27e79be970b96f415f97f8d65269166a33bcb Mon Sep 17 00:00:00 2001 From: "string.Empty" Date: Wed, 23 Oct 2024 05:06:20 +0800 Subject: [PATCH] fix(pc): build --- Dice/CharacterCard.cpp | 19 +++++++++++++++---- Dice/CharacterCard.h | 14 +++----------- Dice/DiceConsole.cpp | 2 +- Dice/DiceEvent.cpp | 10 +++++----- DiceWebUI | 1 + 5 files changed, 25 insertions(+), 21 deletions(-) create mode 160000 DiceWebUI diff --git a/Dice/CharacterCard.cpp b/Dice/CharacterCard.cpp index ca1369e0..5e7af6ba 100644 --- a/Dice/CharacterCard.cpp +++ b/Dice/CharacterCard.cpp @@ -504,6 +504,17 @@ void CharaCard::cntRcStat(int die, int rate) { } unordered_map PList; +Player::Player() { + mGroupCard[0] = mCardList[0] = std::make_shared("角色卡", (size_t)0); +} + +Player::Player(const Player& pl) +{ + indexMax = pl.indexMax; + mCardList = pl.mCardList; + NameList = pl.NameList; + mGroupCard = pl.mGroupCard; +} Player& getPlayer(long long uid) { //if (!PList.count(uid))PList[uid] = {}; @@ -573,11 +584,11 @@ int Player::copyCard(const string& name1, const string& name2, long long group) *getCard(name1) << *getCard(name2); return 0; } -PC Player::getCard(const string& name, long long group) +PC Player::getCard(const string& name, long long group) const { - if (!name.empty() && NameList.count(name))return NameList[name]; - if (mGroupCard.count(group))return mGroupCard[group]; - if (mGroupCard.count(0))return mGroupCard[0]; + if (!name.empty() && NameList.count(name))return NameList.at(name); + if (mGroupCard.count(group))return mGroupCard.at(group); + if (mGroupCard.count(0))return mGroupCard.at(0); return mCardList.begin()->second; } PC Player::getCardByID(long long id)const { diff --git a/Dice/CharacterCard.h b/Dice/CharacterCard.h index b220783a..2c82f860 100644 --- a/Dice/CharacterCard.h +++ b/Dice/CharacterCard.h @@ -285,17 +285,9 @@ class Player // 人物卡互斥 mutable std::mutex cardMutex; public: - Player() { - mCardList[0] = std::make_shared("角色卡", 0); - } + Player(); - Player(const Player& pl) - { - indexMax = pl.indexMax; - mCardList = pl.mCardList; - NameList = pl.NameList; - mGroupCard = pl.mGroupCard; - } + Player(const Player& pl); /*Player& operator=(const Player& pl) { @@ -347,7 +339,7 @@ class Player return Res.show(); } - PC getCard(const string& name, long long group = 0); + PC getCard(const string& name, long long group = 0) const; PC getCardByID(long long id) const; PC operator[](long long id) const { diff --git a/Dice/DiceConsole.cpp b/Dice/DiceConsole.cpp index 5ba21d13..cce0d23d 100644 --- a/Dice/DiceConsole.cpp +++ b/Dice/DiceConsole.cpp @@ -114,7 +114,7 @@ const std::unordered_mapConsole::confComment{ {"ReferMsgReply","响应消息时回复该消息,需要框架支持"}, {"EnableWebUI","是否启用WebUI,重启生效"}, {"WebUIAllowInternetAccess","是否允许远程访问WebUI(端口须对外开放)重启生效"}, - {"WebUIPort","固定WebUI端口,重启生效"}, + {"WebUIPort","指定使用的WebUI端口号,重启生效"}, {"EnablePython","是否启用Python,重启生效"}, {"DebugMode","调试模式:将所有接受的指令写入文件"}, {"DefaultCOCRoomRule","未设置rc房规时调用的检定规则"}, diff --git a/Dice/DiceEvent.cpp b/Dice/DiceEvent.cpp index e8f54a7e..fbf0697f 100644 --- a/Dice/DiceEvent.cpp +++ b/Dice/DiceEvent.cpp @@ -887,7 +887,7 @@ int DiceEvent::BasicOrder() while (isspace(static_cast(strMsg[intMsgCnt]))) intMsgCnt++; //指令匹配 - if (console["DebugMode"])console.log("listen:" + strMsg, 0, printSTNow()); + if (console["DebugMode"])DD::debugLog(printSTNow() + " listen:" + strMsg); if (strLowerMessage.substr(intMsgCnt, 9) == "authorize") { intMsgCnt += 9; @@ -3398,9 +3398,9 @@ int DiceEvent::InnerOrder() { else if (strOption == "build") { string strPC{ strip(filter_CQcode(readRest(), fromChat.gid))}; if (!(resno = pl.buildCard(strPC, false, fromChat.gid))) { - auto pc = pl.getCard(strPC); + auto pc = pl[fromChat.gid]; set("show", pc->show(true)); - set("char", pc->getName()); + set("char", strPC); replyMsg("strPcCardBuild"); } else { @@ -3610,14 +3610,14 @@ int DiceEvent::InnerOrder() { } } if (attr.find("自动成功") == 0) { - strDifficulty = attr.substr(0, 8); + strDifficulty = attr.substr(0, 12); attr = attr.substr(12); isAutomatic = true; } if (attr.find("困难") == 0 || attr.find("极难") == 0) { strDifficulty += attr.substr(0, 6); intDifficulty = (attr.substr(0, 6) == "困难") ? 2 : 5; - attr = attr.substr(4); + attr = attr.substr(6); } if (pc) { attr = pc->standard(attr); diff --git a/DiceWebUI b/DiceWebUI new file mode 160000 index 00000000..cd70ad71 --- /dev/null +++ b/DiceWebUI @@ -0,0 +1 @@ +Subproject commit cd70ad71f0957f36f5cb4203d2749421a26d4cb9