{
  "id": "019_nanpi_pressure",
  "name": "Nanpi Pressure",
  "objectives": {
    "victory": "Reach Nanpi's outer line with Cao Cao, then defeat Yuan Tan's defenders.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 16."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "nanpi_line_breached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 16, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Nanpi Pressure",
    "location": "Nanpi Approaches, 203 CE",
    "lines": [
      "Yuan Tan gathers frightened northern captains near Nanpi, hoping a city gate can become a new court.",
      "Cao Cao advances before the Yuan heirs can turn flight into negotiation, while Zhang He marks the captains most likely to break."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "pressed_north_to_nanpi": true },
        "lines": [
          "The hard march from the northern road reaches Nanpi before Yuan Tan's outposts agree who commands the approach."
        ]
      },
      {
        "campaign_flags": { "secured_ji_province": true },
        "lines": [
          "Secured Ji towns keep Cao Cao's rear steady, letting the army arrive at Nanpi with fresh supplies and fewer alarms behind it."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "pressed_north_to_nanpi": true },
        "items": ["war_drum"]
      },
      {
        "campaign_flags": { "secured_ji_province": 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": [
      "GGGGGHHGGGGGGGGGGG",
      "GGFFGHHGGGFFGGGFFG",
      "GGRRRRRRRRRRRRGFFG",
      "GGGGGRGGGGRRGGGGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGGGGRGGGGRRGGGGGG",
      "GGHHGFFFGGFFFGGHHG",
      "GGHHGFFFGGFFFGGHHG",
      "GGGGGGFFGGHHHGGGGG",
      "GGFFGGGGGGHHHFFGGG",
      "GGGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch19",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch19",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch19",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch19",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch19",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch19",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch19",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "yuan_tan_outer_guard",
      "name": "Yuan Tan Outer Guard",
      "class_id": "commander",
      "team": "enemy",
      "level": 18,
      "pos": [14, 4],
      "base": { "hp": 88, "mp": 22, "atk": 24, "def": 18, "int": 14, "agi": 12 }
    },
    {
      "unit_id": "nanpi_gate_captain",
      "name": "Nanpi Gate Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 17,
      "pos": [12, 4],
      "base": { "hp": 66, "atk": 21, "def": 17 }
    },
    {
      "unit_id": "nanpi_advisor",
      "name": "Nanpi Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 17,
      "pos": [15, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 54, "mp": 38, "atk": 7, "def": 9, "int": 20, "agi": 11 }
    },
    {
      "unit_id": "nanpi_spear_north",
      "name": "Nanpi Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 17,
      "pos": [12, 3],
      "base": { "hp": 58, "atk": 20, "def": 14 }
    },
    {
      "unit_id": "nanpi_spear_south",
      "name": "Nanpi Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 17,
      "pos": [12, 5],
      "base": { "hp": 58, "atk": 20, "def": 14 }
    },
    {
      "unit_id": "nanpi_archer_north",
      "name": "Nanpi Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 17,
      "pos": [13, 2],
      "base": { "hp": 48, "atk": 20, "def": 8, "agi": 15 }
    },
    {
      "unit_id": "nanpi_archer_south",
      "name": "Nanpi Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 17,
      "pos": [14, 6],
      "base": { "hp": 48, "atk": 20, "def": 8, "agi": 15 }
    },
    {
      "unit_id": "nanpi_rider_screen",
      "name": "Nanpi Rider Screen",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 17,
      "pos": [15, 3],
      "base": { "hp": 62, "atk": 21, "def": 12, "agi": 16 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Yuan Tan's defenders form a broken line outside Nanpi." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "Yuan Tan has a city behind him and suspicion on every side. His captains are watching one another more than us." },
            { "speaker": "Cao Cao", "text": "Then let Nanpi see which side still gives orders." },
            { "speaker": "Guo Jia", "text": "A frightened gate opens inward first." }
          ]
        }
      ]
    },
    {
      "id": "rapid_nanpi_pressure",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_north_to_nanpi": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yuan Tan Outer Guard", "text": "Cao Cao is already at Nanpi? Yuan Shang promised his rearguard would buy us days." },
            { "speaker": "Zhang He", "text": "The days were spent before they were counted." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "hurried_nanpi_rider",
            "name": "Hurried Nanpi Rider",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 17,
            "pos": [16, 3],
            "base": { "hp": 52, "atk": 19, "def": 10, "agi": 13 }
          }
        }
      ]
    },
    {
      "id": "ji_supply_line",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_ji_province": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "Ji Province roads are answering our seals. The supply carts are keeping pace." },
            { "speaker": "Cao Cao", "text": "Then Nanpi cannot wait for hunger to fight for it." }
          ]
        }
      ]
    },
    {
      "id": "turn_3_yuan_tan_orders",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 3 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Yuan Tan Outer Guard", "text": "Hold the approach. Nanpi must not see Cao Cao's banners near the gate." },
            { "speaker": "Guo Jia", "text": "He fears what the city sees more than what the soldiers suffer." }
          ]
        }
      ]
    },
    {
      "id": "nanpi_line_breached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "Nanpi's outer line is breached. Defeat Yuan Tan's remaining defenders.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 16."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "The outer line breaks. Keep the gate in sight and give Yuan Tan no room to bargain." },
            { "speaker": "Yuan Tan Outer Guard", "text": "Raise the reserve banner. The gate must not open for fear." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "nanpi_reserve_guard",
              "name": "Nanpi Reserve Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 17,
              "pos": [16, 4],
              "base": { "hp": 62, "atk": 20, "def": 16 }
            },
            {
              "unit_id": "nanpi_reserve_archer",
              "name": "Nanpi Reserve Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 17,
              "pos": [16, 5],
              "base": { "hp": 42, "atk": 18, "def": 7, "agi": 13 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_8_nanpi_wavers",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 8 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "Nanpi's gate officers are no longer watching Yuan Tan's banner. They are watching our terms." },
            { "speaker": "Cao Cao", "text": "Then the next blow should sound like law, not anger." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 3500,
    "items": ["bean", "wine", "iron_armor"]
  },
  "post_battle_dialogue": [
    { "speaker": "Zhang He", "text": "Nanpi's outer line is broken. Yuan Tan can still hide behind a gate, but he cannot hide the fear inside it." },
    { "speaker": "Guo Jia", "text": "A city with fear inside has two walls. The stone wall and the one around its lord." },
    { "speaker": "Cao Cao", "text": "Then choose which wall we strike first." }
  ],
  "post_battle_choices": [
    {
      "id": "press_yuan_tan_surrender",
      "label": "Press Yuan Tan",
      "description": "Cao Cao pressures Yuan Tan directly before Nanpi's court can steady itself.",
      "set_flags": { "pressed_yuan_tan_surrender": true, "secured_nanpi_admin": false },
      "gold": 200,
      "items": ["war_drum"]
    },
    {
      "id": "secure_nanpi_admin",
      "label": "Secure Nanpi Admin",
      "description": "The army courts Nanpi officials and prepares a measured surrender push.",
      "set_flags": { "pressed_yuan_tan_surrender": false, "secured_nanpi_admin": true },
      "gold": 450,
      "items": ["imperial_seal"]
    }
  ]
}
