Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crisu83/knights
A game of knights.
https://github.com/crisu83/knights
Last synced: 23 days ago
JSON representation
A game of knights.
- Host: GitHub
- URL: https://github.com/crisu83/knights
- Owner: crisu83
- Created: 2022-05-23T11:29:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-25T06:15:48.000Z (over 2 years ago)
- Last Synced: 2024-12-17T12:08:04.478Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Knights
A game of knights.
## Usage
Clone or download the repository.
Install dependencies:
```sh
yarn install
```Start the game:
```sh
yarn start
```## Output
Example output for a single game:
```sh
K1 hits K2 for 5 damage
K2 hits K3 for 2 damage
K3 hits K4 for 4 damage
K4 hits K5 for 5 damage
K5 hits K6 for 4 damage
K6 hits K1 for 1 damage
K1 hits K2 for 2 damage
K2 hits K3 for 3 damage
K3 hits K4 for 5 damage
K4 hits K5 for 1 damage
K5 hits K6 for 1 damage
K6 hits K1 for 3 damage
K1 hits K2 for 1 damage
K2 hits K3 for 5 damage
K3 is defeated
K4 hits K5 for 6 damage
K5 is defeated
K6 hits K1 for 1 damage
K1 hits K2 for 4 damage
K2 is defeated
K4 hits K6 for 6 damage
K6 is defeated
K1 hits K4 for 2 damage
K4 is defeated
K1 is the winner
```## Improvement ideas
* [x] Make constants easy to configure
* [x] Create a factory for knights
* [x] Do not mutate the knights array
* [x] Use a range for the damage
* [ ] Add some unit tests
* [ ] Introduce a game state
* [ ] Use reducers to update the game state
* [ ] Use a linked list for the knights
* [ ] Move knight logic into a `Knight` class