8000 GitHub - crisu83/knights: A game of knights.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

crisu83/knights

Repository files navigation

Knights

A game of knights.

Usage

Clone or download the repository.

Install dependencies:

yarn install

Start the game:

yarn start

Output

Example output for a single game:

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

  • Make constants easy to configure
  • Create a factory for knights
  • Do not mutate the knights array
  • 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

About

A game of knights.

Resources

Stars

Watchers

Forks

0