Files
2nd/10_Wiki/Topics/Domain_Programming/Frontend/Kingdom vs. Kingdom Events (KvK).md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

5.0 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-kingdom-vs-kingdom-events-kvk Kingdom vs. Kingdom Events (KvK) 10_Wiki/Topics verified self
KvK
Kingdom vs Kingdom
Cross-Kingdom Event
none B 0.85 applied
game
mmo
rok
event
server-architecture
2026-05-10 pending
language framework
TypeScript GameServer

Kingdom vs. Kingdom Events (KvK)

매 한 줄

"매 KvK 는 multiple game shards (kingdoms) 가 same world map 에서 PvP 경쟁하는 cross-shard event". Rise of Kingdoms (Lilith), Lords Mobile (IGG), Evony 등 4X mobile MMO 의 핵심 monetization driver. 매 frontend 입장에서 cross-kingdom matching, real-time map sync, leaderboard 가 challenge.

매 핵심

매 매칭 단계

  • Pre-KvK: 매 power matchmaking — 매 비슷한 power 의 kingdoms 매칭.
  • Lost Kingdom (LK) / Pass 1: 매 kingdoms 가 새 map 에 spawn.
  • Main KvK (Pass 2-3): 매 holy site / pass / altar 점령.
  • Post-KvK: 매 reward distribution, kingdom power recompute.

매 frontend challenge

  • Map sync: 매 1000+ players concurrent → 매 viewport-based delta sync.
  • Leaderboard: 매 cross-shard aggregation — 매 5-min cache.
  • Chat: 매 kingdom-only / alliance-only / cross-kingdom 매 channel 분리.
  • Replay: 매 battle replay — 매 server-authoritative state log.

매 응용

  1. Rise of Kingdoms — 매 8 kingdom matchup, 70-day season.
  2. Lords Mobile Kingdom Vs Kingdom.
  3. Evony Server War.
  4. Top War: Battle Game — 매 SvS (Server vs Server).

💻 패턴

Cross-shard matchmaking

// 매 power-bracket 매칭
async function matchKvK(season: number) {
  const kingdoms = await db.kingdoms
    .where("season", season)
    .where("optedIn", true)
    .orderBy("totalPower", "desc")
    .get();

  // 매 8 kingdoms / bracket
  const brackets: Kingdom[][] = [];
  for (let i = 0; i < kingdoms.length; i += 8) {
    brackets.push(kingdoms.slice(i, i + 8));
  }
  return brackets;
}

Viewport-based map sync (frontend)

class KvKMap {
  private wsUrl = "wss://kvk.game/v1/map";

  subscribe(viewport: Bounds) {
    this.ws.send({
      op: "subscribe",
      bbox: viewport,           // 매 viewport bbox 만 sync
      lod: viewport.zoom < 5 ? "tile" : "unit",
    });
  }

  onMessage({ delta }: { delta: TileDelta[] }) {
    delta.forEach((d) => this.applyTile(d));
  }
}

Leaderboard cache pattern

// 매 cross-shard aggregation 비쌈 → 매 Redis sorted set + 5min TTL
async function getKvKLeaderboard(seasonId: string) {
  const cached = await redis.get(`kvk:lb:${seasonId}`);
  if (cached) return JSON.parse(cached);

  const data = await aggregateAcrossShards(seasonId); // 매 fan-out
  await redis.setex(`kvk:lb:${seasonId}`, 300, JSON.stringify(data));
  return data;
}

Real-time troop march UI

function MarchPath({ march }: { march: MarchEvent }) {
  const [progress, setProgress] = useState(0);
  useEffect(() => {
    const start = march.startedAt;
    const dur = march.duration;
    const id = requestAnimationFrame(function tick() {
      setProgress(Math.min(1, (Date.now() - start) / dur));
      if (Date.now() < start + dur) requestAnimationFrame(tick);
    });
    return () => cancelAnimationFrame(id);
  }, [march]);

  return <Line from={march.from} to={march.to} t={progress} />;
}

Holy site capture timer (server-authoritative)

interface HolySiteState {
  ownerKingdom: number | null;
  captureProgress: number; // 0-1
  contestedBy: number[];
  lastUpdate: number; // server timestamp
}

// 매 client 는 server time 만 신뢰
function renderProgress(state: HolySiteState, serverTime: number) {
  const elapsed = serverTime - state.lastUpdate;
  return state.captureProgress + (elapsed / CAPTURE_DURATION);
}

매 결정 기준

Aspect Approach
Matchmaking Power-bracket, opt-in
Map sync Viewport delta (not full snapshot)
Leaderboard Cached aggregation, 5min TTL
Anti-cheat Server-authoritative timer + replay log
Chat Channel separation, rate limit per kingdom

기본값: server-authoritative state, viewport-based delta, Redis-cached leaderboard.

🔗 Graph

🤖 LLM 활용

언제: KvK frontend 설계, cross-shard matchmaking, leaderboard cache 설계. 언제 X: 매 single-shard PvP — 매 별도 패턴.

안티패턴

  • Full map snapshot per tick: 매 BW 폭증 — 매 viewport delta 가 정답.
  • Client-side capture timer: 매 cheat 가능 — 매 server-authoritative.
  • Real-time leaderboard: 매 fan-out 비용 → 매 5min cache 충분.

🧪 검증 / 중복

  • Verified (Lilith Games KvK 매커니즘 documentation, 4X mobile game 공통 패턴).
  • 신뢰도 B (game-specific).

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — KvK matchmaking + frontend sync 패턴