{
  "id": "030_red_cliffs_fire",
  "name": "Red Cliffs Fire",
  "objectives": {
    "victory": "Reach the burning fleet line with Cao Cao, then defeat the coalition fire attack.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "fire_attack_exposed" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Red Cliffs Fire",
    "location": "Red Cliffs, Yangtze River, 208 CE",
    "lines": [
      "The coalition vanguard has been driven back, but the river wind now carries more than mist between the fleets.",
      "Cao Cao's chained ships hold the line as Wu fire boats move in the dark, waiting for one mistake to turn order into flame."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "reinforced_chain_line": true },
        "lines": [
          "Reinforced chains keep the fleet steady, but their strength may also carry fire from ship to ship if the coalition reaches them."
        ]
      },
      {
        "campaign_flags": { "ordered_night_raid": true },
        "lines": [
          "The night raid has unsettled the coalition, yet scattered torches on the river suggest their fire plan survived the blow."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "reinforced_chain_line": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "ordered_night_raid": 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": [
      "GGGGHHGGGGGGHHGGGG",
      "GGFFHHGGRRGGHHFFGG",
      "GGRRRRRRRRRRRRFFGG",
      "GGGFGHGGGGRRGGGGGG",
      "RRRRRRRRRRRRRRRRRR",
      "GGGGGHHGGGRRGFFGGG",
      "GGHHGFFFGGFFFGGHHG",
      "GGHHGFFFGGFFFGGHHG",
      "GGGGGGFFGGHHHGGGGG",
      "GGFFGGGGGGHHHFFGGG",
      "GGGGGGGGGGGGGGGGGG"
    ]
  },
  "deployments": [
    {
      "unit_id": "cao_cao_ch30",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch30",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch30",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch30",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch30",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch30",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch30",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "huang_gai_fire_ship",
      "name": "Huang Gai Fire Ship",
      "class_id": "champion",
      "team": "enemy",
      "level": 28,
      "pos": [14, 4],
      "base": { "hp": 114, "mp": 8, "atk": 31, "def": 23, "int": 12, "agi": 18 }
    },
    {
      "unit_id": "coalition_fire_captain",
      "name": "Coalition Fire Captain",
      "class_id": "commander",
      "team": "enemy",
      "level": 27,
      "pos": [12, 4],
      "base": { "hp": 108, "mp": 34, "atk": 30, "def": 23, "int": 21, "agi": 17 }
    },
    {
      "unit_id": "river_wind_advisor",
      "name": "River Wind Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 27,
      "pos": [15, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 74, "mp": 58, "atk": 7, "def": 13, "int": 30, "agi": 14 }
    },
    {
      "unit_id": "fire_ship_spear_north",
      "name": "Fire Ship Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 27,
      "pos": [12, 3],
      "base": { "hp": 76, "atk": 28, "def": 20 }
    },
    {
      "unit_id": "fire_ship_spear_south",
      "name": "Fire Ship Spear Guard",
      "class_id": "infantry",
      "team": "enemy",
      "level": 27,
      "pos": [12, 5],
      "base": { "hp": 76, "atk": 28, "def": 20 }
    },
    {
      "unit_id": "fire_arrow_north",
      "name": "Fire Arrow Team",
      "class_id": "marksman",
      "team": "enemy",
      "level": 27,
      "pos": [13, 2],
      "base": { "hp": 68, "atk": 29, "def": 10, "agi": 21 }
    },
    {
      "unit_id": "fire_arrow_south",
      "name": "Fire Arrow Team",
      "class_id": "marksman",
      "team": "enemy",
      "level": 27,
      "pos": [14, 6],
      "base": { "hp": 68, "atk": 29, "def": 10, "agi": 21 }
    },
    {
      "unit_id": "coalition_flame_boat",
      "name": "Coalition Flame Boat",
      "class_id": "elite_cavalry",
      "team": "enemy",
      "level": 27,
      "pos": [15, 3],
      "base": { "hp": 84, "atk": 29, "def": 16, "agi": 22 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Fire ships move under Red Cliffs' wind as Cao Cao's chained fleet waits in the dark." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Guo Jia", "text": "The river smells wrong tonight. Oil, damp rope, and men trying to hide fear." },
            { "speaker": "Cao Cao", "text": "Then we expose the fear before it becomes flame." },
            { "speaker": "Zhang He", "text": "Those ships approach too willingly. No captain rows toward chains without another plan." }
          ]
        }
      ]
    },
    {
      "id": "reinforced_chains_carry_risk",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "reinforced_chain_line": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "River Wind Advisor", "text": "Their chains are stronger now. Good. Fire loves a road that cannot scatter." },
            { "speaker": "Guo Jia", "text": "Strength and danger are sometimes the same knot." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "chain_fire_boat",
            "name": "Chain Fire Boat",
            "class_id": "cavalry",
            "team": "enemy",
            "level": 27,
            "pos": [16, 3],
            "base": { "hp": 72, "atk": 27, "def": 14, "agi": 18 }
          }
        }
      ]
    },
    {
      "id": "night_raid_delays_fire",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "ordered_night_raid": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Dun", "text": "The night raid scattered a few fire crews, but not enough to empty the river." },
            { "speaker": "Cao Cao", "text": "Then use the delay as a blade, not a pillow." }
          ]
        }
      ]
    },
    {
      "id": "turn_4_wind_turns",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Huang Gai Fire Ship", "text": "The wind answers. Light the decks when the gap opens." },
            { "speaker": "Guo Jia", "text": "There. The river has chosen a side for the moment." }
          ]
        }
      ]
    },
    {
      "id": "fire_attack_exposed",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The fire attack is exposed. Defeat the coalition fire ships.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "So that is their answer. Cut the fire ships before they reach the chain line." },
            { "speaker": "Huang Gai Fire Ship", "text": "Too late to fear flame now. Forward!" }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "ignited_deck_guard",
              "name": "Ignited Deck Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 27,
              "pos": [16, 4],
              "base": { "hp": 84, "atk": 28, "def": 22 }
            },
            {
              "unit_id": "fire_arrow_screen",
              "name": "Fire Arrow Screen",
              "class_id": "archer",
              "team": "enemy",
              "level": 27,
              "pos": [16, 5],
              "base": { "hp": 62, "atk": 27, "def": 8, "agi": 19 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_smoke_thickens",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Zhang He", "text": "Smoke is making the river smaller." },
            { "speaker": "Cao Cao", "text": "Then fight as if every step is a shore." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 5800,
    "items": ["bean", "wine", "imperial_seal"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "The fire ships are broken, but the fleet has learned fear. Red Cliffs is no longer a single battle." },
    { "speaker": "Zhang He", "text": "The safest road may be behind us now. The river keeps taking shapes we did not choose." },
    { "speaker": "Cao Cao", "text": "Then decide whether we hold the fleet together or begin the retreat through Huarong before the coalition closes." }
  ],
  "post_battle_choices": [
    {
      "id": "hold_red_cliffs_line",
      "label": "Hold Line",
      "description": "Cao Cao holds the damaged fleet line, trying to restore order before withdrawing.",
      "set_flags": { "held_red_cliffs_line": true, "opened_huarong_retreat": false },
      "gold": 700,
      "items": ["imperial_seal"]
    },
    {
      "id": "open_huarong_retreat",
      "label": "Open Retreat",
      "description": "Cao Cao opens the Huarong retreat route before the coalition can trap the fleet's survivors.",
      "set_flags": { "held_red_cliffs_line": false, "opened_huarong_retreat": true },
      "gold": 500,
      "items": ["war_drum"]
    }
  ]
}
