{
  "id": "043_ruxu_river_line",
  "name": "Ruxu River Line",
  "objectives": {
    "victory": "Reach Sun Quan's river line with Cao Cao, then defeat the Wu river commander.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "sun_quan_line_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Ruxu River Line",
    "location": "Ruxu River Line, Eastern Front, 217 CE",
    "lines": [
      "The Ruxu bank is open, but Sun Quan's deeper river line still covers the channels beyond the first camps.",
      "Cao Cao must break the Wu boats watching the bank before the river becomes a wall again."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "secured_ruxu_bank": true },
        "lines": [
          "Securing the Ruxu bank gives Cao Cao time to stake camps and bring shield screens close to the river line."
        ]
      },
      {
        "campaign_flags": { "pressed_sun_quan_line": true },
        "lines": [
          "Pressing Sun Quan's line keeps Wu unsettled, but Gan Ning's boats are already slipping into the side channels."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "secured_ruxu_bank": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "pressed_sun_quan_line": 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_ch43",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch43",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch43",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch43",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch43",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch43",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch43",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "sun_quan_river_commander",
      "name": "Sun Quan River Commander",
      "class_id": "commander",
      "team": "enemy",
      "level": 40,
      "pos": [14, 4],
      "base": { "hp": 136, "mp": 58, "atk": 41, "def": 33, "int": 33, "agi": 22 }
    },
    {
      "unit_id": "ruxu_line_captain",
      "name": "Ruxu Line Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 40,
      "pos": [12, 4],
      "base": { "hp": 112, "atk": 41, "def": 34 }
    },
    {
      "unit_id": "gan_ning_strike_boat",
      "name": "Gan Ning Strike Boat",
      "class_id": "champion",
      "team": "enemy",
      "move_type": "water",
      "level": 40,
      "pos": [4, 3],
      "base": { "hp": 140, "mp": 12, "atk": 43, "def": 30, "int": 13, "agi": 27 }
    },
    {
      "unit_id": "lu_meng_line_advisor",
      "name": "Lu Meng Line Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 40,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 100, "mp": 84, "atk": 8, "def": 21, "int": 43, "agi": 20 }
    },
    {
      "unit_id": "ruxu_line_spear_north",
      "name": "Ruxu Line Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 40,
      "pos": [12, 3],
      "base": { "hp": 102, "atk": 41, "def": 31 }
    },
    {
      "unit_id": "ruxu_line_spear_south",
      "name": "Ruxu Line Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 40,
      "pos": [12, 5],
      "base": { "hp": 102, "atk": 41, "def": 31 }
    },
    {
      "unit_id": "ruxu_arrow_boat",
      "name": "Ruxu Arrow Boat",
      "class_id": "marksman",
      "team": "enemy",
      "move_type": "water",
      "level": 40,
      "pos": [5, 5],
      "base": { "hp": 94, "atk": 42, "def": 18, "agi": 30 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Wu's Ruxu river line waits behind the first bank, with strike boats moving through the side channels." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "Those boats are not decorations. Wu means to strike the bank from the water itself." },
            { "speaker": "Guo Jia", "text": "Then our line must watch two roads: the one underfoot, and the one that floats." },
            { "speaker": "Cao Cao", "text": "Break the boats close to shore, then break the men who trusted them." }
          ]
        }
      ]
    },
    {
      "id": "secured_bank_extends_camps",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "secured_ruxu_bank": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The secured bank let us stake camps close to the water. The shield line is ready." },
            { "speaker": "Cao Cao", "text": "Good. Let Wu find iron where it expected mud." }
          ]
        }
      ]
    },
    {
      "id": "pressed_line_sends_fire_boats",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_sun_quan_line": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Sun Quan River Commander", "text": "Cao Cao presses before the camps settle. Send fire boats into the channel and make haste burn." },
            { "speaker": "Xiahou Dun", "text": "If they want a quick fight, we will give them a short one." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "ruxu_fire_boat_flank",
            "name": "Ruxu Fire Boat",
            "class_id": "champion",
            "team": "enemy",
            "move_type": "water",
            "level": 40,
            "pos": [5, 3],
            "base": { "hp": 104, "atk": 39, "def": 22, "agi": 28 }
          }
        }
      ]
    },
    {
      "id": "turn_4_boats_close",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Lu Meng Line Advisor", "text": "Hold the bank troops in place. Let the boats cut the courage from their sides." },
            { "speaker": "Guo Jia", "text": "They are trying to make our formation face the river instead of the commander." }
          ]
        }
      ]
    },
    {
      "id": "sun_quan_line_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "Sun Quan's river line is reached. Defeat the Wu river commander.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This is Sun Quan's line. Take the bank and the boats lose their shield." },
            { "speaker": "Sun Quan River Commander", "text": "Ruxu does not yield because your banner reaches the mud." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "sun_quan_halberd_guard",
              "name": "Sun Quan Halberd Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 40,
              "pos": [16, 4],
              "base": { "hp": 110, "atk": 41, "def": 34 }
            },
            {
              "unit_id": "ruxu_chain_arrow_boat",
              "name": "Ruxu Chain Arrow Boat",
              "class_id": "marksman",
              "team": "enemy",
              "move_type": "water",
              "level": 40,
              "pos": [10, 1],
              "base": { "hp": 88, "atk": 40, "def": 14, "agi": 29 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_river_line_breaks",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "The river boats are pulling back. Their bank troops are losing the rhythm." },
            { "speaker": "Cao Cao", "text": "Then keep the beat until Wu cannot march to it." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 8400,
    "items": ["bean", "wine", "war_drum"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Sun Quan's river line bends, but Ruxu is not yet a crossing. Wu still has depth beyond the water." },
    { "speaker": "Cao Ren", "text": "Anchor the camps and the line will hold. Force the crossing now and Wu may not have time to breathe." },
    { "speaker": "Cao Cao", "text": "A river gives no answer twice. Choose how we use this one." }
  ],
  "post_battle_choices": [
    {
      "id": "anchor_ruxu_camps",
      "label": "Anchor Camps",
      "description": "Cao Cao anchors the Ruxu camps and turns the river line into a stable eastern base.",
      "set_flags": { "anchored_ruxu_camps": true, "forced_ruxu_crossing": false },
      "gold": 1400,
      "items": ["imperial_seal"]
    },
    {
      "id": "force_ruxu_crossing",
      "label": "Force Crossing",
      "description": "Cao Cao forces a Ruxu crossing before Wu can rebuild its river defense.",
      "set_flags": { "anchored_ruxu_camps": false, "forced_ruxu_crossing": true },
      "gold": 1200,
      "items": ["war_drum"]
    }
  ]
}
