Refactors constants out of Disciplines.h.
This commit is contained in:
@@ -18,6 +18,7 @@ using std::vector;
|
||||
|
||||
const int kBackgroundPoints = 5;
|
||||
const int kInitialGeneration = 13;
|
||||
const int kDisciplinePoints = 3;
|
||||
|
||||
CharacterType::CharacterType() {
|
||||
// Scalars
|
||||
@@ -67,7 +68,7 @@ CharacterType::CharacterType() {
|
||||
}
|
||||
|
||||
// Disciplines
|
||||
for (int id = 0; id <= kDisciplinesCount; id++) {
|
||||
for (int id = 0; id <= GetNumDisciplines(); id++) {
|
||||
SetDisciplineValue(id, 0);
|
||||
}
|
||||
}
|
||||
@@ -212,7 +213,7 @@ void CharacterType::FillDisciplineValues(std::vector<int>& values) const {
|
||||
// TODO: This method sucks, but was needed in QBasic.
|
||||
values.clear();
|
||||
values.push_back(0); // To pad the indexes.
|
||||
for (int id = 1; id <= kDisciplinesCount; id++) {
|
||||
for (int id = 1; id <= GetNumDisciplines(); id++) {
|
||||
values.push_back(GetDisciplineValue(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "Utils.h"
|
||||
#include "sbf-cpp/Abilities.h"
|
||||
#include "sbf-cpp/Backgrounds.h"
|
||||
#include "sbf-cpp/Disciplines.h"
|
||||
|
||||
namespace SBF {
|
||||
namespace {
|
||||
@@ -209,7 +210,7 @@ void CGSpendDisciplinePoint(CharacterType& ch) {
|
||||
MaybeClearScreen();
|
||||
MenuStyle ms;
|
||||
ms.show_cancel = true;
|
||||
ms.cancel_item_id = kDisciplinesCount + 1;
|
||||
ms.cancel_item_id = GetNumDisciplines() + 1;
|
||||
vector<int> values = ch.GetDisciplineValues();
|
||||
vector<string> labels;
|
||||
FillDisciplineLabels(labels);
|
||||
@@ -345,7 +346,7 @@ void ShowCharacterSheet(CharacterType& ch) {
|
||||
const int kRightColumnWidth = 37;
|
||||
vector<string> discipline_strings;
|
||||
size_t index;
|
||||
for (index = 1; index <= kDisciplinesCount; index++) {
|
||||
for (index = 1; index <= GetNumDisciplines(); index++) {
|
||||
int value = ch.GetDisciplineValue(index);
|
||||
if (value > 0) {
|
||||
string suffix = "";
|
||||
|
||||
@@ -7,6 +7,59 @@ namespace SBF {
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
const std::string kDisciplineAnimalismLabel = "Animalism";
|
||||
const std::string kDisciplineAuspexLabel = "Auspex";
|
||||
const std::string kDisciplineBardoLabel = "Bardo";
|
||||
const std::string kDisciplineCelerityLabel = "Celerity";
|
||||
const std::string kDisciplineChimestryLabel = "Chimestry";
|
||||
const std::string kDisciplineDementationLabel = "Dementation";
|
||||
const std::string kDisciplineDominateLabel = "Dominate";
|
||||
const std::string kDisciplineFortitudeLabel = "Fortitude";
|
||||
const std::string kDisciplineMelpomineeLabel = "Melpominee";
|
||||
const std::string kDisciplineMortisLabel = "Mortis";
|
||||
const std::string kDisciplineMytherceriaLabel = "Mytherceria";
|
||||
const std::string kDisciplineNecromancyLabel = "Necromancy";
|
||||
const std::string kDisciplineObeahLabel = "Obeah";
|
||||
const std::string kDisciplineObfuscateLabel = "Obfuscate";
|
||||
const std::string kDisciplineObtenebrationLabel = "Obtenebration";
|
||||
const std::string kDisciplinePotenceLabel = "Potence";
|
||||
const std::string kDisciplinePresenceLabel = "Presence";
|
||||
const std::string kDisciplineProteanLabel = "Protean";
|
||||
const std::string kDisciplineQuietusLabel = "Quietus";
|
||||
const std::string kDisciplineSerpentisLabel = "Serpentis";
|
||||
const std::string kDisciplineSpiritusLabel = "Spiritus";
|
||||
const std::string kDisciplineThanantosisLabel = "Thanantosis";
|
||||
const std::string kDisciplineThaumaturgyLabel = "Thaumaturgy";
|
||||
const std::string kDisciplineVicissitudeLabel = "Vicissitude";
|
||||
const int kDisciplinesCount = 24;
|
||||
const std::string kDisciplines[] = {
|
||||
"",
|
||||
kDisciplineAnimalismLabel,
|
||||
kDisciplineAuspexLabel,
|
||||
kDisciplineBardoLabel,
|
||||
kDisciplineCelerityLabel,
|
||||
kDisciplineChimestryLabel,
|
||||
kDisciplineDementationLabel,
|
||||
kDisciplineDominateLabel,
|
||||
kDisciplineFortitudeLabel,
|
||||
kDisciplineMelpomineeLabel,
|
||||
kDisciplineMortisLabel,
|
||||
kDisciplineMytherceriaLabel,
|
||||
kDisciplineNecromancyLabel,
|
||||
kDisciplineObeahLabel,
|
||||
kDisciplineObfuscateLabel,
|
||||
kDisciplineObtenebrationLabel,
|
||||
kDisciplinePotenceLabel,
|
||||
kDisciplinePresenceLabel,
|
||||
kDisciplineProteanLabel,
|
||||
kDisciplineQuietusLabel,
|
||||
kDisciplineSerpentisLabel,
|
||||
kDisciplineSpiritusLabel,
|
||||
kDisciplineThanantosisLabel,
|
||||
kDisciplineThaumaturgyLabel,
|
||||
kDisciplineVicissitudeLabel,
|
||||
};
|
||||
|
||||
string GetDisciplineLabel(int disciplineId) {
|
||||
if (disciplineId > 0 && disciplineId <= kDisciplinesCount) {
|
||||
return kDisciplines[disciplineId];
|
||||
@@ -21,4 +74,8 @@ void FillDisciplineLabels(vector<string>& labels) {
|
||||
labels.push_back(GetDisciplineLabel(id));
|
||||
}
|
||||
}
|
||||
|
||||
int GetNumDisciplines() {
|
||||
return kDisciplinesCount;
|
||||
}
|
||||
} // End namespace SBF
|
||||
|
||||
@@ -16,83 +16,31 @@
|
||||
* @{
|
||||
*/
|
||||
namespace SBF {
|
||||
const int kDisciplinePoints = 3;
|
||||
|
||||
const int kDisciplineAnimalismId = 1;
|
||||
const std::string kDisciplineAnimalismLabel = "Animalism";
|
||||
const int kDisciplineAuspexId = 2;
|
||||
const std::string kDisciplineAuspexLabel = "Auspex";
|
||||
const int kDisciplineBardoId = 3;
|
||||
const std::string kDisciplineBardoLabel = "Bardo";
|
||||
const int kDisciplineCelerityId = 4;
|
||||
const std::string kDisciplineCelerityLabel = "Celerity";
|
||||
const int kDisciplineChimestryId = 5;
|
||||
const std::string kDisciplineChimestryLabel = "Chimestry";
|
||||
const int kDisciplineDementationId = 6;
|
||||
const std::string kDisciplineDementationLabel = "Dementation";
|
||||
const int kDisciplineDominateId = 7;
|
||||
const std::string kDisciplineDominateLabel = "Dominate";
|
||||
const int kDisciplineFortitudeId = 8;
|
||||
const std::string kDisciplineFortitudeLabel = "Fortitude";
|
||||
const int kDisciplineMelpomineeId = 9;
|
||||
const std::string kDisciplineMelpomineeLabel = "Melpominee";
|
||||
const int kDisciplineMortisId = 10;
|
||||
const std::string kDisciplineMortisLabel = "Mortis";
|
||||
const int kDisciplineMytherceriaId = 11;
|
||||
const std::string kDisciplineMytherceriaLabel = "Mytherceria";
|
||||
const int kDisciplineNecromancyId = 12;
|
||||
const std::string kDisciplineNecromancyLabel = "Necromancy";
|
||||
const int kDisciplineObeahId = 13;
|
||||
const std::string kDisciplineObeahLabel = "Obeah";
|
||||
const int kDisciplineObfuscateId = 14;
|
||||
const std::string kDisciplineObfuscateLabel = "Obfuscate";
|
||||
const int kDisciplineObtenebrationId = 15;
|
||||
const std::string kDisciplineObtenebrationLabel = "Obtenebration";
|
||||
const int kDisciplinePotenceId = 16;
|
||||
const std::string kDisciplinePotenceLabel = "Potence";
|
||||
const int kDisciplinePresenceId = 17;
|
||||
const std::string kDisciplinePresenceLabel = "Presence";
|
||||
const int kDisciplineProteanId = 18;
|
||||
const std::string kDisciplineProteanLabel = "Protean";
|
||||
const int kDisciplineQuietusId = 19;
|
||||
const std::string kDisciplineQuietusLabel = "Quietus";
|
||||
const int kDisciplineSerpentisId = 20;
|
||||
const std::string kDisciplineSerpentisLabel = "Serpentis";
|
||||
const int kDisciplineSpiritusId = 21;
|
||||
const std::string kDisciplineSpiritusLabel = "Spiritus";
|
||||
const int kDisciplineThanantosisId = 22;
|
||||
const std::string kDisciplineThanantosisLabel = "Thanantosis";
|
||||
const int kDisciplineThaumaturgyId = 23;
|
||||
const std::string kDisciplineThaumaturgyLabel = "Thaumaturgy";
|
||||
const int kDisciplineVicissitudeId = 24;
|
||||
const std::string kDisciplineVicissitudeLabel = "Vicissitude";
|
||||
const int kDisciplinesCount = 24;
|
||||
const std::string kDisciplines[] = {
|
||||
"",
|
||||
kDisciplineAnimalismLabel,
|
||||
kDisciplineAuspexLabel,
|
||||
kDisciplineBardoLabel,
|
||||
kDisciplineCelerityLabel,
|
||||
kDisciplineChimestryLabel,
|
||||
kDisciplineDementationLabel,
|
||||
kDisciplineDominateLabel,
|
||||
kDisciplineFortitudeLabel,
|
||||
kDisciplineMelpomineeLabel,
|
||||
kDisciplineMortisLabel,
|
||||
kDisciplineMytherceriaLabel,
|
||||
kDisciplineNecromancyLabel,
|
||||
kDisciplineObeahLabel,
|
||||
kDisciplineObfuscateLabel,
|
||||
kDisciplineObtenebrationLabel,
|
||||
kDisciplinePotenceLabel,
|
||||
kDisciplinePresenceLabel,
|
||||
kDisciplineProteanLabel,
|
||||
kDisciplineQuietusLabel,
|
||||
kDisciplineSerpentisLabel,
|
||||
kDisciplineSpiritusLabel,
|
||||
kDisciplineThanantosisLabel,
|
||||
kDisciplineThaumaturgyLabel,
|
||||
kDisciplineVicissitudeLabel,
|
||||
};
|
||||
|
||||
/// @brief Gets the label for a discipline with a specific id.
|
||||
/// @param discipline_id The id of the discipline to get the label for.
|
||||
@@ -102,6 +50,8 @@ std::string GetDisciplineLabel(int discipline_id);
|
||||
/// @brief Fills the provided vector with all of the valid discipline labels.
|
||||
/// @param discipline_labels The vector to fill. It will be cleared first.
|
||||
void FillDisciplineLabels(std::vector<std::string>& discipline_labels);
|
||||
|
||||
int GetNumDisciplines();
|
||||
} // End namespace SBF
|
||||
|
||||
/** @}*/
|
||||
|
||||
@@ -52,14 +52,10 @@ TestResults test_FillDisciplineLabels() {
|
||||
auto fnToTest = []() -> string {
|
||||
ostringstream error_message;
|
||||
vector<string> expected = {
|
||||
kDisciplineAnimalismLabel, kDisciplineAuspexLabel, kDisciplineBardoLabel,
|
||||
kDisciplineCelerityLabel, kDisciplineChimestryLabel, kDisciplineDementationLabel,
|
||||
kDisciplineDominateLabel, kDisciplineFortitudeLabel, kDisciplineMelpomineeLabel,
|
||||
kDisciplineMortisLabel, kDisciplineMytherceriaLabel, kDisciplineNecromancyLabel,
|
||||
kDisciplineObeahLabel, kDisciplineObfuscateLabel, kDisciplineObtenebrationLabel,
|
||||
kDisciplinePotenceLabel, kDisciplinePresenceLabel, kDisciplineProteanLabel,
|
||||
kDisciplineQuietusLabel, kDisciplineSerpentisLabel, kDisciplineSpiritusLabel,
|
||||
kDisciplineThanantosisLabel, kDisciplineThaumaturgyLabel, kDisciplineVicissitudeLabel,
|
||||
"Animalism", "Auspex", "Bardo", "Celerity", "Chimestry", "Dementation",
|
||||
"Dominate", "Fortitude", "Melpominee", "Mortis", "Mytherceria", "Necromancy",
|
||||
"Obeah", "Obfuscate", "Obtenebration", "Potence", "Presence", "Protean",
|
||||
"Quietus", "Serpentis", "Spiritus", "Thanantosis", "Thaumaturgy", "Vicissitude",
|
||||
};
|
||||
vector<string> actual = {"This should be removed."};
|
||||
FillDisciplineLabels(actual);
|
||||
|
||||
Reference in New Issue
Block a user