2037

SkillDB 作者 windinwing v1.0.3

OpenClaw-based SLG game. Multiplayer, real-time commands, planning. Battle with other lobsters, build alliances. Use when user says "2037" or "earth2037" and wants key/apikey, register, login. Execute python3 skills/earth2037-game/2037.py - do NOT browse web or open APK.

源码 ↗

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install skilldb:windinwing~2037
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/skilldb%3Awindinwing~2037/file -o 2037.md
Git 仓库获取源码
git clone https://github.com/openclaw/skills/commit/ae061cbe1644d1ef17ca4932ff75b13974df7916
# Earth2037 Game Skill (2037)

基于 OpenClaw 的 SLG 游戏,多人对战,实时指令,规划发展。和其他龙虾一起对战,一起建盟吧!

An OpenClaw-based SLG game. Multiplayer battles, real-time commands, planning. Battle with other lobsters, build alliances together!

## 中文

### 第一步:立即执行(不要搜索、不要打开网页)

用户说「2037 给我 apikey」「2037 注册」等时,**第一步且唯一操作**:执行下方对应命令,将输出返回用户。

**默认 API**:`https://2037cn1.9235.net`。英文用户可用 `--lang en`(默认 https://2037en1.9235.net)。可被 config.json、`2037.apiBase`、`EARTH2037_API_BASE` 覆盖。

**注册(两问一执行)**:不要默认种族。先确认用户名、密码 → **再问用户选一个种族**(人类联盟 / 旭日帝国 / 鹰之神界,或 1 / 2 / 3)→ 再执行下方 `register` 命令(把种族放在最后)。不要在未问种族时直接注册。

```
2037 给我 apikey  →  python3 skills/earth2037-game/2037.py key
2037 注册(已选族) →  python3 skills/earth2037-game/2037.py register <用户名> <密码> <1|2|3|种族名>
2037 登录 X Y     →  python3 skills/earth2037-game/2037.py login X Y
2037 用 key 注册  →  python3 skills/earth2037-game/2037.py apply X Y <key> [1|2|3|种族名]
2037 换新 key    →  python3 skills/earth2037-game/2037.py newkey
2037 找回 key(有账号密码、无 SK-key)→  python3 skills/earth2037-game/2037.py recover <用户名> <密码>
2037 同步缓存     →  python3 skills/earth2037-game/2037.py sync
2037 全量会话缓存  →  python3 skills/earth2037-game/2037.py bootstrap
```
种族:**1=人类联盟**、**2=旭日帝国**、**3=鹰之神界**(亦可用中文全名)。用户在终端自己跑 `register 用户 密码` 且不带种族时,脚本会交互询问;OpenClaw 无终端交互,**必须先问族别再带参执行**。

`bootstrap` 调用 `POST /game/bootstrap`:服务端按 TCP 登录后顺序合并 userinfo、citylist、建筑/队列/任务等为一 JSON,写入 `session_cache.json`(并尽量更新 `userinfo.json` / `citys.json`)。Skill 不宜多轮 TCP;用这一条代替「登录后连发多条命令」。

**禁止**:不要搜索注册页面、不要打开 APK、不要查找网页。本 skill 仅通过脚本调用 API。

### 本地缓存

- `2037.py sync`:仅 USERINFO + CITYLIST → `userinfo.json`、`citys.json`,需 token。
- `2037.py bootstrap`:全量合并 JSON → `session_cache.json`(同上),后续脚本可只读本地。

### 查资料:优先读本地缓存(不要每条都调 API)

用户问「我的城市」「建筑」「兵种/军队」「任务」「队列」「背包」「英雄」等 **状态类** 问题时:

1. **不要**反复 `POST /game/command` 拉 USERINFO/CITYLIST/ARMIES…(除非用户明确要求 **实时** 或承认缓存过期)。
2. **先**确认已执行过 `2037.py bootstrap`(生成 `skills/earth2037-game/session_cache.json`)。
3. **用下面命令在终端打出可读块**(或 Agent 直接读 `session_cache.json` 里对应键):

```text
python3 skills/earth2037-game/2037.py show              # 全部块
python3 skills/earth2037-game/2037.py show city        # 城市
python3 skills/earth2037-game/2037.py show build       # 建筑相关
python3 skills/earth2037-game/2037.py show troops      # 驻军 + 兵种等
python3 skills/earth2037-game/2037.py show task        # 任务
python3 skills/earth2037-game/2037.py show queue       # 各类队列
python3 skills/earth2037-game/2037.py show hero | goods
```

**键与内容对应**(`session_cache.json` 顶层键,与 `POST /game/bootstrap` 一致):`userinfo` 账号;`citylist` 城市;`citybuildlist` 各城建筑;`buildlist` 建筑类型;`getuserbuildqueue` 建造队列;`getcitytroops` 城内驻军;`armies` 兵种表;`gettasklist` 任务;`combatqueue` 出征;`userheros` 英雄;`usergoodslist` 背包;等。地图线框仍用 `maps_util.py --ascii`(见 `MAP_FOR_AI.md`)。

若用户 **从未 bootstrap**,提示先 `bootstrap` 再 `show`;仅有 `sync` 时只有 `userinfo.json` / `citys.json`,信息比整包少。

### 无 Token 时

1. 执行 `2037.py key` 获取 key
2. 用户提供用户名、密码后,执行 `2037.py apply <用户名> <密码> <key> [tribe_id]`
3. 收到 token 后,提示用户填入 OpenClaw 的 2037 API Key 配置

### 安装

1. 复制本目录到 `~/.openclaw/skills/earth2037-game`
2. (可选)修改 `config.json` 的 `apiBase`,默认 `https://2037cn1.9235.net`
3. 重启 OpenClaw

---

## English

### Step 1: Execute Immediately (Do NOT search or open web pages)

When user says "2037 give me apikey", "2037 register username X password Y", etc., **first and only action**: run the corresponding command below and return output to user.

**Default API**: `https://2037cn1.9235.net`. For English users use `--lang en` (default https://2037en1.9235.net). Overridable via config.json, `2037.apiBase`, or `EARTH2037_API_BASE`.

```
2037 give me key  →  python3 skills/earth2037-game/2037.py --lang en key
2037 register X Y [tribe]  →  python3 skills/earth2037-game/2037.py --lang en register X Y [1|2|3]
2037 login X Y    →  python3 skills/earth2037-game/2037.py --lang en login X Y
2037 apply with key  →  python3 skills/earth2037-game/2037.py --lang en apply X Y <key> [1|2|3]
2037 new key      →  python3 skills/earth2037-game/2037.py --lang en newkey
2037 recover key (have account, no SK-key)  →  python3 skills/earth2037-game/2037.py --lang en recover <user> <password>
2037 sync cache   →  python3 skills/earth2037-game/2037.py --lang en sync
```
tribe_id: 1=Human Federation 2=Empire of the Rising Sun 3=Eagle's Realm. Default 1.

**Forbidden**: Do NOT search for registration pages, open APK, or browse web. This skill only calls API via script.

### Local Cache

Run `2037.py sync` to fetch userinfo and citys to `userinfo.json`, `citys.json`. Requires token.

### When No Token

1. Run `2037.py key` to get key
2. After user provides username and password, run `2037.py apply <username> <password> <key> [tribe_id]`
3. After receiving token, prompt user to fill in OpenClaw 2037 API Key config

### Installation

1. Copy this directory to `~/.openclaw/skills/earth2037-game`
2. (Optional) Edit `apiBase` in config.json, default `https://2037cn1.9235.net`
3. Restart OpenClaw

---

## Auth Flow (通用 / Common)

| Action | Endpoint | Body |
|--------|----------|------|
| 申请 key / Get key | `GET {apiBase}/auth/key?skill_id=2037` | No auth, key long-term valid |
| 注册 / Register | `POST {apiBase}/auth/register` | `{"username":"...","password":"...","tribe_id":1}` |
| 登录 / Login | `POST {apiBase}/auth/token` | `{"username":"...","password":"..."}` |
| Skill 申请 / Apply | `POST {apiBase}/auth/apply` | `{"username":"...","password":"...","action":"register\|login","key":"...","skill_id":"2037","tribe_id":1}` |
| 换新 key / New key | `POST {apiBase}/auth/newkey` | Header: `Authorization: Bearer <token>` |
| 找回 key(密码)/ Recover key | `POST {apiBase}/auth/recover-key` | `{"username","password","skill_id":"2037"}` 无需 SK-key |
| 验证 / Verify | `GET {apiBase}/auth/verify` | Header: `Authorization: Bearer <token>` |

## Game Commands

```
POST {apiBase}/game/command
Authorization: Bearer <token>
Content-Type: application/json

{"cmd": "CMD_NAME", "args": "arg1 arg2 ..."}
```
Auth: `Authorization: Bearer <token>` or body `apiKey`. Empty `args` → server fills defaults (e.g. capital tileID).

### Intent → Command Mapping

| 意图 / Intent | cmd | args |
|---------------|-----|------|
| 我的城市 / My cities | CITYLIST | (空) |
| 城市详情 / City info | GETCITYINFO | tileID,空=主城 |
| 用户信息 / User info | USERINFO | (空) |
| 资源 / Resources | GETRESOURCE | tileID,空=主城 |
| 建筑列表 / Buildings | BUILDLIST | tileID,空=主城 |
| **查建造成本** | GETBUILDCOST | 见下「建造/升级」;脚本 **`build_ops.py getbuildcost`** |
| **入队建造/升级** | ADDBUILDQUEUE | 单行 **JSON**;脚本 **`build_ops.py addbuildqueue`** / **`compose`** |
| 出兵 / Send troops | ADDCOMBATQUEUE | JSON;打野可用 **`march_ops.py attack-oasis`** |
| 征兵 / Recruit | ADDCONSCRIPTIONQUEUE | JSON |
| 联盟 / Alliance | GETALLY | allianceID |
| 消息 / Messages | GETMESSAGES | (空) |
| **世界聊天拉取** | GETWMSGS | 起始消息 **ID**(如新消息从 **`0`**)→ `/svr getwmsgs [...]` |
| **联盟聊天拉取** | GETALLYCHAT | 游标,如 **`0`** → JSON 含 `messages`、`nextCursor` |
| **发世界消息** | SENDWMSG | 单行 **Message JSON**(脚本见 **`chat_ops.py send-world`**) |
| **发联盟消息** | SENDALLYMSG | 单行 JSON,需 `allianceID`(脚本 **`chat_ops.py send-ally`**) |
| 战报 / Reports | GETREPORTS | (空) |
| 地图查图 / Map query | QM | `1 x,y,w,h`;**空 args** = **当前城市** 周围 **7×7**(无当前城则用主城) |
| 地块详情 / Tile info | TILEINFO | **玩家城/可建城格**(FieldType **1~7** 等),tileID;空=主城 |
| 绿洲野怪 / Oasis NPC | GETNPCCITY | **FieldType=0** 时查看该格,`args`=`tileID` |
| 英雄 / Heroes | USERHEROS | (空) |
| 任务 / Tasks | GETTASKLIST | (空) |
| 服务器时间 / Server time | SERVERTIME | (空) |
| **周期排行榜** / Time-window ranks | GETTOPBYTIME | 见下节「排行榜」 |
| **总防 / 总攻 / 总发展 / 联盟总榜** | GETDEFENDRANK / GETATTACKRANK / GETUSERRANK / GETALLYRANK | 见下节 |
| **每日之星 / 周榜 / 名人堂** | HALLOFFAME | 见下节 |

### 建造 / 升级(与游戏 TCP 一致:只有两条命令)

游戏内升级**没有**单独的「升级」指令名;标准流程是:

1. **`GETBUILDCOST`** — 查消耗与时间。  
   - **多等级**:`args` = **`buildID:等级1,等级2,...`**,例 **`8:3,2`** 表示建筑 8 在等级 3 与 2 的造价列表。  
   - **单等级**:`args` 也可为 **`buildID 等级`**(空格),例 **`8 3`**。
2. **`ADDBUILDQUEUE`** — 入队;`args` = **单行 JSON**(与 **`/addbuildqueue {...}`** 相同),含 `buildAction`(多为 **1**)、