No description
  • JavaScript 98.2%
  • Python 1.7%
Find a file
og_arist0tle 772679930b
All checks were successful
build-and-publish / test (push) Successful in 5s
build-and-publish / build (push) Successful in 5s
feat: replace triangle spire sprite with rendered gothic tower asset
public/assets/spire.png — 477x1576 RGBA, the manually-cleaned sprite
  (replaces the flat triangle placeholder drawn at Renderer.js step 9).

src/render/Renderer.js:
  - Constructor: spireSprite = new Image() + spireSpriteReady flag + load
    listener. Preload is non-blocking.
  - Step 9 (spire body): drawImage with screen-relative geometry.
    spireH = minDim * (0.20 + tier * 0.03), spireW = spireH * 477/1576.
    No hardcoded pixel values — same relative size on phone/laptop/desktop.
  - Beacon centered at (cx, cy) — the sprite is anchored so its beacon
    lands on the gameplay center (halo / lantern orbit / weapon origin
    / enemy pathing target). All those systems continue to treat (cx, cy)
    as their reference point, so the beacon is now the visual heart of
    every gameplay system. Beacon measured at y=84/1576 in the PNG, so
    BEACON_Y_FRACTION = 0.0533 from sprite top.
  - Step 9c (tip ball): REMOVED — the sprite's lantern cage + beacon
    glow are baked in. The legacy tip-ball would overlay the sprite's
    own beacon with a flat-color circle. Removed (not just hidden)
    because the draw call is dead code.
  - Fallback: while sprite loads, draws a triangle with apex at (cx, cy)
    and base at (cx, cy + spireH) — same beacon-at-center approximation
    so the canvas is never blank during boot.

src/main.js:
  - One line after Renderer construction:
    renderer.spireSprite.src = './public/assets/spire.png'
  Kicks off the async preload. Listener in the constructor flips
  spireSpriteReady = true on completion.

Verified: node --check passes on both files. Asset serves 200 OK from
the http server.
2026-08-15 13:54:48 -04:00
.forgejo/workflows ci: node-based test image (checkout action needs node in the job container) 2026-08-06 17:05:24 +00:00
public/assets feat: replace triangle spire sprite with rendered gothic tower asset 2026-08-15 13:54:48 -04:00
src feat: replace triangle spire sprite with rendered gothic tower asset 2026-08-15 13:54:48 -04:00
tasks spire-defense: dockerize + forgejo build pipeline 2026-08-06 17:04:34 +00:00
tests fix: migrate unlockedSystems.combo for saves that predate the T7:25 unlock 2026-08-14 21:03:03 -04:00
vendor Pull idle-scaffold infrastructure modules into spire-defense 2026-07-25 13:41:06 -04:00
.dockerignore spire-defense: dockerize + forgejo build pipeline 2026-08-06 17:04:34 +00:00
.gitignore spire-defense: dockerize + forgejo build pipeline 2026-08-06 17:04:34 +00:00
.tier2-milestones.md Add Tier 2 milestone TODO tracker (.tier2-milestones.md) 2026-07-28 20:32:32 -04:00
DESIGN.md Remove lantern range upgrade, slow speed scaling (25% -> 10% / level) 2026-07-25 17:55:09 -04:00
docker-compose.yml spire-defense: dockerize + forgejo build pipeline 2026-08-06 17:04:34 +00:00
Dockerfile spire-defense: dockerize + forgejo build pipeline 2026-08-06 17:04:34 +00:00
index.html Force no-cache in index.html so Safari revalidates on each load 2026-07-26 15:02:05 -04:00
KNOWN_ISSUES.md spire-defense: add KNOWN_ISSUES.md for investigated-but-not-fixed bugs 2026-08-05 17:22:31 -04:00
README.md spire-defense: README overhaul (download, install, run, test, accurate architecture) 2026-08-05 21:47:21 -04:00
server.py spire-defense: dockerize + forgejo build pipeline 2026-08-06 17:04:34 +00:00

Spire-Defense

Idle incremental top-down tower defense. Defend the central spire from progressive waves of enemies using oil-powered light-based weapons. When the beacon dies, prestige for gems.

Status: Playable. Tier-5 ship cycle complete (stable-chain06 + 34 follow-on commits through 2026-08-05). Latest build: 1ed26b5 HEAD / 1fa9a6b BUILD_VERSION (chain gem-market weapon-gate fix). Latest stable tag: see git tag -l 'stable-*' | tail.

For the canonical design contract, see DESIGN.md. For investigated-but-not-fixed bugs and open by-design issues, see KNOWN_ISSUES.md.


