Skip to content

Commit

Permalink
fix(pc): build
Browse files Browse the repository at this point in the history
  • Loading branch information
mystringEmpty committed Oct 22, 2024
1 parent fc8adf0 commit 31f27e7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
19 changes: 15 additions & 4 deletions Dice/CharacterCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,17 @@ void CharaCard::cntRcStat(int die, int rate) {
}
unordered_map<long long, Player> PList;

Player::Player() {
mGroupCard[0] = mCardList[0] = std::make_shared<CharaCard>("角色卡", (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] = {};
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 3 additions & 11 deletions Dice/CharacterCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,9 @@ class Player
// 人物卡互斥
mutable std::mutex cardMutex;
public:
Player() {
mCardList[0] = std::make_shared<CharaCard>("角色卡", 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)
{
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Dice/DiceConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const std::unordered_map<std::string,string>Console::confComment{
{"ReferMsgReply","响应消息时回复该消息,需要框架支持"},
{"EnableWebUI","是否启用WebUI,重启生效"},
{"WebUIAllowInternetAccess","是否允许远程访问WebUI(端口须对外开放)重启生效"},
{"WebUIPort","固定WebUI端口,重启生效"},
{"WebUIPort","指定使用的WebUI端口号,重启生效"},
{"EnablePython","是否启用Python,重启生效"},
{"DebugMode","调试模式:将所有接受的指令写入文件"},
{"DefaultCOCRoomRule","未设置rc房规时调用的检定规则"},
Expand Down
10 changes: 5 additions & 5 deletions Dice/DiceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ int DiceEvent::BasicOrder()
while (isspace(static_cast<unsigned char>(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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions DiceWebUI
Submodule DiceWebUI added at cd70ad

0 comments on commit 31f27e7

Please sign in to comment.