I am assigned to solve a task that demonstrates a realistic problem in C++.
A laser cannon may have the following skill :
Recoil Armor :
HP reduces 10% then damage taken reduces xx%. When HP is 0, this hero can still fight for xx seconds. |
So assume I have a number of soldiers (for example, 20 DPS, 20 damage per attack) fight against a heavily upgraded laser cannon which has 3888 HP. We can assume the laser cannon never attacks. The laser cannon is equipped with "Recoil Armor" skill as the following :
HP reduces 10% then damage taken reduces 3.8%. When HP is 0, this hero can still fight for 3.6 seconds. |
When the laser cannon's HP runs out, invincibility is activated. If the laser cannon continue to get hit after 3.6 seconds of invincibility has passed, the laser cannon is destroyed.
So I have to calculate exactly how many times we need to hit the laser cannon over and over and the time needed to destroy this cannon. All soldiers don't necessarily attack all at the same time, those who come first will attack first and repeat. I need to count the number of hits, total HP dealt and time needed to destroy the building.
The purpose of this task is to measure the effectiveness of the "Recoil Armor" skill when it is applied to laser cannons. I would appreciate it if anyone has some great inspiration how to implement this. It is done in console application, and information should present as fast as possible as soon as the calculation starts.