{
  "id": "036_weishui_crossing",
  "name": "Weishui Crossing",
  "objectives": {
    "victory": "Reach the Wei River crossing with Cao Cao, then defeat the western alliance defenders.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "weishui_crossing_seized" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Weishui Crossing",
    "location": "Wei River Crossing, Guanzhong, 211 CE",
    "lines": [
      "With the Wei River camps standing, Cao Cao pushes toward a crossing that can turn the western campaign from defense to advance.",
      "Ma Chao's riders still guard the riverbank, while Han Sui's captains listen for signs that the alliance is beginning to split."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "secured_weishui_crossing": true },
        "lines": [
          "The earlier crossing work gives Cao Cao a prepared ford and a chance to seize the far bank before the riders recover."
        ]
      },
      {
        "campaign_flags": { "deepened_han_sui_rift": true },
        "lines": [
          "The rift between Han Sui and Ma Chao deepens; western messengers now carry orders and suspicion in equal measure."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "secured_weishui_crossing": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "deepened_han_sui_rift": 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_ch36",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch36",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch36",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch36",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch36",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch36",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch36",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "ma_chao_crossing_guard",
      "name": "Ma Chao Crossing Guard",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 34,
      "pos": [14, 4],
      "base": { "hp": 136, "mp": 14, "atk": 39, "def": 27, "int": 13, "agi": 28 }
    },
    {
      "unit_id": "han_sui_river_captain",
      "name": "Han Sui River Captain",
      "class_id": "commander",
      "team": "enemy",
      "level": 33,
      "pos": [15, 5],
      "base": { "hp": 120, "mp": 46, "atk": 35, "def": 27, "int": 27, "agi": 19 }
    },
    {
      "unit_id": "crossing_gate_captain",
      "name": "Crossing Gate Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 33,
      "pos": [12, 4],
      "base": { "hp": 98, "atk": 34, "def": 27 }
    },
    {
      "unit_id": "river_crossing_advisor",
      "name": "River Crossing Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 33,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 86, "mp": 70, "atk": 8, "def": 16, "int": 36, "agi": 17 }
    },
    {
      "unit_id": "crossing_spear_north",
      "name": "Crossing Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 33,
      "pos": [12, 3],
      "base": { "hp": 88, "atk": 34, "def": 24 }
    },
    {
      "unit_id": "crossing_spear_south",
      "name": "Crossing Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 33,
      "pos": [12, 5],
      "base": { "hp": 88, "atk": 34, "def": 24 }
    },
    {
      "unit_id": "river_crossbow_screen",
      "name": "River Crossbow Screen",
      "class_id": "marksman",
      "team": "enemy",
      "level": 33,
      "pos": [13, 2],
      "base": { "hp": 80, "atk": 35, "def": 13, "agi": 25 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao advances on the Wei River crossing as the western alliance struggles to keep one voice." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Yuan", "text": "The crossing is narrow. Their horsemen cannot all strike at once, but neither can we advance carelessly." },
            { "speaker": "Guo Jia", "text": "A crossing is a promise: either we keep it, or the river takes interest." },
            { "speaker": "Cao Cao", "text": "Then make the promise with steel." }
          ]
        }
      ]
    },
    {
      "id": "secured_crossing_prepares_ford",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_weishui_crossing": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The prepared ford is marked. The front can cross before Ma Chao's riders fully close." },
            { "speaker": "Cao Cao", "text": "Then turn preparation into distance." }
          ]
        }
      ]
    },
    {
      "id": "deepened_rift_delays_western_orders",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "deepened_han_sui_rift": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Han Sui River Captain", "text": "Ma Chao wants the crossing sealed. Han Sui wants the reserves held. Which order reaches the front first?" },
            { "speaker": "Guo Jia", "text": "There. Doubt has begun to command." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "delayed_alliance_riders",
            "name": "Delayed Alliance Riders",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 33,
            "pos": [16, 3],
            "base": { "hp": 80, "atk": 31, "def": 17, "agi": 22 }
          }
        }
      ]
    },
    {
      "id": "turn_4_crossing_pressure",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Ma Chao Crossing Guard", "text": "If Cao Cao takes the crossing, Guanzhong opens behind us. Hold the riverbank!" },
            { "speaker": "Xiahou Yuan", "text": "He knows the crossing matters. That means we chose the right place." }
          ]
        }
      ]
    },
    {
      "id": "weishui_crossing_seized",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Wei River crossing is seized. Defeat the western alliance defenders.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "The crossing is ours. Now break the defenders before they can bind the alliance back together." },
            { "speaker": "Ma Chao Crossing Guard", "text": "You have the bank, not the west. Come farther if you dare." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "crossing_halberd_guard",
              "name": "Crossing Halberd Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 33,
              "pos": [16, 4],
              "base": { "hp": 96, "atk": 34, "def": 27 }
            },
            {
              "unit_id": "far_bank_arrow_screen",
              "name": "Far Bank Arrow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 33,
              "pos": [16, 5],
              "base": { "hp": 74, "atk": 33, "def": 11, "agi": 23 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_far_bank_opens",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "The far bank is opening. Their line cannot decide whether to charge or withdraw." },
            { "speaker": "Cao Cao", "text": "An army that cannot decide has already given us a road." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 7000,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The crossing is secure. Ma Chao still has courage, but the alliance no longer speaks cleanly." },
    { "speaker": "Cao Ren", "text": "We can build a Guanzhong foothold from this bank, or force the western captains to choose between Ma Chao and Han Sui." },
    { "speaker": "Cao Cao", "text": "A foothold conquers ground. A split conquers decisions. Choose." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_guanzhong_foothold",
      "label": "Secure Foothold",
      "description": "Cao Cao builds a firm Guanzhong foothold from the seized Wei River crossing.",
      "set_flags": { "secured_guanzhong_foothold": true, "split_western_alliance": false },
      "gold": 1050,
      "items": ["imperial_seal"]
    },
    {
      "id": "split_western_alliance",
      "label": "Split Alliance",
      "description": "Cao Cao exploits the crossing victory to split Han Sui's captains away from Ma Chao.",
      "set_flags": { "secured_guanzhong_foothold": false, "split_western_alliance": true },
      "gold": 850,
      "items": ["war_drum"]
    }
  ]
}