Features

  • 6 weapons across 5 tiers (Beacon Pulse, Lantern, Signal Flare, Spire Zone at T1-T4; Chain Lightning at T4; Homing Missiles at T5), each with 3-5 shop sub-cards + gem-find economy cards.
  • 6+ enemy archetypes (common, strong, hybrid, ranged + bosses, Sapper, Splitter/Splinter cascade) with per-archetype damage profiles and behavior flags (oil-cut aura, split-on-death, star-shape cascade).
  • Wave progression through 10 tiers; bosses spawn at every 25th wave; tier-picker UI at Beacon Out.
  • Gem Market (prestige shop) with weapon-specific gates: weapon gem-market upgrades lock until the weapon itself is purchased in the shop.
  • Milestone system that grows the spire, unlocks weapons, gates sub-cards, and surfaces 1K/1.6K/2.5K/4.2K/5K wave rewards.
  • Save system with multi-slot picker (delete + load + create), 24h offline-progress cap, and player-name hashing for the diagnostic log.
  • Dev panel for testing: game speed (1x-10x), wave skip, dev 10x, orient-log diagnostic dump, test-save mid-game state, RUN buttons.
  • Server-side diagnostic logging (POST /api/log, key-gated GET /api/log/query + /api/log/stats) for replaying real sessions.
  • No npm install. Pure browser ES modules + Python stdlib server.

