{
  "id": "050_wei_succession",
  "name": "Wei Succession",
  "objectives": {
    "victory": "Reach the Wei succession dais with Cao Cao, then defeat the court loyalists.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "wei_succession_dais_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Wei Succession",
    "location": "Luoyang Court Dais, 220 CE",
    "lines": [
      "The court road is open, but Luoyang's halls still tremble between imperial ceremony, Wei authority, and soldiers who understand both too well.",
      "Cao Cao moves to secure the succession dais before court loyalists can turn hesitation into a capital crisis."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "secured_luoyang_court": true },
        "lines": [
          "Securing Luoyang's court order gives Cao Cao a formal path to the dais, though the loyalists still gather behind the outer screen."
        ]
      },
      {
        "campaign_flags": { "prepared_wei_succession": true },
        "lines": [
          "Preparing Wei's succession has made the court transition swift, but speed also gives anxious loyalists a reason to draw steel."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "secured_luoyang_court": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "prepared_wei_succession": 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_ch50",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch50",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch50",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch50",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch50",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch50",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch50",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "wei_succession_loyalist_commander",
      "name": "Wei Succession Loyalist",
      "class_id": "commander",
      "team": "enemy",
      "level": 47,
      "pos": [14, 4],
      "base": { "hp": 158, "mp": 74, "atk": 50, "def": 41, "int": 39, "agi": 26 }
    },
    {
      "unit_id": "court_screen_captain",
      "name": "Court Screen Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 47,
      "pos": [12, 4],
      "base": { "hp": 128, "atk": 49, "def": 42 }
    },
    {
      "unit_id": "imperial_oath_champion",
      "name": "Imperial Oath Champion",
      "class_id": "champion",
      "team": "enemy",
      "level": 47,
      "pos": [15, 3],
      "base": { "hp": 156, "mp": 12, "atk": 51, "def": 37, "int": 14, "agi": 33 }
    },
    {
      "unit_id": "succession_court_advisor",
      "name": "Succession Court Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 47,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 114, "mp": 98, "atk": 8, "def": 28, "int": 50, "agi": 24 }
    },
    {
      "unit_id": "succession_spear_north",
      "name": "Succession Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 47,
      "pos": [12, 3],
      "base": { "hp": 116, "atk": 48, "def": 38 }
    },
    {
      "unit_id": "succession_spear_south",
      "name": "Succession Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 47,
      "pos": [12, 5],
      "base": { "hp": 116, "atk": 48, "def": 38 }
    },
    {
      "unit_id": "succession_crossbow_guard",
      "name": "Succession Crossbow Guard",
      "class_id": "marksman",
      "team": "enemy",
      "level": 47,
      "pos": [13, 2],
      "base": { "hp": 108, "atk": 49, "def": 24, "agi": 36 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao advances through Luoyang's inner court to secure the Wei succession dais." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The court road opened, but the inner dais still bristles with loyalist spears." },
            { "speaker": "Guo Jia", "text": "Ceremony is just another battlefield when every bow decides which way history kneels." },
            { "speaker": "Cao Cao", "text": "Then we cross it with order. Wei's future will not be left to frightened hands." }
          ]
        }
      ]
    },
    {
      "id": "secured_court_formal_path",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_luoyang_court": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "The secured court order gives us the formal path. Their resistance must now explain itself to every watching clerk." },
            { "speaker": "Cao Cao", "text": "A written order can be sharper than a blade when men still pretend to obey it." }
          ]
        }
      ]
    },
    {
      "id": "prepared_succession_draws_loyalist_riders",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "prepared_wei_succession": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Wei Succession Loyalist", "text": "Wei moves too quickly. Riders, cut across the court road before the dais changes hands." },
            { "speaker": "Zhang He", "text": "They fear speed because it leaves them no time to choose a better lie." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "succession_loyalist_riders",
            "name": "Succession Loyalist Riders",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 47,
            "pos": [16, 3],
            "base": { "hp": 106, "atk": 44, "def": 28, "agi": 34 }
          }
        }
      ]
    },
    {
      "id": "turn_4_dais_pressure",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Succession Court Advisor", "text": "Hold the screen. If Cao Cao reaches the dais, every seal in Luoyang will know which hand directs it." },
            { "speaker": "Guo Jia", "text": "The seals already know. The men holding them are slower." }
          ]
        }
      ]
    },
    {
      "id": "wei_succession_dais_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Wei succession dais is reached. Defeat the court loyalists.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "The dais is reached. Let the court see that order stands here, not panic." },
            { "speaker": "Wei Succession Loyalist", "text": "A dais is not authority while loyal blades still stand between it and the court." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "succession_inner_screen_guard",
              "name": "Succession Inner Screen Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 47,
              "pos": [16, 4],
              "base": { "hp": 124, "atk": 48, "def": 41 }
            },
            {
              "unit_id": "succession_arrow_screen",
              "name": "Succession Arrow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 47,
              "pos": [16, 5],
              "base": { "hp": 100, "atk": 47, "def": 21, "agi": 35 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_succession_settles",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Dun", "text": "Their screen is cracking. Even the court scribes are starting to look past them." },
            { "speaker": "Cao Cao", "text": "Then let the record show the last doubt falling." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 9800,
    "items": ["bean", "wine", "war_drum"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The succession dais is secure. Luoyang's seals now move with fewer trembling hands." },
    { "speaker": "Cao Ren", "text": "We can proclaim Wei's authority from the capital, or prepare the eastern front before Wu tests the transition." },
    { "speaker": "Cao Cao", "text": "Authority written in Luoyang must still be defended on the rivers. Choose where tomorrow hears it first." }
  ],
  "post_battle_choices": [
    {
      "id": "proclaim_wei_authority",
      "label": "Proclaim Wei",
      "description": "Cao Cao proclaims Wei authority from Luoyang before turning back to the frontiers.",
      "set_flags": { "proclaimed_wei_authority": true, "prepared_eastern_front": false },
      "gold": 1750,
      "items": ["imperial_seal"]
    },
    {
      "id": "prepare_eastern_front",
      "label": "Eastern Front",
      "description": "Cao Cao prepares the eastern front before Wu can test the court transition.",
      "set_flags": { "proclaimed_wei_authority": false, "prepared_eastern_front": true },
      "gold": 1550,
      "items": ["war_drum"]
    }
  ]
}
