Pig Game is a simple, yet fun dice game where players take turns to roll a single die as many times as they wish, or until they roll a 1. The aim of the game is to score 100 points before your opponent does.
Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player decides to "hold":
- If the player rolls a 1, they score nothing and it becomes the next player's turn.
- If the player rolls any other number, it is added to their turn total and the player's turn continues.
- If a player chooses to "hold", their turn total is added to their score, and it becomes the next player's turn.
The first player to score 100 or more points wins.
The project is structured into two main files: index.html
and script.js
.
This file contains the HTML structure of the game. It includes sections for each player, displaying their total score and current score. It also includes buttons for rolling the dice, holding the current score, and starting a new game.
This file contains the JavaScript logic of the game. It includes functions for initializing the game, switching the active player, rolling the dice, and holding the current score.
To play the game, simply open the index.html
file in your web browser.
Unfortunately, screenshots are not available in this markdown file. Please refer to the index.html
file to view the game interface.
Contributions are welcome! Please feel free to submit a pull request.
This project is open source, feel free to use, modify, and distribute the code.