Requirements

  • Python 3.11+ for server.py (uses stdlib only — http.server, sqlite3, hmac, hashlib).
  • Node 24+ for running the test suite (tests/*.mjs).
  • Playwright (already installed at node_modules/) — the test suite drives the game in headless Chromium.
  • A modern browser (Chrome, Firefox, Safari). iOS Safari supported (the server.py no-cache headers fix the Safari caching issue).

Download

# SSH (preferred — matches the project's remote)
git clone ssh://git@git.hl.c4.io/og_arist0tle/Spire-Defense.git
cd Spire-Defense

# Or HTTPS if SSH isn't set up
git clone https://git.hl.c4.io/og_arist0tle/Spire-Defense.git
cd Spire-Defense

Install

The game has no npm dependencies for runtime — only Playwright for tests. If you only want to play:

# nothing to install

If you want to run the test suite:

# playwright is already in node_modules; if you cloned fresh,
# install once:
npm install

Run

# Start the static-file server. Default port is 8768.
python3 server.py

# To bind to a different port:
python3 server.py 9000

Then open http://localhost:8768/index.html in your browser.

Important: do NOT use python3 -m http.server — it does not send the Cache-Control: no-store headers that iOS Safari needs to revalidate JS modules on each load. Without server.py, Safari will cache stale module versions between sessions.

Running on iOS / mobile

The project is developed against iOS Safari via the Tailscale mesh (ogflow.taile970c7.ts.net → local 8768). To test on a real device:

  1. Run python3 server.py on the dev machine (it binds 0.0.0.0 by default).
  2. From the iPhone, navigate to the dev machine's LAN IP on port 8768, or via Tailscale serve for HTTPS.

Test

The test suite lives in tests/ and is documented in tests/README.md.

# Run a single test:
node tests/chain-gem-market-gate-verify.mjs

# Most tests follow the naming convention
# tests/<feature>-verify.mjs (regression / ship verification) or
# tests/<feature>_audit.mjs (audits a class of consistency).

The verify tests assert specific gameplay invariants and produce screenshots at /tmp/screen-*.png for Discord attachment. The audit tests catch drift across the milestone → catalog → shop-item consistency surfaces.


Architecture

index.html                Entry document (cache-control meta + viewport)
server.py                 Static-file server with no-cache headers +
                          POST /api/log + GET /api/log/query (key-gated)
DESIGN.md                 Canonical design contract (OG-arbitrated)
KNOWN_ISSUES.md           Investigated-but-not-fixed issues
tests/                    Regression + audit tests (Playwright)

src/
├── main.js               Bootstrap (canvas, state, loop, HUD, dev panel)
├── canvas.js             DPR-aware canvas sizing
├── core/
│   ├── GameState.js      Single source of truth for game state
│   ├── GameLoop.js       rAF + fixed-timestep accumulator
│   ├── EventBus.js       Pub/sub bus for cross-system messaging
│   └── build.js          BUILD_VERSION constant (git rev-parse short)
├── beacon/
│   └── Beacon.js         Spire HP, damage intake, death → run end
├── wave/
│   └── WaveManager.js    Spawn loop, boss cadence, wave persist,
│                          Sapper aura, Splitter cascade
├── enemies/
│   ├── Enemy.js          Per-enemy state + takeDamage + emit enemyDied
│   └── EnemyArchetype.js Profile-driven archetype data (HP, speed,
│                          damage profile, behavior flags, render shape)
├── weapons/
│   ├── Weapon.js         Base class (active / purchased / tick gating)
│   ├── BeaconPulse.js    T1 — pulse damage at intervals
│   ├── Lantern.js        T1 — orbiting contact-DPS
│   ├── SignalFlare.js    T2 — gem-find focused
│   ├── SpireZone.js      T2 — spire-zone aura
│   ├── ChainLightning.js T4 — probabilistic chain jumps
│   └── HomingMissiles.js T5 — homing projectiles + splash
├── economy/
│   └── gemMarket.js      Gem Market card roster + per-card gates
├── shop/
│   └── catalog.js        Base upgrades + tier unlock rules
├── milestones/
│   ├── MilestoneSystem.js  Tier-scoped milestone triggers
│   └── tierTemplates.js    Wave/threshold template data
├── prestige/
│   ├── PrestigeManager.js  Beacon-Out → Begin New Run flow
│   └── PrestigeLayer.js    Cross-run gem economy
├── saves/
│   └── SaveManager.js    localStorage persistence + wipe + listPlayers
├── offline/
│   └── OfflineSimulator.js  24h offline cap + resume
├── automation/
│   └── AutoBuyManager.js   Autobuy slots
├── render/
│   └── Renderer.js       Canvas2D render pipeline + pathForShape
├── ui/
│   ├── Shop.js           Per-weapon sub-card UI + Buy handlers
│   ├── GemMarket.js      Gem Market modal (locks via weaponGateMessage)
│   ├── PlayerPicker.js   Multi-slot picker (delete, create, load)
│   ├── DevPanel.js       Dev speed / wave skip / orient-log / test-save
│   ├── TierPicker.js     Post-Beacon-Out tier picker (1-10)
│   ├── Hud.js            Resource bar + beacon HP + wave counter
│   └── ...
├── diagnostics/
│   └── DiagnosticLogger.js  Client-side batching → POST /api/log
├── debug/
│   ├── orientLog.js      Device ground-truth capture (orient-bug)
│   └── testSave.js       Mid-game state seeder (dev panel button)
└── utils/
    └── Decimal.js        break_infinity.js-compatible Decimal wrapper

Development

Game speed + dev panel

The dev panel (top-left, hidden behind a button in production builds) exposes:

  • Game speed 1x / 2x / 5x / 10x (per-step unlocks are gated by the gameSpeed gem-market card — wave 5000 in N tiers).
  • Dev speed multiplier devSpeedMult — independent of game speed, used for headless regression tests and OG-style rapid-iteration debugging.
  • Wave skip — jump forward by N waves.
  • Orient-log button — POST to /api/orient-log, dumps current canvas + viewport + state to orient-log-<timestamp>.json for iOS Safari orient-bug diagnosis.
  • Test save button — seeds a mid-game state (Tier 2 wave 50) for orient-bug repro.

Build markers

src/core/build.js exports BUILD_VERSION (a short git SHA, manually bumped in a separate commit per build-protocol rule 50) and BUILD_TIME (ISO timestamp). The HUD badge reads these — if BUILD_VERSION and git rev-parse --short HEAD differ, the marker is one commit behind HEAD by design.

Build protocol

This project follows a strict build protocol documented in ~/.hermes/skills/game-dev/spire-defense-build-protocol/. Highlights:

  • Rule 48: verify-before-shipping-link. Every commit with new content ships with a tests/<feature>-verify.mjs regression test.
  • Rule 50: build-marker chicken-and-egg. Bump BUILD_VERSION in a separate commit after the feature lands.
  • Rule 76: reconciliation paths must mirror display paths. Every reader of upgrade keys uses the same getUpgradeLevel u:-prefix fallback.
  • Rule 88: stop + incremental-progress + diagnostic-log-dump when local repro doesn't match device. (orient-bug lesson).

Known issues

See KNOWN_ISSUES.md for the running list. Most notable:

  • Landscape play area is ~30% smaller than portrait (by design — see issue #1). The play-area formula uses min(innerWidth, innerHeight) × 0.45, which is smaller in landscape. Not fixed because OG chose to document rather than rebalance.

Roadmap

The 2026-08-05 Tier-5 ship cycle is complete. Future cycles (Tier-6+) follow the same shape:

  1. One new weapon + one new enemy per tier (per OG rule).
  2. Verify-before-shipping-link (rule 48).
  3. BUILD_VERSION bump in a separate commit (rule 50).
  4. Update KNOWN_ISSUES.md for any investigated-but-not-fixed issues.

License

MIT (per the build-protocol SKILL.md header).