How felcardoso/highdice works
Project type & purpose (what you’re diagramming)
This is a static, single-page browser game (HTML/CSS/vanilla JS) that runs entirely on the client. There is no backend, no database, and no network API layer. The “system” is therefore the browser runtime + UI + game engine/state + rendering/events, optionally packaged as a PWA via the web manifest.
Primary purpose: implement a single-player, poker-like dice game loop (roll/select/reroll/play/score/upgrade/reset) with stateful progression (stake, levels, hand upgrades) and UI updates.
File-structure-driven architecture (how the repo maps to components)
From the tree:
• index.html
The UI shell: DOM structure, buttons, dice area, HUD, log console, modal(s) for upgrades.
• css/styles.css
Pure presentation layer (layout, styling, responsive, visual states like “selected die”).
• js/game.js
The entire application logic: state model, rules, scoring, rendering functions, DOM event handlers.
• assets/site.webmanifest
• release/v1.0A.md
DOM/UI → event handlers → game engine/state → scoring/evaluation → render/update DOM.
README-derived “key runtime symbols” (what to highlight)
js/game.js contains the core modules/classes and major flows:
• Core classes (domain model / state):
• Dice — represents individual die state/value/selection.
• Table — evaluates hands and likely holds dice/hand evaluation logic.
• Run — orchestrates a “run” / progression loop (stake, plays, rerolls, level-up).
• Player — player progression, hand levels/upgrades, resources.
• Constants (rules configuration):
• HAND_SCORE, HAND_NAMES, HAND_ORDER — scoring tables and ordering.
• Rendering/UI functions:
• renderHUD, renderDice — translate current state into DOM.
• Actions / controllers:
• rerollSelected, playOnce, openUpgradeModal, resetGame — user-triggered operations that mutate state then trigger re-render/logging.
UI/DOM Layer (index.html)
• Dice display area
• HUD (stake/plays/rerolls/level)
• Controls (Reroll, Play Hand, Hand Upgrade, Reset)
• Console log
• Upgrade modal
Event Handling / Controller (in game.js)
• Click die (toggle select)
• Click reroll (rerollSelected)
• Click play (playOnce)
• Click upgrade (openUpgradeModal)
• Click reset (resetGame)
Game State / Domain Model (in game.js)
• Run (game loop/progression; stake depletion → level up)
• Player (hand levels, upgrades)
• Dice (values, selected flags)
• Table (hand evaluation methods; “rules engine”)
Rules & Scoring Configuration (in game.js)
• HAND_SCORE, HAND_ORDER, HAND_NAMES
Rendering (in game.js)
• renderDice (state → dice DOM)
• renderHUD (state → HUD DOM)
• (If present) log rendering / append-to-console
PWA Manifest (assets/site.webmanifest)
• Relationship to browser install prompt (no runtime logic, but include as packaging)
• User → UI/DOM (clicks)
• UI/DOM → Controller actions (event listeners call functions)
• Controller actions → Game State (mutations: reroll changes dice values; playOnce updates stake, plays; upgrades modify player hand levels)
• Controller actions → Table (hand evaluation) (compute hand type, apply HAND_SCORE)
• Controller actions → Rules constants (read scoring tables)
• Controller actions → Rendering (after state change, call renderHUD/renderDice, update log)
• Rendering → UI/DOM (DOM updates)
Architectural patterns/design principles present
• Domain model vs. rendering: stateful classes (Run/Player/Table/Dice) vs render* functions.
• Controller/action functions as the boundary between UI events and state mutation.
• Configuration-driven scoring: scoring tables (HAND_SCORE) as declarative rule configuration.
• Single-threaded event loop: everything runs in the browser JS runtime; no concurrency model besides standard event callbacks.
Relevant technologies
• HTML5 + CSS3 + Vanilla JavaScript
• Browser DOM APIs
• PWA manifest (install metadata)
renderHUD(), renderDice(), append log
To maximize clarity:
• Clear labels:
• Use concrete names: renderHUD, renderDice, rerollSelected, playOnce, Run, Player, Table, Dice, HAND_SCORE.
• Blue rectangles: UI/DOM components
• Green rectangles: Domain model/state (Run/Player/Dice/Table)
• Orange rectangles: Controllers/actions (playOnce, rerollSelected, etc.)
• Gray rectangles: Config/constants (HAND_SCORE)
• Purple rectangle: Rendering functions
Practical “don’t overthink it” decomposition (recommended final component list)
• UI Shell (index.html)
• Styles (css/styles.css)
• Controllers:
• rerollSelected
• playOnce
• openUpgradeModal
• resetGame
• “die click handler” (toggle select)
• Rendering:
• renderHUD
• renderDice
• “log renderer” (if present)
• Domain Model:
• Run
• Player
• Table
• Dice
• Rules/Config:
• HAND_SCORE
• HAND_NAMES
• HAND_ORDER
• PWA:
• assets/site.webmanifest
• Hosting/Execution Environment:
• Browser JS runtime / DOM
• (Optional) GitHub Pages static hosting