使用 GCodes/card203098_follow.py 作为测试卡牌(亨赛特国王)。
python ASTToPython.py确保GC代码被正确翻译成Python代码。
python HostTest.py- 打开Tabletop Simulator
- 加载包含亨赛特国王的卡组
- 打出亨赛特国王
-
触发Deploy效果
- 打出亨赛特国王
- 应该弹出选择UI,显示具有"操控"关键字的卡牌
-
选择卡牌
- 点击选择一张卡牌
- 点击"确定"按钮
-
验证跟随效果
- ✅ 选中的卡牌应该出现在你的光标位置
- ✅ 移动鼠标,卡牌应该跟随光标
- ✅ 卡牌保持在适当高度(不插入桌面)
-
打出卡牌
- 将卡牌拖入近战或远程行
- ✅ 卡牌应该停留在出牌区
- ✅ Lua控制台应显示:
[FollowCursor] Purple 打出了卡牌到 zoneMeleeA!
-
触发跟随效果(同上)
-
放下卡牌到桌面
- 将卡牌拖到非出牌区(如桌面空白处)
- 松开鼠标
-
验证重新拾起
- ✅ 等待约0.1秒后,卡牌应该重新回到光标位置
- ✅ Lua控制台应显示:
[FollowCursor] Purple 放下了卡牌,重新拾起!
-
继续尝试直到成功打出
-
玩家A触发follow_cursor
- 玩家A打出亨赛特国王并选择卡牌
-
玩家B也触发follow_cursor
- 玩家B打出另一张具有类似效果的卡牌
-
验证互不干扰
- ✅ 两个玩家的卡牌应该各自跟随自己的光标
- ✅ 一个玩家打出卡牌不影响另一个玩家
-
卡牌被销毁
- 在跟随过程中,通过其他方式销毁卡牌
- ✅ 追踪应该自动停止
- ✅ Lua控制台应显示:
[FollowCursor] 卡牌已被销毁,停止追踪
-
长时间不打出
- 让卡牌跟随光标超过1分钟
- ✅ 不应该出现性能问题
- ✅ 卡牌持续跟随
在TTS中按 ~ 键打开控制台,查看以下日志:
[FollowCursor] 开始追踪: Purple 的卡牌 abc123
[FollowCursor] Purple 放下了卡牌,重新拾起!
[FollowCursor] Purple 打出了卡牌到 zoneMeleeA!
[FollowCursor] 停止追踪: Purple
在运行HostTest.py的终端中查看:
已发送 followCursor 指令: abc123 跟随 Purple 玩家光标
已启动 follow_cursor 效果: 某某卡牌
检查清单:
- 确认
play(selected_card)被正确调用 - 检查Lua控制台是否有错误信息
- 确认player_color参数正确("Purple"或"Yellow")
- 确认卡牌GUID有效
解决方案:
# 添加调试输出
print(f"selected_card: {selected_card}")
print(f"selected_card.card.inGameObjGuid: {selected_card.card.inGameObjGuid}")
play(selected_card)检查清单:
- 确认出牌区的tag与PLAY_ZONES配置匹配
- 检查onObjectEnterZone是否被调用
解决方案: 在code.lua中添加调试输出:
function onObjectEnterZone(zone, object)
print("onObjectEnterZone called")
print("zone tags:", table.concat(zone.getTags(), ", "))
-- ... 其余代码
end检查清单:
- 确认onObjectDrop被调用
- 检查Wait.frames延迟是否合适
解决方案: 调整延迟时间:
Wait.frames(function()
-- ... 重新拾起逻辑
end, 2) -- 尝试改为 3 或 4在TTS控制台中输入:
print(Global.getFPS())- ✅ 正常:60 FPS
⚠️ 警告:< 30 FPS(可能有性能问题)- ❌ 异常:< 10 FPS(需要优化)
监控Lua内存使用:
print(collectgarbage("count"))可以创建自动化测试脚本来验证功能:
# test_follow_cursor.py
import requests
import time
def test_follow_cursor():
"""自动化测试follow_cursor功能"""
# 1. 模拟选择卡牌
response = requests.post('http://localhost/choose', data={
'event': {
'type': 'ChooseEnd',
'args': {
'cards': [{'guid': 'test_guid', 'dataId': '123456'}]
}
}
})
# 2. 检查返回的actions
actions = response.json()
has_follow_cursor = any(
action.get('action') == 'followCursor'
for action in actions
)
assert has_follow_cursor, "未找到followCursor action"
print("✅ 测试通过:followCursor action已发送")
if __name__ == '__main__':
test_follow_cursor()# FollowCursor 功能测试报告
**测试日期:** 2026-05-18
**测试人员:** [你的名字]
**测试环境:** TTS vXXX, Python 3.X
## 测试结果
| 测试项 | 状态 | 备注 |
|--------|------|------|
| 基本跟随功能 | ✅ 通过 | - |
| 放下后重新拾起 | ✅ 通过 | - |
| 多玩家测试 | ✅ 通过 | - |
| 卡牌销毁处理 | ✅ 通过 | - |
| 长时间运行 | ✅ 通过 | 无性能问题 |
## 发现的问题
1. [如果有问题,详细描述]
## 建议改进
1. [如果有建议,详细说明]
## 结论
FollowCursor功能实现完整,所有测试用例通过,可以投入使用。最后更新: 2026年5月18日