Skip to content

Commit

Permalink
refactor(game): ob
Browse files Browse the repository at this point in the history
将ob开关从群迁移至房间
  • Loading branch information
mystringEmpty committed Feb 7, 2024
1 parent 9a49183 commit c9c944f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dice/DiceAttrVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class AnysTable: public std::enable_shared_from_this<AnysTable> {
bool empty()const;
virtual string print()const;
virtual bool has(const string& key)const;
void set(const string& key, const AttrVar& val);
virtual void set(const string& key, const AttrVar& val);
void set(const string& key);
void set(int i, const AttrVar& val);
void reset(const string& key);
Expand Down
33 changes: 16 additions & 17 deletions Dice/DiceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3412,11 +3412,20 @@ int DiceEvent::InnerOrder() {
replyMsg("strPermissionDeniedErr");
return 1;
}
string& option { (at("option") = "禁用ob").text };
if (strOption == "off") {
if (groupset(fromChat.gid, option) < 1) {
chat(fromChat.gid).set(option);
if (auto game{ thisGame() })game->clear_ob();
auto game{ thisGame() };
if (strOption == "join") {
if (!game || !game->is("no_ob")) {
sessions.get(fromChat)->ob_enter(this);
}
else replyMsg("strObOffAlready");
return 1;
}
else if (!game) {
replyMsg("strGameVoidHere");
}
else if (strOption == "off") {
if (!game->is("no_ob")) {
game->set("no_ob", true);
replyMsg("strObOff");
}
else {
Expand All @@ -3425,25 +3434,15 @@ int DiceEvent::InnerOrder() {
return 1;
}
if (strOption == "on") {
if (groupset(fromChat.gid, option) > 0) {
chat(fromChat.gid).reset(option);
if (game->is("no_ob")) {
game->reset("no_ob");
replyMsg("strObOn");
}
else {
replyMsg("strObOnAlready");
}
return 1;
}
if (groupset(fromChat.gid, option) > 0) {
replyMsg("strObOffAlready");
return 1;
}
if (strOption == "join") {
sessions.get(fromChat)->ob_enter(this);
}
else if (auto game{ thisGame() }; !game) {
replyMsg("strObListEmpty");
}
else if (strOption == "list") {
auto game{ thisGame() }; game->ob_list(this);
}
Expand Down
2 changes: 1 addition & 1 deletion Dice/DiceSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class DiceSession: public AnysTable{
string show()const;
bool has(const string& key)const override;
AttrVar get(const string& key, const AttrVar& val = {})const override;
void set(const string& key, const AttrVar& val){
void set(const string& key, const AttrVar& val) override {
if (!key.empty()) {
if (val.is_null())dict.erase(key);
else dict[key] = val;
Expand Down
13 changes: 6 additions & 7 deletions Dice/GlobalVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <Windows.h>
#endif
#include "GlobalVar.h"
#include "MsgFormat.h"
#include "DiceExtensionManager.h"
#include "DiceMod.h"

Expand Down Expand Up @@ -102,7 +101,7 @@ const dict_ci<string> PlainMsg
{"strGameExited","玩家{nick}已退出游戏√"},
{"strGameNotJoined","嗯?{nick}原来有在桌上吗?"},
{"strGameNotMaster","请{nick}让这桌的GM进行此操作×"},
{"strGameVoidHere","{self}连桌布还没铺上,{nick}就要动桌子么?"},
{"strGameVoidHere","{self}连桌布还没铺上,{nick}就要动桌子么?(请先.game new 新建游戏)"},
{"strGameNotExit","{self}不记得有一桌叫{game_id}的游戏了×"},
{"strGameItemSet","{self}已将本桌游戏的{set_item}设置为{set_val}√"},
{"strGameItemShow","本桌游戏的{set_item}为{set_val}√"},
Expand Down Expand Up @@ -671,8 +670,8 @@ const dict_ci<> HelpDoc = {
{"r","掷骰:.r [掷骰表达式] ([掷骰原因]) [掷骰表达式]:([掷骰轮数]#)[骰子个数]d骰子面数(p[惩罚骰个数])(k[取点数最大的骰子数])不带参数时视为掷一个默认骰\n合法参数要求掷骰轮数1-10,奖惩骰个数1-9,个数范围1-100,面数范围1-1000\n.r3#d\t//3轮掷骰\n.rh心理学 暗骰\n.rs1D10+1D6+3 沙鹰伤害\t//rs省略单个骰子的点数,直接给结果"},
{"暗骰","群聊限定,掷骰指令后接h视为暗骰,结果将私发本人和群内ob的用户\n为了保证发送成功,请加骰娘好友"},
{"reply",R"(自定义回复:.reply
.reply on/off 开启/关闭群内回复
回复触发顺序:指令->完全Match->前缀Prefix->模糊Search->正则Regex
.reply on/off 开/关群内回复
触发顺序:指令->回复 完全Match->前缀Prefix->模糊Search->正则Regex
//以下操作回复指令仅admin可用
.reply set
Type=[回复性质](Reply/Order)
Expand Down Expand Up @@ -885,14 +884,14 @@ const dict_ci<> HelpDoc = {
.group diver //查看潜水成员
.group +/-[群管词条] //为群加减设置,需要对应权限
例:.group +禁用回复 //关闭本群自定义回复
群管词条:停用指令/禁用回复/禁用jrrp/禁用draw/禁用me/禁用help/禁用ob/许可使用/免清/免黑)"
群管词条:停用指令/禁用回复/禁用jrrp/禁用draw/禁用me/禁用help/许可使用/免清/免黑)"
},
{ "groups_list", "&取群列表" },
{ "取群列表", R"(取群列表.groups list(管理限定)
.groups list idle //按闲置天数降序列出群
.groups list size //按群规模降序列出群
.groups list [群管词条] //列出带有词条的群
群管词条:停用指令/禁用回复/禁用jrrp/禁用draw/禁用me/禁用help/禁用ob/许可使用/免清/免黑)" },
群管词条:停用指令/禁用回复/禁用jrrp/禁用draw/禁用me/禁用help/许可使用/免清/免黑)" },
{"消息链接","&link"},
{"link",R"(消息链接.link
.link [转发方向] [对象窗口] 建立本窗口与对象窗口的转发
Expand Down Expand Up @@ -920,7 +919,7 @@ const dict_ci<> HelpDoc = {
Ignore //无视
Notice //仅在0级窗口通知
Caution //提醒用户,并在1级窗口提醒
Warning //【默认等级】警告用户,并在1级窗口提醒
Warning //【默认】警告用户,并在1级窗口提醒
Danger //警告用户且拒绝指令,并在3级窗口警告
*请避免为纯字母/数字的敏感词设置较高触发等级,这些字符存在误匹配图片码的可能性
# 词库批量加载方式见手册)" },
Expand Down
2 changes: 1 addition & 1 deletion Dice/GlobalVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* 请修改Dice_Short_Ver或Dice_Full_Ver常量以达到版本自定义
*/
constexpr unsigned short Dice_Build = 655u;
inline const std::string Dice_Ver_Without_Build = "2.7.0beta7";
inline const std::string Dice_Ver_Without_Build = "2.7.0beta6";
constexpr auto DiceRequestHeader = "Dice/2.7.0";
inline const std::string Dice_Ver = Dice_Ver_Without_Build + "(" + std::to_string(Dice_Build) + ")";
inline const std::string Dice_Short_Ver = "Dice! by 溯洄 & Shiki Ver " + Dice_Ver;
Expand Down
2 changes: 0 additions & 2 deletions Dice/MsgFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

#ifndef DICE_MSG_FORMAT
#define DICE_MSG_FORMAT
#include <string>
#include <map>
#include <unordered_map>
#include <utility>
#include <vector>
#include "STLExtern.hpp"
Expand Down

0 comments on commit c9c944f

Please sign in to comment.