{
  "id": "042_ruxu_advance",
  "name": "Ruxu Advance",
  "objectives": {
    "victory": "Reach the Ruxu riverbank with Cao Cao, then defeat the Wu river vanguard.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "ruxu_bank_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Ruxu Advance",
    "location": "Ruxu Riverbank, Eastern Front, 217 CE",
    "lines": [
      "With Hanzhong settled, Cao Cao turns back toward the lower Yangtze, where Sun Quan's river camps watch Ruxu.",
      "The army must force the Ruxu bank before Wu can turn the waterline into another wall of boats, arrows, and tide."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "garrisoned_hanzhong": true },
        "lines": [
          "The Hanzhong garrison keeps the western mountains quiet, letting Cao Cao march east without fearing a cut road behind him."
        ]
      },
      {
        "campaign_flags": { "pivoted_to_ruxu": true },
        "lines": [
          "The fast pivot from Hanzhong brings Cao Cao to Ruxu early, but Wu scouts have raced ahead along the river channels."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "garrisoned_hanzhong": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "pivoted_to_ruxu": 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_ch42",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch42",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch42",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch42",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch42",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch42",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch42",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "wu_ruxu_vanguard_admiral",
      "name": "Wu Ruxu Vanguard Admiral",
      "class_id": "commander",
      "team": "enemy",
      "level": 39,
      "pos": [14, 4],
      "base": { "hp": 134, "mp": 56, "atk": 40, "def": 32, "int": 32, "agi": 22 }
    },
    {
      "unit_id": "ruxu_deck_captain",
      "name": "Ruxu Deck Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 39,
      "pos": [12, 4],
      "base": { "hp": 110, "atk": 40, "def": 33 }
    },
    {
      "unit_id": "gan_ning_raid_boat",
      "name": "Gan Ning Raid Boat",
      "class_id": "champion",
      "team": "enemy",
      "level": 39,
      "pos": [15, 3],
      "base": { "hp": 138, "mp": 12, "atk": 42, "def": 30, "int": 13, "agi": 26 }
    },
    {
      "unit_id": "lu_meng_river_advisor",
      "name": "Lu Meng River Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 39,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 98, "mp": 82, "atk": 8, "def": 21, "int": 42, "agi": 20 }
    },
    {
      "unit_id": "ruxu_spear_north",
      "name": "Ruxu Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 39,
      "pos": [12, 3],
      "base": { "hp": 100, "atk": 40, "def": 30 }
    },
    {
      "unit_id": "ruxu_spear_south",
      "name": "Ruxu Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 39,
      "pos": [12, 5],
      "base": { "hp": 100, "atk": 40, "def": 30 }
    },
    {
      "unit_id": "ruxu_river_marksman",
      "name": "Ruxu River Marksman",
      "class_id": "marksman",
      "team": "enemy",
      "level": 39,
      "pos": [13, 2],
      "base": { "hp": 92, "atk": 41, "def": 17, "agi": 29 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Cao Cao's eastern army reaches Ruxu, where Wu river camps guard the bank with boats, archers, and tide-watched roads." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Dun", "text": "The river is wide, but the bank is narrow enough for men to die over." },
            { "speaker": "Guo Jia", "text": "Wu prefers a battlefield that moves. The tide will be their second officer." },
            { "speaker": "Cao Cao", "text": "Then seize the bank before the river receives orders." }
          ]
        }
      ]
    },
    {
      "id": "hanzhong_garrison_secures_rear",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "garrisoned_hanzhong": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "Reports from Hanzhong are quiet. The western garrison is holding the mountain roads." },
            { "speaker": "Cao Cao", "text": "A quiet rear lets the front speak louder." }
          ]
        }
      ]
    },
    {
      "id": "ruxu_pivot_draws_wu_scouts",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pivoted_to_ruxu": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Wu Ruxu Vanguard Admiral", "text": "Cao Cao pivoted east faster than expected. Send the scout boats in before his line settles." },
            { "speaker": "Zhang He", "text": "Their scouts are quick. Good. Quick men fall before slow plans can save them." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "wu_ruxu_scout_boats",
            "name": "Wu Ruxu Scout Boats",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 39,
            "pos": [16, 3],
            "base": { "hp": 92, "atk": 37, "def": 21, "agi": 27 }
          }
        }
      ]
    },
    {
      "id": "turn_4_river_tide",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Lu Meng River Advisor", "text": "Let the bank bend them inward. Arrows first, boats second, blades only when they cannot step aside." },
            { "speaker": "Guo Jia", "text": "They are using the river like a wall that breathes." }
          ]
        }
      ]
    },
    {
      "id": "ruxu_bank_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Ruxu bank is reached. Defeat the Wu river vanguard.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This is the bank. Take it, and Wu must answer us on land." },
            { "speaker": "Wu Ruxu Vanguard Admiral", "text": "Ruxu answers from the river first. Hold the bank!" }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "ruxu_halberd_guard",
              "name": "Ruxu Halberd Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 39,
              "pos": [16, 4],
              "base": { "hp": 108, "atk": 40, "def": 33 }
            },
            {
              "unit_id": "ruxu_arrow_screen",
              "name": "Ruxu Arrow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 39,
              "pos": [16, 5],
              "base": { "hp": 86, "atk": 39, "def": 14, "agi": 28 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_ruxu_line_wavers",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Yuan", "text": "Their river line is wavering. The boats keep backing into their own archers." },
            { "speaker": "Cao Cao", "text": "Then push until the river carries their courage away." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 8200,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Ruxu's bank is in our hands, but Wu still has the deeper river line and Sun Quan's banners beyond it." },
    { "speaker": "Zhang He", "text": "We can secure the bank and bring up camps, or press Sun Quan's line before Wu's ships gather." },
    { "speaker": "Cao Cao", "text": "A river battle is a question of timing. Decide whether the next answer is a stake or a blade." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_ruxu_bank",
      "label": "Secure Bank",
      "description": "Cao Cao secures the Ruxu bank and builds camps before pressing deeper into Wu's river line.",
      "set_flags": { "secured_ruxu_bank": true, "pressed_sun_quan_line": false },
      "gold": 1350,
      "items": ["imperial_seal"]
    },
    {
      "id": "press_sun_quan_line",
      "label": "Press Sun Quan",
      "description": "Cao Cao presses Sun Quan's river line before Wu can gather its ships at Ruxu.",
      "set_flags": { "secured_ruxu_bank": false, "pressed_sun_quan_line": true },
      "gold": 1150,
      "items": ["war_drum"]
    }
  ]
}
