Fixed namespace issues. Removed static

This commit is contained in:
Glowbal 2015-05-14 17:36:58 +02:00
parent 4dbacbead8
commit a48b6c9426
5 changed files with 107 additions and 109 deletions

View File

@ -1,13 +1,11 @@
#include "DamageType.h" #include "DamageType.h"
using namespace ace::medical; ace::medical::injuries::DamageType::DamageType(std::string aTypeName, double minimalLethalDamage, double minDamage, double maxDamage)
injuries::DamageType::DamageType(std::string aTypeName, double minimalLethalDamage, double minDamage, double maxDamage)
: typeName(aTypeName), minLethalDamage(minimalLethalDamage), minDamageThreshold(minDamage), maxDamageThreshold(maxDamage) : typeName(aTypeName), minLethalDamage(minimalLethalDamage), minDamageThreshold(minDamage), maxDamageThreshold(maxDamage)
{ {
} }
injuries::DamageType::~DamageType() ace::medical::injuries::DamageType::~DamageType()
{ {
} }

View File

@ -1,14 +1,13 @@
#include "InjuryType.h" #include "InjuryType.h"
#include "DamageType.h" #include "DamageType.h"
using namespace ace::medical;
injuries::InjuryType::InjuryType(signed int anId, const std::string& aClassname, std::vector<std::string>& allowedSelections, double theBloodLoss, double thePain, double minimumDamage, double maximumDamage, std::vector<std::string>& possibleCauses, std::string& aDisplayname) ace::medical::injuries::InjuryType::InjuryType(signed int anId, const std::string& aClassname, std::vector<std::string>& allowedSelections, double theBloodLoss, double thePain, double minimumDamage, double maximumDamage, std::vector<std::string>& possibleCauses, std::string& aDisplayname)
: ID(anId), className(aClassname), selections(allowedSelections), bloodLoss(theBloodLoss), pain(thePain), minDamage(minimumDamage), maxDamage(maximumDamage), causes(possibleCauses), displayName(aDisplayname) : ID(anId), className(aClassname), selections(allowedSelections), bloodLoss(theBloodLoss), pain(thePain), minDamage(minimumDamage), maxDamage(maximumDamage), causes(possibleCauses), displayName(aDisplayname)
{ {
} }
injuries::InjuryType::~InjuryType() ace::medical::injuries::InjuryType::~InjuryType()
{ {
} }

View File

