mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Ported over handleDamage_wounds
This commit is contained in:
parent
e98c7cd1b7
commit
5756c8530f
@ -1,7 +1,7 @@
|
||||
#include "DamageType.h"
|
||||
|
||||
ace::medical::injuries::DamageType::DamageType(std::string aTypeName, double minimalLethalDamage, double minDamage, double maxDamage)
|
||||
: typeName(aTypeName), minLethalDamage(minimalLethalDamage), minDamageThreshold(minDamage), maxDamageThreshold(maxDamage)
|
||||
ace::medical::injuries::DamageType::DamageType(std::string aTypeName, double minimalLethalDamage, std::vector<double> minDamage, std::vector<double> amountOfInjuresOnDamage, bool specificOnly)
|
||||
: typeName(aTypeName), minLethalDamage(minimalLethalDamage), minDamageThreshold(minDamage), amountOfInjuresOnDamage(amountOfInjuresOnDamage), selectionSpecific(specificOnly)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,15 @@ namespace ace {
|
||||
class DamageType
|
||||
{
|
||||
public:
|
||||
DamageType(std::string aTypeName, double minimalLethalDamage, double minDamageThreshold, double maxDamageThreshold);
|
||||
DamageType(std::string aTypeName, double minimalLethalDamage, std::vector<double> minDamageThreshold, std::vector<double> amountOfInjuresOnDamage, bool specificOnly);
|
||||
~DamageType();
|
||||
|
||||
std::string typeName;
|
||||
double minLethalDamage;
|
||||
double minDamageThreshold;
|
||||
double maxDamageThreshold;
|
||||
std::vector<double> minDamageThreshold;
|
||||
std::vector<double> amountOfInjuresOnDamage;
|
||||
|
||||
bool selectionSpecific;
|
||||
|
||||
std::vector<std::shared_ptr<InjuryType>> possibleInjuries;
|
||||
};
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "OpenWound.h"
|
||||
#include <sstream>
|
||||
|
||||
ace::medical::injuries::OpenWound::OpenWound(double anID, double aBodyPart, double bloodloss) : classID(anID), bodyPart(aBodyPart), bloodlossRate(bloodloss)
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,16 @@ namespace ace {
|
||||
class OpenWound
|
||||
{
|
||||
public:
|
||||
OpenWound(double anID, double aBodyPart, double bloodloss);
|
||||
OpenWound(int aClassID, int aBodyPartId, double aPercentage, double aBl, double painAmount);
|
||||
~OpenWound();
|
||||
|
||||
std::string AsString();
|
||||
|
||||
double classID;
|
||||
int classID;
|
||||
int percentage;
|
||||
double bodyPart;
|
||||
double bloodlossRate;
|
||||
double pain;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -28,22 +28,82 @@ namespace ace {
|
||||
int selectionN = SelectionToNumber(selectionName);
|
||||
if (selectionN >= 0)
|
||||
{
|
||||
// std::vector<std::shared_ptr<ace::medical::injuries::InjuryType>> injuryTypeInfo = GetInjuryInfoFor(typeOfDamage);
|
||||
wounds = GetInjuryInfoFor(typeOfDamage, amountOfDamage, selectionN);
|
||||
}
|
||||
|
||||
return wounds;
|
||||
}
|
||||
|
||||
std::vector<ace::medical::injuries::OpenWound> handleDamage::GetInjuryInfoFor(const std::string& typeOfDamage, double amountOfDamage, int selection)
|
||||
{
|
||||
std::vector<ace::medical::injuries::OpenWound> injuriesToAdd;
|
||||
std::vector<std::shared_ptr<ace::medical::injuries::InjuryType>> information;
|
||||
std::shared_ptr<ace::medical::injuries::InjuryType> highestSpot;
|
||||
|
||||
for each (std::shared_ptr<ace::medical::injuries::DamageType> damageType in damageTypes)
|
||||
{
|
||||
if (damageType->typeName == typeOfDamage)
|
||||
{
|
||||
for each (std::shared_ptr<ace::medical::injuries::InjuryType> 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;
|
||||
|
||||
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<ace::medical::injuries::InjuryType> 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;
|
||||
}
|
||||
|
||||
/* static */ void handleDamage::AddDamageType(const std::vector<std::string>& input)
|
||||
{
|
||||
if (input.size() == 4)
|
||||
if (input.size() == 5)
|
||||
{
|
||||
std::string typeName = input[0];
|
||||
double minimalLethalDamage = std::stod(input[1]);
|
||||
double minDamageThreshold = std::stod(input[2]);
|
||||
double maxDamageThreshold = std::stod(input[3]);
|
||||
std::vector<double> minDamageThreshold;// = std::stod(input[2]);
|
||||
std::vector<double> amountOfInjuresOnDamage; //= std::stod(input[3]);
|
||||
bool selectionSpecific = std::stod(input[4]) > 0;
|
||||
|
||||
std::shared_ptr<ace::medical::injuries::DamageType> type(new ace::medical::injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, maxDamageThreshold));
|
||||
std::shared_ptr<ace::medical::injuries::DamageType> type(new ace::medical::injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, amountOfInjuresOnDamage, selectionSpecific));
|
||||
damageTypes.push_back(type);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ namespace ace {
|
||||
*/
|
||||
std::vector<ace::medical::injuries::OpenWound> HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage);
|
||||
|
||||
std::vector<ace::medical::injuries::OpenWound> GetInjuryInfoFor(const std::string& typeOfDamage, double amountOfDamage, int selection);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user