2010-09-24 13:28:14 +00:00
|
|
|
#include "attr.hpp"
|
2023-05-20 15:49:32 +00:00
|
|
|
#include <components/misc/strings/algorithm.hpp>
|
2023-05-25 10:49:27 +00:00
|
|
|
#include <stdexcept>
|
2010-09-24 13:28:14 +00:00
|
|
|
|
|
|
|
using namespace ESM;
|
|
|
|
|
2013-08-09 12:14:58 +00:00
|
|
|
const std::string Attribute::sAttributeNames[Attribute::Length] = {
|
|
|
|
"Strength",
|
|
|
|
"Intelligence",
|
|
|
|
"Willpower",
|
|
|
|
"Agility",
|
|
|
|
"Speed",
|
|
|
|
"Endurance",
|
|
|
|
"Personality",
|
2022-09-12 16:35:54 +00:00
|
|
|
"Luck",
|
2013-08-09 12:14:58 +00:00
|
|
|
};
|
|
|
|
|
2023-05-20 15:49:32 +00:00
|
|
|
Attribute::AttributeID Attribute::stringToAttributeId(std::string_view attribute)
|
|
|
|
{
|
2023-05-27 19:54:13 +00:00
|
|
|
for (int id = 0; id < Attribute::Length; ++id)
|
2023-05-21 11:01:11 +00:00
|
|
|
if (Misc::StringUtils::ciEqual(sAttributeNames[id], attribute))
|
2023-05-27 19:54:13 +00:00
|
|
|
return Attribute::AttributeID(id);
|
2023-05-20 15:49:32 +00:00
|
|
|
|
|
|
|
throw std::logic_error("No such attribute: " + std::string(attribute));
|
|
|
|
}
|