dsh-game-center 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +176 -2
- package/client.js +1103 -0
- package/cordis.patch.yml +5 -0
- package/icon.svg +10 -0
- package/index.js +2 -0
- package/locale/en.json +36 -0
- package/locale/zh.json +36 -0
- package/package.json +56 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Guo Lu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,177 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Game Center
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](#english) | [中文](#中文)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## English
|
|
12
|
+
|
|
13
|
+
A DeepSeek Harness panel plugin that keeps the mini-games built for this harness in one place, and lets you play them without leaving the window. Ships with Tetris and Cops & Robbers.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
### Requirements
|
|
20
|
+
|
|
21
|
+
| | |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| DeepSeek Harness | `0.2.1-rc.5` (Web UI) |
|
|
24
|
+
| Node.js | `>= 22` |
|
|
25
|
+
| npm dependencies | none at runtime — the panel injects `@deepseek-ai/dsh-client-locale` and `@deepseek-ai/dsh-client-ui-slots`, which the harness provides |
|
|
26
|
+
|
|
27
|
+
### Install
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
dsh plugin add github:stallenlu/dsh-game-center
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Restart DSH (or refresh the Web UI) afterwards, then open **Game Center** from the sidebar.
|
|
34
|
+
|
|
35
|
+
### What it does
|
|
36
|
+
|
|
37
|
+
- **One list for the games.** The panel is a game library: each game is a card with a picture built from the game itself, its name, category, version and status, and it plays in the same panel — no new tab or window.
|
|
38
|
+
- **Tetris.** A 10×20 board, seven pieces with wall kicks, a ghost piece, a next-piece preview, line-clear scoring, levels that speed the falling piece up, pause/restart, and a best score kept in `localStorage`.
|
|
39
|
+
- **Cops & Robbers.** Play the thief on a walled grid: collect every piece of loot to clear the level while the police hunt you down. They path around the walls toward you, each level sends one more, and three lives stand between you and game over.
|
|
40
|
+
- **Per-game difficulty.** Difficulty is the game's own setting, chosen on its start screen and remembered per game: Easy / Normal / Hard start Tetris at level 1 / 3 / 5 and give Cops & Robbers 1 / 2 / 3 police; the level still rises as you play.
|
|
41
|
+
- **Settings.** The panel's own settings only: show or hide the sidebar entry, and reset to defaults. Reachable from the gear button in the panel header and from the plugin's page under **Plugins**.
|
|
42
|
+
- **Theme.** Colours come from the harness theme tokens (`--dsw-alias-*`), so the panel follows light and dark mode.
|
|
43
|
+
|
|
44
|
+
### Controls
|
|
45
|
+
|
|
46
|
+
**Tetris**
|
|
47
|
+
|
|
48
|
+
| Key | Action |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `←` `→` | Move |
|
|
51
|
+
| `↑` `X` | Rotate |
|
|
52
|
+
| `↓` | Soft drop |
|
|
53
|
+
| `Space` | Hard drop |
|
|
54
|
+
| `P` | Pause |
|
|
55
|
+
|
|
56
|
+
**Cops & Robbers**
|
|
57
|
+
|
|
58
|
+
| Key | Action |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `W` `A` `S` `D` | Move one cell |
|
|
61
|
+
| `←` `↑` `↓` `→` | Move one cell |
|
|
62
|
+
| `P` | Pause |
|
|
63
|
+
|
|
64
|
+
### Layout
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
client.js the Web client plugin: panel, settings, games, Tetris, Cops & Robbers
|
|
68
|
+
index.js host-side entry (no host behaviour)
|
|
69
|
+
cordis.patch.yml the insert row that mounts the bundle
|
|
70
|
+
locale/*.json the plugin-list title and description
|
|
71
|
+
icon.svg the in-app icon
|
|
72
|
+
assets/ storefront images
|
|
73
|
+
verify.mjs runnable check (node verify.mjs) — wiring + both games' cores
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Adding a game
|
|
77
|
+
|
|
78
|
+
`client.js` has a `GAMES` registry; an entry declares `{ id, nameKey, descKey, categoryKey, version, statusKey, thumb, thumbCell, thumbGap, render(t) }` and appears in the library automatically. `render` receives the translate function and returns the game's element. A new game also needs its strings added to the `zh` / `en` dictionaries registered at the top of `apply()`.
|
|
79
|
+
|
|
80
|
+
**The card's picture must come from the game, not from decoration.** Write a `xxxThumb()` that builds the matrix out of that game's own constants — a board, a map, its real colours — and set `thumbCell` / `thumbGap` so it fits the 104px panel. Both shipped games do this (`tetrisThumb()` drops real pieces through `SHAPES` / `COLORS` / `collides`, `chaseThumb()` draws `CHASE_MAP`), and `verify.mjs` asserts for every registered game that the picture is a non-blank grid of equal-width rows holding colours — so a hand-drawn or empty one fails the check. Note `.gc-thumb` is a `grid`: it used to be a `flex` row, which laid a 2D matrix out as one clipped line of cells.
|
|
81
|
+
|
|
82
|
+
### Development
|
|
83
|
+
|
|
84
|
+
`verify.mjs` runs without the harness: it loads `client.js`, captures the module, calls `apply()` against a stub context, asserts the three slots (main panel, sidebar entry, plugin-page config) and the locale registrations, then exercises the Tetris core (rotation, collision, line clearing, drop scoring) and the chase core (map integrity, pathfinding, loot, lives).
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
node verify.mjs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 中文
|
|
97
|
+
|
|
98
|
+
一个 DeepSeek Harness 面板插件:把为这个 harness 开发的小游戏集中到一处,不用离开当前窗口就能玩。自带游戏:俄罗斯方块、警察抓小偷。
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+

|
|
103
|
+
|
|
104
|
+
### 环境要求
|
|
105
|
+
|
|
106
|
+
| | |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| DeepSeek Harness | `0.2.1-rc.5`(Web UI) |
|
|
109
|
+
| Node.js | `>= 22` |
|
|
110
|
+
| npm 依赖 | 运行时无依赖——面板只注入 `@deepseek-ai/dsh-client-locale` 和 `@deepseek-ai/dsh-client-ui-slots`,由 harness 提供 |
|
|
111
|
+
|
|
112
|
+
### 安装
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
dsh plugin add github:stallenlu/dsh-game-center
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
安装后重启 DSH(或刷新 Web UI),从侧边栏打开**游戏中心**。
|
|
119
|
+
|
|
120
|
+
### 功能
|
|
121
|
+
|
|
122
|
+
- **一个列表管理游戏。** 面板本身就是游戏库:每款游戏一张卡片,带一张由游戏本身生成的示意图、名称、分类、版本与状态,点开就在同一面板里游玩,不新开标签页或窗口。
|
|
123
|
+
- **俄罗斯方块。** 10×20 棋盘、七种方块(含靠墙微调)、落点虚影、下一个方块预览、消行计分、等级越高落得越快、暂停/重开,最高分存在 `localStorage`。
|
|
124
|
+
- **警察抓小偷。** 你扮演小偷,在有墙的棋盘上把赃物全部捡走即可过关,同时要躲开追捕的警察。警察会绕开墙走最短路线追你,每过一关多一个警察,你有三条命。
|
|
125
|
+
- **每个游戏自己的难度。** 难度是游戏自身的设置,在各自的开始界面上选择、按游戏分别记住:简单 / 普通 / 困难分别让俄罗斯方块从第 1 / 3 / 5 级开始,并让警察抓小偷开局有 1 / 2 / 3 个警察;等级仍会随游玩继续上升。
|
|
126
|
+
- **设置。** 只放面板自身的设置:显示或隐藏侧边栏入口,以及恢复默认。面板右上角的齿轮按钮和插件页都能打开。
|
|
127
|
+
- **主题。** 配色取自 harness 主题变量(`--dsw-alias-*`),明暗主题自动跟随。
|
|
128
|
+
|
|
129
|
+
### 操作
|
|
130
|
+
|
|
131
|
+
**俄罗斯方块**
|
|
132
|
+
|
|
133
|
+
| 按键 | 作用 |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| `←` `→` | 移动 |
|
|
136
|
+
| `↑` `X` | 旋转 |
|
|
137
|
+
| `↓` | 软降 |
|
|
138
|
+
| `Space` | 硬降 |
|
|
139
|
+
| `P` | 暂停 |
|
|
140
|
+
|
|
141
|
+
**警察抓小偷**
|
|
142
|
+
|
|
143
|
+
| 按键 | 作用 |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `W` `A` `S` `D` | 走一格 |
|
|
146
|
+
| `←` `↑` `↓` `→` | 走一格 |
|
|
147
|
+
| `P` | 暂停 |
|
|
148
|
+
|
|
149
|
+
### 目录
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
client.js Web 客户端插件:面板、设置、游戏、俄罗斯方块、警察抓小偷
|
|
153
|
+
index.js 宿主侧入口(无宿主行为)
|
|
154
|
+
cordis.patch.yml 挂载 bundle 的 insert 行
|
|
155
|
+
locale/*.json 插件列表的标题与描述
|
|
156
|
+
icon.svg 应用内图标
|
|
157
|
+
assets/ 商店图片
|
|
158
|
+
verify.mjs 可运行自检(node verify.mjs):接线 + 两款游戏的核心逻辑
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 增加小游戏
|
|
162
|
+
|
|
163
|
+
`client.js` 里有一个 `GAMES` 注册表,一条记录声明 `{ id, nameKey, descKey, categoryKey, version, statusKey, thumb, thumbCell, thumbGap, render(t) }` 后会自动出现在游戏库中。`render` 收到翻译函数并返回游戏元素;新游戏还需要把文案加进 `apply()` 顶部注册的 `zh` / `en` 字典。
|
|
164
|
+
|
|
165
|
+
**卡片示意图必须来自游戏本身,不能用装饰性的图。** 写一个 `xxxThumb()`,用这款游戏自己的常量搭出矩阵——棋盘、地图、真实配色——再用 `thumbCell` / `thumbGap` 让它放进 104px 的图区。现有两款都是这么做的(`tetrisThumb()` 通过 `SHAPES` / `COLORS` / `collides` 真的落方块,`chaseThumb()` 画的就是 `CHASE_MAP`),`verify.mjs` 会对注册表里**每一款**游戏断言示意图是非空网格、每行等宽、格子是颜色——所以手写的装饰图或空图会直接被自检拦下。另外注意 `.gc-thumb` 是 `grid`:它曾经是 `flex` 单行,会把二维矩阵排成一行再裁掉。
|
|
166
|
+
|
|
167
|
+
### 开发
|
|
168
|
+
|
|
169
|
+
`verify.mjs` 不依赖 harness 即可运行:加载 `client.js`、捕获模块、用桩上下文调用 `apply()`,断言三个插槽(主面板、侧边栏入口、插件页配置)与语言注册,再跑一遍俄罗斯方块核心逻辑(旋转、碰撞、消行、下落计分)和追捕逻辑(地图连通性、寻路、拾取赃物、命数)。
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
node verify.mjs
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 许可
|
|
176
|
+
|
|
177
|
+
MIT
|