{
  "id": "048_jing_province_settlement",
  "name": "Jing Province Settlement",
  "objectives": {
    "victory": "Reach the Jing Province command post with Cao Cao, then defeat the remaining guard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "jing_command_post_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Jing Province Settlement",
    "location": "Jing Province Command Road, 219 CE",
    "lines": [
      "The Maicheng road has been sealed, but the province still shakes with scattered banners, wary towns, and soldiers who do not yet know which lord commands the morning.",
      "Cao Cao advances on the command post to settle the front before Jing Province becomes a struggle of small fires."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "coordinated_wu_encirclement": true },
        "lines": [
          "Coordinating with Wu pressure tightens the encirclement, though every allied banner also watches where Wei will stand after victory."
        ]
      },
      {
        "campaign_flags": { "secured_xiangfan_front": true },
        "lines": [
          "Securing the Xiangfan front gives Cao Cao a steadier northern base, but Jing Province remnants gather before the command post can change hands."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "coordinated_wu_encirclement": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "secured_xiangfan_front": true },
        "items": ["war_drum"]
      }
    ]
  },
  "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",
      "GGRRRRGGFFGGRRRRGG",
      "GGGFGHGGGGRRGGGGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGGGGHHGGGRRGFFGGG",
      "GGHHGFFFGGFFFGGHHG",
      "GGHHGFFFGGFFFGGHHG",
      "GGGGGGFFGGHHHGGGGG",
      "GGFFGGGGGGHHHFFGGG",
      "GGGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch48",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch48",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch48",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch48",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch48",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch48",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch48",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "jing_province_remnant_commander",
      "name": "Jing Province Remnant Commander",
      "class_id": "commander",
      "team": "enemy",
      "level": 45,
      "pos": [14, 4],
      "base": { "hp": 154, "mp": 70, "atk": 48, "def": 39, "int": 37, "agi": 25 }
    },
    {
      "unit_id": "jing_command_post_captain",
      "name": "Command Post Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 45,
      "pos": [12, 4],
      "base": { "hp": 124, "atk": 47, "def": 40 }
    },
    {
      "unit_id": "jing_province_oath_keeper",
      "name": "Jing Province Oath Keeper",
      "class_id": "champion",
      "team": "enemy",
      "level": 45,
      "pos": [15, 3],
      "base": { "hp": 152, "mp": 12, "atk": 49, "def": 35, "int": 13, "agi": 31 }
    },
    {
      "unit_id": "jing_settlement_advisor",
      "name": "Jing Settlement Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 45,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 110, "mp": 94, "atk": 8, "def": 26, "int": 48, "agi": 23 }
    },
    {
      "unit_id": "jing_remnant_spear_north",
      "name": "Jing Remnant Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 45,
      "pos": [12, 3],
      "base": { "hp": 112, "atk": 46, "def": 36 }
    },
    {
      "unit_id": "jing_remnant_spear_south",
      "name": "Jing Remnant Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 45,
      "pos": [12, 5],
      "base": { "hp": 112, "atk": 46, "def": 36 }
    },
    {
      "unit_id": "jing_command_marksman",
      "name": "Jing Command Marksman",
      "class_id": "marksman",
      "team": "enemy",
      "level": 45,
      "pos": [13, 2],
      "base": { "hp": 104, "atk": 47, "def": 22, "agi": 34 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao advances on the Jing Province command post while scattered remnants rally for one last settlement fight." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The siege is gone, yet the province is still full of men waiting to see which banner survives." },
            { "speaker": "Guo Jia", "text": "A province after battle is like a bowstring after release. Touch it carelessly and it still snaps." },
            { "speaker": "Cao Cao", "text": "Then we settle the command post before fear chooses its own lord." }
          ]
        }
      ]
    },
    {
      "id": "wu_encirclement_tightens",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "coordinated_wu_encirclement": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Wu pressure seals the outer roads. The remnants before us have fewer exits than they believe." },
            { "speaker": "Cao Cao", "text": "Then finish quickly, and let every watcher learn who set the order." }
          ]
        }
      ]
    },
    {
      "id": "xiangfan_front_draws_breakout",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "secured_xiangfan_front": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Jing Province Remnant Commander", "text": "Xiangfan is sealed behind us. Break through Cao Cao's flank before the command post bends." },
            { "speaker": "Cao Ren", "text": "They know the northern road is gone, so they will spend their strength in front of us." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "jing_breakout_riders",
            "name": "Jing Breakout Riders",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 45,
            "pos": [16, 3],
            "base": { "hp": 102, "atk": 42, "def": 26, "agi": 32 }
          }
        }
      ]
    },
    {
      "id": "turn_4_command_post_pressure",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Jing Settlement Advisor", "text": "Hold the command post. If Wei takes the seal table, every garrison will decide the war is already over." },
            { "speaker": "Zhang He", "text": "Then the table is worth more than the gate." }
          ]
        }
      ]
    },
    {
      "id": "jing_command_post_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Jing Province command post is reached. Defeat the remaining guard.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This command post now answers to Wei. Remove the guard that still argues." },
            { "speaker": "Jing Province Remnant Commander", "text": "A province is not settled while a single blade remembers its old oath." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "jing_command_inner_guard",
              "name": "Jing Command Inner Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 45,
              "pos": [16, 4],
              "base": { "hp": 120, "atk": 46, "def": 39 }
            },
            {
              "unit_id": "jing_command_arrow_screen",
              "name": "Jing Command Arrow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 45,
              "pos": [16, 5],
              "base": { "hp": 96, "atk": 45, "def": 19, "agi": 33 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_settlement_nears",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Yuan", "text": "Their banners are folding around the command post. Jing Province is running out of places to resist." },
            { "speaker": "Cao Cao", "text": "Then let the last place fall with discipline." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 9400,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Jing Province is settled for now. Roads, storehouses, and frightened towns all look toward Wei's command." },
    { "speaker": "Cao Ren", "text": "We can stabilize the new province, or answer the summons from Luoyang while the front still obeys." },
    { "speaker": "Cao Cao", "text": "A province won is a promise to hold it. A summons ignored is also a choice. Decide which duty speaks first." }
  ],
  "post_battle_choices": [
    {
      "id": "stabilize_jing_province",
      "label": "Stabilize Jing",
      "description": "Cao Cao stabilizes Jing Province before turning away from the newly settled front.",
      "set_flags": { "stabilized_jing_province": true, "answered_luoyang_summons": false },
      "gold": 1650,
      "items": ["imperial_seal"]
    },
    {
      "id": "answer_luoyang_summons",
      "label": "Answer Luoyang",
      "description": "Cao Cao answers Luoyang's summons while the newly settled front is still fresh.",
      "set_flags": { "stabilized_jing_province": false, "answered_luoyang_summons": true },
      "gold": 1450,
      "items": ["war_drum"]
    }
  ]
}
