Refactors constants out of Virtues.h.
This commit is contained in:
@@ -257,7 +257,7 @@ int CharacterType::GetVirtueValue(int id) const {
|
||||
|
||||
void CharacterType::FillVirtueValues(std::vector<int>& values) const {
|
||||
values.clear();
|
||||
for (int id = 0; id <= kVirtuesCount; id++) {
|
||||
for (int id = 0; id <= GetNumVirtues(); id++) {
|
||||
values.push_back(GetVirtueValue(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ void CGSpendAbilityPoint(CharacterType& ch) {
|
||||
void CGSpendVirtuePoint(CharacterType& ch) {
|
||||
MenuStyle ms;
|
||||
ms.show_cancel = true;
|
||||
ms.cancel_item_id = kVirtuesCount + 1;
|
||||
ms.cancel_item_id = GetNumVirtues() + 1;
|
||||
string prompt = "What virtue would you like to add 1 dot to?";
|
||||
int id = ChooseStringIdWithValues(GetVirtueLabels(), ch.GetVirtueValues(), ms, prompt);
|
||||
if (id != ms.cancel_item_id) {
|
||||
|
||||
@@ -9,6 +9,18 @@ using std::string;
|
||||
using std::vector;
|
||||
} // End namespace
|
||||
|
||||
const std::string kVirtueUnknownLabel = "";
|
||||
const std::string kVirtueSelfControlLabel = "Self-Control";
|
||||
const std::string kVirtueCourageLabel = "Courage";
|
||||
const std::string kVirtueConscienceLabel = "Conscience";
|
||||
const int kVirtuesCount = 3;
|
||||
const std::string kVirtueLabels[] = {
|
||||
kVirtueUnknownLabel,
|
||||
kVirtueSelfControlLabel,
|
||||
kVirtueCourageLabel,
|
||||
kVirtueConscienceLabel,
|
||||
};
|
||||
|
||||
const string GetVirtueLabel(int id) {
|
||||
if (id > 0 && id <= kVirtuesCount) {
|
||||
return kVirtueLabels[id];
|
||||
@@ -28,4 +40,8 @@ vector<string> GetVirtueLabels() {
|
||||
FillVirtueLabels(labels);
|
||||
return labels;
|
||||
}
|
||||
|
||||
int GetNumVirtues() {
|
||||
return kVirtuesCount;
|
||||
}
|
||||
} // End namespace SBF
|
||||
|
||||
@@ -16,20 +16,9 @@
|
||||
*/
|
||||
namespace SBF {
|
||||
const int kVirtuePoints = 7;
|
||||
const std::string kVirtueUnknownLabel = "";
|
||||
const int kVirtueSelfControlId = 1;
|
||||
const std::string kVirtueSelfControlLabel = "Self-Control";
|
||||
const int kVirtueCourageId = 2;
|
||||
const std::string kVirtueCourageLabel = "Courage";
|
||||
const int kVirtueConscienceId = 3;
|
||||
const std::string kVirtueConscienceLabel = "Conscience";
|
||||
const int kVirtuesCount = 3;
|
||||
const std::string kVirtueLabels[] = {
|
||||
kVirtueUnknownLabel,
|
||||
kVirtueSelfControlLabel,
|
||||
kVirtueCourageLabel,
|
||||
kVirtueConscienceLabel,
|
||||
};
|
||||
|
||||
/// @brief Gets the label for virtue with the specified id.
|
||||
/// @param virtue_id The id of the virtue to find.
|
||||
@@ -41,6 +30,7 @@ const std::string GetVirtueLabel(int virtue_id);
|
||||
void FillVirtueLabels(std::vector<std::string>& virtue_labels);
|
||||
|
||||
std::vector<std::string> GetVirtueLabels();
|
||||
int GetNumVirtues();
|
||||
} // End namespace SBF
|
||||
|
||||
/** @}*/
|
||||
|
||||
@@ -13,6 +13,17 @@ using namespace Test;
|
||||
using namespace std;
|
||||
} // End namespace
|
||||
|
||||
const std::string kVirtueUnknownLabel = "";
|
||||
const std::string kVirtueSelfControlLabel = "Self-Control";
|
||||
const std::string kVirtueCourageLabel = "Courage";
|
||||
const std::string kVirtueConscienceLabel = "Conscience";
|
||||
const std::string kVirtueLabels[] = {
|
||||
kVirtueUnknownLabel,
|
||||
kVirtueSelfControlLabel,
|
||||
kVirtueCourageLabel,
|
||||
kVirtueConscienceLabel,
|
||||
};
|
||||
|
||||
TestResults test_GetVirtueLabel() {
|
||||
return execute_suite<string, int>(make_test_suite(
|
||||
"SBF::GetVirtueLabel",
|
||||
|
||||
Reference in New Issue
Block a user