{
  "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."
    ],
    "camp_conversations": [
      {
        "id": "sishui_coalition_reading",
        "group": "officer",
        "officer_id": "cao_cao",
        "label": "Cao Cao - Coalition Nerve",
        "speaker": "Cao Cao",
        "summary": "Measure the coalition before challenging Hua Xiong.",
        "lines": [
          { "speaker": "Cao Cao", "side": "left", "text": "The coalition has banners enough to shade the pass, yet every lord waits for another to move first." },
          { "speaker": "Xiahou Dun", "side": "right", "text": "Then let them watch us move. Hua Xiong will learn which banner has teeth." }
        ]
      },
      {
        "id": "sishui_xiahou_yuan_ridge",
        "group": "officer",
        "officer_id": "xiahou_yuan",
        "label": "Xiahou Yuan - Ridge Line",
        "speaker": "Xiahou Yuan",
        "summary": "Discuss the archers watching the road.",
        "lines": [
          { "speaker": "Xiahou Yuan", "side": "right", "text": "Their archers favor the ridge above the road. If we let them settle, the vanguard will bleed before touching Hua Xiong." },
          { "speaker": "Cao Cao", "side": "left", "text": "Keep their eyes busy. A single opened flank will make the pass feel wider than it is." }
        ]
      },
      {
        "id": "sishui_quartermaster_antidote",
        "group": "topic",
        "label": "Quartermaster's Bundle",
        "summary": "Check the last useful supplies before the gate.",
        "lines": [
          { "speaker": "Coalition Quartermaster", "side": "left", "text": "My lord, the western stores are crowded with borrowed seals and empty promises. I found one antidote bundle that is actually useful." },
          { "speaker": "Cao Ren", "side": "right", "text": "Take it. A single clean cure can keep a line from folding." }
        ],
        "effects": [
          { "type": "grant_item", "item_id": "antidote", "count": 1, "text": "The quartermaster adds an Antidote to the field supplies." }
        ]
      }
    ]
  },
  "shop": {
    "merchant": {
      "name": "Coalition Merchant",
      "lines": [
        "Every lord at Sishui wants credit, but only the first vanguard buys enough bandages.",
        "I have robes, armor, bows, and spears. If Hua Xiong breaks through, nobody will ask where they came from."
      ]
    },
    "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,
    "background": "res://art/backgrounds/sishui_gate_pass.png",
    "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." }
  ]
}
