tyrants-edge/CLAUDE.md

2.7 KiB
Raw Blame History

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Running the Game

./start_web.sh        # Starts Python HTTP server on port 8000

Open http://localhost:8000 in a browser. No build step — all source is raw ES modules. Changes take effect on page refresh.

There are no tests or linting configured.

Architecture

Tyrants Edge is a browser-based deck-building card game built with Phaser 3 (v3.60.0, loaded via CDN). Vanilla JavaScript only — no bundler, no npm.

Scene Flow

BootSceneMainMenuScene → any of:

  • BattleScene — 1v1 card battles vs AI
  • DeckBuilderScene — customize decks (1 commander + 310 assault cards)
  • CampaignScene → launches BattleScene with mission config
  • CollectionScene, StoreScene, FusionScene

BootScene loads all JSON data (data/*.json) and card art images, then instantiates global managers stored in Phaser's game registry.

Global Managers (accessed via this.registry.get(...))

Key Class Purpose
cardManager CardManager Card definitions and instance creation
packManager PackManager Booster pack opening logic
save SaveManager localStorage persistence (versioned)
missions raw JSON Campaign mission data

Combat System (src/combat/)

  • CombatEngine.js — Core battle loop. Turn phases: Draw → Deploy → Activation → Rupture → Jam → Commander Skills → Card Attacks → Cleanup. Uses event queue for animation sequencing.
  • SkillProcessor.js — Resolves card skill effects (strike, swipe, pierce, rupture, berserk, siege, rally, heal, protect, jam, enfeeble, weaken, etc.) with triggers: on_turn_start, on_attack, on_kill.
  • CombatAI.js — AI opponent decision-making.

Combat uses RNG.js (seeded random) for deterministic, replayable battles.

Card Rendering

CardObject.js handles all visual card rendering (stats, art, skills). BattleField.js manages the 4-lane battle arena layout.

Data Model

All game content is JSON in data/:

  • cards.json — Card stats, faction, rarity, skills
  • packs.json — Booster pack definitions
  • missions.json — Campaign missions with enemy decks and rewards
  • skills.json — Skill reference (skills are also inline in cards)

Card factions: imperial, raider, bloodthirsty, xeno, righteous Card types: commander, assault Rarities: common, rare, epic, legendary

Save Format (localStorage)

{
  "version": 1,
  "gold": 400,
  "collection": { "cardId": count },
  "decks": [],
  "campaignProgress": { "completedMissions": [], "currentChapter": 1 },
  "starterDeckReceived": false
}