How amankr01/rock-paper-scissor-game works
Project type and purpose
• This is a single-page, frontend-only web game (“Rock Paper Scissors”) implemented purely in HTML, CSS, and JavaScript.
• There is no backend or database; all logic and state live in the browser.
File structure
• index.html: hosts the DOM skeleton (buttons, score display, result area).
• rps.js: contains the core game logic (event handlers, random computer choice, score tracking, DOM updates).
• README.md: explains features, tech stack, and usage.
README for additional insights
• Confirms the tech stack (HTML5, CSS3, JS).
• Describes gameplay flow and features (clean UI, randomized computer move, score tracking).
• No mention of external APIs or services.
a. Main components
• UI Layer (index.html + style.css)
• Game Logic Layer (rps.js)
• Browser Runtime (JavaScript engine + DOM API + Event Loop)
• Game State (in-memory JS objects for scores, selections)
b. Relationships & interactions
1. User clicks one of the three buttons in the UI.
2. Browser propagates a click event to rps.js’s event handler.
3. Game Logic determines the computer’s choice (random function).
4. Logic updates the in-memory game state (scores, last result).
5. Logic invokes DOM APIs to update the view (scoreboard, result text).
c. Architectural patterns / design principles
• MVC‐style separation (View=HTML/CSS, Controller=event handlers in rps.js, Model=JS objects holding scores and selections).
• Single responsibility per file: styling, markup, behavior are clearly partitioned.
d. Key technologies & libraries
• Native DOM API for rendering and event handling
• JavaScript’s Math.random() for computer choice
• CSS Flexbox/Grid (if used) for responsive layout