@ -1,17 +1,15 @@
#include "OpenWound.h" #include "OpenWound.h"
#include <sstream> #include <sstream>
using namespace ace::medical; ace::medical::injuries::OpenWound::OpenWound(double anID, double aBodyPart, double bloodloss) : classID(anID), bodyPart(aBodyPart), bloodlossRate(bloodloss)
injuries::OpenWound::OpenWound(double anID, double aBodyPart, double bloodloss) : classID(anID), bodyPart(aBodyPart), bloodlossRate(bloodloss)
{ {
} }
injuries::OpenWound::~OpenWound() ace::medical::injuries::OpenWound::~OpenWound()
{ {
} }
std::string injuries::OpenWound::AsString() std::string ace::medical::injuries::OpenWound::AsString()
{ {
std::stringstream stream; std::stringstream stream;
stream << classID << "," << bodyPart << "," << 1 << "," << bloodlossRate; stream << classID << "," << bodyPart << "," << 1 << "," << bloodlossRate;

View File

@ -4,7 +4,8 @@
#include "InjuryType.h" #include "InjuryType.h"
#include <sstream> #include <sstream>
using namespace ace::medical; namespace ace {
namespace medical {
handleDamage::handleDamage() handleDamage::handleDamage()
{ {
@ -15,13 +16,13 @@ handleDamage::~handleDamage()
{ {
} }
/* static */ std::vector<injuries::OpenWound> handleDamage::HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage) /* static */ std::vector<ace::medical::injuries::OpenWound> handleDamage::HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage)
{ {
std::vector<injuries::OpenWound> wounds; std::vector<ace::medical::injuries::OpenWound> wounds;
int selectionN = SelectionToNumber(selectionName); int selectionN = SelectionToNumber(selectionName);
if (selectionN >= 0) if (selectionN >= 0)
{ {
std::vector<std::shared_ptr<injuries::InjuryType>> injuryTypeInfo = GetInjuryInfoFor(typeOfDamage); // std::vector<std::shared_ptr<ace::medical::injuries::InjuryType>> injuryTypeInfo = GetInjuryInfoFor(typeOfDamage);
} }
return wounds; return wounds;
@ -36,12 +37,12 @@ handleDamage::~handleDamage()
double minDamageThreshold = std::stod(input[2]); double minDamageThreshold = std::stod(input[2]);
double maxDamageThreshold = std::stod(input[3]); double maxDamageThreshold = std::stod(input[3]);
std::shared_ptr<injuries::DamageType> type(new injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, maxDamageThreshold)); std::shared_ptr<ace::medical::injuries::DamageType> type(new ace::medical::injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, maxDamageThreshold));
damageTypes.push_back(type); damageTypes.push_back(type);
} }
} }
/* static */ void handleDamage::AddInjuryType(const std::vector<std::string>& input) void handleDamage::AddInjuryType(const std::vector<std::string>& input)
{ {
if (input.size() == 9) if (input.size() == 9)
{ {
@ -58,17 +59,17 @@ handleDamage::~handleDamage()
std::vector<std::string> possibleCauses; // input[7]; std::vector<std::string> possibleCauses; // input[7];
std::string displayName = input[8]; std::string displayName = input[8];
std::shared_ptr<injuries::InjuryType> type(new injuries::InjuryType(ID, className, allowedSelections, bloodLoss, pain, minDamage, maxDamage, possibleCauses, displayName)); std::shared_ptr<ace::medical::injuries::InjuryType> type(new ace::medical::injuries::InjuryType(ID, className, allowedSelections, bloodLoss, pain, minDamage, maxDamage, possibleCauses, displayName));
injuryTypes.push_back(type); injuryTypes.push_back(type);
} }
} }
/* static */ void handleDamage::FinalizeDefinitions() void handleDamage::FinalizeDefinitions()
{ {
// We are finding all possible injuries for a specific damage type here, so we don't have to figure that out at a later stage. // We are finding all possible injuries for a specific damage type here, so we don't have to figure that out at a later stage.
for each (std::shared_ptr<injuries::DamageType> damageType in damageTypes) for each (std::shared_ptr<ace::medical::injuries::DamageType> damageType in damageTypes)
{ {
for each (std::shared_ptr<injuries::InjuryType> injuryType in injuryTypes) for each (std::shared_ptr<ace::medical::injuries::InjuryType> injuryType in injuryTypes)
{ {
if (find(injuryType->causes.begin(), injuryType->causes.end(), damageType->typeName) != injuryType->causes.end()) if (find(injuryType->causes.begin(), injuryType->causes.end(), damageType->typeName) != injuryType->causes.end())
{ {
@ -78,7 +79,7 @@ handleDamage::~handleDamage()
} }
} }
/* static */ int SelectionToNumber(const std::string& selectionName) int handleDamage::SelectionToNumber(const std::string& selectionName)
{ {
// TODO use dynamic selections instead // TODO use dynamic selections instead
std::vector<std::string> selections = { "head", "body", "hand_l", "hand_r", "leg_l", "leg_r" }; std::vector<std::string> selections = { "head", "body", "hand_l", "hand_r", "leg_l", "leg_r" };
@ -92,3 +93,5 @@ handleDamage::~handleDamage()
return -1; // TODO throw exception return -1; // TODO throw exception
} }
} }
}
}

View File

@ -21,46 +21,46 @@ namespace ace {
/** /**
* *
*/ */
static std::vector<injuries::OpenWound> HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage); std::vector<ace::medical::injuries::OpenWound> HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage);
/** /**
* *
*/ */
static void AddDamageType(const std::vector<std::string>& sqfDamageTypeDefinition); void AddDamageType(const std::vector<std::string>& sqfDamageTypeDefinition);
/** /**
* *
*/ */
static void AddInjuryType(const std::vector<std::string>& sqfInjuryDefinition); void AddInjuryType(const std::vector<std::string>& sqfInjuryDefinition);
/** /**
* *
*/ */
static std::string SetInjuryTypeData(const std::string& data); //static std::string SetInjuryTypeData(const std::string& data);
/** /**
* *
*/ */
static int SelectionToNumber(const std::string& selectionName); int SelectionToNumber(const std::string& selectionName);
/** /**
* *
*/ */
static std::vector<std::shared_ptr<injuries::InjuryType>> GetInjuryInfoFor(const std::string& damageType); //static std::vector<std::shared_ptr<ace::medical::injuries::InjuryType>> GetInjuryInfoFor(const std::string& damageType);
/** /**
* *
*/ */
static void FinalizeDefinitions(); void FinalizeDefinitions();
private: private:
handleDamage(); handleDamage();
static std::vector<std::shared_ptr<injuries::DamageType>> damageTypes; std::vector<std::shared_ptr<ace::medical::injuries::DamageType>> damageTypes;
static std::vector<std::shared_ptr<injuries::InjuryType>> injuryTypes; std::vector<std::shared_ptr<ace::medical::injuries::InjuryType>> injuryTypes;
static std::vector<std::string> selections; std::vector<std::string> selections;
static std::vector<std::string> hitPoints; std::vector<std::string> hitPoints;
}; };
} }
} }