From eb2383a6f076d07287ab2c2e3367166b849d1f5c Mon Sep 17 00:00:00 2001 From: Glowbal Date: Thu, 14 May 2015 18:56:23 +0200 Subject: [PATCH] tabs --- extensions/medical/DamageType.h | 4 +- extensions/medical/InjuryType.h | 2 +- extensions/medical/OpenWound.cpp | 2 +- extensions/medical/OpenWound.h | 4 +- extensions/medical/handleDamage.cpp | 272 ++++++++++++++-------------- extensions/medical/handleDamage.h | 16 +- 6 files changed, 150 insertions(+), 150 deletions(-) diff --git a/extensions/medical/DamageType.h b/extensions/medical/DamageType.h index de8e73a07d..3cd9fb41d0 100644 --- a/extensions/medical/DamageType.h +++ b/extensions/medical/DamageType.h @@ -17,9 +17,9 @@ namespace ace { std::string typeName; double minLethalDamage; std::vector minDamageThreshold; - std::vector amountOfInjuresOnDamage; + std::vector amountOfInjuresOnDamage; - bool selectionSpecific; + bool selectionSpecific; std::vector> possibleInjuries; }; diff --git a/extensions/medical/InjuryType.h b/extensions/medical/InjuryType.h index ad99518252..2790917468 100644 --- a/extensions/medical/InjuryType.h +++ b/extensions/medical/InjuryType.h @@ -9,7 +9,7 @@ namespace ace { class InjuryType { public: - InjuryType(signed int anId, const std::string& aClassname, std::vector& allowedSelections, double theBloodLoss, double thePain, double minimumDamage, double maximumDamage, std::vector& possibleCauses, std::string& aDisplayname); + InjuryType(signed int anId, const std::string& aClassname, std::vector& allowedSelections, double theBloodLoss, double thePain, double minimumDamage, double maximumDamage, std::vector& possibleCauses, std::string& aDisplayname); ~InjuryType(); signed int ID; diff --git a/extensions/medical/OpenWound.cpp b/extensions/medical/OpenWound.cpp index b28cf79df5..62eadfdfe9 100644 --- a/extensions/medical/OpenWound.cpp +++ b/extensions/medical/OpenWound.cpp @@ -2,7 +2,7 @@ #include ace::medical::injuries::OpenWound::OpenWound(int aClassID, int aBodyPartId, double aPercentage, double aBl, double painAmount) : - classID(aClassID), bodyPart(aBodyPartId), percentage(aPercentage), bloodlossRate(aBl), pain(painAmount) + classID(aClassID), bodyPart(aBodyPartId), percentage(aPercentage), bloodlossRate(aBl), pain(painAmount) { } diff --git a/extensions/medical/OpenWound.h b/extensions/medical/OpenWound.h index 4d2d7892eb..00e6c1fe7a 100644 --- a/extensions/medical/OpenWound.h +++ b/extensions/medical/OpenWound.h @@ -14,10 +14,10 @@ namespace ace { std::string AsString(); int classID; - int percentage; + int percentage; double bodyPart; double bloodlossRate; - double pain; + double pain; }; } diff --git a/extensions/medical/handleDamage.cpp b/extensions/medical/handleDamage.cpp index 6fbc53e071..1e2cf53e84 100644 --- a/extensions/medical/handleDamage.cpp +++ b/extensions/medical/handleDamage.cpp @@ -5,159 +5,159 @@ #include namespace ace { - namespace medical { + namespace medical { - handleDamage::handleDamage() - { - } + handleDamage::handleDamage() + { + } - handleDamage& handleDamage::GetInstance() - { - static handleDamage instance; - return instance; - } + handleDamage& handleDamage::GetInstance() + { + static handleDamage instance; + return instance; + } - handleDamage::~handleDamage() - { - } + handleDamage::~handleDamage() + { + } - /* static */ std::vector handleDamage::HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage) - { - std::vector wounds; - int selectionN = SelectionToNumber(selectionName); - if (selectionN >= 0) - { - wounds = GetInjuryInfoFor(typeOfDamage, amountOfDamage, selectionN); - } - return wounds; - } + /* static */ std::vector handleDamage::HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage) + { + std::vector wounds; + int selectionN = SelectionToNumber(selectionName); + if (selectionN >= 0) + { + wounds = GetInjuryInfoFor(typeOfDamage, amountOfDamage, selectionN); + } + return wounds; + } - std::vector handleDamage::GetInjuryInfoFor(const std::string& typeOfDamage, double amountOfDamage, int selection) - { - std::vector injuriesToAdd; - std::vector> information; - std::shared_ptr highestSpot; + std::vector handleDamage::GetInjuryInfoFor(const std::string& typeOfDamage, double amountOfDamage, int selection) + { + std::vector injuriesToAdd; + std::vector> information; + std::shared_ptr highestSpot; - for each (std::shared_ptr damageType in damageTypes) - { - if (damageType->typeName == typeOfDamage) - { - for each (std::shared_ptr possibleInjury in damageType->possibleInjuries) - { - if (amountOfDamage >= possibleInjury->minDamage && (amountOfDamage <= possibleInjury->maxDamage || possibleInjury->maxDamage == 0)) - { - if (highestSpot == NULL) - highestSpot = possibleInjury; + for each (std::shared_ptr damageType in damageTypes) + { + if (damageType->typeName == typeOfDamage) + { + for each (std::shared_ptr possibleInjury in damageType->possibleInjuries) + { + if (amountOfDamage >= possibleInjury->minDamage && (amountOfDamage <= possibleInjury->maxDamage || possibleInjury->maxDamage == 0)) + { + if (highestSpot == NULL) + highestSpot = possibleInjury; - if (possibleInjury->minDamage > highestSpot->minDamage) - highestSpot = possibleInjury; + if (possibleInjury->minDamage > highestSpot->minDamage) + highestSpot = possibleInjury; - information.push_back(possibleInjury); - } - } + information.push_back(possibleInjury); + } + } - int c = 0; - for each (double threshold in damageType->minDamageThreshold) - { - if (threshold >= amountOfDamage) - { - double amountOfInjuriesOnDamage = damageType->amountOfInjuresOnDamage.at(c); - for (double injuryAmount = 0; injuryAmount < amountOfInjuriesOnDamage; ++injuryAmount) - { - std::shared_ptr injuryToAdd; - if (rand() % 1 >= 0.85) - { - injuryToAdd = highestSpot; - } - else - { - injuryToAdd = information.at(0); - } + int c = 0; + for each (double threshold in damageType->minDamageThreshold) + { + if (threshold >= amountOfDamage) + { + double amountOfInjuriesOnDamage = damageType->amountOfInjuresOnDamage.at(c); + for (double injuryAmount = 0; injuryAmount < amountOfInjuriesOnDamage; ++injuryAmount) + { + std::shared_ptr injuryToAdd; + if (rand() % 1 >= 0.85) + { + injuryToAdd = highestSpot; + } + else + { + injuryToAdd = information.at(0); + } - int bodyPartID = selection; - if (!damageType->selectionSpecific) - { - bodyPartID = rand() % 6; - } - - injuries::OpenWound newWound(injuryToAdd->ID, bodyPartID, 1, injuryToAdd->bloodLoss, injuryToAdd->pain); - injuriesToAdd.push_back(newWound); - } - } - ++c; - } - return injuriesToAdd; - } - } - return injuriesToAdd; - } + int bodyPartID = selection; + if (!damageType->selectionSpecific) + { + bodyPartID = rand() % 6; + } + + injuries::OpenWound newWound(injuryToAdd->ID, bodyPartID, 1, injuryToAdd->bloodLoss, injuryToAdd->pain); + injuriesToAdd.push_back(newWound); + } + } + ++c; + } + return injuriesToAdd; + } + } + return injuriesToAdd; + } - /* static */ void handleDamage::AddDamageType(const std::vector& input) - { - if (input.size() == 5) - { - std::string typeName = input[0]; - double minimalLethalDamage = std::stod(input[1]); - std::vector minDamageThreshold;// = std::stod(input[2]); - std::vector amountOfInjuresOnDamage; //= std::stod(input[3]); - bool selectionSpecific = std::stod(input[4]) > 0; + /* static */ void handleDamage::AddDamageType(const std::vector& input) + { + if (input.size() == 5) + { + std::string typeName = input[0]; + double minimalLethalDamage = std::stod(input[1]); + std::vector minDamageThreshold;// = std::stod(input[2]); + std::vector amountOfInjuresOnDamage; //= std::stod(input[3]); + bool selectionSpecific = std::stod(input[4]) > 0; - std::shared_ptr type(new ace::medical::injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, amountOfInjuresOnDamage, selectionSpecific)); - damageTypes.push_back(type); - } - } + std::shared_ptr type(new ace::medical::injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, amountOfInjuresOnDamage, selectionSpecific)); + damageTypes.push_back(type); + } + } - void handleDamage::AddInjuryType(const std::vector& input) - { - if (input.size() == 9) - { - // TODO parse arrays from string input + void handleDamage::AddInjuryType(const std::vector& input) + { + if (input.size() == 9) + { + // TODO parse arrays from string input - int ID = std::stod(input[0]); - std::string className = input[1]; - std::vector allowedSelections; // input[2]; - double bloodLoss = std::stod(input[3]); - double pain = std::stod(input[4]); + int ID = std::stod(input[0]); + std::string className = input[1]; + std::vector allowedSelections; // input[2]; + double bloodLoss = std::stod(input[3]); + double pain = std::stod(input[4]); - double minDamage = std::stod(input[5]); - double maxDamage = std::stod(input[6]); - std::vector possibleCauses; // input[7]; - std::string displayName = input[8]; + double minDamage = std::stod(input[5]); + double maxDamage = std::stod(input[6]); + std::vector possibleCauses; // input[7]; + std::string displayName = input[8]; - std::shared_ptr type(new ace::medical::injuries::InjuryType(ID, className, allowedSelections, bloodLoss, pain, minDamage, maxDamage, possibleCauses, displayName)); - injuryTypes.push_back(type); - } - } + std::shared_ptr type(new ace::medical::injuries::InjuryType(ID, className, allowedSelections, bloodLoss, pain, minDamage, maxDamage, possibleCauses, displayName)); + injuryTypes.push_back(type); + } + } - 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. - for each (std::shared_ptr damageType in damageTypes) - { - for each (std::shared_ptr injuryType in injuryTypes) - { - if (find(injuryType->causes.begin(), injuryType->causes.end(), damageType->typeName) != injuryType->causes.end()) - { - damageType->possibleInjuries.push_back(injuryType); - } - } - } - } + 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. + for each (std::shared_ptr damageType in damageTypes) + { + for each (std::shared_ptr injuryType in injuryTypes) + { + if (find(injuryType->causes.begin(), injuryType->causes.end(), damageType->typeName) != injuryType->causes.end()) + { + damageType->possibleInjuries.push_back(injuryType); + } + } + } + } - int handleDamage::SelectionToNumber(const std::string& selectionName) - { - // TODO use dynamic selections instead - std::vector selections = { "head", "body", "hand_l", "hand_r", "leg_l", "leg_r" }; - std::vector::iterator it = find(selections.begin(), selections.end(), selectionName); - if (it != selections.end()) - { - return it - selections.begin(); - } - else - { - return -1; // TODO throw exception - } - } - } + int handleDamage::SelectionToNumber(const std::string& selectionName) + { + // TODO use dynamic selections instead + std::vector selections = { "head", "body", "hand_l", "hand_r", "leg_l", "leg_r" }; + std::vector::iterator it = find(selections.begin(), selections.end(), selectionName); + if (it != selections.end()) + { + return it - selections.begin(); + } + else + { + return -1; // TODO throw exception + } + } + } } diff --git a/extensions/medical/handleDamage.h b/extensions/medical/handleDamage.h index fdaa952bfd..16b9cb6783 100644 --- a/extensions/medical/handleDamage.h +++ b/extensions/medical/handleDamage.h @@ -16,10 +16,10 @@ namespace ace { class handleDamage { public: - /** - * - */ - static handleDamage& GetInstance(); + /** + * + */ + static handleDamage& GetInstance(); ~handleDamage(); @@ -28,7 +28,7 @@ namespace ace { */ std::vector HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage); - std::vector GetInjuryInfoFor(const std::string& typeOfDamage, double amountOfDamage, int selection); + std::vector GetInjuryInfoFor(const std::string& typeOfDamage, double amountOfDamage, int selection); /** * @@ -63,9 +63,9 @@ namespace ace { private: handleDamage(); - - handleDamage(handleDamage const&) = delete; - void operator=(handleDamage const&) = delete; + + handleDamage(handleDamage const&) = delete; + void operator=(handleDamage const&) = delete; std::vector> damageTypes; std::vector> injuryTypes;