{
  "id": "010_white_horse_relief",
  "name": "White Horse Relief",
  "objectives": {
    "victory": "Defeat Yan Liang's vanguard after the decoy line is sprung.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "turn_3_decoy_line" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 12, "team": "player" }
    ]
  },
  "briefing": {
    "title": "White Horse Relief",
    "location": "White Horse, 200 CE",
    "lines": [
      "Yuan Shao's forward army presses toward White Horse with Yan Liang at its point.",
      "Guo Jia proposes a decoy line: draw the vanguard down the road, then strike once its wings stretch too far."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "integrated_xu_province": true },
        "lines": [
          "Officials left in Xu Province keep the rear quiet, letting Cao Cao commit steadier reserves to the northern front."
        ]
      },
      {
        "campaign_flags": { "pressed_northern_campaign": true },
        "lines": [
          "The army marches quickly from Xiapi, hoping speed can strike Yuan Shao's vanguard before it settles."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "panacea",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "integrated_xu_province": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "pressed_northern_campaign": true },
        "items": ["war_drum"]
      }
    ]
  },
  "roster": {
    "max_units": 6,
    "required_officers": ["cao_cao", "guo_jia"]
  },
  "formation": {
    "cells": [[1, 3], [1, 4], [1, 5], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 3], [3, 4]]
  },
  "map": {
    "width": 15,
    "height": 10,
    "terrain": [
      "GGGGGGHHGGGGGGG",
      "GGFFGGHHGGGFFGG",
      "GGFFRRRRRRGFFGG",
      "GGGGGRGGGRGGGGG",
      "RRRRRRRRRRRRRRR",
      "GGGGGRGGGRGGGGG",
      "GGHHGRRRGGFFFGG",
      "GGHHGFFFGGFFFGG",
      "GGGGGFFFGGWWGGG",
      "GGGGGGGGGGWWGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch10",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch10",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "xiahou_dun_ch10",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch10",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch10",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "cao_ren_ch10",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "yan_liang_vanguard",
      "name": "Yan Liang Vanguard",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 10,
      "pos": [11, 4],
      "base": { "hp": 62, "atk": 20, "def": 11, "agi": 13 }
    },
    {
      "unit_id": "yuan_shao_spear_line",
      "name": "Yuan Spear Line",
      "class_id": "infantry",
      "team": "enemy",
      "level": 9,
      "pos": [9, 4],
      "base": { "hp": 50, "atk": 16, "def": 10 }
    },
    {
      "unit_id": "yuan_shao_guard",
      "name": "Yuan Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 9,
      "pos": [10, 5],
      "base": { "hp": 48, "atk": 15, "def": 11 }
    },
    {
      "unit_id": "white_horse_archer_north",
      "name": "White Horse Archer",
      "class_id": "archer",
      "team": "enemy",
      "level": 9,
      "pos": [10, 2],
      "base": { "hp": 34, "atk": 14, "def": 6 }
    },
    {
      "unit_id": "white_horse_archer_south",
      "name": "White Horse Archer",
      "class_id": "archer",
      "team": "enemy",
      "level": 9,
      "pos": [12, 6],
      "base": { "hp": 34, "atk": 14, "def": 6 }
    },
    {
      "unit_id": "yuan_shao_advisor",
      "name": "Yuan Advisor",
      "class_id": "strategist",
      "team": "enemy",
      "level": 9,
      "pos": [12, 5],
      "skills": ["blaze"],
      "base": { "hp": 38, "mp": 22, "atk": 6, "def": 6, "int": 14 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Yuan Shao's vanguard advances toward White Horse." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Yan Liang is brave enough to follow a retreating banner. That is the door we open." },
            { "speaker": "Cao Cao", "text": "Then the center yields just enough. When his wings stretch, we cut them." },
            { "speaker": "Xiahou Dun", "text": "A false retreat still needs men willing to look beaten." }
          ]
        }
      ]
    },
    {
      "id": "turn_2_yan_liang_push",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yan Liang", "text": "Cao Cao's line bends already. Drive straight down the road!" },
            { "speaker": "Guo Jia", "text": "He takes the bait. Hold until the second signal." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "yan_liang_rider_north",
              "name": "Yan Liang Rider",
              "class_id": "cavalry",
              "team": "enemy",
              "level": 9,
              "pos": [8, 2],
              "base": { "hp": 42, "atk": 15, "def": 8, "agi": 11 }
            },
            {
              "unit_id": "yan_liang_rider_south",
              "name": "Yan Liang Rider",
              "class_id": "cavalry",
              "team": "enemy",
              "level": 9,
              "pos": [8, 6],
              "base": { "hp": 42, "atk": 15, "def": 8, "agi": 11 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_3_decoy_line",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 3 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "Signal the counterstroke. Yan Liang has outrun his supports." },
            { "speaker": "Guo Jia", "text": "The vanguard is isolated. Strike the horse first, then the spears." }
          ]
        },
        {
          "type": "set_objective",
          "victory": "Defeat Yan Liang and every isolated vanguard unit.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "decoy_cutoff_guard",
              "name": "Cutoff Guard",
              "class_id": "infantry",
              "team": "enemy",
              "level": 9,
              "pos": [7, 4],
              "base": { "hp": 44, "atk": 15, "def": 9 }
            },
            {
              "unit_id": "decoy_cutoff_archer",
              "name": "Cutoff Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 9,
              "pos": [7, 5],
              "base": { "hp": 32, "atk": 13, "def": 5 }
            }
          ]
        }
      ]
    },
    {
      "id": "xu_province_reserve",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 4, "campaign_flags": { "integrated_xu_province": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "Xu Province's roads are quiet. The reserve wagons have arrived on time." },
            { "speaker": "Cao Cao", "text": "Order and grain win battles before blades touch." }
          ]
        }
      ]
    },
    {
      "id": "northern_pressure",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4, "campaign_flags": { "pressed_northern_campaign": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yuan Scout", "text": "Cao Cao came quickly. Send the rear riders before his men settle!" },
            { "speaker": "Xiahou Yuan", "text": "More riders from the east. They are trying to punish our speed." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "yuan_rear_rider",
            "name": "Yuan Rear Rider",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 9,
            "pos": [5, 8],
            "base": { "hp": 40, "atk": 15, "def": 8, "agi": 11 }
          }
        }
      ]
    },
    {
      "id": "turn_6_finish_vanguard",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 6 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Yan Liang's formation is no longer an army. It is a collection of frightened men." },
            { "speaker": "Cao Cao", "text": "Then finish this cleanly. White Horse must not remain under threat." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 1500,
    "items": ["bean", "wine", "iron_armor"]
  },
  "post_battle_dialogue": [
    { "speaker": "Xiahou Dun", "text": "Yan Liang's charge broke exactly where Guo Jia said it would." },
    { "speaker": "Guo Jia", "text": "Bravery is useful. Predictable bravery is a road sign." },
    { "speaker": "Cao Cao", "text": "White Horse is relieved. Now Yuan Shao must answer us with more than numbers." }
  ],
  "post_battle_choices": [
    {
      "id": "fortify_white_horse",
      "label": "Fortify White Horse",
      "description": "Cao Cao strengthens the crossing before the main Guandu confrontation.",
      "set_flags": { "fortified_white_horse": true, "raided_yuan_supplies": false },
      "gold": 150,
      "items": ["iron_armor"]
    },
    {
      "id": "raid_yuan_supplies",
      "label": "Raid Supplies",
      "description": "The army uses the vanguard's collapse to harass Yuan Shao's supply train.",
      "set_flags": { "fortified_white_horse": false, "raided_yuan_supplies": true },
      "gold": 100,
      "items": ["wine", "training_spear"]
    }
  ]
}
