{
  "id": "024_liaodong_pursuit",
  "name": "Liaodong Pursuit",
  "objectives": {
    "victory": "Reach the Liaodong road with Cao Cao, then defeat the Yuan fugitives and border guard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "liaodong_post_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Liaodong Pursuit",
    "location": "Liaodong Border, 204 CE",
    "lines": [
      "White Wolf has fallen silent behind Cao Cao's army. Yuan Shang and Yuan Xi flee toward Liaodong, where Gongsun Kang watches the border with careful hands.",
      "The pursuit now reaches the edge of Han command, where fugitives, border guards, and borrowed loyalty all choose how expensive the Yuan name remains."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "pressed_liaodong_pursuit": true },
        "lines": [
          "The hard pursuit has kept the Yuan brothers from resting. Their escort is forced to fight before Liaodong can decide whether to shelter them."
        ]
      },
      {
        "campaign_flags": { "secured_wuhuan_submission": true },
        "lines": [
          "Wuhuan pledges and guides steady the northern roads, letting Cao Cao approach Liaodong with fewer ambushes behind him."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "pressed_liaodong_pursuit": true },
        "items": ["war_drum"]
      },
      {
        "campaign_flags": { "secured_wuhuan_submission": true },
        "items": ["imperial_seal"]
      }
    ]
  },
  "roster": {
    "max_units": 7,
    "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, 2], [3, 3], [3, 4], [3, 5], [3, 6]]
  },
  "map": {
    "width": 18,
    "height": 11,
    "terrain": [
      "GGGHHHGGGGGHHHGGGG",
      "GGFFHHGGRRGGHHFFGG",
      "GGRRRRRRRRRRRRFFGG",
      "GGGFGHGGGGRRGGGGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGGGGHHGGGRRGFFGGG",
      "GGHHGFFFGGFFFGGHHG",
      "GGHHGFFFGGFFFGGHHG",
      "GGGGGGFFGGHHHGGGGG",
      "GGFFGGGGGGHHHFFGGG",
      "GGGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch24",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch24",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch24",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch24",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch24",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch24",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch24",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "yuan_shang_escape_guard",
      "name": "Yuan Shang Escape Guard",
      "class_id": "commander",
      "team": "enemy",
      "level": 23,
      "pos": [14, 4],
      "base": { "hp": 102, "mp": 30, "atk": 28, "def": 22, "int": 18, "agi": 15 }
    },
    {
      "unit_id": "yuan_xi_border_guard",
      "name": "Yuan Xi Border Guard",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 22,
      "pos": [12, 4],
      "base": { "hp": 76, "atk": 25, "def": 21 }
    },
    {
      "unit_id": "liaodong_border_advisor",
      "name": "Liaodong Border Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 22,
      "pos": [15, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 64, "mp": 48, "atk": 7, "def": 12, "int": 25, "agi": 13 }
    },
    {
      "unit_id": "liaodong_spear_north",
      "name": "Liaodong Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 22,
      "pos": [12, 3],
      "base": { "hp": 66, "atk": 24, "def": 17 }
    },
    {
      "unit_id": "liaodong_spear_south",
      "name": "Liaodong Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 22,
      "pos": [12, 5],
      "base": { "hp": 66, "atk": 24, "def": 17 }
    },
    {
      "unit_id": "liaodong_archer_north",
      "name": "Liaodong Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 22,
      "pos": [13, 2],
      "base": { "hp": 58, "atk": 25, "def": 10, "agi": 18 }
    },
    {
      "unit_id": "liaodong_archer_south",
      "name": "Liaodong Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 22,
      "pos": [14, 6],
      "base": { "hp": 58, "atk": 25, "def": 10, "agi": 18 }
    },
    {
      "unit_id": "yuan_fugitive_rider",
      "name": "Yuan Fugitive Rider",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 22,
      "pos": [15, 3],
      "base": { "hp": 72, "atk": 26, "def": 15, "agi": 19 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "The Yuan fugitives race for Liaodong while border guards weigh shelter against survival." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Liaodong waits to see whether the Yuan brothers arrive as guests or burdens." },
            { "speaker": "Cao Cao", "text": "Then make them arrive as a warning." },
            { "speaker": "Zhang He", "text": "Their guards are still protecting banners. The men carrying them are protecting exits." }
          ]
        }
      ]
    },
    {
      "id": "yuan_rearguard_panics",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_liaodong_pursuit": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yuan Shang Escape Guard", "text": "Cao Cao has followed us to the border. Liaodong cannot pretend this is only our quarrel now." },
            { "speaker": "Xiahou Dun", "text": "Good. Let every gate hear us coming." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "panicked_yuan_rider",
            "name": "Panicked Yuan Rider",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 22,
            "pos": [16, 3],
            "base": { "hp": 62, "atk": 24, "def": 13, "agi": 16 }
          }
        }
      ]
    },
    {
      "id": "wuhuan_guides_arrive",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_wuhuan_submission": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "Wuhuan guides hold the rear roads. No rider has slipped behind the column." },
            { "speaker": "Cao Cao", "text": "Then Liaodong will see an army, not a chase." }
          ]
        }
      ]
    },
    {
      "id": "turn_4_liaodong_watch",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Liaodong Border Advisor", "text": "Gongsun Kang will not spend Liaodong cheaply. Hold long enough for him to name his price." },
            { "speaker": "Guo Jia", "text": "Men who name prices in battle are already counting losses." }
          ]
        }
      ]
    },
    {
      "id": "liaodong_post_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Liaodong road is seized. Defeat the Yuan fugitives and border guard.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This road decides who still dares to shelter the Yuan name. Take it." },
            { "speaker": "Yuan Shang Escape Guard", "text": "If this road falls, Liaodong will sell us before sunset. Hold!" }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "gongsun_border_captain",
              "name": "Gongsun Border Captain",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 22,
              "pos": [16, 4],
              "base": { "hp": 74, "atk": 25, "def": 20 }
            },
            {
              "unit_id": "yuan_fugitive_archer",
              "name": "Yuan Fugitive Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 22,
              "pos": [16, 5],
              "base": { "hp": 52, "atk": 23, "def": 8, "agi": 16 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_border_breaks",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "The border guards are looking east for orders and west for escape." },
            { "speaker": "Cao Cao", "text": "Then leave them neither excuse." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 4600,
    "items": ["bean", "wine", "iron_armor"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Liaodong has learned that sheltering the Yuan brothers costs more than betraying them." },
    { "speaker": "Zhang He", "text": "The north is quieting. The road back to the heartland will not stay quiet for long." },
    { "speaker": "Cao Cao", "text": "Then decide whether we accept Liaodong's terms or press our authority to the border itself." }
  ],
  "post_battle_choices": [
    {
      "id": "accept_liaodong_terms",
      "label": "Accept Terms",
      "description": "Cao Cao accepts Liaodong's submission terms and closes the northern campaign with order.",
      "set_flags": { "accepted_liaodong_terms": true, "pressed_liaodong_authority": false },
      "gold": 700,
      "items": ["imperial_seal"]
    },
    {
      "id": "press_liaodong_authority",
      "label": "Press Authority",
      "description": "The army expands pressure on Liaodong to make the northern border answer directly to Cao Cao.",
      "set_flags": { "accepted_liaodong_terms": false, "pressed_liaodong_authority": true },
      "gold": 400,
      "items": ["war_drum"]
    }
  ]
}
