---
id: wiki-2026-0508-defense-buildings
title: Defense Buildings
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [defense-buildings, turrets, base-defense, towers]
duplicate_of: none
source_trust_level: A
confidence_score: 0.88
verification_status: applied
tags: [game-design, base-defense, war-commander, td, layout]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: design-doc
  framework: base-defense-system
---

# Defense Buildings

## 매 한 줄
> **"매 enemy unit 의 attack path 를 차단 / damage 하는 매 stationary structure"**. 매 War Commander / Boom Beach / Clash of Clans 등 매 PvP-base genre 의 핵심. 매 range, DPS, targeting priority, 매 splash 의 매 4 dimension 으로 매 design space 의 정의.

## 매 핵심

### 매 분류
- **Single-target**: 매 high-DPS, anti-elite.
- **Splash**: 매 area damage, anti-swarm.
- **Anti-air**: 매 ground 무력, air specialized.
- **Slowing/EMP**: 매 control, debuff.
- **Long-range arty**: 매 sniper, low fire-rate.

### 매 design dimension
- **Range**: 매 4-12 tiles.
- **DPS**: 매 normalized to HP per second of typical attacker.
- **Reload**: 매 fire-rate gating splash power.
- **Cost / build-time**: 매 economic gating.

### 매 응용
1. 매 base layout design.
2. 매 kill-zone funneling.
3. 매 PvP attack-meta counter.

## 💻 패턴

### Defense building targeting
```typescript
type TargetPriority = "closest" | "lowest_hp" | "highest_dps" | "first_in_range";

class DefenseTower {
  pos: Vec2;
  range: number;
  dps: number;
  reload_ms: number;
  last_fire = 0;
  priority: TargetPriority = "closest";
  splash_radius = 0;
  anti_air = false;

  selectTarget(units: Unit[]): Unit | null {
    const inRange = units.filter(u => {
      if (u.is_air && !this.anti_air) return false;
      return distance(this.pos, u.pos) <= this.range;
    });
    if (!inRange.length) return null;

    switch (this.priority) {
      case "closest":
        return minBy(inRange, u => distance(this.pos, u.pos));
      case "lowest_hp":
        return minBy(inRange, u => u.hp);
      case "highest_dps":
        return maxBy(inRange, u => u.dps);
      case "first_in_range":
        return inRange[0];
    }
  }

  tryFire(now: number, targets: Unit[]) {
    if (now - this.last_fire < this.reload_ms) return;
    const target = this.selectTarget(targets);
    if (!target) return;
    this.last_fire = now;
    if (this.splash_radius > 0) {
      this.applySplash(target.pos, targets);
    } else {
      target.hp -= this.dps * (this.reload_ms / 1000);
    }
  }

  applySplash(center: Vec2, units: Unit[]) {
    for (const u of units) {
      if (distance(center, u.pos) <= this.splash_radius) {
        u.hp -= this.dps * (this.reload_ms / 1000);
      }
    }
  }
}
```

### Layout coverage analysis
```typescript
function coverageMap(towers: DefenseTower[], grid_size: number): number[][] {
  const map = Array.from({ length: grid_size }, () => Array(grid_size).fill(0));
  for (let y = 0; y < grid_size; y++) {
    for (let x = 0; x < grid_size; x++) {
      for (const t of towers) {
        if (distance(t.pos, { x, y }) <= t.range) {
          map[y][x]++;
        }
      }
    }
  }
  return map;
}

function uncoveredCells(map: number[][]): number {
  return map.flat().filter(v => v === 0).length;
}
```

### Funnel / kill-zone scorer
```typescript
function killZoneScore(layout: Layout, attacker_paths: Path[]): number {
  let score = 0;
  for (const path of attacker_paths) {
    const exposure = path.cells.map(c => layout.coverage_at(c)).reduce((a, b) => a + b, 0);
    score += exposure / path.cells.length;
  }
  return score / attacker_paths.length;
}
```

### Build-cost optimizer
```typescript
function maximizeDefense(
  budget: number,
  available: DefenseTower[],
  slot_count: number
): DefenseTower[] {
  // Greedy by DPS-per-cost
  const sorted = [...available].sort((a, b) => (b.dps / b.cost) - (a.dps / a.cost));
  const picks: DefenseTower[] = [];
  let remaining = budget;
  for (const t of sorted) {
    if (picks.length >= slot_count) break;
    if (t.cost <= remaining) {
      picks.push(t);
      remaining -= t.cost;
    }
  }
  return picks;
}
```

### Defensive synergy buff
```typescript
function applySynergyBuffs(towers: DefenseTower[]) {
  for (const t of towers) {
    const nearby = towers.filter(o => o !== t && distance(t.pos, o.pos) <= 3);
    if (nearby.some(o => o.type === "command_post")) {
      t.dps *= 1.15; // +15% DPS near command post
    }
    if (nearby.length >= 2) {
      t.range *= 1.10; // +10% range when clustered
    }
  }
}
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 swarm meta | Splash 우선, anti-air balanced |
| 매 elite-stack meta | Single-target high-DPS |
| 매 air meta | Anti-air dominant + long-range |
| 매 mixed | Layered ring (long-range outer, splash inner) |

**기본값**: 매 layered defense + 매 funnel kill-zone + 매 anti-air coverage 70%+.

## 🔗 Graph
- 부모: [[Base-Layouts-and-Kill-Zones]] · [[Tower-Defense]]
- 변형: [[Anti-Air-and-Anti-Ground-Combat]] · [[Damage-Resistance-Platforms]]
- 응용: [[Combat_Balance_Buff]] · [[Evolution-of-the-War-Commander-Combat-Ecosystem]]
- Adjacent: [[Jailing]]

## 🤖 LLM 활용
**언제**: 매 base layout design, defense balance, kill-zone analysis.
**언제 X**: 매 PvE-only — 매 design tension 부족.

## ❌ 안티패턴
- **Single-type spam**: 매 splash-only → 매 elite stomp.
- **No anti-air**: 매 air comp 의 free win.
- **Edge-only**: 매 funnel 무시 → 매 trivial path.
- **Range overlap 의 부족**: 매 isolated tower → 매 single-target focus 의 free kill.

## 🧪 검증 / 중복
- Verified (Clash of Clans / Boom Beach / War Commander community meta 2024-2025).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — defense buildings targeting + layout + synergy patterns. |
