Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 1.7 KB

README.md

File metadata and controls

39 lines (23 loc) · 1.7 KB

Dice Game Readme

Functionality

This JavaScript file implements a simple two-player dice game. Here's a brief overview of the functionality:

  1. Rolling Dice: Players can take turns rolling a six-sided die by clicking the "Roll Dice" button (btnRoll). The rolled number is displayed, and if it's not 1, the current player's score accumulates. If it is 1, the turn switches to the other player.

  2. Hold Score: Players can click the "Hold" button (btnHold) to add their current score to their total score. If a player's total score reaches or exceeds 100, they win the game.

  3. New Game: Clicking the "New Game" button (btnNew) resets the game, scores, and player turns.

Features

  • Player Switching: The game automatically switches to the next player after rolling a 1 or clicking "Hold."

  • Dynamic UI: The active player is visually highlighted, and the dice image changes based on the rolled number.

  • Winning Animation: When a player wins, their section is highlighted as the winner, and the game stops accepting further input.

  • Responsive Design: The game has a clean and responsive design using CSS classes to update player and dice visuals.

  • Scalable Scores: The game can be easily modified for different winning score thresholds or additional players.

How to Play

  1. Open the HTML file in a web browser.
  2. Click the "Roll Dice" button to roll the dice.
  3. If you roll a 1, your turn ends. Otherwise, your current score accumulates.
  4. Click "Hold" to add your current score to your total score.
  5. The first player to reach or exceed 100 points wins.
  6. Click "New Game" to start a new game.

Enjoy the game!

Author : @ahmadfed

My LinkedIn
@ahmadfed