Home assessment
This is a take home assessment for the interviews.
This example is based on the Cones of Dunshire, a fictional game from the tv show Parks Recreation.
In this game, a character contains both health and strength. Each time they take a turn, they lose 1 health and 1 strength. Simple enough.
Of course, it's not that simple.
- health and strength can't drop below 0 and strength can't increase above 20.
- some characters have special behaviors:
The Ledgerman is just the score keeper and never gains or loses health and strength.
The Maverick is the offensive role and has these unique traits:
- can gain a maximum of 40 strength
- gains 2 strength if health is 5 or less
- gains 1 strength if health is between 6 and 10
The Alchemist is very bespoke:
- if strength is less than 10, they gain 1 strength
- if the Alchemist ends the turn with 5 health or less, they lose all their strength
- the Alchemist has an additional property, vilesAvailable, which is equal to 1/2 their end of turn strength (rounded up).
Since we all have many other priorities in life, please timebox this assignment to no more than a few hours.
Your objective is to add a new character, the "Farmer".
The Farmer of course has special behaviors:
- loses 2 health each turn
- loses 1 strength each turn
- loses an additional strength if health is at or below 5
- when health reaches 0, strength gets set to 20. Why? Because "it's about the cones"
These test cases have already been written for you on lines 394-496. Please remove the skip
on lines 394 and make them green!
Of course, refactoring cones-of-dunshire.ts
is suggested. We are fans of both object oriented and functional styles of programming, take your pick!
Once completed, please create a private GitHub repo and invite brandonwestcott as a contributor.
Install dependencies
yarn install
yarn run test