Implements Attributes.
Moves attribute functions from Character.cpp to Attributes.cpp.
This commit is contained in:
@@ -0,0 +1,140 @@
|
|||||||
|
#include "Attributes.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace SBF{
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
string GetAttributeGroupLabel(int attributeGroupId) {
|
||||||
|
if (attributeGroupId > 0 && attributeGroupId <= kAttributeGroupsCount) {
|
||||||
|
return kAttributeGroups[attributeGroupId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetAttributeLabel(int attributeGroupId, int attributeId) {
|
||||||
|
switch (attributeGroupId) {
|
||||||
|
case kAttributeGroupPhysicalId:
|
||||||
|
return GetPhysicalAttributeLabel(attributeId);
|
||||||
|
case kAttributeGroupSocialId:
|
||||||
|
return GetSocialAttributeLabel(attributeId);
|
||||||
|
case kAttributeGroupMentalId:
|
||||||
|
return GetMentalAttributeLabel(attributeId);
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetAttributeLabelAbbreviation(int attributeGroupId, int attributeId) {
|
||||||
|
switch (attributeGroupId) {
|
||||||
|
case kAttributeGroupPhysicalId:
|
||||||
|
return GetPhysicalAttributeLabelAbbreviation(attributeId);
|
||||||
|
case kAttributeGroupSocialId:
|
||||||
|
return GetSocialAttributeLabelAbbreviation(attributeId);
|
||||||
|
case kAttributeGroupMentalId:
|
||||||
|
return GetMentalAttributeLabelAbbreviation(attributeId);
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetNumAttributesInGroup(int attributeGroupId) {
|
||||||
|
switch (attributeGroupId) {
|
||||||
|
case kAttributeGroupPhysicalId:
|
||||||
|
return kPhysicalAttributesCount;
|
||||||
|
case kAttributeGroupSocialId:
|
||||||
|
return kSocialAttributesCount;
|
||||||
|
case kAttributeGroupMentalId:
|
||||||
|
return kMentalAttributesCount;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetPhysicalAttributeLabel(int attributeId) {
|
||||||
|
if (attributeId > 0 && attributeId <= kPhysicalAttributesCount) {
|
||||||
|
return kPhysicalAttributeLabels[attributeId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetPhysicalAttributeLabelAbbreviation(int attributeId) {
|
||||||
|
if (attributeId > 0 && attributeId <= kPhysicalAttributesCount) {
|
||||||
|
return kPhysicalAttributeLabelAbbreviations[attributeId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetSocialAttributeLabel(int attributeId) {
|
||||||
|
if (attributeId > 0 && attributeId <= kSocialAttributesCount) {
|
||||||
|
return kSocialAttributeLabels[attributeId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetSocialAttributeLabelAbbreviation(int attributeId) {
|
||||||
|
if (attributeId > 0 && attributeId <= kSocialAttributesCount) {
|
||||||
|
return kSocialAttributeLabelAbbreviations[attributeId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetMentalAttributeLabel(int attributeId) {
|
||||||
|
if (attributeId > 0 && attributeId <= kMentalAttributesCount) {
|
||||||
|
return kMentalAttributeLabels[attributeId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetMentalAttributeLabelAbbreviation(int attributeId) {
|
||||||
|
if (attributeId > 0 && attributeId <= kMentalAttributesCount) {
|
||||||
|
return kMentalAttributeLabelAbbreviations[attributeId];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillAttributeGroupLabels(std::vector<std::string>& labels) {
|
||||||
|
labels.clear();
|
||||||
|
for (int id = 1; id <= kAttributeGroupsCount; id++) {
|
||||||
|
labels.push_back(kAttributeGroups[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillAttributeLabelsInGroup(std::vector<std::string>& labels, int groupId) {
|
||||||
|
labels.clear();
|
||||||
|
switch (groupId) {
|
||||||
|
case kAttributeGroupPhysicalId:
|
||||||
|
FillPhysicalAttributeLabels(labels);
|
||||||
|
break;
|
||||||
|
case kAttributeGroupSocialId:
|
||||||
|
FillSocialAttributeLabels(labels);
|
||||||
|
break;
|
||||||
|
case kAttributeGroupMentalId:
|
||||||
|
FillMentalAttributeLabels(labels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillPhysicalAttributeLabels(std::vector<std::string>& labels) {
|
||||||
|
labels.clear();
|
||||||
|
for (int id = 1; id <= kPhysicalAttributesCount; id++) {
|
||||||
|
labels.push_back(kPhysicalAttributeLabels[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillSocialAttributeLabels(std::vector<std::string>& labels) {
|
||||||
|
labels.clear();
|
||||||
|
for (int id = 1; id <= kSocialAttributesCount; id++) {
|
||||||
|
labels.push_back(kSocialAttributeLabels[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillMentalAttributeLabels(std::vector<std::string>& labels) {
|
||||||
|
labels.clear();
|
||||||
|
for (int id = 1; id <= kMentalAttributesCount; id++) {
|
||||||
|
labels.push_back(kMentalAttributeLabels[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End namespace SBF
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace SBF {
|
|||||||
kPhysicalAttributeDexterityLabel,
|
kPhysicalAttributeDexterityLabel,
|
||||||
kPhysicalAttributeStaminaLabel,
|
kPhysicalAttributeStaminaLabel,
|
||||||
};
|
};
|
||||||
const std::string kPhysicalAttributeAbbreviations[] = {
|
const std::string kPhysicalAttributeLabelAbbreviations[] = {
|
||||||
"",
|
"",
|
||||||
kPhysicalAttributeStrengthAbbreviation,
|
kPhysicalAttributeStrengthAbbreviation,
|
||||||
kPhysicalAttributeDexterityAbbreviation,
|
kPhysicalAttributeDexterityAbbreviation,
|
||||||
@@ -43,7 +43,7 @@ namespace SBF {
|
|||||||
kSocialAttributeManipulationLabel,
|
kSocialAttributeManipulationLabel,
|
||||||
kSocialAttributeAppearanceLabel,
|
kSocialAttributeAppearanceLabel,
|
||||||
};
|
};
|
||||||
const std::string kSocialAttributeAbbreviations[] = {
|
const std::string kSocialAttributeLabelAbbreviations[] = {
|
||||||
"",
|
"",
|
||||||
kSocialAttributeCharismaAbbreviation,
|
kSocialAttributeCharismaAbbreviation,
|
||||||
kSocialAttributeManipulationAbbreviation,
|
kSocialAttributeManipulationAbbreviation,
|
||||||
@@ -66,9 +66,9 @@ namespace SBF {
|
|||||||
kMentalAttributePerceptionLabel,
|
kMentalAttributePerceptionLabel,
|
||||||
kMentalAttributeWitsLabel,
|
kMentalAttributeWitsLabel,
|
||||||
};
|
};
|
||||||
const std::string kMentalAttributeAbbreviations[] = {
|
const std::string kMentalAttributeLabelAbbreviations[] = {
|
||||||
"",
|
"",
|
||||||
kMentalAttributeIntelligenceLabel,
|
kMentalAttributeIntelligenceAbbreviation,
|
||||||
kMentalAttributePerceptionAbbreviation,
|
kMentalAttributePerceptionAbbreviation,
|
||||||
kMentalAttributeWitsAbbreviation,
|
kMentalAttributeWitsAbbreviation,
|
||||||
};
|
};
|
||||||
@@ -87,15 +87,20 @@ namespace SBF {
|
|||||||
kAttributeGroupMentalLabel,
|
kAttributeGroupMentalLabel,
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string& GetAttributeGroupLabel(int attributeGroupId);
|
std::string GetAttributeGroupLabel(int attributeGroupId);
|
||||||
const std::string& GetAtttributeLabel(int attributeGroupId, int attributeId);
|
std::string GetAttributeLabel(int attributeGroupId, int attributeId);
|
||||||
const std::string& GetPhysicalAttributeLabel(int attributeId);
|
std::string GetAttributeLabelAbbreviation(int attributeGroupId, int attributeId);
|
||||||
const std::string& GetSocialAttributeLabel(int attributeId);
|
std::string GetPhysicalAttributeLabel(int attributeId);
|
||||||
const std::string& GetMentalAttributeLabel(int attributeId);
|
std::string GetPhysicalAttributeLabelAbbreviation(int attributeId);
|
||||||
void FillAttributeGroupLabels(std::vector<std::string> attributeGroupLabels);
|
int GetNumAttributesInGroup(int attributeGroupId);
|
||||||
void FillAttributeLabelInGroup(std::vector<std::string> attributeLabels);
|
std::string GetSocialAttributeLabel(int attributeId);
|
||||||
void FillPhysicalAttributeLabels(std::vector<std::string> physicalAttributeLabels);
|
std::string GetSocialAttributeLabelAbbreviation(int attributeId);
|
||||||
void FillSocialAttributeLabels(std::vector<std::string> socialAttributeLabels);
|
std::string GetMentalAttributeLabel(int attributeId);
|
||||||
void FillMentalAttributeLabels(std::vector<std::string> mentalAttributeLabels);
|
std::string GetMentalAttributeLabelAbbreviation(int attributeId);
|
||||||
|
void FillAttributeGroupLabels(std::vector<std::string>& attributeGroupLabels);
|
||||||
|
void FillAttributeLabelsInGroup(std::vector<std::string>& attributeLabels, int groupId);
|
||||||
|
void FillPhysicalAttributeLabels(std::vector<std::string>& physicalAttributeLabels);
|
||||||
|
void FillSocialAttributeLabels(std::vector<std::string>& socialAttributeLabels);
|
||||||
|
void FillMentalAttributeLabels(std::vector<std::string>& mentalAttributeLabels);
|
||||||
} // End namespace SBF
|
} // End namespace SBF
|
||||||
#endif // End !defined ATTRIBUTES_H__
|
#endif // End !defined ATTRIBUTES_H__
|
||||||
|
|||||||
@@ -1,10 +1,542 @@
|
|||||||
#include "Attributes.h"
|
#include "Attributes.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <tuple>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
using namespace SBF;
|
using namespace SBF;
|
||||||
using namespace Test;
|
using namespace Test;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Test::Attributes {
|
||||||
|
TestResults test_GetAttributeGroupLabel();
|
||||||
|
TestResults test_GetAttributeLabel();
|
||||||
|
TestResults test_GetAttributeLabelAbbreviation();
|
||||||
|
TestResults test_GetNumAttributesInGroup();
|
||||||
|
TestResults test_GetPhysicalAttributeLabel();
|
||||||
|
TestResults test_GetPhysicalAttributeLabelAbbreviation();
|
||||||
|
TestResults test_GetSocialAttributeLabel();
|
||||||
|
TestResults test_GetSocialAttributeLabelAbbreviation();
|
||||||
|
TestResults test_GetMentalAttributeLabel();
|
||||||
|
TestResults test_GetMentalAttributeLabelAbbreviation();
|
||||||
|
TestResults test_FillAttributeGroupLabels();
|
||||||
|
TestResults test_FillAttributeLabelsInGroup();
|
||||||
|
TestResults test_FillPhysicalAttributeLabels();
|
||||||
|
TestResults test_FillSocialAttributeLabels();
|
||||||
|
TestResults test_FillMentalAttributeLabels();
|
||||||
|
} // End namespace Test::Attributes
|
||||||
|
using namespace Test::Attributes;
|
||||||
|
|
||||||
TestResults main_test_Attributes(int argc, char** argv) {
|
TestResults main_test_Attributes(int argc, char** argv) {
|
||||||
TestResults results;
|
TestResults results;
|
||||||
|
|
||||||
|
results += test_GetAttributeGroupLabel();
|
||||||
|
results += test_GetAttributeLabel();
|
||||||
|
results += test_GetAttributeLabelAbbreviation();
|
||||||
|
results += test_GetNumAttributesInGroup();
|
||||||
|
results += test_GetPhysicalAttributeLabel();
|
||||||
|
results += test_GetPhysicalAttributeLabelAbbreviation();
|
||||||
|
results += test_GetSocialAttributeLabel();
|
||||||
|
results += test_GetSocialAttributeLabelAbbreviation();
|
||||||
|
results += test_GetMentalAttributeLabel();
|
||||||
|
results += test_GetMentalAttributeLabelAbbreviation();
|
||||||
|
results += test_FillAttributeGroupLabels();
|
||||||
|
results += test_FillAttributeLabelsInGroup();
|
||||||
|
results += test_FillPhysicalAttributeLabels();
|
||||||
|
results += test_FillSocialAttributeLabels();
|
||||||
|
results += test_FillMentalAttributeLabels();
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Test::Attributes {
|
||||||
|
TestResults test_GetAttributeGroupLabel() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetAttributeGroupLabel",
|
||||||
|
GetAttributeGroupLabel,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Physical\" for id 1",
|
||||||
|
"Physical",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Social\" for id 2",
|
||||||
|
"Social",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Mental\" for id 3",
|
||||||
|
"Mental",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetAttributeLabel() {
|
||||||
|
return execute_suite<string, int, int>(make_test_suite(
|
||||||
|
"SBF::GetAttributeLabel",
|
||||||
|
GetAttributeLabel,
|
||||||
|
vector<TestTuple<string, int, int>>({
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Strength\" for group id 1 and id 1",
|
||||||
|
"Strength",
|
||||||
|
make_tuple(1, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Dexterity\" for group id 1 and id 2",
|
||||||
|
"Dexterity",
|
||||||
|
make_tuple(1, 2)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Stamina\" for group id 1 and id 3",
|
||||||
|
"Stamina",
|
||||||
|
make_tuple(1, 3)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Charisma\" for group id 2 and id 1",
|
||||||
|
"Charisma",
|
||||||
|
make_tuple(2, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Manipulation\" for group id 2 and id 2",
|
||||||
|
"Manipulation",
|
||||||
|
make_tuple(2, 2)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Appearance\" for group id 2 and id 3",
|
||||||
|
"Appearance",
|
||||||
|
make_tuple(2, 3)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Intelligence\" for group id 3 and id 1",
|
||||||
|
"Intelligence",
|
||||||
|
make_tuple(3, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Perception\" for group id 3 and id 2",
|
||||||
|
"Perception",
|
||||||
|
make_tuple(3, 2)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Wits\" for group id 3 and id 3",
|
||||||
|
"Wits",
|
||||||
|
make_tuple(3, 3)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for an invalid group id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for an invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(1, 0)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for invalid group id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for an invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(1, 4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetAttributeLabelAbbreviation() {
|
||||||
|
return execute_suite<string, int, int>(make_test_suite(
|
||||||
|
"SBF::GetAttributeLabelAbbreviation",
|
||||||
|
GetAttributeLabelAbbreviation,
|
||||||
|
vector<TestTuple<string, int, int>>({
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Str.\" for group id 1 and id 1",
|
||||||
|
"Str.",
|
||||||
|
make_tuple(1, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Dex.\" for group id 1 and id 2",
|
||||||
|
"Dex.",
|
||||||
|
make_tuple(1, 2)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Sta.\" for group id 1 and id 3",
|
||||||
|
"Sta.",
|
||||||
|
make_tuple(1, 3)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Cha.\" for group id 2 and id 1",
|
||||||
|
"Cha.",
|
||||||
|
make_tuple(2, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Man.\" for group id 2 and id 2",
|
||||||
|
"Man.",
|
||||||
|
make_tuple(2, 2)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"App.\" for group id 2 and id 3",
|
||||||
|
"App.",
|
||||||
|
make_tuple(2, 3)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Int.\" for group id 3 and id 1",
|
||||||
|
"Int.",
|
||||||
|
make_tuple(3, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Per.\" for group id 3 and id 2",
|
||||||
|
"Per.",
|
||||||
|
make_tuple(3, 2)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"Wits\" for group id 3 and id 3",
|
||||||
|
"Wits",
|
||||||
|
make_tuple(3, 3)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for an invalid group id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for an invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(1, 0)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for invalid group id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4, 1)),
|
||||||
|
make_test<string, int, int>(
|
||||||
|
"should get \"\" for an invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(1, 4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetPhysicalAttributeLabel() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetPhysicalAttributeLabel",
|
||||||
|
GetPhysicalAttributeLabel,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Strength\" for id 1",
|
||||||
|
"Strength",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Dexterity\" for id 2",
|
||||||
|
"Dexterity",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Stamina\" for id 3",
|
||||||
|
"Stamina",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetPhysicalAttributeLabelAbbreviation() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetPhysicalAttributeLabelAbbreviation",
|
||||||
|
GetPhysicalAttributeLabelAbbreviation,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Str.\" for id 1",
|
||||||
|
"Str.",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Dex.\" for id 2",
|
||||||
|
"Dex.",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Sta.\" for id 3",
|
||||||
|
"Sta.",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetSocialAttributeLabel() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetSocialAttributeLabel",
|
||||||
|
GetSocialAttributeLabel,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Charisma\" for id 1",
|
||||||
|
"Charisma",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Manipulation\" for id 2",
|
||||||
|
"Manipulation",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Appearance\" for id 3",
|
||||||
|
"Appearance",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetSocialAttributeLabelAbbreviation() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetSocialAttributeLabelAbbreviation",
|
||||||
|
GetSocialAttributeLabelAbbreviation,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Cha.\" for id 1",
|
||||||
|
"Cha.",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Man.\" for id 2",
|
||||||
|
"Man.",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"App.\" for id 3",
|
||||||
|
"App.",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetMentalAttributeLabel() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetMentalAttributeLabel",
|
||||||
|
GetMentalAttributeLabel,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Intelligence\" for id 1",
|
||||||
|
"Intelligence",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Perception\" for id 2",
|
||||||
|
"Perception",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Wits\" for id 3",
|
||||||
|
"Wits",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetMentalAttributeLabelAbbreviation() {
|
||||||
|
return execute_suite<string, int>(make_test_suite(
|
||||||
|
"SBF::GetMentalAttributeLabelAbbreviation",
|
||||||
|
GetMentalAttributeLabelAbbreviation,
|
||||||
|
vector<TestTuple<string, int>>({
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Int.\" for id 1",
|
||||||
|
"Int.",
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Per.\" for id 2",
|
||||||
|
"Per.",
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"Wits\" for id 3",
|
||||||
|
"Wits",
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 0",
|
||||||
|
"",
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<string, int>(
|
||||||
|
"should get \"\" for invalid id 4",
|
||||||
|
"",
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_GetNumAttributesInGroup() {
|
||||||
|
return execute_suite<int, int>(make_test_suite(
|
||||||
|
"SBF::GetNumAttributesInGroup",
|
||||||
|
GetNumAttributesInGroup,
|
||||||
|
vector<TestTuple<int, int>>({
|
||||||
|
make_test<int, int>(
|
||||||
|
"should get 0 for invalid group 0",
|
||||||
|
0,
|
||||||
|
make_tuple(0)),
|
||||||
|
make_test<int, int>(
|
||||||
|
"should get 3 for group 1 kAttributeGroupPhysicalId",
|
||||||
|
3,
|
||||||
|
make_tuple(1)),
|
||||||
|
make_test<int, int>(
|
||||||
|
"should get 3 for group 2 kAttributeGropuSocialId",
|
||||||
|
3,
|
||||||
|
make_tuple(2)),
|
||||||
|
make_test<int, int>(
|
||||||
|
"should get 3 for group 3 kAttributeGroupMentalId",
|
||||||
|
3,
|
||||||
|
make_tuple(3)),
|
||||||
|
make_test<int, int>(
|
||||||
|
"should get 0 for invalid group 4",
|
||||||
|
0,
|
||||||
|
make_tuple(4)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_FillAttributeGroupLabels() {
|
||||||
|
return execute_suite<string>(make_test_suite(
|
||||||
|
"SBF::FillAttributeGroupLabels",
|
||||||
|
[]()->string {
|
||||||
|
ostringstream error_message;
|
||||||
|
vector<string> expected = {"Physical", "Social", "Mental"};
|
||||||
|
vector<string> actual = {"This should be removed."};
|
||||||
|
FillAttributeGroupLabels(actual);
|
||||||
|
compare(error_message, expected, actual);
|
||||||
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return "no errors";
|
||||||
|
},
|
||||||
|
vector<TestTuple<string>>({
|
||||||
|
make_test<string>(
|
||||||
|
"should fill attribute group labels",
|
||||||
|
"no errors",
|
||||||
|
make_tuple()),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// void FillAttributeLabelInGroup(std::vector<std::string> attributeLabels);
|
||||||
|
TestResults test_FillAttributeLabelsInGroup() {
|
||||||
|
return execute_suite<string, int, vector<string>>(make_test_suite(
|
||||||
|
"SBF::FillAttributeLabelsInGroup",
|
||||||
|
[](int id, vector<string> expected)->string {
|
||||||
|
ostringstream error_message;
|
||||||
|
vector<string> actual = {"This should be removed."};
|
||||||
|
FillAttributeLabelsInGroup(actual, id);
|
||||||
|
compare(error_message, expected, actual);
|
||||||
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return "no errors";
|
||||||
|
},
|
||||||
|
vector<TestTuple<string, int, vector<string>>>({
|
||||||
|
make_test<string, int, vector<string>>(
|
||||||
|
"should fill an empty list for invalid group 0",
|
||||||
|
"no errors",
|
||||||
|
make_tuple(0, vector<string>({}))),
|
||||||
|
make_test<string, int, vector<string>>(
|
||||||
|
"should fill physical attribute labels for group 1 kAttributeGropuPhysicalId",
|
||||||
|
"no errors",
|
||||||
|
make_tuple(1, vector<string>({"Strength", "Dexterity", "Stamina"}))),
|
||||||
|
make_test<string, int, vector<string>>(
|
||||||
|
"should fill social attribute labels for group 2 kAttributeGroupSocialId",
|
||||||
|
"no errors",
|
||||||
|
make_tuple(2, vector<string>({"Charisma", "Manipulation", "Appearance"}))),
|
||||||
|
make_test<string, int, vector<string>>(
|
||||||
|
"should should fill mental attribute labels for group 3 kAttributeGroupMentalId",
|
||||||
|
"no errors",
|
||||||
|
make_tuple(3, vector<string>({"Intelligence", "Perception", "Wits"}))),
|
||||||
|
make_test<string, int, vector<string>>(
|
||||||
|
"should fill an empty list for invalid group 4",
|
||||||
|
"no errors",
|
||||||
|
make_tuple(4, vector<string>({}))),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestResults test_FillPhysicalAttributeLabels() {
|
||||||
|
return execute_suite<string>(make_test_suite(
|
||||||
|
"SBF::FillPhysicalAttributeLabels",
|
||||||
|
[]()->string {
|
||||||
|
ostringstream error_message;
|
||||||
|
vector<string> expected = {"Strength", "Dexterity", "Stamina"};
|
||||||
|
vector<string> actual = {"This should be removed."};
|
||||||
|
FillPhysicalAttributeLabels(actual);
|
||||||
|
compare(error_message, expected, actual);
|
||||||
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return "no errors";
|
||||||
|
},
|
||||||
|
vector<TestTuple<string>>({
|
||||||
|
make_test<string>(
|
||||||
|
"should fill physical attribute labels",
|
||||||
|
"no errors",
|
||||||
|
make_tuple()),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// void FillSocialAttributeLabels(std::vector<std::string> socialAttributeLabels);
|
||||||
|
TestResults test_FillSocialAttributeLabels() {
|
||||||
|
return execute_suite<string>(make_test_suite(
|
||||||
|
"SBF::FillSocialAttributeLabels",
|
||||||
|
[]()->string {
|
||||||
|
ostringstream error_message;
|
||||||
|
vector<string> expected = {"Charisma", "Manipulation", "Appearance"};
|
||||||
|
vector<string> actual = {"This should be removed."};
|
||||||
|
FillSocialAttributeLabels(actual);
|
||||||
|
compare(error_message, expected, actual);
|
||||||
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return "no errors";
|
||||||
|
},
|
||||||
|
vector<TestTuple<string>>({
|
||||||
|
make_test<string>(
|
||||||
|
"should fill social attribute labels",
|
||||||
|
"no errors",
|
||||||
|
make_tuple()),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// void FillMentalAttributeLabels(std::vector<std::string> mentalAttributeLabels);
|
||||||
|
TestResults test_FillMentalAttributeLabels() {
|
||||||
|
return execute_suite<string>(make_test_suite(
|
||||||
|
"SBF::FillMentalAttributeLabels",
|
||||||
|
[]()->string {
|
||||||
|
ostringstream error_message;
|
||||||
|
vector<string> expected = {"Intelligence", "Perception", "Wits"};
|
||||||
|
vector<string> actual = {"This should be removed."};
|
||||||
|
FillMentalAttributeLabels(actual);
|
||||||
|
compare(error_message, expected, actual);
|
||||||
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return "no errors";
|
||||||
|
},
|
||||||
|
vector<TestTuple<string>>({
|
||||||
|
make_test<string>(
|
||||||
|
"should fill mental attribute labels",
|
||||||
|
"no errors",
|
||||||
|
make_tuple()),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,19 +5,6 @@ namespace SBF {
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
int GetNumAttributesInGroup(int groupId) {
|
|
||||||
switch (groupId) {
|
|
||||||
case kAttributeGroupPhysicalId:
|
|
||||||
return kPhysicalAttributesCount;
|
|
||||||
case kAttributeGroupSocialId:
|
|
||||||
return kSocialAttributesCount;
|
|
||||||
case kAttributeGroupMentalId:
|
|
||||||
return kMentalAttributesCount;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterType::CharacterType() {
|
CharacterType::CharacterType() {
|
||||||
// Scalars
|
// Scalars
|
||||||
name = "";
|
name = "";
|
||||||
@@ -262,19 +249,6 @@ namespace SBF {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetAttributeLabel(int attributeGroupId, int attributeId) {
|
|
||||||
switch (attributeGroupId) {
|
|
||||||
case kAttributeGroupPhysicalId:
|
|
||||||
return kPhysicalAttributeLabels[attributeId];
|
|
||||||
case kAttributeGroupSocialId:
|
|
||||||
return kSocialAttributeLabels[attributeId];
|
|
||||||
case kAttributeGroupMentalId:
|
|
||||||
return kMentalAttributeLabels[attributeId];
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FillAttributeLabelsInGroup(std::vector<string> attributeLabels, int attributeGroupId) {
|
void FillAttributeLabelsInGroup(std::vector<string> attributeLabels, int attributeGroupId) {
|
||||||
attributeLabels.clear();
|
attributeLabels.clear();
|
||||||
switch (attributeGroupId) {
|
switch (attributeGroupId) {
|
||||||
@@ -301,17 +275,17 @@ namespace SBF {
|
|||||||
switch (attributeGroupId) {
|
switch (attributeGroupId) {
|
||||||
case kAttributeGroupPhysicalId:
|
case kAttributeGroupPhysicalId:
|
||||||
for (int attributeId = 0; attributeId <= kPhysicalAttributesCount; attributeId++) {
|
for (int attributeId = 0; attributeId <= kPhysicalAttributesCount; attributeId++) {
|
||||||
attributeAbbreviations[attributeId] = kPhysicalAttributeAbbreviations[attributeId];
|
attributeAbbreviations[attributeId] = kPhysicalAttributeLabelAbbreviations[attributeId];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kAttributeGroupSocialId:
|
case kAttributeGroupSocialId:
|
||||||
for (int attributeId = 0; attributeId <= kSocialAttributesCount; attributeId++) {
|
for (int attributeId = 0; attributeId <= kSocialAttributesCount; attributeId++) {
|
||||||
attributeAbbreviations[attributeId] = kSocialAttributeAbbreviations[attributeId];
|
attributeAbbreviations[attributeId] = kSocialAttributeLabelAbbreviations[attributeId];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kAttributeGroupMentalId:
|
case kAttributeGroupMentalId:
|
||||||
for (int attributeId = 0; attributeId <= kMentalAttributesCount; attributeId++) {
|
for (int attributeId = 0; attributeId <= kMentalAttributesCount; attributeId++) {
|
||||||
attributeAbbreviations[attributeId] = kMentalAttributeAbbreviations[attributeId];
|
attributeAbbreviations[attributeId] = kMentalAttributeLabelAbbreviations[attributeId];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user