All MicroEvals
Warhammer 40k tabletop
Create MicroEval

Warhammer 40k tabletop

Warhammer

Prompt

Build a complete, playable single-file web application (HTML, CSS, and JavaScript) that simulates a simplified tactical tabletop wargame inspired by Warhammer 40k (10th Edition style), allowing a human player (Space Marines) to play a full match against an AI opponent (Orks) on a 2D top-down battlefield. ### 1. Visuals & Battlefield Layout - **Canvas/Board:** Render a top-down 2D tabletop board (e.g., 44" x 30" scaled to pixels, roughly 880x600px) using HTML5 Canvas or SVG with a subtle grid overlay. - **Terrain:** Place 4–6 distinct terrain pieces (Ruins/Buildings) on the board that block Line of Sight (LoS) and provide a Cover bonus (+1 to armor saves) when a unit is partially obscured or within terrain bounds. - **Objectives:** Place 3 circular objective markers (Left, Center, Right) with a 3-inch capture radius. Controlling objectives at the end of a turn awards Victory Points (VP). - **UI Layout:** Clean, dark sci-fi HUD. Include a top bar showing Battle Round (1 to 3), Current Phase, Active Player, and VP Score. Include a right-hand sidebar displaying the selected unit's datasheet stats, weapon profiles, an action button ("Next Phase"), and a scrollable, color-coded Combat Log detailing dice rolls. ### 2. Factions & Unit Datasheets Create 3 distinct squads per side, rendered as colored circular tokens with health bars and model counts: **Player (Space Marines - Blue):** 1. **Intercessor Squad** (5 models | M: 6" | T: 4 | Sv: 3+ | W: 2 | OC: 2) - *Ranged:* Bolt Rifle (Range: 24" | A: 2 | BS: 3+ | S: 4 | AP: -1 | D: 1) - *Melee:* Close Combat Weapon (A: 3 | WS: 3+ | S: 4 | AP: 0 | D: 1) 2. **Hellblaster Squad** (5 models | M: 6" | T: 4 | Sv: 3+ | W: 2 | OC: 2) - *Ranged:* Plasma Incinerator (Range: 24" | A: 2 | BS: 3+ | S: 7 | AP: -2 | D: 2) - *Melee:* Close Combat Weapon (A: 3 | WS: 3+ | S: 4 | AP: 0 | D: 1) 3. **Redemptor Dreadnought** (1 model | M: 8" | T: 10 | Sv: 2+ | W: 12 | OC: 4) - *Ranged:* Macro Plasma (Range: 36" | A: 4 | BS: 3+ | S: 8 | AP: -3 | D: 2) - *Melee:* Redemptor Fist (A: 5 | WS: 3+ | S: 12 | AP: -2 | D: 3) **AI Opponent (Orks - Red/Green):** 1. **Ork Boyz** (10 models | M: 6" | T: 5 | Sv: 5+ | W: 1 | OC: 2) - *Ranged:* Slugga (Range: 12" | A: 1 | BS: 5+ | S: 4 | AP: 0 | D: 1) - *Melee:* Choppa (A: 3 | WS: 3+ | S: 4 | AP: -1 | D: 1) 2. **Ork Nobz** (5 models | M: 6" | T: 5 | Sv: 4+ | W: 2 | OC: 1) - *Ranged:* Slugga (Range: 12" | A: 1 | BS: 5+ | S: 4 | AP: 0 | D: 1) - *Melee:* Power Klaw (A: 3 | WS: 4+ | S: 9 | AP: -2 | D: 2) 3. **Deff Dread** (1 model | M: 8" | T: 9 | Sv: 2+ | W: 8 | OC: 3) - *Ranged:* Big Shoota (Range: 36" | A: 3 | BS: 5+ | S: 5 | AP: 0 | D: 1) - *Melee:* Dread Klaw (A: 4 | WS: 3+ | S: 10 | AP: -2 | D: 3) ### 3. Core Turn Sequence & Rules Engine Implement a strict 4-phase turn structure per player across 3 Battle Rounds: 1. **Movement Phase:** Click a unit to display a translucent movement radius ring (equal to its `M` stat in inches, scaled to pixels). Click within the ring (avoiding terrain collision) to move the unit. Units cannot move within 1" of enemy units (Engagement Range). 2. **Shooting Phase:** Click an eligible unit to see its weapon range ring and valid targets (checking distance and raycast Line of Sight around terrain). Clicking a valid enemy triggers the full tabletop attack sequence: - **Hit Roll:** Roll `A` d6s per surviving model; >= BS hits. - **Wound Roll:** Compare Strength (S) vs Toughness (T) using standard tabletop thresholds (S >= 2xT = 2+, S > T = 3+, S == T = 4+, S < T = 5+, S <= 0.5xT = 6+). - **Save Roll:** Defender rolls d6; must meet or beat `Sv - AP` (modified by +1 if in Cover). - **Damage:** Failed saves inflict `D` damage, removing models when their individual Wounds (`W`) reach 0. 3. **Charge Phase:** Units within 12" of an enemy (that did not advance/fall back) can attempt a Charge. Roll 2d6; if the result (in inches) reaches Engagement Range (within 1") of the target, snap the charging unit into base contact. 4. **Fight Phase:** All units in Engagement Range (within 1" of an enemy) fight using their Melee weapon profile. Charging units fight first. ### 4. AI Opponent Logic When it is the AI's turn, execute its phases automatically with a brief delay (e.g., 600ms per action) so the human player can watch the AI's moves and read the combat log: - **Movement:** Move units toward the nearest uncaptured Objective Marker or nearest high-value enemy unit while respecting movement limits and terrain. - **Shooting:** Target the highest-threat enemy unit within range and Line of Sight. - **Charge & Fight:** Attempt charges against any enemy unit within 9" and resolve melee attacks. ### 5. Technical Constraints - Output everything in a single, self-contained HTML file with embedded CSS and vanilla JS (no external assets, image URLs, or CDN dependencies that might fail to load). - Ensure zero syntax errors, crisp visual feedback (animated laser/tracer lines when shooting, floating damage numbers on hit), and a clean "Game Over / Victory" modal at the end of Round 3.

A system prompt was added to support web rendering

Drag to resize

Response not available

Drag to resize
Drag to resize