Files
2nd/10_Wiki/Topic_Programming/Frontend/Kingdom vs. Kingdom Events (KvK).md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +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 패턴