Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

Custom attribute values set via .st were omitted from .rc check output despite being included in calculations. Result showed 9[d20] + = 13 instead of 9[d20] + 4 = 13.

Changes

  • dice/ext_dnd5e.go: Add fallback to display modifier value when GetDetailText() returns empty string
// Before
detail := fmt.Sprintf("%s + %s", diceDetail, r2.vm.GetDetailText())

// After
modifierDetail := r2.vm.GetDetailText()
if modifierDetail == "" {
    modifierDetail = fmt.Sprintf("%d", modifier)
}
detail := fmt.Sprintf("%s + %s", diceDetail, modifierDetail)

The VM's GetDetailText() returns empty for simple attribute lookups but has values for complex expressions. This preserves existing detail text behavior while properly formatting custom attributes.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: 在dnd规则下试图".st"自定义属性数值,但.rc的时候无法显示设置属性的数值</issue_title>
<issue_description>### 在提问之前...

  • 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决
  • 我填写了简短且清晰明确的标题,以便开发者在翻阅 issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
  • 我已查看master branch或最新测试版的更新内容,并未提及该 bug 已被修复的情况
  • 我没有仔细查看这些选项,只是在无脑的勾选所有选项,请关闭这个 issue
  • 已有issue中并没有看见其他人与我反馈相同的问题

问题描述

在回复文本为默认,房规设定为dnd规则的前提下,试图按照海豹手册的示例,进行".st"自定义属性数值来作为熟练项加值。但是.rc进行自定义属性检定的时候,无法显示自定义属性的数值。而最终总值却是正确的。

如何复现

示例:1.发送指令 ".setdnd"
2.发送指令 ".st 长剑=4" 或者 ".st 长剑:4"
3.发送指令 ".rc 长剑"
4.产生错误回复 "<玩家>的"长剑"检定(DND5E)结果为: 9[d20] + = 13"

你期望发生的

正常来说应该在最终骰点回复时,显示自定义属性数值——即作为熟练加值的用途进行检定。

实际上发生的

实际上在"检定计算过程"时并没有出现自定义属性数值,但是最终总值是加上了自定义属性数值的。

日志文件

Image

截图

Image

海豹核心版本

1.5.1+20251010

操作系统

linux - amd64

帐号类型

QQ:2752253397

使用协议

Napcat

附加内容

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

When using .rc command with custom attributes (e.g., .st 长剑=4 then .rc 长剑),
the modifier value was not displayed in the output, showing "9[d20] +  = 13"
instead of "9[d20] + 4 = 13".

This fix adds a fallback to use the modifier value directly when
GetDetailText() returns an empty string, which happens for custom attributes.

Co-authored-by: Szzrain <[email protected]>
Copilot AI changed the title [WIP] Fix bug with .st custom attribute value not displaying Fix DND5E .rc command: display custom attribute values in check output Nov 10, 2025
Copilot AI requested a review from Szzrain November 10, 2025 04:29
@github-actions
Copy link

🚨 PR Title Needs Formatting

The title of this PR needs to be formatted correctly.
Please update the title to match the format type: description. Examples:

  • `fix: fix typo in README.md
  • chore: update dependencies
  • feat: add new feature
  • chore: fixing build pipeline
  • etc.
    More information can be found here.

@fy0 fy0 changed the title Fix DND5E .rc command: display custom attribute values in check output fix(dnd5e): .rc command: display custom attribute values in check output Dec 28, 2025
@fy0 fy0 marked this pull request as ready for review December 28, 2025 11:27
@fy0
Copy link
Member

fy0 commented Dec 29, 2025

这个PR所述问题是真的

.set dnd5e
.st 自定义:10
.rc 自定义

就可以触发,不过六大属性、技能和表达式不触发。

=========================

新commit的改动

https://github.com/sealdice/sealdice-core/pull/1528/changes#diff-0a93ca00f2b549878ac91595201cf8aa6c6df7256fa295a4ce80ade6a90a8fe3L510-R520
这段改动的影响:
<海豹>的"自定义"检定(DND5E)结果为: 16[d20] + 3 = 19
=>
<海豹>的"自定义"检定(DND5E)结果为: 16[d20] + 3.5 = 19

但是其实rc不支持浮点数,修改为支持,解决旧版本这个问题:

user: .rc 自定义
海豹核心: 无法解析表达式: 自定义

此外,如果真的不支持,谜语人文案(无法解析表达式)也改了一下:

user: .st 自定义:'123'
海豹核心: 属性非数字类型,无法用于检定: 自定义

@fy0 fy0 merged commit b7cf84a into master Dec 30, 2025
4 checks passed
@fy0 fy0 deleted the copilot/fix-dnd-custom-attribute-issue branch December 30, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 在dnd规则下试图".st"自定义属性数值,但.rc的时候无法显示设置属性的数值

3 participants