{
  "id": "027_jiangling_chase",
  "name": "Jiangling Chase",
  "objectives": {
    "victory": "Reach Jiangling's storehouse road with Cao Cao, then defeat the Jing Province defenders.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "jiangling_storehouses_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Jiangling Chase",
    "location": "Jiangling, Jing Province, 208 CE",
    "lines": [
      "Changban's bridge has fallen behind Cao Cao's army. Ahead lies Jiangling, where Jing Province's storehouses and river roads can feed the next campaign.",
      "Liu Bei's retreating officers and local defenders try to keep the city from becoming Cao Cao's southern granary."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "pressed_jiangling_chase": true },
        "lines": [
          "The cavalry chase from Changban has reached Jiangling before the defenders can sort fugitives from soldiers."
        ]
      },
      {
        "campaign_flags": { "secured_changban_crossings": true },
        "lines": [
          "Secured crossings behind the army keep the road open, letting Cao Cao approach Jiangling with ordered columns instead of scattered pursuit."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "pressed_jiangling_chase": true },
        "items": ["war_drum"]
      },
      {
        "campaign_flags": { "secured_changban_crossings": 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_ch27",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch27",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch27",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch27",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch27",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch27",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch27",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "jiangling_storehouse_captain",
      "name": "Jiangling Storehouse Captain",
      "class_id": "commander",
      "team": "enemy",
      "level": 25,
      "pos": [14, 4],
      "base": { "hp": 106, "mp": 32, "atk": 29, "def": 23, "int": 19, "agi": 16 }
    },
    {
      "unit_id": "jing_river_guard",
      "name": "Jing River Guard",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 24,
      "pos": [12, 4],
      "base": { "hp": 80, "atk": 26, "def": 21 }
    },
    {
      "unit_id": "jiangling_advisor",
      "name": "Jiangling Advisor",
      "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": "jiangling_spear_north",
      "name": "Jiangling Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 24,
      "pos": [12, 3],
      "base": { "hp": 70, "atk": 25, "def": 18 }
    },
    {
      "unit_id": "jiangling_spear_south",
      "name": "Jiangling Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 24,
      "pos": [12, 5],
      "base": { "hp": 70, "atk": 25, "def": 18 }
    },
    {
      "unit_id": "jiangling_archer_north",
      "name": "Jiangling Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 24,
      "pos": [13, 2],
      "base": { "hp": 62, "atk": 26, "def": 10, "agi": 19 }
    },
    {
      "unit_id": "jiangling_archer_south",
      "name": "Jiangling Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 24,
      "pos": [14, 6],
      "base": { "hp": 62, "atk": 26, "def": 10, "agi": 19 }
    },
    {
      "unit_id": "liu_bei_escape_rider",
      "name": "Liu Bei Escape Rider",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 24,
      "pos": [15, 3],
      "base": { "hp": 78, "atk": 27, "def": 16, "agi": 20 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Jiangling's storehouses become the next prize as Liu Bei's rearguard flees downriver." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Jiangling is not merely a city. It is grain, boats, and the road to the river war." },
            { "speaker": "Cao Cao", "text": "Then we take the storehouses before fear empties them." },
            { "speaker": "Zhang He", "text": "Liu Bei's men are guarding carts as fiercely as banners now." }
          ]
        }
      ]
    },
    {
      "id": "jiangling_chase_arrives",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_jiangling_chase": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Jiangling Storehouse Captain", "text": "Cao Cao's riders are already here. The storehouse lists are still on the tables." },
            { "speaker": "Xiahou Yuan", "text": "Then their ledgers can count arrows." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "hurried_jiangling_rider",
            "name": "Hurried Jiangling Rider",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 24,
            "pos": [16, 3],
            "base": { "hp": 66, "atk": 25, "def": 13, "agi": 17 }
          }
        }
      ]
    },
    {
      "id": "crossings_keep_columns_whole",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_changban_crossings": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "Changban's crossings are marked behind us. Stragglers and wagons are still in order." },
            { "speaker": "Cao Cao", "text": "Then Jiangling sees a campaign, not a scattered hunt." }
          ]
        }
      ]
    },
    {
      "id": "turn_4_storehouse_orders",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Jiangling Advisor", "text": "Burn nothing unless the gates fail. A city without grain has no master worth serving." },
            { "speaker": "Guo Jia", "text": "They want to keep the prize and deny it at the same time. Useful confusion." }
          ]
        }
      ]
    },
    {
      "id": "jiangling_storehouses_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "Jiangling's storehouse road is reached. Defeat the Jing Province defenders.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "The storehouse road is ours. Keep the grain standing and the defenders falling." },
            { "speaker": "Jiangling Storehouse Captain", "text": "If Cao Cao eats from Jiangling, the river will carry his war south. Stop him!" }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "jiangling_storehouse_guard",
              "name": "Jiangling Storehouse Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 24,
              "pos": [16, 4],
              "base": { "hp": 78, "atk": 25, "def": 21 }
            },
            {
              "unit_id": "jiangling_storehouse_archer",
              "name": "Jiangling Storehouse Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 24,
              "pos": [16, 5],
              "base": { "hp": 56, "atk": 24, "def": 8, "agi": 17 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_jiangling_wavers",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "The defenders keep looking from the gates to the river. They no longer know which way saves them." },
            { "speaker": "Cao Cao", "text": "Then let neither way answer." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 5200,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Jiangling's storehouses are ours. The river has become the next battlefield whether Sun Quan admits it or not." },
    { "speaker": "Zhang He", "text": "Liu Bei runs toward Xiakou. If he reaches Wu with a story, he may return with ships." },
    { "speaker": "Cao Cao", "text": "Then decide whether we chase Xiakou or secure Jiangling's stores for the river campaign." }
  ],
  "post_battle_choices": [
    {
      "id": "press_xiakou_pursuit",
      "label": "Chase Xiakou",
      "description": "Cao Cao sends fast columns downriver before Liu Bei can make his escape useful to Wu.",
      "set_flags": { "pressed_xiakou_pursuit": true, "secured_jiangling_storehouses": false },
      "gold": 550,
      "items": ["war_drum"]
    },
    {
      "id": "secure_jiangling_storehouses",
      "label": "Secure Stores",
      "description": "The army secures Jiangling's grain, boats, and ledgers before pressing toward the river coalition.",
      "set_flags": { "pressed_xiakou_pursuit": false, "secured_jiangling_storehouses": true },
      "gold": 850,
      "items": ["imperial_seal"]
    }
  ]
}
