Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Added condition to check first UMLjointTime #73

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions UnitClasses/HealableUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../Game.h"

HealableUnit::HealableUnit(Game* gamePtr, UnitType unitType, double health, int power, int attackCapacity)
: Unit(gamePtr, unitType, health, power, attackCapacity), UMLjoinTime(0)
: Unit(gamePtr, unitType, health, power, attackCapacity), UMLjoinTime(-1)
{}

bool HealableUnit::needsHeal() const
Expand All @@ -22,6 +22,11 @@ bool HealableUnit::isHealed() const
return health > initialHealth * 0.2;
}

bool HealableUnit::hasBeenInUMLbefore() const
{
return UMLjoinTime != -1;
}

void HealableUnit::receiveHeal(double UHP)
{
// Infected units get twice the time to get healed
Expand All @@ -33,5 +38,7 @@ void HealableUnit::receiveHeal(double UHP)

void HealableUnit::setUMLjoinTime(int UMLjoinTime)
{
this->UMLjoinTime = UMLjoinTime;
}
// Check if it's the unit first time to join uml
if (!hasBeenInUMLbefore())
this->UMLjoinTime = UMLjoinTime;
}
1 change: 1 addition & 0 deletions UnitClasses/HealableUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class HealableUnit: public Unit
bool needsHeal() const; // Check if the unit is eligible for healing
bool hasWaitedForTooLong() const; // Decides whether to kill or heal the unit based on its wait time
bool isHealed() const; // Checks if the unit's health has increased enough
bool hasBeenInUMLbefore() const; // Check if it has been inside uml before or not

void receiveHeal(double); // Increase the health of the unit by "UHP"

Expand Down
Loading