{
  "id": "049_luoyang_summons",
  "name": "Luoyang Summons",
  "objectives": {
    "victory": "Reach Luoyang's outer court road with Cao Cao, then defeat the court road guard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "luoyang_court_road_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Luoyang Summons",
    "location": "Luoyang Outer Court Road, 220 CE",
    "lines": [
      "Jing Province has been settled, and a summons from Luoyang pulls Cao Cao's army from the field toward the court road.",
      "The road to the capital is guarded by men who fear that every banner approaching Luoyang carries a decision larger than battle."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "stabilized_jing_province": true },
        "lines": [
          "Stabilizing Jing Province leaves the rear quieter, letting Cao Cao answer Luoyang with a disciplined column and full supply carts."
        ]
      },
      {
        "campaign_flags": { "answered_luoyang_summons": true },
        "lines": [
          "Answering Luoyang quickly has won speed, but the hurried road leaves anxious court guards guessing Cao Cao's intent."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "stabilized_jing_province": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "answered_luoyang_summons": 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_ch49",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch49",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch49",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch49",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch49",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch49",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch49",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "luoyang_court_road_guard",
      "name": "Luoyang Court Road Guard",
      "class_id": "commander",
      "team": "enemy",
      "level": 46,
      "pos": [14, 4],
      "base": { "hp": 156, "mp": 72, "atk": 49, "def": 40, "int": 38, "agi": 26 }
    },
    {
      "unit_id": "imperial_gate_captain",
      "name": "Imperial Gate Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 46,
      "pos": [12, 4],
      "base": { "hp": 126, "atk": 48, "def": 41 }
    },
    {
      "unit_id": "court_road_oath_keeper",
      "name": "Court Road Oath Keeper",
      "class_id": "champion",
      "team": "enemy",
      "level": 46,
      "pos": [15, 3],
      "base": { "hp": 154, "mp": 12, "atk": 50, "def": 36, "int": 14, "agi": 32 }
    },
    {
      "unit_id": "luoyang_court_advisor",
      "name": "Luoyang Court Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 46,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 112, "mp": 96, "atk": 8, "def": 27, "int": 49, "agi": 24 }
    },
    {
      "unit_id": "court_road_spear_north",
      "name": "Court Road Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 46,
      "pos": [12, 3],
      "base": { "hp": 114, "atk": 47, "def": 37 }
    },
    {
      "unit_id": "court_road_spear_south",
      "name": "Court Road Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 46,
      "pos": [12, 5],
      "base": { "hp": 114, "atk": 47, "def": 37 }
    },
    {
      "unit_id": "court_road_marksman",
      "name": "Court Road Marksman",
      "class_id": "marksman",
      "team": "enemy",
      "level": 46,
      "pos": [13, 2],
      "base": { "hp": 106, "atk": 48, "def": 23, "agi": 35 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao answers Luoyang's summons as armed court guards close the outer road." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The court road is guarded like a battlefield. Luoyang must be louder than the summons admitted." },
            { "speaker": "Guo Jia", "text": "When men fear the meaning of a banner, they challenge the road before they challenge the man." },
            { "speaker": "Cao Cao", "text": "Then we answer clearly. Reach Luoyang without letting fear write the first decree." }
          ]
        }
      ]
    },
    {
      "id": "stabilized_jing_supply_column",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "stabilized_jing_province": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Yuan", "text": "The Jing Province supply column keeps pace behind us. The road to Luoyang will not starve the army." },
            { "speaker": "Cao Cao", "text": "A quiet rear lets the front speak with authority." }
          ]
        }
      ]
    },
    {
      "id": "hurried_summons_draws_gate_riders",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "answered_luoyang_summons": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Luoyang Court Road Guard", "text": "Cao Cao comes too quickly. Riders, test the flank before his banners reach the gate." },
            { "speaker": "Zhang He", "text": "Speed has made them nervous. Nervous men reveal the road they mean to keep." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "luoyang_gate_riders",
            "name": "Luoyang Gate Riders",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 46,
            "pos": [16, 3],
            "base": { "hp": 104, "atk": 43, "def": 27, "agi": 33 }
          }
        }
      ]
    },
    {
      "id": "turn_4_court_road_tension",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Luoyang Court Advisor", "text": "Hold the outer road. If Cao Cao enters Luoyang under arms, the court will never decide whether it invited him or yielded to him." },
            { "speaker": "Guo Jia", "text": "They fear appearance as much as defeat. That makes the road narrower than it looks." }
          ]
        }
      ]
    },
    {
      "id": "luoyang_court_road_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "Luoyang's outer court road is reached. Defeat the court road guard.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "The outer court road is ours. Put down the guard before the summons becomes a siege." },
            { "speaker": "Luoyang Court Road Guard", "text": "Luoyang does not open because one man declares the road his." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "luoyang_inner_gate_guard",
              "name": "Luoyang Inner Gate Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 46,
              "pos": [16, 4],
              "base": { "hp": 122, "atk": 47, "def": 40 }
            },
            {
              "unit_id": "luoyang_crossbow_screen",
              "name": "Luoyang Crossbow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 46,
              "pos": [16, 5],
              "base": { "hp": 98, "atk": 46, "def": 20, "agi": 34 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_court_road_opens",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The court road is opening. Their guards are beginning to step back from their own decree." },
            { "speaker": "Cao Cao", "text": "Then let the last hesitation fall before Luoyang sees us." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 9600,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The road to Luoyang is open. The court will hear Cao Cao's answer without a guard choosing its tone." },
    { "speaker": "Cao Ren", "text": "We can secure the court's order first, or prepare the Wei succession before the next storm breaks." },
    { "speaker": "Cao Cao", "text": "The court asks for certainty. The army asks for tomorrow. Choose which answer we shape first." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_luoyang_court",
      "label": "Secure Court",
      "description": "Cao Cao secures Luoyang's court order before turning to the next military front.",
      "set_flags": { "secured_luoyang_court": true, "prepared_wei_succession": false },
      "gold": 1700,
      "items": ["imperial_seal"]
    },
    {
      "id": "prepare_wei_succession",
      "label": "Prepare Wei",
      "description": "Cao Cao prepares Wei's succession while Luoyang's summons still echoes through the court.",
      "set_flags": { "secured_luoyang_court": false, "prepared_wei_succession": true },
      "gold": 1500,
      "items": ["war_drum"]
    }
  ]
}
