build-game-inventory
它能做什么
这个技能指导智能体构建游戏的物品和装备系统。适合需要拾取、穿戴和交换每次都正常工作、且不丢失或复制物品的游戏开发者。
适用场景
- ✓游戏需要物品、战利品、堆叠或装备栏的时候。
- ✓拖动、交换或穿戴物品时绝不能丢失物品的时候。
- ✓已保存的游戏需要在不同版本之间安全迁移背包数据的时候。
技能链接
https://github.com/MengTo/Skills/blob/main/agent-skills/game-development/build-game-inventory/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为我的游戏添加一个带有装备栏和拖放交换功能的背包,并确保没有任何物品丢失。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会保持一份有类型的物品列表,在改变任何内容之前检查每一次移动,并且每次更改只提交一次。它会保存有效的结果,并测试物品丢失、背包已满和重复操作等情况。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Build Game Inventory
Use one typed, serializable item source of truth and make every transfer atomic.
Define the item contract
Model stable IDs, item definitions, ownership, stack limits, equipment compatibility, effects, rarity, presentation data, and migration version separately. Runtime UI must reference definitions by ID rather than duplicate stats or descriptions.
Implement transfers as transactions
For pickup, equip, unequip, swap, drag/drop, consume, and sell:
- Validate source ownership and destination legality.
- Compute the entire next inventory/equipment state.
- Commit once or reject without changing either side.
- Persist only after the committed state is valid.
Never remove an item before confirming a legal destination. Preserve item identity across a swap and prevent duplicate effect registration.
Build usable UI
Expose slot compatibility, equipped state, quantity, tooltip facts, and failure feedback. Support keyboard and touch alternatives to drag-only interactions. Keep focus behavior, dialogs, and tooltips accessible.
Test loss boundaries
Cover invalid destinations, full inventory, duplicate pickup, equip swap, mid-action swap, save/load, schema migration, reset/new game, tooltip updates, and repeated dispatch. Validate that total owned item identity is conserved except for explicit consumption or reward rules.
常见问题
如果某次移动不被允许怎么办?
技能规定拒绝该移动,且不改变任何一侧,因此不会丢失任何物品。
拖放是移动物品的唯一方式吗?
不是。技能要求同时提供键盘和触屏的替代方式。
存档如何处理?
已保存的背包数据带有版本号,技能涵盖将旧存档迁移的方法。
详情
作者的原始描述
Build or repair game inventory, loot, equipment, tooltips, drag-and-drop, persistence, and progression systems. Use for item schemas, pickup flows, stack rules, equipment slots, atomic swaps, save migration, and no-loss regression testing.
repo: MengTo/Skills
热度
- GitHub 星标
- 7.2k
- 排名
- #13355
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
3d-cloth-material
7.2k帮你的智能体在 Three.js 中制作逼真的编织织物,包括纱线编织纹理、柔和光泽、自然褶皱、下摆和缝线。
3d-falling-leaves
7.2k帮你的智能体在 3D 场景中添加逼真的飘落树叶,树叶会翻滚、随风飘动,并在镜头移动时循环利用。
3d-four-seasons
7.2k帮你的智能体为 3D 场景添加春夏秋冬四季效果,无需重建场景即可改变植被、光线、天空和积雪。
3d-high-poly-models
7.2k帮你的智能体构建形状平滑、边缘可信的精细 3D 模型,然后制作在网页上运行流畅的轻量版本。