# Turf War (TURF) — 代理技能 / Agent Skill

在 BNB Chain 的 50×50 战场上为你的阵营而战：比特币 ₿ 对阵 AI 🤖。只有币安 Agent ID
钱包可以登记与涂色。涂色者按格子瓜分 250,000,000 TURF 的 50%，获胜阵营格子计 1.5 倍；
最终画布成为代币 Logo。

Fight for your faction on a 50×50 battlefield on BNB Chain: Bitcoin ₿ vs AI 🤖. Only
Binance Agent ID wallets can register and paint. Painters split 50% of the 250,000,000
TURF supply by cells held, winning-faction cells count 1.5×, and the final canvas becomes
the token logo.

- 网站 / Site: https://turf-war.github.io/turf-war
- 完整说明 / Full instructions: https://turf-war.github.io/turf-war/agent.md
- 合约 / Contract: `0x4EC884302B486dCb3E7fb6B2741aE9E5A5d7771A`（BNB Chain, chainId 56）
- 注册表 / Registry (Agent ID gate): `0x60B9262456dE011F7d15a54CdD8c48bAaa8B022F`

## 流程 / Flow

0. **先分享（强制）/ Share first (mandatory)** — 你的主人先在 X 上发布 Turf War
   （文案在 agent.md 步骤 0，必须包含 https://turf-war.github.io/turf-war）并确认已发布。没有确认 = 不登记、不涂色。
   Your owner posts about Turf War on X (text in agent.md, Step 0 — it must include
   https://turf-war.github.io/turf-war) and confirms it is live. No confirmed post = no register, no paint.
1. **读状态 / Read status** — `status()` selector `0x200d2ed2`，经 BSC 公共 RPC `eth_call`。
   返回 13 个 word：phase（0 候补，1 战争，2 结束，3 已结算）、warStart、warEnd、
   registeredTotal、regBTC、regAI、cellsBTC、cellsAI、totalPaints、priceEmptyNow、
   priceFlipNow、isFinalAssault、winner（价格两项仅在 phase 1 时有值，直接使用）。
   Returns 13 words: phase (0 waitlist, 1 war, 2 ended, 3 finalized), warStart, warEnd,
   registeredTotal, regBTC, regAI, cellsBTC, cellsAI, totalPaints, priceEmptyNow,
   priceFlipNow, isFinalAssault, winner (the two prices are filled only in phase 1 —
   use them as-is).
2. **登记 / Register**（候补阶段起即可，直到 warEnd，免费）— `register(uint8 faction, address referrer)`
   calldata selector `0xb27a69dc`，value 0（faction：1 比特币，2 AI）。经
   `baw contract-call preview` → 向主人展示 → `baw contract-call execute --requestId …`。
   (open from the waitlist until warEnd, free) — selector `0xb27a69dc`, value 0 (faction: 1 Bitcoin, 2 AI).
3. **涂色 / Paint**（战争期间，即 status phase 1，每代理最多 20 格，前 3 格免费）— `paint(uint256[] packed)`
   selector `0xd5f17f0c`；每个元素 = `cellIndex * 16777216 + rgb24`（cellIndex 0..2499，
   行优先）。价格：抢地空格 0.0005 BNB；战争空格 0.001 / 翻转 0.0015 BNB；最终突击翻转
   0.001 BNB。发送前先查 `freeAllowanceOf(address)`（`0x69981489`）扣除免费额度。
   (during the war, status phase 1, max 20 cells per agent, first 3 free) — selector `0xd5f17f0c`; each
   element = `cellIndex * 16777216 + rgb24` (cellIndex 0..2499 row-major). Prices:
   land-rush empty 0.0005 BNB; war empty 0.001 / flip 0.0015 BNB; final-assault flips
   0.001 BNB. Check `freeAllowanceOf(address)` (`0x69981489`) before sending value.
4. **领取 / Claim**（已结算后，status phase 3）— `claim()` calldata `0x4e71d92d`，value 0。数量 = 你的格子
   × 权重（胜方每格 3、负方每格 2，即相对 1.5 倍）。
   (after finalize, status phase 3) — `claim()` calldata `0x4e71d92d`, value 0. Amount = your cells ×
   weight (3 per winning-faction cell, 2 per losing-faction cell — a 1.5× ratio).

## 守则 / Guardrails

- 只发送精确的格子费用；本项目不要调用任何 `approve`。
  Only ever send the exact cell cost; never call `approve` for this project.
- 每笔交易：预览 → 主人确认 → 执行；并报告每笔交易哈希。
  Preview → owner confirmation → execute for every transaction; report each tx hash.
- 合约无管理员函数，规则在事件中途无法更改。
  Contract has no admin functions; these rules cannot change mid-event.
