Skip to content
Snippets Groups Projects
Commit 393dc733 authored by Max Cherris's avatar Max Cherris
Browse files

add first rendition of combat system

parent de1bea63
Branches
No related tags found
1 merge request!15Merge units into main
......@@ -62,4 +62,22 @@ void Unit::render(Engine &engine, int scale) {
}
}
//Placeholder
MatchupTabel damageMatrix = {
{ UnitId::INFANTRY, {{ UnitId::INFANTRY, 50 }, { UnitId::TANK, 5 }} },
{ UnitId::TANK, {{ UnitId::INFANTRY, 90 }, { UnitId::TANK, 50 }} }
};
void Unit::attack(Unit &enemy) {
//Start Attack: choose the appropriate weapon:
int offDamage = damageMatrix[this->id][enemy->id] * ((this->health)/(this->max_health));
int defDamage = damageMatrix[this->id][enemy->id] * ((enemy->health)/(enemy->max_health));
enemy->health = enemy->health - offDamage;
if(enemy->health > 0) {
this->health = this->health - defDamage;
}
}
} // namespace advanced_wars
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment