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