Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bernatmarcilla/vidchain-test
https://github.com/bernatmarcilla/vidchain-test
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bernatmarcilla/vidchain-test
- Owner: bernatmarcilla
- Created: 2023-04-28T16:09:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-29T21:32:26.000Z (over 1 year ago)
- Last Synced: 2024-09-11T15:48:06.814Z (2 months ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# VIDchain-test
### Install Dependencies
```
npm install
```### Run a 2 players game
Simple script to play a 2 players game waiting for a `enter` key input to roll the dice on each turn.
```
npm run play
```### Run tests
```
npm test
```## SnakesAndLadders Implementation
The solution consists of two classes: `GameBoard` and `Dice`.
### GameBoard
`GameBoard` represents the game board.
`GameBoard` properties:
- `currentPosition`: The current position of the player's token on the board.
- `gameWon`: Whether the game has been won or not.
- `finalSquare`: The final square on the board (square 100).`GameBoard` methods:
- `constructor()`: Initializes currentPosition to 1 and gameWon to false.
- `moveToken(numSquares: number)`: Moves the player's token by the specified number of squares. Checks whether the move is valid and the game has been won with the specified move.### Dice
`Dice` represents a standard six-sided die.
`Dice` methods:
- `roll(): number`: Rolls the dice and returns a random number from 1 to 6.