@nexusgame/dev 0.0.0-stage → 0.2.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 +58 -2
- package/dist/engine-worker.js +5033 -0
- package/dist/index.js +301 -0
- package/package.json +27 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nexus Playground Contributors
|
|
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,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nexusgame/dev
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nexus Playground 的**本地开发调试工具**(bin:`npgame-dev`)。它不负责创建游戏,也不做认证、注册或部署——这些都在平台侧完成。
|
|
4
|
+
|
|
5
|
+
- 创建游戏:使用 GitHub 模板仓库 [`npgame/nexus-game-template`](https://github.com/npgame/nexus-game-template),或通过 `ftc` 的 `register_game` 由平台建仓。
|
|
6
|
+
- 开发文档:[`npgame/nexus-docs`](https://github.com/npgame/nexus-docs)。
|
|
7
|
+
|
|
8
|
+
## 快速开始
|
|
9
|
+
|
|
10
|
+
本地引擎是一个跑在 Miniflare 上的 GameDO 单文件 bundle,不依赖 backend / frontend / LLM,用来快速验证逻辑与 UI。
|
|
11
|
+
|
|
12
|
+
> 以下命令都可以用 `npx @nexusgame/dev ...` 直接运行,无需全局安装。
|
|
13
|
+
|
|
14
|
+
### 1. 启动本地引擎
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npgame-dev start
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
默认端口 `56512`,状态持久化到当前目录的 `./.nexus`。
|
|
21
|
+
|
|
22
|
+
### 2. 连接游戏 Worker
|
|
23
|
+
|
|
24
|
+
先在游戏仓库里启动 Worker(通常是 `pnpm run dev`,默认 `http://localhost:8788`),然后:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npgame-dev setup --worker-url http://localhost:8788
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`setup` 会依次创建房间、设置游戏、开始游戏,一次性完成全链路。
|
|
31
|
+
|
|
32
|
+
### 3. 查看与交互
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# 查看房间全局状态(权威 gameState、roleMapping、history)
|
|
36
|
+
npgame-dev state
|
|
37
|
+
|
|
38
|
+
# 查看某角色的视角,并输出一个可在浏览器打开的调试 UI URL
|
|
39
|
+
npgame-dev perspective player_1
|
|
40
|
+
|
|
41
|
+
# 以指定角色执行动作
|
|
42
|
+
npgame-dev action player_1 '{"action_id":"place","params":{"row":0,"col":0}}'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 常用参数
|
|
46
|
+
|
|
47
|
+
| 命令 | 参数 | 说明 |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `start` | `-p, --port <port>` | 引擎端口,默认 `56512` |
|
|
50
|
+
| `setup` | `-w, --worker-url <url>` | Game Worker URL(必填) |
|
|
51
|
+
| `setup` | `-p, --port <port>` | 引擎端口,默认 `56512` |
|
|
52
|
+
| `setup` | `-n, --players <count>` | 指定参与人数(适用于 UNO 等可选人数游戏) |
|
|
53
|
+
| `state` / `perspective` / `action` | `-p, --port <port>` | 引擎端口,默认 `56512` |
|
|
54
|
+
|
|
55
|
+
## 构建
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pnpm run build # 打包 CLI,并把 nexus-engine 的单文件 worker 复制进 dist/
|
|
59
|
+
```
|