{
  "id": "051_eastern_front_alarm",
  "name": "Eastern Front Alarm",
  "objectives": {
    "victory": "Reach the eastern front crossing with Cao Cao, then defeat the Wu river guard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "eastern_crossing_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Eastern Front Alarm",
    "location": "Eastern River Front, Ruxu Approaches, 220 CE",
    "lines": [
      "Wei's authority has settled in Luoyang, but the eastern rivers answer with alarm bells from Ruxu and quick Wu boats in the channels.",
      "Cao Cao must reach the crossing before Wu turns the court transition into a river-front crisis."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "proclaimed_wei_authority": true },
        "lines": [
          "Proclaiming Wei authority gives the army a clear banner, but Wu commanders now test whether that authority reaches the river."
        ]
      },
      {
        "campaign_flags": { "prepared_eastern_front": true },
        "lines": [
          "Preparing the eastern front puts shield boats and supply carts in place before Wu can turn the current against Wei."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "proclaimed_wei_authority": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "prepared_eastern_front": 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": [
      "WWWWWWWWWWWWWWWWWW",
      "WGGGFFWWRRWWFFGGGW",
      "GGGGWWGGGGRRGGGGGG",
      "GGFFWWGGRRRRGFFGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGFFWWGGRRRRGFFGGG",
      "GGGGWWGGGGRRGGGGGG",
      "GHHHWWGFFFGGFFFGGG",
      "GHHHWWGGGGHHHGGGGG",
      "GGGGWWGGGGHHHFFGGG",
      "WWWWWWWWWWWWWWWWWW"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch51",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch51",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch51",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch51",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch51",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch51",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch51",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "wu_eastern_river_guard",
      "name": "Wu Eastern River Guard",
      "class_id": "commander",
      "team": "enemy",
      "level": 48,
      "pos": [14, 4],
      "base": { "hp": 160, "mp": 76, "atk": 51, "def": 42, "int": 40, "agi": 27 }
    },
    {
      "unit_id": "ruxu_alarm_captain",
      "name": "Ruxu Alarm Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 48,
      "pos": [12, 4],
      "base": { "hp": 130, "atk": 50, "def": 43 }
    },
    {
      "unit_id": "gan_ning_alarm_boat",
      "name": "Gan Ning Alarm Boat",
      "class_id": "champion",
      "team": "enemy",
      "move_type": "water",
      "level": 48,
      "pos": [4, 3],
      "base": { "hp": 158, "mp": 12, "atk": 52, "def": 38, "int": 14, "agi": 34 }
    },
    {
      "unit_id": "eastern_front_advisor",
      "name": "Eastern Front Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 48,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 116, "mp": 100, "atk": 8, "def": 29, "int": 51, "agi": 25 }
    },
    {
      "unit_id": "eastern_river_spear_north",
      "name": "Eastern River Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 48,
      "pos": [12, 3],
      "base": { "hp": 118, "atk": 49, "def": 39 }
    },
    {
      "unit_id": "eastern_river_spear_south",
      "name": "Eastern River Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 48,
      "pos": [12, 5],
      "base": { "hp": 118, "atk": 49, "def": 39 }
    },
    {
      "unit_id": "ruxu_alarm_arrow_boat",
      "name": "Ruxu Alarm Arrow Boat",
      "class_id": "marksman",
      "team": "enemy",
      "move_type": "water",
      "level": 48,
      "pos": [5, 5],
      "base": { "hp": 110, "atk": 50, "def": 25, "agi": 37 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Wu boats sound the alarm along the eastern river front as Wei's new authority reaches Ruxu." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "Luoyang's seals are barely dry, and already Ruxu's water carries Wu drums." },
            { "speaker": "Guo Jia", "text": "A new authority is always tested where the map is wettest and the roads are thinnest." },
            { "speaker": "Cao Cao", "text": "Then the river will learn that Wei's order reaches farther than court stone." }
          ]
        }
      ]
    },
    {
      "id": "wei_authority_draws_wu_test",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "proclaimed_wei_authority": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Wu Eastern River Guard", "text": "Wei proclaims authority from Luoyang. Test whether that authority can cross water." },
            { "speaker": "Zhang He", "text": "They challenge the proclamation at the river. Good. A challenge seen is a challenge answered." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "wu_probe_boat",
            "name": "Wu Probe Boat",
            "class_id": "champion",
            "team": "enemy",
            "move_type": "water",
            "level": 48,
            "pos": [5, 3],
            "base": { "hp": 108, "atk": 45, "def": 29, "agi": 35 }
          }
        }
      ]
    },
    {
      "id": "prepared_front_holds_bank",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "prepared_eastern_front": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Yuan", "text": "The eastern front was ready. Our shield carts already cover the bank road." },
            { "speaker": "Cao Cao", "text": "Preparation turns a river alarm into a timetable." }
          ]
        }
      ]
    },
    {
      "id": "turn_4_river_alarm",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Eastern Front Advisor", "text": "Keep their army on the bank and make every plank of the crossing cost a command." },
            { "speaker": "Guo Jia", "text": "Wu wants the river to speak louder than Luoyang." }
          ]
        }
      ]
    },
    {
      "id": "eastern_crossing_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The eastern front crossing is reached. Defeat the Wu river guard.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This crossing answers to Wei. Break the guard before Wu turns alarm into invasion." },
            { "speaker": "Wu Eastern River Guard", "text": "A crossing is only yours while boats stop fearing your banner." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "eastern_crossing_halberd_guard",
              "name": "Eastern Crossing Halberd Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 48,
              "pos": [16, 4],
              "base": { "hp": 126, "atk": 49, "def": 42 }
            },
            {
              "unit_id": "eastern_crossing_arrow_boat",
              "name": "Eastern Crossing Arrow Boat",
              "class_id": "marksman",
              "team": "enemy",
              "move_type": "water",
              "level": 48,
              "pos": [10, 1],
              "base": { "hp": 102, "atk": 48, "def": 22, "agi": 36 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_bank_stabilizes",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The river bank is stabilizing. Wu's boats are drifting wider from the crossing." },
            { "speaker": "Cao Cao", "text": "Then let the water carry one lesson clearly." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 10000,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The eastern front alarm is quiet for now. Wu has learned that Wei's transition did not leave the river empty." },
    { "speaker": "Cao Ren", "text": "We can secure the eastern fleet, or press the Wu river line while their alarm is still unanswered." },
    { "speaker": "Cao Cao", "text": "A quiet river can hide a blade or carry one. Choose what the next current bears." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_eastern_fleet",
      "label": "Secure Fleet",
      "description": "Cao Cao secures the eastern fleet before the next river push.",
      "set_flags": { "secured_eastern_fleet": true, "pressed_wu_river_line": false },
      "gold": 1800,
      "items": ["imperial_seal"]
    },
    {
      "id": "press_wu_river_line",
      "label": "Press Wu",
      "description": "Cao Cao presses Wu's river line before the eastern alarm can settle.",
      "set_flags": { "secured_eastern_fleet": false, "pressed_wu_river_line": true },
      "gold": 1600,
      "items": ["war_drum"]
    }
  ]
}
