#include "StatProperty.h" #include StatProperty::StatProperty(eStatTypes type, eStatModifier modifier, float value) { this->type = type; this->modifier = modifier; this->value = value; } std::string StatProperty::HtmlString() { // "Physical: +20%\n..." std::stringstream ss; ss << ""; switch (type) { case eStatTypes::Health: ss << "Health"; break; case eStatTypes::Armor: ss << "Armor"; break; case eStatTypes::Imagination: ss << "Imagination"; break; case eStatTypes::Physical: ss << "Physical"; break; case eStatTypes::Electric: ss << "Electric"; break; case eStatTypes::Corruption: ss << "Corruption"; break; case eStatTypes::Heat: ss << "Heat"; break; case eStatTypes::Shadow: ss << "Shadow"; break; case eStatTypes::Pierce: ss << "Pierce"; break; case eStatTypes::Vitality: ss << "Vitality"; break; case eStatTypes::Domination: ss << "Domination"; break; default: ss << "Unknown"; break; } switch (modifier) { case eStatModifier::DamageResistance: ss << " Resistance"; break; case eStatModifier::DamagePercent: case eStatModifier::DamageAbsolute: ss << " Damage"; break; } ss << ""; switch (modifier) { case eStatModifier::Percent: case eStatModifier::DamagePercent: case eStatModifier::DamageResistance: { float percent = value * 100.0f; // Round to 2 decimal places percent = static_cast(static_cast(percent * 100.0f)) / 100.0f; ss << ": +" << percent << "%"; } break; case eStatModifier::Absolute: case eStatModifier::DamageAbsolute: default: ss << ": +" << value; break; } return ss.str(); }