{
  "id": "001_yellow_turbans",
  "name": "Yingchuan Skirmish",
  "objectives": {
    "victory": "Defeat all Yellow Turban units.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 8."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 8, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Yingchuan Skirmish",
    "location": "Yingchuan, 184 CE",
    "lines": [
      "Yellow Turban rebels have gathered near Yingchuan.",
      "Cao Cao and Xiahou Dun must break their formation before the revolt spreads."
    ],
    "camp_dialogue": [
      { "speaker": "Cao Cao", "side": "left", "text": "Yingchuan is a spark in dry grass. If we move decisively, the court may still believe order can return." },
      { "speaker": "Xiahou Dun", "side": "right", "text": "The men are ready. Give me the front, and I will keep the rebels fixed while you cut their nerve." }
    ],
    "camp_conversations": [
      {
        "id": "cao_cao_strategy",
        "group": "officer",
        "officer_id": "cao_cao",
        "label": "Cao Cao - Strategy",
        "speaker": "Cao Cao",
        "summary": "Read the revolt before the first move.",
        "lines": [
          { "speaker": "Cao Cao", "side": "left", "text": "Yingchuan is a spark in dry grass. If we move decisively, the court may still believe order can return." },
          { "speaker": "Cao Cao", "side": "left", "text": "Their center is loose. Break the front, then deny them time to gather more banners." }
        ]
      },
      {
        "id": "xiahou_dun_vanguard",
        "group": "officer",
        "officer_id": "xiahou_dun",
        "label": "Xiahou Dun - Vanguard",
        "speaker": "Xiahou Dun",
        "summary": "Discuss the first clash.",
        "lines": [
          { "speaker": "Xiahou Dun", "side": "right", "text": "The men are ready. Give me the front, and I will keep the rebels fixed while you cut their nerve." },
          { "speaker": "Cao Cao", "side": "left", "text": "Hold them in place, but do not chase too deep. We still need eyes on the woods." }
        ]
      },
      {
        "id": "northern_woods_cache",
        "group": "topic",
        "label": "Northern Woods Cache",
        "summary": "Follow up on the merchant's rumor.",
        "lines": [
          { "speaker": "Cao Cao", "side": "left", "text": "The merchant's rumor may be useful. If the line holds, send a scout through the northern woods." },
          { "speaker": "Xiahou Dun", "side": "right", "text": "A hidden cache in rebel country? Then we take it before they remember where they left it." }
        ],
        "effects": [
          { "type": "grant_item", "item_id": "bean", "count": 1, "text": "The scout detail adds a Bean to the field supplies." }
        ]
      }
    ]
  },
  "shop": {
    "merchant": {
      "name": "Camp Merchant",
      "lines": [
        "Roadside stores are thin, my lord, but I saved beans and antidotes for your column.",
        "The northern woods have rumors of a hidden cache, if your scouts can reach it."
      ]
    },
    "items": ["bean", "antidote"]
  },
  "roster": {
    "max_units": 2,
    "required_officers": ["cao_cao", "xiahou_dun"]
  },
  "formation": {
    "cells": [[1, 3], [1, 4], [2, 3], [2, 4]]
  },
  "map": {
    "width": 10,
    "height": 8,
    "background": "res://art/backgrounds/battlefield_frontier.png",
    "terrain": [
      "GGGGGGGGCC",
      "GGGFFFFGCC",
      "GGGFFFGGGG",
      "GGGRRGGGGG",
      "GGGRRGGHHG",
      "GGGGGGGHHG",
      "GGGWWGGGGG",
      "GGGWWGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 3]
    },
    {
      "unit_id": "xiahou_dun",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "yellow_turban_1",
      "name": "Zhang Mancheng",
      "class_id": "bandit",
      "team": "enemy",
      "level": 1,
      "pos": [7, 2],
      "base": { "hp": 34, "atk": 11, "def": 5 }
    },
    {
      "unit_id": "yellow_turban_2",
      "name": "Peasant Rebel",
      "class_id": "infantry",
      "team": "enemy",
      "level": 1,
      "pos": [8, 5],
      "base": { "hp": 30, "atk": 10, "def": 5 }
    },
    {
      "unit_id": "yellow_turban_3",
      "name": "Rebel Archer",
      "class_id": "archer",
      "team": "enemy",
      "level": 1,
      "pos": [7, 6],
      "base": { "hp": 26, "atk": 9, "def": 4 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao engages the Yellow Turbans." },
        { "type": "log", "text": "A small supply cache is hidden in the northern woods." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "side": "left", "text": "The rebels are scattered, but their numbers will swell if we hesitate." },
            { "speaker": "Xiahou Dun", "side": "right", "text": "Then we strike now. I will open a path through their front line." }
          ]
        }
      ]
    },
    {
      "id": "northern_woods_cache",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "pos": [3, 2] },
      "actions": [
        { "type": "log", "text": "The northern woods cache is recovered." },
        { "type": "grant_item", "item_id": "bean" }
      ]
    },
    {
      "id": "turn_2_warning",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2 },
      "actions": [
        { "type": "log", "text": "The Yellow Turbans are looking for an opening." }
      ]
    }
  ],
  "rewards": {
    "gold": 300,
    "items": ["bean"],
    "join_officers": ["xiahou_yuan", "cao_ren"]
  },
  "post_battle_dialogue": [
    { "speaker": "Xiahou Dun", "side": "right", "text": "The rebels are scattered. Yingchuan should breathe easier tonight." },
    { "speaker": "Cao Cao", "side": "left", "text": "This is only the first fire. If the court cannot move quickly, we must." },
    { "speaker": "Xiahou Yuan", "side": "right", "text": "Then call on us for the next campaign. We will ride with you." },
    { "speaker": "Cao Ren", "side": "right", "text": "The clan stands ready, my lord." }
  ]
}
