{
  "id": "066_sea_exiles",
  "name": "Sea Exiles",
  "objectives": {
    "victory": "Reach the sea exile line with Cao Cao, then defeat the exile captain.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "sea_exile_line_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Sea Exiles",
    "location": "Sea Exile Road, Outer Southern Coast, Eastern Front, 220 CE",
    "lines": [
      "The last captains have been broken, but their scattered followers gather as sea exiles along the outer coast.",
      "Cao Cao advances to decide whether the exiles are settled into Wei's coastal order or driven toward the outer islands."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "settled_last_captains": true },
        "lines": [
          "Settling the last captains gives Wei names, crew rolls, and pilot testimony that narrow the exiles' hiding places."
        ]
      },
      {
        "campaign_flags": { "pursued_sea_exiles": true },
        "lines": [
          "Pursuing the sea exiles keeps them from forming a new banner, but every remaining boat now runs with desperate speed."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "settled_last_captains": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "pursued_sea_exiles": 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_ch66",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch66",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch66",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch66",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch66",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch66",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch66",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "sea_exile_captain",
      "name": "Sea Exile Captain",
      "class_id": "commander",
      "team": "enemy",
      "level": 63,
      "pos": [14, 4],
      "base": { "hp": 218, "mp": 106, "atk": 66, "def": 57, "int": 55, "agi": 42 }
    },
    {
      "unit_id": "sea_exile_guard",
      "name": "Sea Exile Guard",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 63,
      "pos": [12, 4],
      "base": { "hp": 160, "atk": 65, "def": 58 }
    },
    {
      "unit_id": "sea_exile_boat",
      "name": "Sea Exile Boat",
      "class_id": "champion",
      "team": "enemy",
      "move_type": "water",
      "level": 63,
      "pos": [4, 3],
      "base": { "hp": 188, "mp": 12, "atk": 67, "def": 53, "int": 16, "agi": 49 }
    },
    {
      "unit_id": "sea_exile_advisor",
      "name": "Sea Exile Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 63,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 146, "mp": 130, "atk": 8, "def": 44, "int": 66, "agi": 39 }
    },
    {
      "unit_id": "sea_exile_spear_north",
      "name": "Sea Exile Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 63,
      "pos": [12, 3],
      "base": { "hp": 148, "atk": 64, "def": 54 }
    },
    {
      "unit_id": "sea_exile_spear_south",
      "name": "Sea Exile Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 63,
      "pos": [12, 5],
      "base": { "hp": 148, "atk": 64, "def": 54 }
    },
    {
      "unit_id": "sea_exile_arrow_boat",
      "name": "Sea Exile Arrow Boat",
      "class_id": "marksman",
      "team": "enemy",
      "move_type": "water",
      "level": 63,
      "pos": [5, 5],
      "base": { "hp": 140, "atk": 65, "def": 40, "agi": 52 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Wei advances along the outer coast to settle or scatter the sea exiles." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The sea exiles have gathered ahead. They have fewer banners, but more boats." },
            { "speaker": "Guo Jia", "text": "Exiles become dangerous when they believe distance is the same as safety." },
            { "speaker": "Cao Cao", "text": "Then teach them that Wei counts distance as another road." }
          ]
        }
      ]
    },
    {
      "id": "settled_captains_name_exile_coves",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "settled_last_captains": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "The settled captains have named the exile coves. Their flight is mapped before it begins." },
            { "speaker": "Cao Cao", "text": "Good. A named cove is already half a prison." }
          ]
        }
      ]
    },
    {
      "id": "pursued_exiles_launch_outer_boat",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pursued_sea_exiles": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Sea Exile Captain", "text": "Wei pursues even the exiles. Launch the outer boat and open a path to the islands." },
            { "speaker": "Xiahou Yuan", "text": "They still think islands are distance enough. We will prove otherwise." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "sea_exile_outer_boat",
            "name": "Sea Exile Outer Boat",
            "class_id": "champion",
            "team": "enemy",
            "move_type": "water",
            "level": 63,
            "pos": [5, 3],
            "base": { "hp": 138, "atk": 60, "def": 44, "agi": 50 }
          }
        }
      ]
    },
    {
      "id": "turn_4_exiles_cut_anchor_lines",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Sea Exile Advisor", "text": "Cut the anchor lines. If the road falls, the boats must already be moving." },
            { "speaker": "Zhang He", "text": "They prepare flight before the fight is decided. Press them." }
          ]
        }
      ]
    },
    {
      "id": "sea_exile_line_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The sea exile line is reached. Defeat the exile captain.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This line ends the exiles' distance. Submit, or carry nothing but defeat to the islands." },
            { "speaker": "Sea Exile Captain", "text": "The sea still has room for men who refuse your count." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "sea_exile_last_guard",
              "name": "Sea Exile Last Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 63,
              "pos": [16, 4],
              "base": { "hp": 156, "atk": 64, "def": 57 }
            },
            {
              "unit_id": "sea_exile_crossbow_boat",
              "name": "Sea Exile Crossbow Boat",
              "class_id": "marksman",
              "team": "enemy",
              "move_type": "water",
              "level": 63,
              "pos": [10, 1],
              "base": { "hp": 132, "atk": 63, "def": 37, "agi": 51 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_exile_line_frays",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Dian Wei", "text": "The exiles are losing their line. The boats rock like they want to leave without orders." },
            { "speaker": "Cao Cao", "text": "Then give them one order they cannot ignore." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 13000,
    "items": ["bean", "wine", "iron_armor"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The sea exiles are broken. Wei can settle them into the coastal register, or press the outer islands before refusal becomes a hidden harbor." },
    { "speaker": "Cao Ren", "text": "Settlement quiets the shore. Pressing the islands quiets the places the shore cannot see." },
    { "speaker": "Cao Cao", "text": "If a road reaches the sea, Wei's order must learn to cross it." }
  ],
  "post_battle_choices": [
    {
      "id": "settle_sea_exiles",
      "label": "Settle Exiles",
      "description": "Cao Cao settles the sea exiles into Wei's coastal register.",
      "set_flags": { "settled_sea_exiles": true, "pressed_outer_islands": false },
      "gold": 2550,
      "items": ["imperial_seal"]
    },
    {
      "id": "press_outer_islands",
      "label": "Press Islands",
      "description": "Cao Cao presses the outer islands before the exiles can form a hidden harbor.",
      "set_flags": { "settled_sea_exiles": false, "pressed_outer_islands": true },
      "gold": 2350,
      "items": ["war_drum"]
    }
  ]
}
