{
  "id": "026_changban_pursuit",
  "name": "Changban Pursuit",
  "objectives": {
    "victory": "Reach Changban Bridge with Cao Cao, then defeat Liu Bei's bridge guard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "changban_bridge_forced" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Changban Pursuit",
    "location": "Changban, Jing Province, 208 CE",
    "lines": [
      "Xinye has opened the road south, but Liu Bei's column stretches toward Changban with soldiers, households, and frightened officials tangled together.",
      "Cao Cao orders the pursuit to break the rearguard before the retreat becomes a rallying cry for Jing Province."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "pressed_xinye_vanguard": true },
        "lines": [
          "The quick vanguard has caught Liu Bei's rear before it can form cleanly, forcing his officers to defend the bridge with whatever men remain near them."
        ]
      },
      {
        "campaign_flags": { "secured_han_river_supply": true },
        "lines": [
          "The secured Han River road keeps Cao Cao's columns ordered, letting the army press Changban without fraying its own supply line."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "pressed_xinye_vanguard": true },
        "items": ["war_drum"]
      },
      {
        "campaign_flags": { "secured_han_river_supply": 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": [
      "GGGGHHGGGGGGHHGGGG",
      "GGFFHHGGRRGGHHFFGG",
      "GGRRRRRRRRRRRRFFGG",
      "GGGFGHGGGGRRGGGGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGGGGHHGGGRRGFFGGG",
      "GGHHGFFFGGFFFGGHHG",
      "GGHHGFFFGGFFFGGHHG",
      "GGGGGGFFGGHHHGGGGG",
      "GGFFGGGGGGHHHFFGGG",
      "GGGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch26",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch26",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch26",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch26",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch26",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch26",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch26",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "zhang_fei_bridge_guard",
      "name": "Zhang Fei Bridge Guard",
      "class_id": "champion",
      "team": "enemy",
      "level": 25,
      "pos": [14, 4],
      "base": { "hp": 110, "mp": 6, "atk": 30, "def": 22, "int": 8, "agi": 15 }
    },
    {
      "unit_id": "liu_bei_rear_officer",
      "name": "Liu Bei Rear Officer",
      "class_id": "commander",
      "team": "enemy",
      "level": 24,
      "pos": [12, 4],
      "base": { "hp": 100, "mp": 30, "atk": 27, "def": 21, "int": 18, "agi": 16 }
    },
    {
      "unit_id": "changban_strategist",
      "name": "Changban Strategist",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 24,
      "pos": [15, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 68, "mp": 52, "atk": 7, "def": 12, "int": 27, "agi": 13 }
    },
    {
      "unit_id": "changban_spear_north",
      "name": "Changban Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 24,
      "pos": [12, 3],
      "base": { "hp": 70, "atk": 25, "def": 18 }
    },
    {
      "unit_id": "changban_spear_south",
      "name": "Changban Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 24,
      "pos": [12, 5],
      "base": { "hp": 70, "atk": 25, "def": 18 }
    },
    {
      "unit_id": "changban_archer_north",
      "name": "Changban Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 24,
      "pos": [13, 2],
      "base": { "hp": 62, "atk": 26, "def": 10, "agi": 19 }
    },
    {
      "unit_id": "changban_archer_south",
      "name": "Changban Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 24,
      "pos": [14, 6],
      "base": { "hp": 62, "atk": 26, "def": 10, "agi": 19 }
    },
    {
      "unit_id": "zhao_yun_rearguard",
      "name": "Zhao Yun Rearguard",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 24,
      "pos": [15, 3],
      "base": { "hp": 78, "atk": 27, "def": 16, "agi": 21 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Liu Bei's column flees through Changban while his officers gather around the bridge." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "A retreat with households moves like a river after rain. Strike the bank and the current changes." },
            { "speaker": "Cao Cao", "text": "Then we take the bridge before Liu Bei turns flight into virtue." },
            { "speaker": "Zhang He", "text": "Zhang Fei is holding the road ahead. He wants us to remember the bridge more than the pursuit." }
          ]
        }
      ]
    },
    {
      "id": "xinye_vanguard_closes",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_xinye_vanguard": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Liu Bei Rear Officer", "text": "Cao Cao's vanguard is already here. The bridge line is not ready." },
            { "speaker": "Xiahou Yuan", "text": "Then we shoot before readiness becomes bravery." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "rushed_changban_rider",
            "name": "Rushed Changban Rider",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 24,
            "pos": [16, 3],
            "base": { "hp": 66, "atk": 25, "def": 13, "agi": 17 }
          }
        }
      ]
    },
    {
      "id": "han_supply_keeps_order",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_han_river_supply": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The Han River wagons are marked and guarded. The pursuit will not outrun its grain today." },
            { "speaker": "Cao Cao", "text": "Good. Even speed needs a road behind it." }
          ]
        }
      ]
    },
    {
      "id": "turn_4_bridge_defiance",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang Fei Bridge Guard", "text": "The bridge holds while I stand. Let Cao Cao's men count every plank." },
            { "speaker": "Guo Jia", "text": "He is turning one man into a wall. Walls still need ground under them." }
          ]
        }
      ]
    },
    {
      "id": "changban_bridge_forced",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "Changban Bridge is forced. Defeat Liu Bei's bridge guard.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "The bridge is in reach. Break the guard and the south road opens." },
            { "speaker": "Zhang Fei Bridge Guard", "text": "Come closer, Cao Cao. The bridge remembers who crosses it." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "changban_bridge_guard",
              "name": "Changban Bridge Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 24,
              "pos": [16, 4],
              "base": { "hp": 78, "atk": 25, "def": 21 }
            },
            {
              "unit_id": "changban_bridge_archer",
              "name": "Changban Bridge Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 24,
              "pos": [16, 5],
              "base": { "hp": 56, "atk": 24, "def": 8, "agi": 17 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_bridge_wavers",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "Their bridge line is loud because it is thin." },
            { "speaker": "Cao Cao", "text": "Then answer with enough weight to silence it." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 5000,
    "items": ["bean", "wine", "iron_armor"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Changban is broken, but Liu Bei's escape will become a tale if Jiangling hears only his courage." },
    { "speaker": "Zhang He", "text": "The road to Jiangling is open enough for cavalry, but a careless rush may leave too much behind us." },
    { "speaker": "Cao Cao", "text": "Then decide whether we chase Jiangling immediately or secure Changban's crossings first." }
  ],
  "post_battle_choices": [
    {
      "id": "press_jiangling_chase",
      "label": "Chase Jiangling",
      "description": "Cao Cao sends cavalry toward Jiangling before Liu Bei's flight becomes organized.",
      "set_flags": { "pressed_jiangling_chase": true, "secured_changban_crossings": false },
      "gold": 500,
      "items": ["war_drum"]
    },
    {
      "id": "secure_changban_crossings",
      "label": "Secure Crossings",
      "description": "The army secures Changban's bridges and roads before pressing farther south.",
      "set_flags": { "pressed_jiangling_chase": false, "secured_changban_crossings": true },
      "gold": 800,
      "items": ["imperial_seal"]
    }
  ]
}
