{
  "id": "013_wuchao_raid",
  "name": "Wuchao Raid",
  "objectives": {
    "victory": "Reach Wuchao's depot with Cao Cao, then defeat the remaining defenders.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "wuchao_depot_burned" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 12, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Wuchao Raid",
    "location": "Wuchao, 200 CE",
    "lines": [
      "The Guandu line holds, but Yuan Shao's army will not collapse while Wuchao feeds it.",
      "Cao Cao leads a night raid toward the granaries, counting on speed, fire, and confusion."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "prepared_wuchao_raid": true },
        "lines": [
          "Scouts placed after the Guandu assault mark a narrow path through the outer camp."
        ]
      },
      {
        "campaign_flags": { "strengthened_guandu_defense": true },
        "lines": [
          "The reinforced Guandu camps can withstand a longer absence, but the raid must still finish before dawn."
        ]
      }
    ],
    "camp_conversations": [
      {
        "id": "wuchao_night_raid_council",
        "group": "topic",
        "label": "Night Raid Council",
        "speaker": "Guo Jia",
        "summary": "Review the depot objective and escape route.",
        "lines": [
          { "speaker": "Guo Jia", "side": "right", "text": "Wuchao feeds Yuan Shao's whole line. Fire there will travel faster than any messenger." },
          { "speaker": "Cao Cao", "side": "left", "text": "Then the first objective is silence. The second is flame. The third is getting back through the panic." },
          { "speaker": "Dian Wei", "side": "right", "text": "Silence, flame, then panic. I can remember that order." }
        ]
      },
      {
        "id": "wuchao_guo_jia_empty_bowl",
        "group": "officer",
        "officer_id": "guo_jia",
        "label": "Guo Jia - Empty Bowl",
        "speaker": "Guo Jia",
        "summary": "Weigh fire against formation.",
        "lines": [
          { "speaker": "Guo Jia", "side": "right", "text": "A burned granary wins nothing if our line scatters in the smoke." },
          { "speaker": "Cao Cao", "side": "left", "text": "So we cut the bowl from Yuan Shao's hand, then march out as one blade." }
        ]
      },
      {
        "id": "wuchao_fast_raid_supplies",
        "group": "topic",
        "label": "Fast Raid Stores",
        "summary": "Claim scout-carried field supplies.",
        "campaign_flags": { "prepared_wuchao_raid": true },
        "lines": [
          { "speaker": "Xiahou Yuan", "side": "right", "text": "The scouts hid dry rations beside the narrow track. Fast riders can carry them without slowing the column." },
          { "speaker": "Cao Cao", "side": "left", "text": "Good. Speed is only useful if it still has breath at the far end." }
        ],
        "effects": [
          { "type": "grant_item", "item_id": "bean", "count": 1, "text": "The raid scouts add a Bean to the field supplies." }
        ]
      },
      {
        "id": "wuchao_guandu_reserve_wagon",
        "group": "topic",
        "label": "Guandu Reserve Wagon",
        "summary": "Claim medicine from the reinforced camp line.",
        "campaign_flags": { "strengthened_guandu_defense": true },
        "lines": [
          { "speaker": "Cao Ren", "side": "right", "text": "The reinforced camps sent a reserve wagon after us. It carries medicine, not speed." },
          { "speaker": "Guo Jia", "side": "right", "text": "Medicine is speed after the first arrow lands." }
        ],
        "effects": [
          { "type": "grant_item", "item_id": "panacea", "count": 1, "text": "The Guandu reserve wagon adds a Panacea to the field supplies." }
        ]
      }
    ]
  },
  "shop": {
    "merchant": {
      "name": "Wuchao Night Trader",
      "lines": [
        "No lanterns, my lord. I wrapped the beans and wine in felt so they make no sound.",
        "If you buy armor tonight, wear it before the moon drops. Dawn will make merchants honest and arrows accurate."
      ]
    },
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "prepared_wuchao_raid": true },
        "items": ["war_drum"]
      },
      {
        "campaign_flags": { "strengthened_guandu_defense": true },
        "items": ["imperial_seal"]
      }
    ]
  },
  "roster": {
    "max_units": 6,
    "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, 3], [3, 4]]
  },
  "map": {
    "width": 17,
    "height": 11,
    "background": "res://art/backgrounds/wuchao_night_granary.png",
    "terrain": [
      "GGGGGHHGGGGGGGGGG",
      "GGFFGHHGGGFFGGGGG",
      "GGFFRRRRRRRRGGFFG",
      "GGGGGRGGGGRRGGGGG",
      "RRRRRRRRRRRRRRRRG",
      "GGGGGRGGGGRRGGGGG",
      "GGHHGFFFGGFFFGGGG",
      "GGHHGFFFGGFFFGGGG",
      "GGGGGGFFGGHHHGGGG",
      "GGFFGGGGGGHHHFFGG",
      "GGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch13",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch13",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "xiahou_dun_ch13",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch13",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch13",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "cao_ren_ch13",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "chunyu_qiong_guard",
      "name": "Chunyu Qiong Guard",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 13,
      "pos": [13, 4],
      "base": { "hp": 64, "atk": 19, "def": 15, "agi": 9 }
    },
    {
      "unit_id": "wuchao_granary_guard",
      "name": "Granary Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 12,
      "pos": [12, 4],
      "base": { "hp": 52, "atk": 17, "def": 12 }
    },
    {
      "unit_id": "wuchao_north_archer",
      "name": "Wuchao Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 12,
      "pos": [12, 2],
      "base": { "hp": 40, "atk": 16, "def": 7, "agi": 14 }
    },
    {
      "unit_id": "wuchao_south_archer",
      "name": "Wuchao Archer",
      "class_id": "marksman",
      "team": "enemy",
      "level": 12,
      "pos": [12, 6],
      "base": { "hp": 40, "atk": 16, "def": 7, "agi": 14 }
    },
    {
      "unit_id": "wuchao_camp_advisor",
      "name": "Camp Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 12,
      "pos": [14, 5],
      "skills": ["blaze", "mend"],
      "base": { "hp": 44, "mp": 28, "atk": 7, "def": 7, "int": 16, "agi": 10 }
    },
    {
      "unit_id": "wuchao_patrol_north",
      "name": "Wuchao Patrol",
      "class_id": "cavalry",
      "team": "enemy",
      "level": 12,
      "pos": [9, 3],
      "base": { "hp": 46, "atk": 17, "def": 9, "agi": 12 }
    },
    {
      "unit_id": "wuchao_patrol_south",
      "name": "Wuchao Patrol",
      "class_id": "cavalry",
      "team": "enemy",
      "level": 12,
      "pos": [9, 5],
      "base": { "hp": 46, "atk": 17, "def": 9, "agi": 12 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao's raiding force approaches Wuchao under cover of darkness." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "If Wuchao burns, Yuan Shao's numbers become mouths instead of soldiers." },
            { "speaker": "Guo Jia", "text": "Strike the granary first. The defenders will fight harder once they see the flame." },
            { "speaker": "Xiahou Dun", "text": "Then we give them fire before they give us formation." }
          ]
        }
      ]
    },
    {
      "id": "prepared_path",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "prepared_wuchao_raid": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "The scout marks are where they should be. The northern patrol is slower to answer." },
            { "speaker": "Cao Cao", "text": "Then we spend that advantage before dawn spends it for us." }
          ]
        }
      ]
    },
    {
      "id": "guandu_line_secure",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "strengthened_guandu_defense": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The Guandu camps remain firm behind us. We can commit fully to the raid." },
            { "speaker": "Cao Cao", "text": "A strong wall is useful because it lets the blade leave the gate." }
          ]
        }
      ]
    },
    {
      "id": "turn_3_alarm",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 3 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Chunyu Qiong", "text": "Cao Cao is near the stores! Wake the rear camp before the grain catches." },
            { "speaker": "Dian Wei", "text": "Too late to wake quietly." }
          ]
        }
      ]
    },
    {
      "id": "wuchao_depot_burned",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [14, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "Wuchao is burning. Defeat every defender before Yuan Shao can recover the stores.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 12."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "Light the granaries. Let Yuan Shao see dawn from an empty bowl." },
            { "speaker": "Guo Jia", "text": "Now the raid becomes an escape through panic. Keep formation." }
          ]
        },
        { "type": "log", "text": "Usable Wuchao stores are seized before the granaries burn." },
        { "type": "grant_gold", "amount": 200, "text": "Wuchao's captured pay chest yields 200 gold." },
        {
          "type": "grant_items",
          "items": [
            { "item_id": "bean", "count": 2 },
            "wine"
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "wuchao_rear_guard",
              "name": "Wuchao Rear Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 12,
              "pos": [15, 4],
              "base": { "hp": 54, "atk": 17, "def": 13 }
            },
            {
              "unit_id": "wuchao_rear_rider",
              "name": "Wuchao Rear Rider",
              "class_id": "cavalry",
              "team": "enemy",
              "level": 12,
              "pos": [15, 5],
              "base": { "hp": 46, "atk": 17, "def": 9, "agi": 12 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_6_granary_collapse",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 6, "after_event": "wuchao_depot_burned" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "Smoke is rising above the camp. Yuan Shao's army will feel this before his messengers explain it." },
            { "speaker": "Cao Cao", "text": "Then leave no guard behind to put the fire out." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 2100,
    "items": ["bean", "wine", "war_drum", "black_tortoise_robe"]
  },
  "post_battle_dialogue": [
    { "speaker": "Xiahou Dun", "text": "Wuchao burns. Yuan Shao's army will wake hungry." },
    { "speaker": "Guo Jia", "text": "Hunger breaks pride more cleanly than argument." },
    { "speaker": "Cao Cao", "text": "Now Guandu turns from endurance to pursuit." }
  ],
  "post_battle_choices": [
    {
      "id": "press_yuan_rout",
      "label": "Press the Rout",
      "description": "Cao Cao prepares to chase Yuan Shao's shaken army before it reforms.",
      "set_flags": { "pressed_yuan_rout": true, "secured_wuchao_stores": false },
      "gold": 100,
      "items": ["war_drum"]
    },
    {
      "id": "secure_wuchao_stores",
      "label": "Secure Stores",
      "description": "The army gathers usable supplies from Wuchao before pursuing.",
      "set_flags": { "pressed_yuan_rout": false, "secured_wuchao_stores": true },
      "gold": 300,
      "items": ["bean", "wine"]
    }
  ]
}
