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

Refactor simple issues

Such as typos, unused includes and unnecessary comments
parent 1c234b83
Branches
No related tags found
1 merge request!15Merge units into main
#include "unit.hpp"
#include <tinyxml2.h>
#include <iostream>
namespace advanced_wars
......@@ -70,9 +69,6 @@ namespace advanced_wars
}
}
MatchupTabel damageMatrix;
std::vector<Unit*> units;
void Unit::attack(Unit& enemy) {
int offDamage = 50;
......@@ -119,17 +115,8 @@ Features:
this->is_selected = true;
std::cout << "I am selected!!" << std::endl;
/*
for (Unit *unit : units)
{
if (!inRange(unit))
{
unit->state = advanced_wars::UnitState::UNAVAILABLE;
};
}
*/
//make move range calc
break;
case SDL_BUTTON_RIGHT:
......@@ -180,50 +167,5 @@ Features:
}
return false;
}
/*
void Unit::loadXML(const char *filename)
{
tinyxml2::XMLDocument doc;
if (doc.LoadFile(filename) != tinyxml2::XML_SUCCESS)
{
std::cerr << "Fehler beim Laden der XML-Datei!" << std::endl;
return;
}
MatchupTabel damageMatrix;
tinyxml2::XMLElement *unitElement = doc.FirstChildElement("Units")->FirstChildElement("Unit");
// get all Units
while (unitElement)
{
const u_int8_t UnitId = unitElement->Attribute("id");
std::unordered_map<u_int8_t, int> attackValues;
tinyxml2::XMLElement *attackElement = unitElement->FirstChildElement("Attack");
// get all attack-values
while (attackElement)
{
tinyxml2::XMLElement *attackTypeElement = attackElement->FirstChildElement();
while (attackTypeElement)
{
UnitId Unit_Id = static_cast<UnitId> attackTypeElement->Name(); // wenn das geht kauf ich maggus sein kochbuch
int attackValue = attackTypeElement->IntText();
attackValues[Unit_Id] = attackValue;
attackTypeElement = attackTypeElement->NextSiblingElement();
}
}
damageMatrix[unitElement][attackValues];
unitElement = unitElement->NextSiblingElement("Unit");
}
}
*/
} // namespace advanced_wars
\ No newline at end of file
......@@ -55,8 +55,7 @@ enum class MovementType {
LANDER = 5,
};
//Fill the MatchupTabel
using MatchupTabel = std::unordered_map<u_int8_t, std::unordered_map<u_int8_t, int>>;
using MatchupTable = std::unordered_map<u_int8_t, std::unordered_map<u_int8_t, int>>;
class Unit {
public:
......@@ -104,13 +103,12 @@ public:
*/
void calculate_movement();
/*
Load the XML and iterate over the entire datastructure
For every Unit, get Unit_Id and create a map for Unit_Id -> {Unit_Id -> damageType}
This function fills the MatchupTable
It would be better if this table would be placed in the level
*/
void loadXML(const char* filename);
void fill_matchupTable();
/*
This function will be called by an external event-handler, eventually.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment