{
  "id": "011_yan_ford_pursuit",
  "name": "Yan Ford Pursuit",
  "objectives": {
    "victory": "Defeat Wen Chou's countercharge after his riders commit.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "turn_2_wen_chou_charge" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 12, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Yan Ford Pursuit",
    "location": "Yan Ford, 200 CE",
    "lines": [
      "Yan Liang's defeat shakes Yuan Shao's forward army, but Wen Chou rides to restore its nerve.",
      "Cao Cao moves toward Yan Ford, where the road narrows between wooded banks and the river crossing."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "fortified_white_horse": true },
        "lines": [
          "The reinforced White Horse crossing slows Yuan Shao's messengers, buying time to arrange a tighter pursuit line."
        ]
      },
      {
        "campaign_flags": { "raided_yuan_supplies": true },
        "lines": [
          "Raids against Yuan Shao's baggage train leave Wen Chou's riders angry and hungry, but still eager to strike."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "fortified_white_horse": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "raided_yuan_supplies": true },
        "items": ["war_axe"]
      }
    ]
  },
  "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": 16,
    "height": 10,
    "terrain": [
      "GGGGHHGGGGGGGGGG",
      "GGFFHHGGGFFGGGGG",
      "GGRRRRRRRGGGHHGG",
      "GGGGGGRGGGRRGGGG",
      "RRRRRRRRRRRRRRRR",
      "GGGGGGRGGGRRGGGG",
      "GGHHGFFFGGWWGGGG",
      "GGHHGFFFGGWWGGGG",
      "GGGGGGFFGGWWGGGG",
      "GGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch11",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch11",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "xiahou_dun_ch11",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch11",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch11",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "cao_ren_ch11",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "wen_chou_vanguard",
      "name": "Wen Chou Vanguard",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 11,
      "pos": [12, 4],
      "base": { "hp": 66, "atk": 21, "def": 12, "agi": 14 }
    },
    {
      "unit_id": "yan_ford_bridge_guard",
      "name": "Yan Ford Guard",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 10,
      "pos": [10, 4],
      "base": { "hp": 54, "atk": 17, "def": 13 }
    },
    {
      "unit_id": "yuan_spear_north",
      "name": "Yuan Spearman",
      "class_id": "infantry",
      "team": "enemy",
      "level": 10,
      "pos": [10, 3],
      "base": { "hp": 48, "atk": 16, "def": 10 }
    },
    {
      "unit_id": "yuan_spear_south",
      "name": "Yuan Spearman",
      "class_id": "infantry",
      "team": "enemy",
      "level": 10,
      "pos": [10, 5],
      "base": { "hp": 48, "atk": 16, "def": 10 }
    },
    {
      "unit_id": "yan_ford_archer_north",
      "name": "Yan Ford Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 10,
      "pos": [12, 2],
      "base": { "hp": 38, "atk": 15, "def": 7, "agi": 13 }
    },
    {
      "unit_id": "yan_ford_archer_south",
      "name": "Yan Ford Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 10,
      "pos": [12, 6],
      "base": { "hp": 38, "atk": 15, "def": 7, "agi": 13 }
    },
    {
      "unit_id": "yuan_field_advisor",
      "name": "Yuan Field Advisor",
      "class_id": "strategist",
      "team": "enemy",
      "level": 10,
      "pos": [13, 5],
      "skills": ["blaze", "mend"],
      "base": { "hp": 40, "mp": 24, "atk": 6, "def": 6, "int": 15 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Wen Chou's riders gather near Yan Ford." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Wen Chou will not accept Yan Liang's defeat as a warning. He will treat it as an insult." },
            { "speaker": "Cao Cao", "text": "Then leave him a road wide enough to charge and narrow enough to close." },
            { "speaker": "Xiahou Yuan", "text": "The ford bends the field for us. I will watch the wooded banks." }
          ]
        }
      ]
    },
    {
      "id": "turn_2_wen_chou_charge",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Wen Chou", "text": "Yan Liang fell because he was alone. I bring enough horsemen to trample Cao Cao's tricks." },
            { "speaker": "Guo Jia", "text": "Good. Pride has supplied the second wing for us." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "wen_chou_rider_north",
              "name": "Wen Chou Rider",
              "class_id": "cavalry",
              "team": "enemy",
              "level": 10,
              "pos": [14, 3],
              "base": { "hp": 44, "atk": 16, "def": 9, "agi": 12 }
            },
            {
              "unit_id": "wen_chou_rider_south",
              "name": "Wen Chou Rider",
              "class_id": "cavalry",
              "team": "enemy",
              "level": 10,
              "pos": [14, 5],
              "base": { "hp": 44, "atk": 16, "def": 9, "agi": 12 }
            }
          ]
        }
      ]
    },
    {
      "id": "ford_ambush",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [9, 4] },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yuan Guard", "text": "Cao Cao has reached the ford. Close the bank behind him!" },
            { "speaker": "Dian Wei", "text": "They picked the wrong bank to close." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "ford_bank_guard",
              "name": "Ford Bank Guard",
              "class_id": "infantry",
              "team": "enemy",
              "level": 10,
              "pos": [8, 3],
              "base": { "hp": 46, "atk": 16, "def": 10 }
            },
            {
              "unit_id": "ford_bank_archer",
              "name": "Ford Bank Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 10,
              "pos": [8, 5],
              "base": { "hp": 34, "atk": 14, "def": 6, "agi": 12 }
            }
          ]
        }
      ]
    },
    {
      "id": "white_horse_fortified",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 3, "campaign_flags": { "fortified_white_horse": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The fortified crossing behind us holds. Wen Chou cannot expect quick help from White Horse." },
            { "speaker": "Cao Cao", "text": "Then this is his battle alone." }
          ]
        }
      ]
    },
    {
      "id": "yuan_supplies_raided",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 3, "campaign_flags": { "raided_yuan_supplies": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yuan Field Advisor", "text": "The supply carts are still scattered from Cao Cao's raid. The riders are charging hungry." },
            { "speaker": "Wen Chou", "text": "Hunger sharpens men. Forward!" }
          ]
        }
      ]
    },
    {
      "id": "turn_6_close_ford",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 6 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "The ford is nearly sealed. Wen Chou's courage cannot carry him back across it." },
            { "speaker": "Cao Cao", "text": "Finish the countercharge and prepare the Guandu line." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 1650,
    "items": ["bean", "wine", "war_axe"]
  },
  "post_battle_dialogue": [
    { "speaker": "Xiahou Yuan", "text": "Wen Chou's riders scattered at the ford. Yuan Shao has lost two blades in two strokes." },
    { "speaker": "Guo Jia", "text": "His numbers remain, but their certainty is damaged. That matters before Guandu." },
    { "speaker": "Cao Cao", "text": "Then we choose where the next certainty breaks." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_guandu_line",
      "label": "Secure Guandu Line",
      "description": "Cao Cao strengthens the main defensive camps before Yuan Shao commits his full army.",
      "set_flags": { "secured_guandu_line": true, "scouted_wuchao_depots": false },
      "gold": 200,
      "items": ["iron_armor"]
    },
    {
      "id": "scout_wuchao_depots",
      "label": "Scout Wuchao",
      "description": "Scouts follow the broken baggage routes toward Yuan Shao's supply depots.",
      "set_flags": { "secured_guandu_line": false, "scouted_wuchao_depots": true },
      "gold": 100,
      "items": ["wine", "war_drum"]
    }
  ]
}
