Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复了d3 测试的输出异常,st代骰的输出异常,以及dnd rc改为小写以增强视觉一致性 #1132

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dice/ext_dnd5e.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func RegisterBuiltinExtDnd5e(self *Dice) {
m = strings.Replace(m, "劣勢", "劣势", 1)
restText = strings.TrimSpace(restText[len(m):])
}
expr := fmt.Sprintf("D20%s + %s", m, restText)
expr := fmt.Sprintf("d20%s + %s", m, restText)
mctx.CreateVmIfNotExists()
tmpl := mctx.Group.GetCharTemplate(mctx.Dice)
mctx.Eval(tmpl.PreloadCode, nil)
Expand Down Expand Up @@ -1034,7 +1034,7 @@ func RegisterBuiltinExtDnd5e(self *Dice) {
if m != "" {
restText = strings.TrimSpace(restText[len(m):])
}
expr := fmt.Sprintf("D20%s%s", m, restText)
expr := fmt.Sprintf("d20%s%s", m, restText)
mctx.CreateVmIfNotExists()
mctx.setDndReadForVM(true)
r := mctx.Eval(expr, nil)
Expand Down Expand Up @@ -1195,7 +1195,7 @@ func RegisterBuiltinExtDnd5e(self *Dice) {

if strings.HasPrefix(text, "+") {
// 加值情况1,D20+
r := ctx.Eval("D20"+text, nil)
r := ctx.Eval("d20"+text, nil)
if r.vm.Error != nil {
// 情况1,加值输入错误
return 1, name, val, detail, ""
Expand All @@ -1206,7 +1206,7 @@ func RegisterBuiltinExtDnd5e(self *Dice) {
exprExists = true
} else if strings.HasPrefix(text, "-") {
// 加值情况1.1,D20-
r := ctx.Eval("D20"+text, nil)
r := ctx.Eval("d20"+text, nil)
if r.vm.Error != nil {
// 情况1,加值输入错误
return 1, name, val, detail, ""
Expand All @@ -1228,7 +1228,7 @@ func RegisterBuiltinExtDnd5e(self *Dice) {
exprExists = true
} else if strings.HasPrefix(text, "优势") || strings.HasPrefix(text, "劣势") {
// 优势/劣势
r := ctx.Eval("D20"+text, nil)
r := ctx.Eval("d20"+text, nil)
if r.vm.Error != nil {
// 优势劣势输入错误
return 2, name, val, detail, ""
Expand Down
2 changes: 1 addition & 1 deletion dice/ext_exp.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ func getCmdStBase(soi CmdStOverrideInfo) *CmdItemInfo {
return CmdExecuteResult{Matched: true, Solved: true, ShowHelp: true}
}

rRestIput := ctx.vm.RestInput
rRestIput := mctx.vm.RestInput

// 处理直接设置属性
var text string
Expand Down
3 changes: 2 additions & 1 deletion dice/rollvm_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ func (ctx *MsgContext) CreateVmIfNotExists() {
detailArr = append(detailArr, d.V())
}

detailStr := string(detailResult)
// TODO: 此时加了TrimSpace表现正常,但深层原因是ds在处理"d3 x"这个表达式时多吃了一个空格,修复后取消trim
detailStr := strings.TrimSpace(string(detailResult))
if detailStr == ctx.Ret.ToString() {
detailStr = "" // 如果detail和结果值完全一致,那么将其置空
}
Expand Down