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

Add comments to signal future progress

parent 393dc733
Branches
No related tags found
1 merge request!15Merge units into main
......@@ -4,7 +4,7 @@ namespace advanced_wars {
Unit::Unit(int x, int y, UnitFaction faction, UnitId id, UnitState state)
: x(x), y(y), faction(faction), id(id), state(state) {
health = max_health;
};
void Unit::render(Engine &engine, int scale) {
......@@ -64,11 +64,15 @@ 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 }} }
{ UnitId::INFANTRY, {{ UnitId::INFANTRY, 50 }, { UnitId::MEDIUM_TANK, 5 }} },
{ UnitId::MEDIUM_TANK, {{ UnitId::INFANTRY, 90 }, { UnitId::MEDIUM_TANK, 50 }} }
};
void Unit::attack(Unit &enemy) {
//checks to be run:
//is unit in range?
//has unit not attacked this turn?
//Start Attack: choose the appropriate weapon:
int offDamage = damageMatrix[this->id][enemy->id] * ((this->health)/(this->max_health));
......@@ -77,6 +81,11 @@ void Unit::attack(Unit &enemy) {
enemy->health = enemy->health - offDamage;
if(enemy->health > 0) {
this->health = this->health - defDamage;
if(this->health <= 0) {
this->~Unit();
}
} else {
enemy->~Unit();
}
}
......
......@@ -60,10 +60,12 @@ using MatchupTabel = std::unordered_map<u_int8_t, std::unordered_map<u_int8_t, i
class Unit {
public:
Unit(int x, int y, UnitFaction faction, UnitId id, UnitState state);
~Unit() {
//Assuming that the destruktion of a unit triggers events
}
void render(Engine &engine, int scale);
/*
The attacker will move towards the defender and thus initiate combat
@params Takes a reference to the defender
......@@ -86,8 +88,6 @@ public:
*/
void calculate_movement();
private:
int x;
int y;
......@@ -96,7 +96,8 @@ private:
UnitId id;
UnitState state;
int health;
int health; //health equals max_health at construction
int max_health; // max_health required for damage_scaling
int range;
int fuel;
int max_fuel;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment