From ec4cf99c609b6d03e955100782caeccee7295e30 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 24 Apr 2023 14:54:45 -0700 Subject: [PATCH] Removes FillDerangements. Refactors GetAllDerangementsLine to be simpler. --- sbf-cpp/Character.cpp | 23 +++++++++-------------- sbf-cpp/Character.h | 1 - 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/sbf-cpp/Character.cpp b/sbf-cpp/Character.cpp index 904d750..9c95fa6 100644 --- a/sbf-cpp/Character.cpp +++ b/sbf-cpp/Character.cpp @@ -1,11 +1,17 @@ #include "Character.h" +#include +#include +#include + #include "Attributes.h" namespace SBF { - +namespace { +using std::ostringstream; using std::string; using std::vector; +} // namespace CharacterType::CharacterType() { // Scalars @@ -711,20 +717,9 @@ void NewDerangement(DerangementType& derangement, int id, string label, int text } string CharacterType::GetAllDerangementsLine() const { - // TODO: Replace this with a stringstream. - std::vector allDerangements; - FillDerangements(allDerangements); - string allDerangementsString = ""; - std::for_each(allDerangements.begin(), allDerangements.end(), [&allDerangementsString](DerangementType derangement) { - allDerangementsString += derangement.label + ", "; - }); - return allDerangementsString; -} - -void CharacterType::FillDerangements(std::vector derangements) const { - derangements.clear(); if (derangementId > 0) { - derangements[0] = kDerangements[derangementId]; + return GetDerangement(derangementId).label; } + return ""; } } // End namespace SBF diff --git a/sbf-cpp/Character.h b/sbf-cpp/Character.h index c463c89..73b0772 100644 --- a/sbf-cpp/Character.h +++ b/sbf-cpp/Character.h @@ -36,7 +36,6 @@ class CharacterType { void FillAttributeValues(std::vector attributeValues, int groupId) const; void FillBackgroundValues(std::vector backgroundValues) const; void FillDisciplineValues(std::vector disciplineValues) const; - void FillDerangements(std::vector derangements) const; void FillVirtueValues(std::vector virtueValues) const; int GetAbilityValue(int abilityGroupId, int abilityId) const; int GetAttributeValue(int attributeGroupId, int abilityId) const;