Skip to content

Commit

Permalink
as review
Browse files Browse the repository at this point in the history
  • Loading branch information
MX-fox committed Aug 13, 2024
1 parent f75360e commit d5189ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
24 changes: 6 additions & 18 deletions dice/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,17 +1103,11 @@ func setupBaseTextTemplate(d *Dice) {
{`跑团日志上传失败:{$t错误原因}\n若未出现线上日志地址,可换时间重试,或联系骰主在data/default/log-exports路径下取出日志\n文件名: 群号_日志名_随机数.zip\n注意此文件log end/get后才会生成`, 1},
},
// 1.5.0+
"名片_coc": {
{`已自动设置名片为COC7格式: {$t名片格式}\n如有权限会持续自动改名片。使用.sn off可关闭`, 1},
"名片_规则模板": {
{`已自动设置名片格式为{$t名片格式}:{$t名片预览}\n如有权限会在属性更新时自动更新名片。使用.sn off可关闭`, 1},
},
"名片_dnd": {
{`已自动设置名片为DND5E格式: {$t名片格式}\n如有权限会持续自动改名片。使用.sn off可关闭`, 1},
},
"名片_none": {
{`已自动设置名片为空白格式: {$t名片格式}\n如有权限会持续自动改名片。使用.sn off可关闭`, 1},
},
"名片_expr": {
{`应用玩家自设,预览文本: {$t名片格式}`, 1},
"名片_玩家自设": {
{`应用玩家自设,预览文本: {$t名片预览}`, 1},
},
},
}
Expand Down Expand Up @@ -1837,16 +1831,10 @@ func setupBaseTextTemplate(d *Dice) {
},

// 1.5.0+
"名片_coc": {
SubType: ".sn",
},
"名片_dnd": {
SubType: ".sn",
},
"名片_none": {
"名片_规则模板": {
SubType: ".sn",
},
"名片_expr": {
"名片_玩家自设": {
SubType: ".sn",
},
},
Expand Down
23 changes: 14 additions & 9 deletions dice/ext_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ func RegisterBuiltinExtLog(self *Dice) {
if errors.Is(err, ErrGroupCardOverlong) {
return handleOverlong(ctx, msg, text)
}
VarSetValueStr(ctx, "$t名片格式", text)
VarSetValueStr(ctx, "$t名片格式", val)
VarSetValueStr(ctx, "$t名片预览", text)
// 玩家 SAN60 HP10/10 DEX65
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_coc"))
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_规则模板"))
case "dnd", "dnd5e":
// PW{pw}
ctx.Player.AutoSetNameTemplate = "{$t玩家_RAW} HP{hp}/{hpmax} AC{ac} DC{dc} PP{pp}"
Expand All @@ -624,18 +625,20 @@ func RegisterBuiltinExtLog(self *Dice) {
if errors.Is(err, ErrGroupCardOverlong) {
return handleOverlong(ctx, msg, text)
}
VarSetValueStr(ctx, "$t名片格式", text)
VarSetValueStr(ctx, "$t名片格式", val)
VarSetValueStr(ctx, "$t名片预览", text)
// 玩家 HP10/10 AC15 DC15 PW10
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_dnd"))
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_规则模板"))
case "none":
ctx.Player.AutoSetNameTemplate = "{$t玩家_RAW}"
ctx.Player.UpdatedAtTime = time.Now().Unix()
text, err := SetPlayerGroupCardByTemplate(ctx, "{$t玩家_RAW}")
if errors.Is(err, ErrGroupCardOverlong) { // 大约不至于会走到这里,但是为了统一也这样写了
return handleOverlong(ctx, msg, text)
}
VarSetValueStr(ctx, "$t名片格式", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_none"))
VarSetValueStr(ctx, "$t名片格式", val)
VarSetValueStr(ctx, "$t名片预览", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_规则模板"))
case "off", "cancel":
_, _ = SetPlayerGroupCardByTemplate(ctx, "{$t玩家_RAW}")
ctx.Player.AutoSetNameTemplate = ""
Expand All @@ -662,8 +665,8 @@ func RegisterBuiltinExtLog(self *Dice) {
return handleOverlong(ctx, msg, text)
} else {
ctx.Player.UpdatedAtTime = time.Now().Unix()
VarSetValueStr(ctx, "$t名片格式", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_expr"))
VarSetValueStr(ctx, "$t名片预览", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_玩家自设"))
}
}
default:
Expand All @@ -683,7 +686,9 @@ func RegisterBuiltinExtLog(self *Dice) {

text, _ := SetPlayerGroupCardByTemplate(ctx, t.Template)
ctx.Player.AutoSetNameTemplate = t.Template
ReplyToSender(ctx, msg, "已自动设置名片为"+val+"格式: "+text+"\n如有权限会持续自动改名片。使用.sn off可关闭")
VarSetValueStr(ctx, "$t名片格式", val)
VarSetValueStr(ctx, "$t名片预览", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_规则模板"))
ok = true
return false
})
Expand Down

0 comments on commit d5189ea

Please sign in to comment.