From 07af18f616487ba7b0ca201c84ffa16a7853f5c2 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Tue, 25 Apr 2023 12:50:46 -0700 Subject: [PATCH] Refactors constants out of Character.h. --- sbf-cpp/Character.cpp | 13 +++++++++++++ sbf-cpp/Character.h | 6 ++++-- sbf-cpp/CharacterGenerator.cpp | 5 +++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/sbf-cpp/Character.cpp b/sbf-cpp/Character.cpp index ea307fb..1ab4675 100644 --- a/sbf-cpp/Character.cpp +++ b/sbf-cpp/Character.cpp @@ -17,6 +17,7 @@ using std::vector; } // namespace const int kBackgroundPoints = 5; +const int kInitialGeneration = 13; CharacterType::CharacterType() { // Scalars @@ -741,4 +742,16 @@ int CharacterType::GetRoadValue() const { void CharacterType::SetRoadValue(int value) { road_value = value; } + +void CharacterType::SetGeneration(int value) { + generation = value; +} + +int CharacterType::GetGeneration() const { + return generation; +} + +int GetInitialGeneration() { + return kInitialGeneration; +} } // End namespace SBF diff --git a/sbf-cpp/Character.h b/sbf-cpp/Character.h index 7191284..b9fedaa 100644 --- a/sbf-cpp/Character.h +++ b/sbf-cpp/Character.h @@ -30,7 +30,7 @@ int GetAttributePointsForRank(int rank_id); int GetBackgroundPoints(); int GetDisciplinePoints(); int GetVirtuePoints(); -const int kInitialGeneration = 13; +int GetInitialGeneration(); class CharacterType { public: @@ -49,6 +49,7 @@ class CharacterType { int GetDisciplineValue(int id) const; std::vector GetDisciplineValues() const; int GetFreebiePoints() const; + int GetGeneration() const; int GetKnowledgeValue(int id) const; int GetMentalAttributeValue(int id) const; int GetPhysicalAttributeValue(int id) const; @@ -64,6 +65,7 @@ class CharacterType { void SetBackgroundValue(int id, int value); void SetDisciplineValue(int id, int value); void SetFreebiePoints(int value); + void SetGeneration(int value); void SetKnowledgeValue(int id, int value); void SetMentalAttributeValue(int id, int value); void SetPhysicalAttributeValue(int id, int value); @@ -87,7 +89,6 @@ class CharacterType { int conscience; int selfControl; int courage; - int generation; int willpower; int bloodPool; int derangementId; @@ -95,6 +96,7 @@ class CharacterType { private: // Scalars int freebie_points; + int generation; std::string road_name; int road_value; diff --git a/sbf-cpp/CharacterGenerator.cpp b/sbf-cpp/CharacterGenerator.cpp index fe307bf..00d0c27 100644 --- a/sbf-cpp/CharacterGenerator.cpp +++ b/sbf-cpp/CharacterGenerator.cpp @@ -12,6 +12,7 @@ #include "Random.h" #include "Utils.h" #include "sbf-cpp/Abilities.h" +#include "sbf-cpp/Backgrounds.h" namespace SBF { namespace { @@ -379,7 +380,7 @@ void ShowCharacterSheet(CharacterType& ch) { MaybeClearScreen(); cout << "╔══════════════════════════════════════╦═══════════════════════════════════════╗" << endl; cout << "║ Name: " << MakeFitL(ch.name, 30) << " ║ Gender: " << MakeFitL(GetGenderLabel(ch.genderId), 14) - << " Generation: " << MakeFitR(to_string(ch.generation), 2) << " ║" << endl; + << " Generation: " << MakeFitR(to_string(ch.GetGeneration()), 2) << " ║" << endl; cout << "║ Clan: " << MakeFitL(GetClanLabel(ch.clanId), 30) << " ║ Age: " << MakeFitL(ch.age, 32) << " ║" << endl; cout << "╠══════════════════════════════════════╣ Player: " << MakeFitL(ch.player, 29) << " ║" << endl; cout << "║ Attributes ║ Chronicle: " << MakeFitL(ch.chronicle, 26) << " ║" << endl; @@ -503,7 +504,7 @@ void CharacterGenerator() { CGGetRoad(ch); CGSpendVirtuePoints(ch); CGGetDerangement(ch); - ch.generation = kInitialGeneration - ch.GetBackgroundValue(kBackgroundGenerationId); + ch.SetGeneration(GetInitialGeneration() - ch.GetBackgroundValue(kBackgroundGenerationId)); ch.willpower = ch.courage; ch.SetRoadValue(ch.conscience + ch.selfControl); ch.bloodPool = GetRandomInt(1, 10);