{
  "id": "004_qingzhou_campaign",
  "name": "Qingzhou Campaign",
  "objectives": {
    "victory": "Defeat the Yellow Turban remnant leaders.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "turn_3_bandit_push" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 12, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Qingzhou Campaign",
    "location": "Qingzhou, 192 CE",
    "lines": [
      "After the coalition fractures, Cao Cao turns toward Qingzhou.",
      "Yellow Turban remnants threaten the villages and trade roads.",
      "Secure the road, defeat the rebel leaders, and gather soldiers for a lasting army."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "pursued_dong_zhuo": true },
        "lines": [
          "The army is still lean from the rapid pursuit after Sishui, but its veterans are hardened by the ambush at Xingyang."
        ]
      },
      {
        "campaign_flags": { "regrouped_after_sishui": true },
        "lines": [
          "Supplies gathered after Sishui let Cao Cao press into Qingzhou with a steadier line."
        ]
      }
    ],
    "camp_conversations": [
      {
        "id": "qingzhou_settlement_council",
        "group": "officer",
        "officer_id": "cao_cao",
        "label": "Cao Cao - Lasting Army",
        "speaker": "Cao Cao",
        "summary": "Discuss turning scattered victories into a standing force.",
        "lines": [
          { "speaker": "Cao Cao", "side": "left", "text": "The coalition scattered after chasing shadows. Qingzhou gives us a harder task: turn hungry men into a disciplined army." },
          { "speaker": "Xiahou Dun", "side": "right", "text": "Then we break the worst of the remnants and give the rest a reason to stand in our line." }
        ]
      },
      {
        "id": "qingzhou_village_screen",
        "group": "officer",
        "officer_id": "cao_ren",
        "label": "Cao Ren - Village Screen",
        "speaker": "Cao Ren",
        "summary": "Protect villages and trade roads while the vanguard advances.",
        "lines": [
          { "speaker": "Cao Ren", "side": "right", "text": "The villages fear every banner now. If our line tramples their fields, they will see no difference between us and the rebels." },
          { "speaker": "Cao Cao", "side": "left", "text": "Hold the road, not the harvest. Order is worth more than a hurried victory." }
        ]
      },
      {
        "id": "qingzhou_hardened_veterans",
        "campaign_flags": { "pursued_dong_zhuo": true },
        "group": "topic",
        "label": "Hardened Veterans",
        "summary": "Issue wine to the men who survived the forced pursuit.",
        "lines": [
          { "speaker": "Xiahou Yuan", "side": "right", "text": "The men who chased Dong Zhuo through Xingyang still march light. They complain less, which worries me more." },
          { "speaker": "Cao Cao", "side": "left", "text": "Give the veterans a little wine before the road opens. A steady hand matters more than a proud silence." }
        ],
        "effects": [
          { "type": "grant_item", "item_id": "wine", "count": 1, "text": "The hardened veterans add Wine to the field supplies." }
        ]
      },
      {
        "id": "qingzhou_sishui_stores",
        "campaign_flags": { "regrouped_after_sishui": true },
        "group": "topic",
        "label": "Sishui Stores",
        "summary": "Open the supplies preserved during the regroup.",
        "lines": [
          { "speaker": "Coalition Merchant", "side": "left", "text": "Those Sishui stores traveled farther than some lords did. I kept the dry beans aside before the wagons bogged down." },
          { "speaker": "Cao Ren", "side": "right", "text": "Good. Feed the front rank before we ask them to spare the villages." }
        ],
        "effects": [
          { "type": "grant_item", "item_id": "bean", "count": 1, "text": "The Sishui stores add a Bean to the field supplies." }
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "antidote",
      "panacea",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "leather_armor",
      "iron_armor"
    ],
    "merchant": {
      "name": "Qingzhou Road Merchant",
      "lines": [
        "The villages pay in grain, not coin, but a road army still needs steel and medicine.",
        "Buy before the drums start. Once the remnants scatter, every cart on this road will claim to be a refugee."
      ]
    }
  },
  "roster": {
    "max_units": 4,
    "required_officers": ["cao_cao"]
  },
  "formation": {
    "cells": [[1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5]]
  },
  "map": {
    "width": 14,
    "height": 10,
    "terrain": [
      "GGGGGGGGGGGGGG",
      "GGGFFFGGGHHGGG",
      "GGGFFFGRRHHGGG",
      "GGGGGGRRRGGGGG",
      "RRRRRRRRRRRRRR",
      "GGGGGGRRRGGGGG",
      "GGHGGGFFFGGGGG",
      "GGHHGGFFFGGWWG",
      "GGGGGGGFFGGWWG",
      "GGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch4",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "xiahou_dun_ch4",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [2, 4]
    },
    {
      "unit_id": "xiahou_yuan_ch4",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "cao_ren_ch4",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "qingzhou_chief",
      "name": "Qingzhou Chief",
      "class_id": "bandit",
      "team": "enemy",
      "level": 4,
      "pos": [11, 4],
      "base": { "hp": 48, "atk": 15, "def": 7 }
    },
    {
      "unit_id": "yellow_turban_spearman_1",
      "name": "Yellow Turban Spearman",
      "class_id": "infantry",
      "team": "enemy",
      "level": 4,
      "pos": [9, 3],
      "base": { "hp": 38, "atk": 13, "def": 7 }
    },
    {
      "unit_id": "yellow_turban_spearman_2",
      "name": "Yellow Turban Spearman",
      "class_id": "infantry",
      "team": "enemy",
      "level": 4,
      "pos": [9, 5],
      "base": { "hp": 38, "atk": 13, "def": 7 }
    },
    {
      "unit_id": "yellow_turban_archer",
      "name": "Yellow Turban Archer",
      "class_id": "archer",
      "team": "enemy",
      "level": 4,
      "pos": [10, 2],
      "base": { "hp": 30, "atk": 11, "def": 5 }
    },
    {
      "unit_id": "yellow_turban_strategist",
      "name": "Yellow Turban Mystic",
      "class_id": "strategist",
      "team": "enemy",
      "level": 4,
      "pos": [11, 6],
      "base": { "hp": 32, "mp": 16, "atk": 7, "def": 4, "int": 11 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao enters Qingzhou to pacify the Yellow Turban remnants." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "A commander needs more than victories. We need men who can hold the land after the banners move on." },
            { "speaker": "Xiahou Dun", "text": "Then we break these remnants and give the villages a reason to trust our flag." },
            { "speaker": "Xiahou Yuan", "text": "Their archers have taken the eastern ridge. I will keep them from harassing the road." }
          ]
        }
      ]
    },
    {
      "id": "turn_3_bandit_push",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 3 },
      "actions": [
        { "type": "log", "text": "Hidden Yellow Turban raiders rush from the woods." },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Qingzhou Chief", "text": "The villages are ours to feed from. Drive Cao Cao back to the west!" },
            { "speaker": "Cao Cao", "text": "They reveal themselves. Hold the road and cut them down in detail." }
          ]
        },
        {
          "type": "set_objective",
          "victory": "Defeat the Qingzhou chief and every raider.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "qingzhou_raider_north",
              "name": "Qingzhou Raider",
              "class_id": "bandit",
              "team": "enemy",
              "level": 4,
              "pos": [6, 1],
              "base": { "hp": 34, "atk": 12, "def": 5 }
            },
            {
              "unit_id": "qingzhou_raider_south",
              "name": "Qingzhou Raider",
              "class_id": "bandit",
              "team": "enemy",
              "level": 4,
              "pos": [6, 8],
              "base": { "hp": 34, "atk": 12, "def": 5 }
            },
            {
              "unit_id": "qingzhou_raider_archer",
              "name": "Qingzhou Archer",
              "class_id": "archer",
              "team": "enemy",
              "level": 4,
              "pos": [13, 7],
              "base": { "hp": 28, "atk": 11, "def": 4 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_5_dian_wei_rumor",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 5 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Scout", "text": "My lord, a fierce warrior has been seen defending villagers east of the ridge." },
            { "speaker": "Cao Cao", "text": "Remember his name. Men who protect the weak are worth more than plunderers." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 800,
    "items": ["bean", "hand_axe", "iron_armor"],
    "join_officers": ["dian_wei"]
  },
  "post_battle_dialogue": [
    { "speaker": "Dian Wei", "text": "You fought the raiders instead of bargaining with them. I can respect that." },
    { "speaker": "Cao Cao", "text": "Then stand with me, Dian Wei. I need warriors who can guard more than their own fame." },
    { "speaker": "Dian Wei", "text": "Give me a place in the line, and I will hold it." }
  ]
}
