{
  "id": "061_nanhai_route",
  "name": "Nanhai Route",
  "objectives": {
    "victory": "Reach the Nanhai route marker with Cao Cao, then defeat the route captain.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "nanhai_route_line_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Nanhai Route",
    "location": "Nanhai Route Camp, Southern Coast, Eastern Front, 220 CE",
    "lines": [
      "The southern holdout camp has fallen, but Wu captains still try to move men and records down the Nanhai route.",
      "Cao Cao advances along the canal road to cut the last organized passage between Jianye's surrender and the southern fleet."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "settled_southern_holdouts": true },
        "lines": [
          "Settling the southern holdouts gives Wei names, store ledgers, and guides who know which camps still feed the Nanhai route."
        ]
      },
      {
        "campaign_flags": { "pressed_nanhai_route": true },
        "lines": [
          "Pressing the Nanhai route early has thrown the holdouts into motion, but their fleet captains now gather every boat that can still fight."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "settled_southern_holdouts": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "pressed_nanhai_route": 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_ch61",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch61",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch61",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch61",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch61",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch61",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch61",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "nanhai_route_captain",
      "name": "Nanhai Route Captain",
      "class_id": "commander",
      "team": "enemy",
      "level": 58,
      "pos": [14, 4],
      "base": { "hp": 198, "mp": 96, "atk": 61, "def": 52, "int": 50, "agi": 37 }
    },
    {
      "unit_id": "nanhai_road_guard",
      "name": "Nanhai Road Guard",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 58,
      "pos": [12, 4],
      "base": { "hp": 150, "atk": 60, "def": 53 }
    },
    {
      "unit_id": "nanhai_canal_boat",
      "name": "Nanhai Canal Boat",
      "class_id": "champion",
      "team": "enemy",
      "move_type": "water",
      "level": 58,
      "pos": [4, 3],
      "base": { "hp": 178, "mp": 12, "atk": 62, "def": 48, "int": 16, "agi": 44 }
    },
    {
      "unit_id": "nanhai_route_advisor",
      "name": "Nanhai Route Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 58,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 136, "mp": 120, "atk": 8, "def": 39, "int": 61, "agi": 34 }
    },
    {
      "unit_id": "nanhai_spear_north",
      "name": "Nanhai Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 58,
      "pos": [12, 3],
      "base": { "hp": 138, "atk": 59, "def": 49 }
    },
    {
      "unit_id": "nanhai_spear_south",
      "name": "Nanhai Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 58,
      "pos": [12, 5],
      "base": { "hp": 138, "atk": 59, "def": 49 }
    },
    {
      "unit_id": "nanhai_arrow_boat",
      "name": "Nanhai Arrow Boat",
      "class_id": "marksman",
      "team": "enemy",
      "move_type": "water",
      "level": 58,
      "pos": [5, 5],
      "base": { "hp": 130, "atk": 60, "def": 35, "agi": 47 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Wei advances onto the Nanhai route to cut the last organized southern passage." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The road bends toward the coast. Their captains have placed guards where carts meet boats." },
            { "speaker": "Guo Jia", "text": "A route is more dangerous than a camp. It can carry defeat somewhere new." },
            { "speaker": "Cao Cao", "text": "Then this route ends here." }
          ]
        }
      ]
    },
    {
      "id": "settled_holdouts_mark_route_stores",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "settled_southern_holdouts": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "The settled holdouts named the route stores. Their ledgers point us past the false depots." },
            { "speaker": "Cao Cao", "text": "Men who accept order should see it move swiftly. Advance by the marked road." }
          ]
        }
      ]
    },
    {
      "id": "pressed_route_calls_fleet_boat",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_nanhai_route": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Nanhai Route Captain", "text": "Wei presses the road already. Bring the fleet boat forward and keep the passage open." },
            { "speaker": "Xiahou Yuan", "text": "They are calling the fleet before the road is even lost. We chose the right hour." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "nanhai_fleet_boat",
            "name": "Nanhai Fleet Boat",
            "class_id": "champion",
            "team": "enemy",
            "move_type": "water",
            "level": 58,
            "pos": [5, 3],
            "base": { "hp": 128, "atk": 55, "def": 39, "agi": 45 }
          }
        }
      ]
    },
    {
      "id": "turn_4_route_captain_closes_passage",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Nanhai Route Advisor", "text": "Hold the road marker. If Wei takes it, every southern camp will know the passage is cut." },
            { "speaker": "Zhang He", "text": "Then the marker is worth more than their captain wishes to admit." }
          ]
        }
      ]
    },
    {
      "id": "nanhai_route_line_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The Nanhai route marker is reached. Defeat the route captain.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This road will no longer carry Wu's refusal south." },
            { "speaker": "Nanhai Route Captain", "text": "Roads remain after armies pass. Someone will use it again." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "nanhai_route_last_guard",
              "name": "Nanhai Route Last Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 58,
              "pos": [16, 4],
              "base": { "hp": 146, "atk": 59, "def": 52 }
            },
            {
              "unit_id": "nanhai_crossbow_boat",
              "name": "Nanhai Crossbow Boat",
              "class_id": "marksman",
              "team": "enemy",
              "move_type": "water",
              "level": 58,
              "pos": [10, 1],
              "base": { "hp": 122, "atk": 58, "def": 32, "agi": 46 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_route_breaks",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Dian Wei", "text": "Their road guard is giving ground. The boats still shout, but the men on land hear us." },
            { "speaker": "Cao Cao", "text": "Land breaks first. Then water has nowhere to return." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 12000,
    "items": ["bean", "wine", "war_axe"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The Nanhai route is cut. Wei can secure the road and let the southern camps surrender into order, or press the remaining fleet before it becomes a banner at sea." },
    { "speaker": "Cao Ren", "text": "Securing the road steadies the coast. Pressing the fleet denies the last captains a horizon." },
    { "speaker": "Cao Cao", "text": "A road taken is a promise. Decide whether that promise is settlement or pursuit." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_nanhai_route",
      "label": "Secure Route",
      "description": "Cao Cao secures the Nanhai route and prepares coastal settlement.",
      "set_flags": { "secured_nanhai_route": true, "pressed_southern_fleet": false },
      "gold": 2300,
      "items": ["imperial_seal"]
    },
    {
      "id": "press_southern_fleet",
      "label": "Press Fleet",
      "description": "Cao Cao presses the southern fleet before the last captains can regroup at sea.",
      "set_flags": { "secured_nanhai_route": false, "pressed_southern_fleet": true },
      "gold": 2100,
      "items": ["war_drum"]
    }
  ]
}
