{
  "id": "002_sishui_gate",
  "name": "Sishui Gate Vanguard",
  "objectives": {
    "victory": "Defeat Hua Xiong's vanguard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 9."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "turn_2_warning" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 9, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Sishui Gate Vanguard",
    "location": "Sishui Gate, 190 CE",
    "lines": [
      "The coalition gathers to challenge Dong Zhuo.",
      "Cao Cao leads a small vanguard to test Hua Xiong's defenses."
    ]
  },
  "shop": {
    "items": [
      "bean",
      "antidote",
      "cloth_robe",
      "leather_armor",
      "short_bow",
      "training_spear"
    ],
    "stock": {
      "cloth_robe": 1,
      "leather_armor": 1,
      "short_bow": 1,
      "training_spear": 1
    }
  },
  "roster": {
    "max_units": 3,
    "required_officers": ["cao_cao"]
  },
  "formation": {
    "cells": [[1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5]]
  },
  "map": {
    "width": 12,
    "height": 9,
    "terrain": [
      "GGGGGRRGGGGG",
      "GGGFFRRGHHGG",
      "GGGFFRRGHHGG",
      "GGGGGRRGGGGG",
      "RRRRRRRRRRRR",
      "GGGGGRRGGGGG",
      "GGHGGFFGGGGG",
      "GGHGGFFGGWWG",
      "GGGGGGGGGWWG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch2",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "xiahou_dun_ch2",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch2",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "cao_ren_ch2",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "hua_xiong_vanguard",
      "name": "Hua Xiong Vanguard",
      "class_id": "cavalry",
      "team": "enemy",
      "level": 2,
      "pos": [9, 4],
      "base": { "hp": 44, "atk": 15, "def": 7 }
    },
    {
      "unit_id": "liang_spearman_1",
      "name": "Liang Spearman",
      "class_id": "infantry",
      "team": "enemy",
      "level": 2,
      "pos": [8, 3],
      "base": { "hp": 34, "atk": 12, "def": 6 }
    },
    {
      "unit_id": "liang_spearman_2",
      "name": "Liang Spearman",
      "class_id": "infantry",
      "team": "enemy",
      "level": 2,
      "pos": [8, 5],
      "base": { "hp": 34, "atk": 12, "def": 6 }
    },
    {
      "unit_id": "liang_archer",
      "name": "Liang Archer",
      "class_id": "archer",
      "team": "enemy",
      "level": 2,
      "pos": [10, 2],
      "base": { "hp": 28, "atk": 10, "def": 4 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "The coalition vanguard moves toward Sishui Gate." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "Hua Xiong's vanguard is testing the coalition's nerve. We cannot give them ground." },
            { "speaker": "Xiahou Yuan", "text": "Their archers hold the ridge. I will keep pressure on their flank." }
          ]
        }
      ]
    },
    {
      "id": "turn_2_warning",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2 },
      "actions": [
        { "type": "log", "text": "Hua Xiong's men tighten their formation." },
        {
          "type": "set_objective",
          "victory": "Defeat Hua Xiong's vanguard and reinforcements.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 9."
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "liang_reinforcement_1",
              "name": "Liang Rider",
              "class_id": "cavalry",
              "team": "enemy",
              "level": 2,
              "pos": [11, 3],
              "base": { "hp": 36, "atk": 12, "def": 6 }
            },
            {
              "unit_id": "liang_reinforcement_2",
              "name": "Liang Guard",
              "class_id": "infantry",
              "team": "enemy",
              "level": 2,
              "pos": [11, 5],
              "base": { "hp": 34, "atk": 11, "def": 7 }
            }
          ]
        }
      ]
    }
  ],
  "post_battle_choices": [
    {
      "id": "pursue_dong_zhuo",
      "label": "Pursue Dong Zhuo",
      "description": "Cao Cao presses the retreating army while Cao Ren secures Sishui.",
      "leave_officers": ["cao_ren"],
      "set_flags": { "pursued_dong_zhuo": true, "regrouped_after_sishui": false }
    },
    {
      "id": "regroup_coalition",
      "label": "Regroup",
      "description": "The vanguard pauses to gather supplies.",
      "set_flags": { "pursued_dong_zhuo": false, "regrouped_after_sishui": true }
    }
  ],
  "rewards": {
    "gold": 500,
    "items": ["bean"]
  },
  "post_battle_dialogue": [
    { "speaker": "Xiahou Yuan", "text": "Sishui Gate is broken, but Dong Zhuo's main force is already moving west." },
    { "speaker": "Cao Cao", "text": "The coalition will argue while the enemy escapes. We must decide whether to pursue or regroup." }
  ]
}
