Refactors constants out of Character.h.

This commit is contained in:
2023-04-25 12:50:46 -07:00
parent 279c5d0893
commit 07af18f616
3 changed files with 20 additions and 4 deletions

View File

@@ -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

View File

@@ -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<int> 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;

View File

@@ -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);