{
  "id": "035_weishui_camps",
  "name": "Weishui Camps",
  "objectives": {
    "victory": "Reach the Wei River camp line with Cao Cao, then defeat the western alliance assault.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "weishui_camp_line_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Weishui Camps",
    "location": "Wei River, Guanzhong, 211 CE",
    "lines": [
      "After Ma Chao's counterstroke breaks, Cao Cao draws the western campaign toward the Wei River camps.",
      "The river line can become a shield against cavalry, but Han Sui's shifting loyalty may matter as much as ground."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "anchored_weishui_camps": true },
        "lines": [
          "Anchored camps along the Wei River give Cao Cao a measured line before the western alliance makes its next assault."
        ]
      },
      {
        "campaign_flags": { "sowed_han_sui_doubt": true },
        "lines": [
          "Rumors between Han Sui and Ma Chao spread through the western alliance, making every order sound slightly suspect."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "anchored_weishui_camps": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "sowed_han_sui_doubt": 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",
      "GGRRRRRRRRRRRRFFGG",
      "GGGFGHGGGGRRGGGGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGGGGHHGGGRRGFFGGG",
      "GGHHGFFFGGFFFGGHHG",
      "GGHHGFFFGGFFFGGHHG",
      "GGGGGGFFGGHHHGGGGG",
      "GGFFGGGGGGHHHFFGGG",
      "GGGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch35",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch35",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch35",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch35",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch35",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch35",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch35",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "ma_chao_river_assault",
      "name": "Ma Chao River Assault",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 33,
      "pos": [14, 4],
      "base": { "hp": 132, "mp": 14, "atk": 38, "def": 26, "int": 13, "agi": 27 }
    },
    {
      "unit_id": "han_sui_camp_wing",
      "name": "Han Sui Camp Wing",
      "class_id": "commander",
      "team": "enemy",
      "level": 32,
      "pos": [15, 5],
      "base": { "hp": 118, "mp": 44, "atk": 34, "def": 26, "int": 26, "agi": 19 }
    },
    {
      "unit_id": "weishui_gate_captain",
      "name": "Weishui Gate Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 32,
      "pos": [12, 4],
      "base": { "hp": 96, "atk": 33, "def": 26 }
    },
    {
      "unit_id": "river_camp_advisor",
      "name": "River Camp Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 32,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 84, "mp": 68, "atk": 8, "def": 16, "int": 35, "agi": 17 }
    },
    {
      "unit_id": "weishui_spear_north",
      "name": "Weishui Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 32,
      "pos": [12, 3],
      "base": { "hp": 86, "atk": 33, "def": 23 }
    },
    {
      "unit_id": "weishui_spear_south",
      "name": "Weishui Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 32,
      "pos": [12, 5],
      "base": { "hp": 86, "atk": 33, "def": 23 }
    },
    {
      "unit_id": "riverbank_crossbow_north",
      "name": "Riverbank Crossbow",
      "class_id": "marksman",
      "team": "enemy",
      "level": 32,
      "pos": [13, 2],
      "base": { "hp": 78, "atk": 34, "def": 12, "agi": 25 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Along the Wei River, Cao Cao's camps face the western alliance's next test of cavalry and trust." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The river gives us a line, but it also gives the enemy something to pin us against." },
            { "speaker": "Guo Jia", "text": "A river is useful only when men on both banks disagree about what it means." },
            { "speaker": "Cao Cao", "text": "Then make the Wei River mean patience to us and doubt to them." }
          ]
        }
      ]
    },
    {
      "id": "anchored_camps_hold_line",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "anchored_weishui_camps": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The anchored camps are holding. Supply carts are inside the line before the riders can cut them." },
            { "speaker": "Cao Cao", "text": "Good. A camp that does not panic is a weapon." }
          ]
        }
      ]
    },
    {
      "id": "han_sui_doubt_splits_orders",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "sowed_han_sui_doubt": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Han Sui Camp Wing", "text": "Ma Chao asks for a full charge, yet every messenger now weighs his words." },
            { "speaker": "Guo Jia", "text": "A delayed order can be sharper than a spear, if it lands in the right hand." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "uncertain_western_riders",
            "name": "Uncertain Western Riders",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 32,
            "pos": [16, 3],
            "base": { "hp": 78, "atk": 30, "def": 16, "agi": 21 }
          }
        }
      ]
    },
    {
      "id": "turn_4_river_pressure",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Ma Chao River Assault", "text": "Do not let Cao Cao settle behind the river. Break the camps before they grow roots." },
            { "speaker": "Xiahou Yuan", "text": "He knows a fixed line is trouble for cavalry. Hold it until he proves why." }
          ]
        }
      ]
    },
    {
      "id": "weishui_camp_line_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Wei River camp line is reached. Defeat the western alliance assault.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This line holds the river. Break their assault and the alliance must look inward." },
            { "speaker": "Ma Chao River Assault", "text": "The river will not save you from horsemen who refuse to stop." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "weishui_halberd_guard",
              "name": "Weishui Halberd Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 32,
              "pos": [16, 4],
              "base": { "hp": 94, "atk": 33, "def": 26 }
            },
            {
              "unit_id": "river_arrow_screen",
              "name": "River Arrow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 32,
              "pos": [16, 5],
              "base": { "hp": 72, "atk": 32, "def": 10, "agi": 23 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_camps_steady",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "Their assault is scattering along the riverbank." },
            { "speaker": "Cao Cao", "text": "Then the camps have done their work. End the charge." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 6800,
    "items": ["bean", "wine", "war_drum"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The Wei River camps stand. The alliance still has riders, but now it also has questions." },
    { "speaker": "Cao Ren", "text": "We can press the river crossing while their assault is spent, or deepen the rift between Han Sui and Ma Chao." },
    { "speaker": "Cao Cao", "text": "Ground and doubt are both roads. Choose which one carries us into the next battle." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_weishui_crossing",
      "label": "Secure Crossing",
      "description": "Cao Cao secures a Wei River crossing before Ma Chao's riders can recover.",
      "set_flags": { "secured_weishui_crossing": true, "deepened_han_sui_rift": false },
      "gold": 1000,
      "items": ["imperial_seal"]
    },
    {
      "id": "deepen_han_sui_rift",
      "label": "Deepen Rift",
      "description": "Cao Cao deepens the mistrust between Han Sui and Ma Chao before the next engagement.",
      "set_flags": { "secured_weishui_crossing": false, "deepened_han_sui_rift": true },
      "gold": 800,
      "items": ["war_drum"]
    }
  ]
}
