{
  "id": "057_inner_jianye",
  "name": "Inner Jianye",
  "objectives": {
    "victory": "Reach the inner Jianye line with Cao Cao, then defeat the inner city commander.",
    "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
  },
  "conditions": {
    "victory": { "type": "all_units_defeated", "team": "enemy", "after_event": "inner_jianye_line_reached" },
    "defeat": [
      { "type": "any_officer_defeated", "team": "player", "officer_ids": ["cao_cao"] },
      { "type": "turn_reached", "turn": 18, "team": "player" }
    ]
  },
  "briefing": {
    "title": "Inner Jianye",
    "location": "Inner Jianye Road, Eastern Front, 220 CE",
    "lines": [
      "The capital sortie has failed, and Wei's banners now press against the inner roads that protect Jianye's command district.",
      "Cao Cao advances to break the inner line, force Wu's guard back again, and decide whether to secure the city road or provoke a final stand."
    ],
    "conditional_lines": [
      {
        "campaign_flags": { "contained_capital_sortie": true },
        "lines": [
          "Containing the capital sortie leaves Wei with guarded roads, orderly supply carts, and enough time to advance into the inner city by measure."
        ]
      },
      {
        "campaign_flags": { "pressed_inner_jianye": true },
        "lines": [
          "Pressing inner Jianye keeps the defenders reeling, but their commanders now crowd the canals and roads to stop Wei before the command district."
        ]
      }
    ]
  },
  "shop": {
    "items": [
      "bean",
      "wine",
      "iron_sword",
      "training_spear",
      "short_bow",
      "hand_axe",
      "war_axe",
      "leather_armor",
      "iron_armor"
    ],
    "conditional_items": [
      {
        "campaign_flags": { "contained_capital_sortie": true },
        "items": ["imperial_seal"]
      },
      {
        "campaign_flags": { "pressed_inner_jianye": 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_ch57",
      "officer_id": "cao_cao",
      "team": "player",
      "pos": [1, 4]
    },
    {
      "unit_id": "guo_jia_ch57",
      "officer_id": "guo_jia",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 4]
    },
    {
      "unit_id": "zhang_he_ch57",
      "officer_id": "zhang_he",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 3]
    },
    {
      "unit_id": "xiahou_dun_ch57",
      "officer_id": "xiahou_dun",
      "team": "player",
      "pos": [1, 5]
    },
    {
      "unit_id": "dian_wei_ch57",
      "officer_id": "dian_wei",
      "team": "player",
      "requires_joined": true,
      "pos": [2, 5]
    },
    {
      "unit_id": "xiahou_yuan_ch57",
      "officer_id": "xiahou_yuan",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 3]
    },
    {
      "unit_id": "cao_ren_ch57",
      "officer_id": "cao_ren",
      "team": "player",
      "requires_joined": true,
      "pos": [3, 4]
    },
    {
      "unit_id": "inner_jianye_commander",
      "name": "Inner Jianye Commander",
      "class_id": "commander",
      "team": "enemy",
      "level": 54,
      "pos": [14, 4],
      "base": { "hp": 182, "mp": 88, "atk": 57, "def": 48, "int": 46, "agi": 33 }
    },
    {
      "unit_id": "inner_city_captain",
      "name": "Inner City Captain",
      "class_id": "guard_captain",
      "team": "enemy",
      "level": 54,
      "pos": [12, 4],
      "base": { "hp": 142, "atk": 56, "def": 49 }
    },
    {
      "unit_id": "lu_xun_canal_boat",
      "name": "Lu Xun Canal Boat",
      "class_id": "champion",
      "team": "enemy",
      "move_type": "water",
      "level": 54,
      "pos": [4, 3],
      "base": { "hp": 170, "mp": 12, "atk": 58, "def": 44, "int": 16, "agi": 40 }
    },
    {
      "unit_id": "inner_jianye_advisor",
      "name": "Inner Jianye Advisor",
      "class_id": "military_advisor",
      "team": "enemy",
      "level": 54,
      "pos": [13, 5],
      "skills": ["blaze", "great_mend"],
      "base": { "hp": 128, "mp": 112, "atk": 8, "def": 35, "int": 57, "agi": 30 }
    },
    {
      "unit_id": "inner_jianye_spear_north",
      "name": "Inner Jianye Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 54,
      "pos": [12, 3],
      "base": { "hp": 130, "atk": 55, "def": 45 }
    },
    {
      "unit_id": "inner_jianye_spear_south",
      "name": "Inner Jianye Spear",
      "class_id": "infantry",
      "team": "enemy",
      "level": 54,
      "pos": [12, 5],
      "base": { "hp": 130, "atk": 55, "def": 45 }
    },
    {
      "unit_id": "inner_jianye_arrow_boat",
      "name": "Inner Jianye Arrow Boat",
      "class_id": "marksman",
      "team": "enemy",
      "move_type": "water",
      "level": 54,
      "pos": [5, 5],
      "base": { "hp": 122, "atk": 56, "def": 31, "agi": 43 }
    }
  ],
  "events": [
    {
      "id": "opening",
      "once": true,
      "when": { "type": "battle_start" },
      "actions": [
        { "type": "log", "text": "Wei presses into inner Jianye after containing the capital sortie." }
      ]
    },
    {
      "id": "opening_dialogue",
      "once": true,
      "when": { "type": "battle_begin" },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The roads inside Jianye are narrower, but the enemy has fewer places left to trade for time." },
            { "speaker": "Guo Jia", "text": "An inner city fights with doors, canals, and fear. Strip one away and the rest answer loudly." },
            { "speaker": "Cao Cao", "text": "Then take the inner road. The capital has hidden behind enough answers." }
          ]
        }
      ]
    },
    {
      "id": "contained_sortie_orders_advance",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 2, "campaign_flags": { "contained_capital_sortie": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Xiahou Yuan", "text": "The contained sortie left the road clean behind us. Our rear guard can hold while the front advances." },
            { "speaker": "Cao Cao", "text": "An army that trusts its rear can make the road ahead smaller for the enemy." }
          ]
        }
      ]
    },
    {
      "id": "inner_pressure_draws_canal_boat",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 2, "campaign_flags": { "pressed_inner_jianye": true } },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Inner Jianye Commander", "text": "Wei presses inside the city. Send the canal boat before their front can settle." },
            { "speaker": "Zhang He", "text": "They still trust the water. Take away that trust and the street line weakens." }
          ]
        },
        {
          "type": "spawn_deployment",
          "deployment": {
            "unit_id": "wu_inner_canal_boat",
            "name": "Wu Inner Canal Boat",
            "class_id": "champion",
            "team": "enemy",
            "move_type": "water",
            "level": 54,
            "pos": [5, 3],
            "base": { "hp": 120, "atk": 51, "def": 35, "agi": 41 }
          }
        }
      ]
    },
    {
      "id": "turn_4_inner_line_tightens",
      "once": true,
      "when": { "type": "turn_start", "team": "enemy", "turn": 4 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Inner Jianye Advisor", "text": "Tighten the inner line. If Wei claims this road, the command district becomes the next battlefield." },
            { "speaker": "Guo Jia", "text": "They defend a district by admitting the city is already a battlefield." }
          ]
        }
      ]
    },
    {
      "id": "inner_jianye_line_reached",
      "once": true,
      "when": { "type": "unit_reaches_tile", "team": "player", "officer_ids": ["cao_cao"], "pos": [10, 4] },
      "actions": [
        {
          "type": "set_objective",
          "victory": "The inner Jianye line is reached. Defeat the inner city commander.",
          "defeat": "Cao Cao is defeated or the battle reaches Turn 18."
        },
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Cao", "text": "This is inner Jianye's line. Break its commander and the command district must show its hand." },
            { "speaker": "Inner Jianye Commander", "text": "A city still has teeth after the road is bloodied." }
          ]
        },
        {
          "type": "spawn_deployments",
          "deployments": [
            {
              "unit_id": "inner_jianye_last_guard",
              "name": "Inner Jianye Last Guard",
              "class_id": "guard_captain",
              "team": "enemy",
              "level": 54,
              "pos": [16, 4],
              "base": { "hp": 138, "atk": 55, "def": 48 }
            },
            {
              "unit_id": "inner_jianye_crossbow_boat",
              "name": "Inner Jianye Crossbow Boat",
              "class_id": "marksman",
              "team": "enemy",
              "move_type": "water",
              "level": 54,
              "pos": [10, 1],
              "base": { "hp": 114, "atk": 54, "def": 28, "agi": 42 }
            }
          ]
        }
      ]
    },
    {
      "id": "turn_9_inner_line_breaks",
      "once": true,
      "when": { "type": "turn_start", "team": "player", "turn": 9 },
      "actions": [
        {
          "type": "dialogue",
          "lines": [
            { "speaker": "Cao Ren", "text": "The inner line is breaking. The defenders are still fierce, but their orders no longer arrive together." },
            { "speaker": "Cao Cao", "text": "Then make each order answer alone." }
          ]
        }
      ]
    }
  ],
  "rewards": {
    "gold": 11200,
    "items": ["bean", "wine", "war_drum"]
  },
  "post_battle_dialogue": [
    { "speaker": "Guo Jia", "text": "Inner Jianye is open enough to shape the next blow. Wei can secure the city road, or drive Wu toward a final stand before its command district." },
    { "speaker": "Cao Ren", "text": "Secure the inner road and the army controls the city's breath. Force the last stand and Wu spends what strength remains." },
    { "speaker": "Cao Cao", "text": "A city with no calm road left must choose where its courage dies." }
  ],
  "post_battle_choices": [
    {
      "id": "secure_inner_jianye",
      "label": "Secure Inner City",
      "description": "Cao Cao secures inner Jianye's road before the final command district battle.",
      "set_flags": { "secured_inner_jianye": true, "forced_wu_last_stand": false },
      "gold": 2100,
      "items": ["imperial_seal"]
    },
    {
      "id": "force_wu_last_stand",
      "label": "Force Last Stand",
      "description": "Cao Cao drives Wu toward a final stand before the command district can recover.",
      "set_flags": { "secured_inner_jianye": false, "forced_wu_last_stand": true },
      "gold": 1900,
      "items": ["war_drum"]
    }
  ]
}
