Hello.
Currently i get codes like this:
"Scroll down if your not interested in code and its unneeded to know it"
void Buffs::Burn(HeroUnit& unit, Buff& objBuf, Battle& objBat)
{
int amount = objBuf.amount - unit.battMA;
if(amount < 1)
amount = 1;
//Check if damage kills unit
if(unit.battHP - amount < 1)
{
//Kill unit
unit.battHP = 0;
unit.isAlive = false;
unit.battRT = 0;
objBat.ChatPushBackText(unit.name + " burned for " + std::to_string(amount) + " and died in process", sf::Color(255,150,150));
}
else
{
//Damage
unit.battHP -= amount;
objBat.ChatPushBackText(unit.name + " burned for " + std::to_string(amount), sf::Color(255,150,150));
}
}
void Buffs::Burn(EnemyUnit& unit, Buff& objBuf, Battle& objBat)
{
int amount = objBuf.amount - unit.battMA;
if(amount < 1)
amount = 1;
//Check if damage kills unit
if(unit.battHP - amount < 1)
{
//Kill unit
unit.battHP = 0;
unit.isAlive = false;
unit.battRT = 0;
objBat.ChatPushBackText(unit.name + " burned for " + std::to_string(amount) + " and died in process", sf::Color(255,150,150));
}
else
{
//Damage
unit.battHP -= amount;
objBat.ChatPushBackText(unit.name + " burned for " + std::to_string(amount), sf::Color(255,150,150));
}
}
Exact code, but takes different unit parameter.
The different between units is sever, but they share same attributes used for/in battle.
I would use "inheritance" (structure units to inherit a "UnitBattleData" class).
But how to call a function when its parameters is "void Battle(UnitBattleData& good_unit, UnitBattleData& evil_unit);" and i have object of "HeroUnit good_unit" "EvilUnit evil_unit".






