Kapow! The Last Tank Standing - NodeJS Tech Challenge
Gear up for a true battle! Your task is to create a simulator where a group of tanks will fight each other until there is only one left. They all have the same stats, but… there is some critical damage involved.
Are you up for the challenge? We are eager to find out! Let the games (pun intended) begin.
Our tanks really want to create a show for everyone, but they are waiting for their commander’s instructions, a.k.a YOU. Also, their code was completely reset due to a 404 Error (classic, we know), so you need to rewrite it from scratch.
There’s a bright side, only n<=5 units registered to take part in this special occasion, and they were all created by the same manufacturer, meaning that their stats are alike.
Even though they are identical when it comes to their properties, you should give each of them a unique name. That’s also how we will know who is the victor, right? The rest of the values are predefined, and look like this:
rechargeTime (1000 * health/100)
criticalChance (10 - health/10)
*The content in the brackets shows the defined values, and how to calculate the given property
Being a heavy tank and plus having to shoot at the same time can be exhausting. That’s why our little war machines need to fill their rechargeTime completely before attacking again. Since they hold no special grudges against other contestants, every attack will be completely random, at a unit that has health > 0.
Even though in anime serials such as Dragon Ball villains happily wait for their opponents to boost their power level and attack, our tanks are nothing like it. They have no chill and will shoot at another unit that is being offensive at the same time. Put in simpler words: every tank can be attacked while attacking. Anime creators - take notes!
Do you like the lottery? Our competitors sure do! In fact, they play it every time they are about to attack, and in their world, it’s called CriticalChance. With every shot, they have the chance to increase its impact, by the following condition: CriticalChance >= random (0, 100);
If it’s met, the unit’s damage while attacking is doubled. The fight lasts until, as the title says, there is only one tank standing! In other words, as long as there is a minimum of two units left - the epic showdown should continue.
Oh, yeah, almost forgot about the secret command that starts the code: node index.js That’s about it! We hope that you will have fun and are looking forward to seeing how it all plays out (pun absolutely intended, once again).
You can contact us here for any questions about the challenge, or perhaps something else related to our scope of work. Good luck, and KAPOW!