Simulate a game where the goal is to kill the enemies by using a tower.
Task definition
Problem Statement
Program should simulate a game where the goal is to kill the enemies by using a tower. Need to kill enemies as fast as possible. At each turn first the tower fires one time then each enemy moves to the tower. If an enemy reaches the tower you lose.
Input
The first line is the tower's firing range. Each next line represents an enemy:
- first column - is the enemy name.
- second column - is the initial distance to the tower.
- the last one - is the unit speed.
Output
- At each turn program should inform if the tower killed the enemy unit.
- At the end program should inform if the tower WINS or LOSES and the count of played turns.
- In case of lost the program should calculate the minimal tower's firing distance to win the game against same set of enemies.
Samples
Sample Input
50m
BotA 100m 10m
BotB 50m 20m
BotC 30m 20m
Sample Output
Firing range is 50m
Turn 1: Kill BotC at 30m
Turn 2: Kill BotB at 30m
Turn 6: Kill BotA at 50m
Tower WIN in 6 turn(s)
Tasks checklist
- Create programmatic simulator for this game that has to be executed on node.js@0.12.14
- Feel free to write unit tests
- NPM available libs are: lodash, winston, chance, should, mocha
Prerequisites
Install NVM
To install or update nvm, you can use the install script using cURL:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
or Wget:
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Install node.js v0.12.14
$ nvm install 0.12.14
Setup
Get sources
$ git clone https://github.com/tbaltrushaitis/tower-strike.git
Install dependencies and build
$ cd tower-strike
$ npm i
Usage
Standard execution
$ nvm exec 0.12.14 npm start
Development stage
$ nvm exec 0.12.14 gulp
$ nvm exec 0.12.14 npm run dev
Testing
$ make test
$ npm test
List of available reporters
Reporter for tests could be changed in mocha options file by changing the value of --reporter
parameter.
Here is the list of possible values for the option:
json
JSON datajson-stream
JSON-stream datamarkdown
Markdown filebase
min
progress
html
xunit
Useful Info
- GitHub / Basic writing and formatting syntax
- BitBucket / Markdown Howto
- Docker / Creating an Automated Build
- Docker / Linking containers
- Docker / Cross-host linking containers
📆 Developed on June 2017
♏