LeoYeAI/agent-master-skills / skills/2037
earth2037-game
VerifiedOpenClaw-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.
| File | Kind | Size |
|---|---|---|
| 2037.py | script | 13.7 KB |
| MAP_FOR_AI.md | markdown | 3.7 KB |
| SKILL.md | skill md | 20.3 KB |
| _meta.json | config | 442 B |
| build_ops.py | script | 5.5 KB |
| cache.py | script | 13.2 KB |
| chat_ops.py | script | 4.5 KB |
| config.json | config | 145 B |
| maps_util.py | script | 4.8 KB |
| march_ops.py | script | 3.4 KB |
chat_ops.py
View on GitHub#!/usr/bin/env python3
"""
世界频道 / 联盟频道 — GETWMSGS、GETALLYCHAT、SENDWMSG、SENDALLYMSG。
发送消息时从 userinfo.json(需先 sync/bootstrap)读取 userID、username、allianceID;可用参数覆盖。
"""
from __future__ import annotations
import argparse
import json
import os
import sys
import time
def _import_game():
base = os.path.dirname(os.path.abspath(__file__))
if base not in sys.path:
sys.path.insert(0, base)
from cache import _game_command, _get_token, _load_config
return _game_command, _get_token, _load_config
def _net_date_ms_now(offset: str = "+0800") -> str:
ms = int(time.time() * 1000)
return f"/Date({ms}{offset})/"
def _load_userinfo(skill_dir: dict) -> dict:
path = os.path.join(skill_dir, "userinfo.json")
if not os.path.isfile(path):
return {}
try:
with open(path, "r", encoding="utf-8") as f:
return json.load(f)
except (json.JSONDecodeError, IOError):
return {}
def main():
gc, get_token, load_cfg = _import_game()
skill_dir = os.path.dirname(os.path.abspath(__file__))
ap = argparse.ArgumentParser(description="Earth2037 聊天(HTTP game/command)")
ap.add_argument("--api-base", dest="api_base", default=os.environ.get("EARTH2037_API_BASE", "").strip() or None)
sub = ap.add_subparsers(dest="cmd", required=True)
p1 = sub.add_parser("world-msgs", help="世界聊天拉取 /getwmsgs;参数为起始消息 ID(新消息从 0 拉)")
p1.add_argument("from_id", nargs="?", type=int, default=0)
p2 = sub.add_parser("ally-chat", help="联盟聊天;参数为游标(示例 0)")
p2.add_argument("cursor", nargs="?", type=int, default=0)
p3 = sub.add_parser("send-world", help="发世界消息(type=2)")
p3.add_argument("text")
p3.add_argument("--user-id", type=int, default=0)
p3.add_argument("--username", default="")
p3.add_argument("--layout-id", type=int, default=2131558440)
p4 = sub.add_parser("send-ally", help="发联盟消息(type=1)")
p4.add_argument("text")
p4.add_argument("--alliance-id", type=int, default=0)
p4.add_argument("--user-id", type=int, default=0)
p4.add_argument("--username", default="")
p4.add_argument("--layout-id", type=int, default=2131558439)
args = ap.parse_args()
api = (args.api_base or load_cfg()).rstrip("/")
token = get_token()
if not token:
print("❌ 需要 EARTH2037_TOKEN 或 config.json token", file=sys.stderr)
sys.exit(1)
ui = _load_userinfo(skill_dir)
uid = ui.get("UserID") or ui.get("userID") or 0
uname = (ui.get("Username") or ui.get("username") or "").strip()
ally = ui.get("AllianceID") or ui.get("allyID") or ui.get("AllianceId") or 0
try:
if args.cmd == "world-msgs":
out = gc(api, token, "GETWMSGS", str(args.from_id))
elif args.cmd == "ally-chat":
out = gc(api, token, "GETALLYCHAT", str(args.cursor))
elif args.cmd == "send-world":
u = args.user_id or int(uid) if uid else 0
n = args.username or uname
msg = {
"content": args.text,
"contentFormat": 0,
"contentMetadata": None,
"id": 0,
"layoutID": args.layout_id,
"payloads": [],
"received": _net_date_ms_now(),
"type": 2,
"userID": u,
"username": n,
}
out = gc(api, token, "SENDWMSG", json.dumps(msg, ensure_ascii=False, separators=(",", ":")))
else:
aid = args.alliance_id or int(ally) if ally else 0
if aid <= 0:
print("❌ 缺少联盟 ID:先 sync 写入 userinfo.json,或传 --alliance-id", file=sys.stderr)
sys.exit(1)
u = args.user_id or int(uid) if uid else 0
n = args.username or uname
msg = {
"allianceID": aid,
"content": args.text,
"contentFormat": 0,
"contentMetadata": None,
"id": 0,
"layoutID": args.layout_id,
"payloads": [],
"received": _net_date_ms_now(),
"type": 1,
"userID": u,
"username": n,
}
out = gc(api, token, "SENDALLYMSG", json.dumps(msg, ensure_ascii=False, separators=(",", ":")))
except Exception as e:
print(f"❌ {e}", file=sys.stderr)
sys.exit(1)
print(out)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |