/tower-strike

:tokyo_tower: Simulator of a game where the goal is to kill the enemies by using a tower

Primary LanguageJavaScript

Tower Strike Logo

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:

  1. first column - is the enemy name.
  2. second column - is the initial distance to the tower.
  3. 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

Start a game

Development stage

$ nvm exec 0.12.14 gulp
$ nvm exec 0.12.14 npm run dev

Testing

$ make test
$ npm test
Spec Reporter

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:

doc Example of HTML code generated
dot
landing
list
nyan
tap
json JSON data
json-stream JSON-stream data
markdown Markdown file
base
min
progress
html
xunit

Useful Info


📆 Developed on June 2017