Changes to test system to allow per class tests.

This commit is contained in:
2023-03-31 03:00:17 -07:00
parent c5c8bddb48
commit c2f04de4f8
41 changed files with 1352 additions and 902 deletions

View File

@@ -18,6 +18,7 @@ endif
BREW86_PREFIX := $(shell arch -x86_64 /usr/local/homebrew/bin/brew --prefix) BREW86_PREFIX := $(shell arch -x86_64 /usr/local/homebrew/bin/brew --prefix)
BREW_PREFIX := $(shell brew --prefix) BREW_PREFIX := $(shell brew --prefix)
LIB_DIR = $(BUILD_DIR)/lib
INCLUDE_DIRS = sbf-cpp $(BREW_PREFIX)/opt/ncurses/include INCLUDE_DIRS = sbf-cpp $(BREW_PREFIX)/opt/ncurses/include
INCLUDES := $(patsubst %, -I%, $(INCLUDE_DIRS)) INCLUDES := $(patsubst %, -I%, $(INCLUDE_DIRS))
LIBRARY_DIRS = $(BUILD_DIR)/lib LIBRARY_DIRS = $(BUILD_DIR)/lib
@@ -38,12 +39,17 @@ BUNDLEFOLDER = $(BUILD_DIR)/$(BUNDLENAME)
BUNDLEIDENTIFIER = com.majinnaibu.test.$(APPNAME) BUNDLEIDENTIFIER = com.majinnaibu.test.$(APPNAME)
BUNDLESIGNATURE = SBF_ BUNDLESIGNATURE = SBF_
RESOURCES_DIR = Resources RESOURCES_DIR = Resources
APP_OBJECTS = Character.o Colors.o Menus.o #APP_OBJECTS = Character.o Colors.o Menus.o
MODULES = Abilities Archetypes Attributes Backgrounds Character Clans Colors Derangements Disciplines Genders Ranks Utils Virtues
TEST_MODULES = $(patsubst %, %_test, $(MODULES))
APP_OBJECTS = $(patsubst %, $(BUILD_DIR)/%.o, $(MODULES))
TEST_OBJECTS = $(patsubst %, $(BUILD_DIR)/%.o, $(TEST_MODULES))
FAT_LIBS = ncurses FAT_LIBS = ncurses
FAT_LIB_OBJECTS = $(patsubst %, $(LIB_DIR)/lib%.a, $(FAT_LIBS))
MANDATORY_TARGETS = Makefile MANDATORY_TARGETS = Makefile
.Phony: all clean app run_all_tests run_incremental_tests .Phony: all clean app test run_all_tests run_incremental_tests
all: $(patsubst %, $(BUILD_DIR)/%, $(APPS)) app all: $(patsubst %, $(BUILD_DIR)/%, $(APPS)) app
@@ -55,12 +61,18 @@ clean:
mkdir -p $(BUNDLEFOLDER)/Contents/MacOS mkdir -p $(BUNDLEFOLDER)/Contents/MacOS
mkdir -p $(BUNDLEFOLDER)/Contents/Resources mkdir -p $(BUNDLEFOLDER)/Contents/Resources
run_all_tests: clean all run_all_tests: clean $(BUILD_DIR)/$(TESTAPPNAME) $(MANDATORY_TARGETS)
$(BUILD_DIR)/$(TESTAPPNAME) $(BUILD_DIR)/$(TESTAPPNAME)
run_incremental_tests: $(BUILD_DIR)/$(TESTAPPNAME) run_incremental_tests: $(BUILD_DIR)/$(TESTAPPNAME) $(MANDATORY_TARGETS)
$(BUILD_DIR)/$(TESTAPPNAME) $(BUILD_DIR)/$(TESTAPPNAME)
test: run_incremental_tests
run_test:
# should depend on Makefile build/something
# runs a single test bundle build/MODULE_test.o's main and prints the results.
run: $(BUILD_DIR)/$(CLIAPPNAME) run: $(BUILD_DIR)/$(CLIAPPNAME)
$(BUILD_DIR)/$(CLIAPPNAME) $(BUILD_DIR)/$(CLIAPPNAME)
@@ -75,15 +87,38 @@ app: $(BUILD_DIR)/$(CLIAPPNAME) $(SRC_DIR)/Info.plist $(RESOURCES_DIR)/en-US.lpr
cp $(BUILD_DIR)/$(CLIAPPNAME) $(BUNDLEFOLDER)/Contents/MacOS/$(APPNAME) cp $(BUILD_DIR)/$(CLIAPPNAME) $(BUNDLEFOLDER)/Contents/MacOS/$(APPNAME)
cp -r $(RESOURCES_DIR)/* $(BUNDLEFOLDER)/Contents/Resources/ cp -r $(RESOURCES_DIR)/* $(BUNDLEFOLDER)/Contents/Resources/
$(BUILD_DIR)/$(CLIAPPNAME): $(BUILD_DIR)/sbf.o $(patsubst %, $(BUILD_DIR)/%, $(APP_OBJECTS)) $(patsubst %, $(BUILD_DIR)/lib/lib%.a, $(FAT_LIBS)) $(MANDATORY_TARGETS) $(BUILD_DIR)/$(CLIAPPNAME): $(BUILD_DIR)/sbf.o $(APP_OBJECTS) $(FAT_LIB_OBJECTS) $(MANDATORY_TARGETS)
$(LD) $(LDFLAGS) -o $@ $< $(patsubst %, $(BUILD_DIR)/%, $(APP_OBJECTS)) $(LD) $(LDFLAGS) -o $@ $< $(APP_OBJECTS)
$(BUILD_DIR)/$(TESTAPPNAME): $(BUILD_DIR)/test.o $(patsubst %, $(BUILD_DIR)/%, $(APP_OBJECTS)) $(patsubst %, $(BUILD_DIR)/lib/lib%.a, $(FAT_LIBS)) $(MANDATORY_TARGETS) $(BUILD_DIR)/$(TESTAPPNAME): $(BUILD_DIR)/test_main.o $(BUILD_DIR)/test.o $(APP_OBJECTS) $(TEST_OBJECTS) $(FAT_LIB_OBJECTS) $(BUILD_DIR)/test_main.cpp $(MANDATORY_TARGETS)
$(LD) $(LDFLAGS) -o $@ $< $(patsubst %, $(BUILD_DIR)/%, $(APP_OBJECTS)) $(LD) $(LDFLAGS) -o $@ $< $(APP_OBJECTS) $(TEST_OBJECTS) $(BUILD_DIR)/test.o
$(BUILD_DIR)/test_main.o: $(BUILD_DIR)/test_main.cpp $(SRC_DIR)/*.h $(SRC_DIR)/*_test.cpp $(MANDATORY_TARGETS)
$(CC) $(CCFLAGS) -c -o $@ $<
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/*.h $(MANDATORY_TARGETS) $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/*.h $(MANDATORY_TARGETS)
$(CC) $(CCFLAGS) -c -o $@ $< $(CC) $(CCFLAGS) -c -o $@ $<
# Create build/test_main.cpp with a main function that calls all of the test_main_* functions in each of the $(TEST_OBJECTS).
$(BUILD_DIR)/test_main.cpp: $(TEST_OBJECTS)
echo "// This file is auto generated\n" > $(BUILD_DIR)/test_main.cpp
echo "$(patsubst %, #include \"../$(SRC_DIR)/%.h\"\n, $(MODULES))" >> $(BUILD_DIR)/test_main.cpp
echo "#include \"../$(SRC_DIR)/test.h\"" >> $(BUILD_DIR)/test_main.cpp
echo "#include <clocale>" >> $(BUILD_DIR)/test_main.cpp
echo "#include <string>" >> $(BUILD_DIR)/test_main.cpp
echo "#include <iostream>" >> $(BUILD_DIR)/test_main.cpp
echo "#include <tuple>" >> $(BUILD_DIR)/test_main.cpp
echo "using namespace Test;" >> $(BUILD_DIR)/test_main.cpp
echo "using std::wcout;\nusing std::endl;\nusing std::tuple;\nusing std::get;" >> $(BUILD_DIR)/test_main.cpp
echo "$(patsubst %, extern test_method_result main_test_%(int argc, char** argv);\n, $(MODULES))" >> $(BUILD_DIR)/test_main.cpp
echo "int main(int argc, char** argv) {\n setlocale(LC_ALL, \"\");\n test_method_result results;\n" >> $(BUILD_DIR)/test_main.cpp
echo "$(patsubst %, results = results + main_test_%(argc, argv);\n, $(MODULES))" >> $(BUILD_DIR)/test_main.cpp
echo " wcout << \"Total tests ran: \" << get<0>(results) << endl;\n" >> $(BUILD_DIR)/test_main.cpp
echo " wcout << \"Total failures: \" << get<1>(results) << endl;\n" >> $(BUILD_DIR)/test_main.cpp
echo "\n return 0;\n}" >> $(BUILD_DIR)/test_main.cpp
# We make our own fat libs cause homebrew sucks # We make our own fat libs cause homebrew sucks
build/lib/lib%.a: $(BREW_PREFIX)/opt/$$*/lib/lib$$*.a $(BREW86_PREFIX)/opt/$$*/lib/lib$$*.a $(MANDATORY_TARGETS) $(LIB_DIR)/lib%.a: $(BREW_PREFIX)/opt/$$*/lib/lib$$*.a $(BREW86_PREFIX)/opt/$$*/lib/lib$$*.a $(MANDATORY_TARGETS)
lipo -create -output $@ $(word 1, $^) $(word 2, $^) lipo -create -output $@ $(word 1, $^) $(word 2, $^)

18
sbf-cpp/Abilities.cpp Normal file
View File

@@ -0,0 +1,18 @@
#include "Abilities.h"
#include <string>
namespace SBF {
using std::wstring;
const wstring& GetAbilityLabel(int abilityGroupId, int abilityId) {
switch (abilityGroupId) {
case kAbilityTalentsId:
return kTalents[abilityId];
case kAbilitySkillsId:
return kSkills[abilityId];
case kAbilityKnowledgesId:
return kKnowledges[abilityId];
}
return L"";
}
} // End namespace SBF

145
sbf-cpp/Abilities.h Normal file
View File

@@ -0,0 +1,145 @@
#ifndef ABILITIES_H__
#define ABILITIES_H__
#include <string>
#include <vector>
namespace SBF {
const int kAbilityTalentsId = 1;
const std::wstring kAbilityTalentsSingular = L"Talent";
const std::wstring kAbilityTalentsPlural = L"Talents";
const int kAbilitySkillsId = 2;
const std::wstring kAbilitySkillsSingular = L"Skill";
const std::wstring kAbilitySkillsPlural = L"Skills";
const int kAbilityKnowledgesId = 3;
const std::wstring kAbilityKnowledgesSingular = L"Skill";
const std::wstring kAbilityKnowledgesPlural = L"Skills";
const int kAbilitiesCount = 3;
struct AbilityType {
int id;
std::wstring singular;
std::wstring plural;
};
const AbilityType kAbilities[] {
{0, L"", L""},
{kAbilityTalentsId, kAbilityTalentsSingular, kAbilityTalentsPlural},
{kAbilitySkillsId, kAbilitySkillsSingular, kAbilitySkillsPlural},
{kAbilityKnowledgesId, kAbilityKnowledgesSingular, kAbilityKnowledgesPlural},
};
const int kTalentActingId = 1;
const std::wstring kTalentActingLabel = L"Acting";
const int kTalentAlertnessId = 2;
const std::wstring kTalentAlertnessLabel = L"Alertness";
const int kTalentAthleticsId = 3;
const std::wstring kTalentAthleticsLabel = L"Athletics";
const int kTalentBrawlId = 4;
const std::wstring kTalentBrawlLabel = L"Brawl";
const int kTalentDodgeId = 5;
const std::wstring kTalentDodgeLabel = L"Dodge";
const int kTalentEmpathyId = 6;
const std::wstring kTalentEmpathyLabel = L"Empathty";
const int kTalentIntimidationId = 7;
const std::wstring kTalentIntimidationLabel = L"Intimidation";
const int kTalentLeadershipId = 8;
const std::wstring kTalentLeadershipLabel = L"Leadership";
const int kTalentStreetwiseId = 9;
const std::wstring kTalentStreetwiseLabel = L"Streetwise";
const int kTalentSubterfugeId = 10;
const std::wstring kTalentSubterfugeLabel = L"Subterfuge";
const int kTalentsCount = 10;
const std::wstring kTalents[] = {
L"",
kTalentActingLabel,
kTalentAlertnessLabel,
kTalentAthleticsLabel,
kTalentBrawlLabel,
kTalentDodgeLabel,
kTalentEmpathyLabel,
kTalentIntimidationLabel,
kTalentLeadershipLabel,
kTalentStreetwiseLabel,
kTalentSubterfugeLabel,
};
const int kSkillAnimalKenId = 1;
const std::wstring kSkillAnimalKenLabel = L"AnimalKen";
const int kSkillDriveId = 2;
const std::wstring kSkillDriveLabel = L"Drive";
const int kSkillEtiquetteId = 3;
const std::wstring kSkillEtiquetteLabel = L"Etiquette";
const int kSkillFirearmsId = 4;
const std::wstring kSkillFirearmsLabel = L"Firearms";
const int kSkillMeleeId = 5;
const std::wstring kSkillMeleeLabel = L"Melee";
const int kSkillMusicId = 6;
const std::wstring kSkillMusicLabel = L"Music";
const int kSkillRepairId = 7;
const std::wstring kSkillRepairLabel = L"Repair";
const int kSkillSecurityId = 8;
const std::wstring kSkillSecurityLabel = L"Security";
const int kSkillStealthId = 9;
const std::wstring kSkillStealthLabel = L"Stealth";
const int kSkillSurvivalId = 10;
const std::wstring kSkillSurvivalLabel = L"Survival";
const int kSkillsCount = 10;
const std::wstring kSkills[] = {
L"",
kSkillAnimalKenLabel,
kSkillDriveLabel,
kSkillEtiquetteLabel,
kSkillFirearmsLabel,
kSkillMeleeLabel,
kSkillMusicLabel,
kSkillRepairLabel,
kSkillSecurityLabel,
kSkillStealthLabel,
kSkillSurvivalLabel,
};
const int kKnowledgeBureaucracyId = 1;
const std::wstring kKnowledgeBureaucracyLabel = L"Bureaucracy";
const int kKnowledgeComputerId = 2;
const std::wstring kKnowledgeComputerLabel = L"Computer";
const int kKnowledgeFinanceId = 3;
const std::wstring kKnowledgeFinanceLabel = L"Finance";
const int kKnowledgeInvestigationId = 4;
const std::wstring kKnowledgeInvestigationLabel = L"Investigation";
const int kKnowledgeLawId = 5;
const std::wstring kKnowledgeLawLabel = L"Law";
const int kKnowledgeLinguisticsId = 6;
const std::wstring kKnowledgeLinguisticsLabel = L"Linguistics";
const int kKnowledgeMedicineId = 7;
const std::wstring kKnowledgeMedicineLabel = L"Medicine";
const int kKnowledgeOccultId = 8;
const std::wstring kKnowledgeOccultLabel = L"Occult";
const int kKnowledgePoliticsId = 9;
const std::wstring kKnowledgePoliticsLabel = L"Politics";
const int kKnowledgeScienceId = 10;
const std::wstring kKnowledgeScienceLabel = L"Science";
const int kKnowledgesCount = 10;
const std::wstring kKnowledges[] = {
L"",
kKnowledgeBureaucracyLabel,
kKnowledgeComputerLabel,
kKnowledgeFinanceLabel,
kKnowledgeInvestigationLabel,
kKnowledgeLawLabel,
kKnowledgeLinguisticsLabel,
kKnowledgeMedicineLabel,
kKnowledgeOccultLabel,
kKnowledgePoliticsLabel,
kKnowledgeScienceLabel,
};
int GetNumItemsForAbilityGroup(int abilityGroupId);
const AbilityType& GetAbility(int abilityId);
void FillAbilities(std::vector<AbilityType> abilities);
const std::wstring& GetTalentLabel(int talentId);
const std::wstring& GetSkillLabel(int talentId);
const std::wstring& GetKnowledgeLabel(int talentId);
const std::wstring& GetAbilityLabel(int abilityGroupId, int abilityId);
void FillTalentLabels(std::vector<std::wstring> talentLabels);
void FillSkillLabels(std::vector<std::wstring> skillLabels);
void FillKnowledgeLabels(std::vector<std::wstring> knowledgeLabels);
} // End namespace SBF
#endif // End !defined ABILITIES_H__

View File

@@ -0,0 +1,23 @@
#include "Abilities.h"
#include "test.h"
using namespace SBF;
using namespace Test;
// void test_GetNumItemsForAbilityGroup()
// int GetNumItemsForAbilityGroup(int abilityGroupId);
// const AbilityType& GetAbility(int abilityId);
// void FillAbilities(std::vector<AbilityType> abilities);
// const std::wstring& GetTalentLabel(int talentId);
// const std::wstring& GetSkillLabel(int talentId);
// const std::wstring& GetKnowledgeLabel(int talentId);
// const std::wstring& GetAbilityLabel(int abilityGroupId, int abilityId);
// void FillTalentLabels(std::vector<std::wstring> talentLabels);
// void FillSkillLabels(std::vector<std::wstring> skillLabels);
// void FillKnowledgeLabels(std::vector<std::wstring> knowledgeLabels);
test_method_result main_test_Abilities(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Archetypes.cpp Normal file
View File

105
sbf-cpp/Archetypes.h Normal file
View File

@@ -0,0 +1,105 @@
#ifndef ARCHETYPES_H__
#define ARCHETYPES_H__
#include <string>
#include <vector>
namespace SBF {
const int kArchetypeArchitectId = 1;
const std::wstring kArchetypeArchitectLabel = L"Architect";
const int kArchetypeAutocratId = 2;
const std::wstring kArchetypeAutocratLabel = L"Autocrat";
const int kArchetypeBarbarianId = 3;
const std::wstring kArchetypeBarbarianLabel = L"Barbarian";
const int kArchetypeBonVivantId = 4;
const std::wstring kArchetypeBonVivantLabel = L"Bon Vivant";
const int kArchetypeBravoId = 5;
const std::wstring kArchetypeBravoLabel = L"Bravo";
const int kArchetypeCaregiverId = 6;
const std::wstring kArchetypeCaregiverLabel = L"Caregiver";
const int kArchetypeCaretakerId = 7;
const std::wstring kArchetypeCaretakerLabel = L"Caretaker";
const int kArchetypeCelebrantId = 8;
const std::wstring kArchetypeCelebrantLabel = L"Celebrant";
const int kArchetypeChildId = 9;
const std::wstring kArchetypeChildLabel = L"Child";
const int kArchetypeConformist = 10;
const std::wstring kArchetypeConformistLabel = L"Conformist";
const int kArchetypeConniverId = 11;
const std::wstring kArchetypeConniverLabel = L"Conniver";
const int kArchetypeCurmudgeonId = 12;
const std::wstring kArchetypeCurmudgeonLabel = L"Curmudgeon";
const int kArchetypeDefenderId = 13;
const std::wstring kArchetypeDefenderLabel = L"Defender";
const int kArchetypeDeviantId = 14;
const std::wstring kArchetypeDeviantLabel = L"Deviant";
const int kArchetypeDirectorId = 15;
const std::wstring kArchetypeDirectorLabel = L"Director";
const int kArchetypeFanaticId = 16;
const std::wstring kArchetypeFanaticLabel = L"Fanatic";
const int kArchetypeGallantId = 17;
const std::wstring kArchetypeGallantLabel = L"Gallant";
const int kArchetypeInnovatorId = 18;
const std::wstring kArchetypeInnovatorLabel = L"Innovator";
const int kArchetypeJesterId = 19;
const std::wstring kArchetypeJesterLabel = L"Jester";
const int kArchetypeJudgeId = 20;
const std::wstring kArchetypeJudgeLabel = L"Judge";
const int kArchetypeLoanerId = 21;
const std::wstring kArchetypeLoanerLabel = L"Loaner";
const int kArchetypeMartyrId = 22;
const std::wstring kArchetypeMartyrLabel = L"Martyr";
const int kArchetypeMonsterId = 23;
const std::wstring kArchetypeMonsterLabel = L"Monster";
const int kArchetypePenitentId = 24;
const std::wstring kArchetypePenitentLabel = L"Penitent";
const int kArchetypeRebelId = 25;
const std::wstring kArchetypeRebelLabel = L"Rebel";
const int kArchetypeRogueId = 26;
const std::wstring kArchetypeRogueLabel = L"Rogue";
const int kArchetypeSurvivorId = 27;
const std::wstring kArchetypeSurvivorLabel = L"Survivor";
const int kArchetypeTraditionalistId = 28;
const std::wstring kArchetypeTraditionalistLabel = L"Traditionalist";
const int kArchetypeTyrantId = 29;
const std::wstring kArchetypeTyrantLabel = L"Tyrant";
const int kArchetypeVisionaryId = 30;
const std::wstring kArchetypeVisionaryLabel = L"Visionary";
const int kArchetypesCount = 30;
const std::wstring kArchetypes[] = {
L"",
kArchetypeArchitectLabel,
kArchetypeAutocratLabel,
kArchetypeBarbarianLabel,
kArchetypeBonVivantLabel,
kArchetypeBravoLabel,
kArchetypeCaregiverLabel,
kArchetypeCaretakerLabel,
kArchetypeCelebrantLabel,
kArchetypeChildLabel,
kArchetypeConformistLabel,
kArchetypeConniverLabel,
kArchetypeCurmudgeonLabel,
kArchetypeDefenderLabel,
kArchetypeDeviantLabel,
kArchetypeDirectorLabel,
kArchetypeFanaticLabel,
kArchetypeGallantLabel,
kArchetypeInnovatorLabel,
kArchetypeJesterLabel,
kArchetypeJudgeLabel,
kArchetypeLoanerLabel,
kArchetypeMartyrLabel,
kArchetypeMonsterLabel,
kArchetypePenitentLabel,
kArchetypeRebelLabel,
kArchetypeRogueLabel,
kArchetypeSurvivorLabel,
kArchetypeTraditionalistLabel,
kArchetypeTyrantLabel,
kArchetypeVisionaryLabel,
};
const std::wstring& GetArchetypeLabel(int archetypeId);
void FillArchetypeLabels(std::vector<std::wstring> archetypeLabels);
} // End namespace SBF
#endif // End !defined ARCHETYPES_H__

View File

@@ -0,0 +1,10 @@
#include "Archetypes.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Archetypes(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Attributes.cpp Normal file
View File

101
sbf-cpp/Attributes.h Normal file
View File

@@ -0,0 +1,101 @@
#ifndef ATTRIBUTES_H__
#define ATTRIBUTES_H__
#include <string>
#include <vector>
namespace SBF {
const int kPhysicalAttributeStrengthId = 1;
const std::wstring kPhysicalAttributeStrengthLabel = L"Strength";
const std::wstring kPhysicalAttributeStrengthAbbreviation = L"Str.";
const int kPhysicalAttributeDexterityId = 2;
const std::wstring kPhysicalAttributeDexterityLabel = L"Dexterity";
const std::wstring kPhysicalAttributeDexterityAbbreviation = L"Dex.";
const int kPhysicalAttributeStaminaId = 3;
const std::wstring kPhysicalAttributeStaminaLabel = L"Stamina";
const std::wstring kPhysicalAttributeStaminaAbbreviation = L"Sta.";
const int kPhysicalAttributesCount = 3;
const std::wstring kPhysicalAttributeLabels[] = {
L"",
kPhysicalAttributeStrengthLabel,
kPhysicalAttributeDexterityLabel,
kPhysicalAttributeStaminaLabel,
};
const std::wstring kPhysicalAttributeAbbreviations[] = {
L"",
kPhysicalAttributeStrengthAbbreviation,
kPhysicalAttributeDexterityAbbreviation,
kPhysicalAttributeStaminaAbbreviation,
};
const int kSocialAttributeCharismaId = 1;
const std::wstring kSocialAttributeCharismaLabel = L"Charisma";
const std::wstring kSocialAttributeCharismaAbbreviation = L"Cha.";
const int kSocialAttributeManipulationId = 2;
const std::wstring kSocialAttributeManipulationLabel = L"Manipulation";
const std::wstring kSocialAttributeManipulationAbbreviation = L"Man.";
const int kSocialAttributeAppearanceId = 3;
const std::wstring kSocialAttributeAppearanceLabel = L"Appearance";
const std::wstring kSocialAttributeAppearanceAbbreviation = L"App.";
const int kSocialAttributesCount = 3;
const std::wstring kSocialAttributeLabels[] = {
L"",
kSocialAttributeCharismaLabel,
kSocialAttributeManipulationLabel,
kSocialAttributeAppearanceLabel,
};
const std::wstring kSocialAttributeAbbreviations[] = {
L"",
kSocialAttributeCharismaAbbreviation,
kSocialAttributeManipulationAbbreviation,
kSocialAttributeAppearanceAbbreviation,
};
const int kMentalAttributeIntelligenceId = 1;
const std::wstring kMentalAttributeIntelligenceLabel = L"Intelligence";
const std::wstring kMentalAttributeIntelligenceAbbreviation = L"Int.";
const int kMentalAttributePerceptionId = 2;
const std::wstring kMentalAttributePerceptionLabel = L"Perception";
const std::wstring kMentalAttributePerceptionAbbreviation = L"Per.";
const int kMentalAttributeWitsId = 3;
const std::wstring kMentalAttributeWitsLabel = L"Wits";
const std::wstring kMentalAttributeWitsAbbreviation = L"Wits";
const int kMentalAttributesCount = 3;
const std::wstring kMentalAttributeLabels[] = {
L"",
kMentalAttributeIntelligenceLabel,
kMentalAttributePerceptionLabel,
kMentalAttributeWitsLabel,
};
const std::wstring kMentalAttributeAbbreviations[] = {
L"",
kMentalAttributeIntelligenceLabel,
kMentalAttributePerceptionAbbreviation,
kMentalAttributeWitsAbbreviation,
};
const int kAttributeGroupPhysicalId = 1;
const std::wstring kAttributeGroupPhysicalLabel = L"Physical";
const int kAttributeGroupSocialId = 2;
const std::wstring kAttributeGroupSocialLabel = L"Social";
const int kAttributeGroupMentalId = 3;
const std::wstring kAttributeGroupMentalLabel = L"Mental";
const int kAttributeGroupsCount = 3;
const std::wstring kAttributeGroups[] = {
L"",
kAttributeGroupPhysicalLabel,
kAttributeGroupSocialLabel,
kAttributeGroupMentalLabel,
};
const std::wstring& GetAttributeGroupLabel(int attributeGroupId);
const std::wstring& GetAtttributeLabel(int attributeGroupId, int attributeId);
const std::wstring& GetPhysicalAttributeLabel(int attributeId);
const std::wstring& GetSocialAttributeLabel(int attributeId);
const std::wstring& GetMentalAttributeLabel(int attributeId);
void FillAttributeGroupLabels(std::vector<std::wstring> attributeGroupLabels);
void FillAttributeLabelInGroup(std::vector<std::wstring> attributeLabels);
void FillPhysicalAttributeLabels(std::vector<std::wstring> physicalAttributeLabels);
void FillSocialAttributeLabels(std::vector<std::wstring> socialAttributeLabels);
void FillMentalAttributeLabels(std::vector<std::wstring> mentalAttributeLabels);
} // End namespace SBF
#endif // End !defined ATTRIBUTES_H__

View File

@@ -0,0 +1,10 @@
#include "Attributes.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Attributes(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Backgrounds.cpp Normal file
View File

45
sbf-cpp/Backgrounds.h Normal file
View File

@@ -0,0 +1,45 @@
#ifndef BACKGROUNDS_H__
#define BACKGROUNDS_H__
#include <string>
#include <vector>
namespace SBF {
const int kBackgroundPoints = 5;
const int kBackgroundAlliesId = 1;
const std::wstring kBackgroundAlliesLabel = L"Allies";
const int kBackgroundContactsId = 2;
const std::wstring kBackgroundContactsLabel = L"Contacts";
const int kBackgroundFameId = 3;
const std::wstring kBackgroundFameLabel = L"Fame";
const int kBackgroundGenerationId = 4;
const std::wstring kBackgroundGenerationLabel = L"Generation";
const int kBackgroundHerdId = 5;
const std::wstring kBackgroundHerdLabel = L"Herd";
const int kBackgroundInfluenceId = 6;
const std::wstring kBackgroundInfluenceLabel = L"Influence";
const int kBackgroundMentorId = 7;
const std::wstring kBackgroundMentorLabel = L"Mentor";
const int kBackgroundResourcesId = 8;
const std::wstring kBackgroundResourcesLabel = L"Resources";
const int kBackgroundRetainersId = 9;
const std::wstring kBackgroundRetainersLabel = L"Retainers";
const int kBackgroundStatusId = 10;
const std::wstring kBackgroundStatusLabel = L"Status";
const int kBackgroundsCount = 10;
const std::wstring kBackgroundLabels[] = {
L"",
kBackgroundAlliesLabel,
kBackgroundContactsLabel,
kBackgroundFameLabel,
kBackgroundGenerationLabel,
kBackgroundHerdLabel,
kBackgroundInfluenceLabel,
kBackgroundMentorLabel,
kBackgroundResourcesLabel,
kBackgroundRetainersLabel,
kBackgroundStatusLabel,
};
const std::wstring& GetBackgroundLabel(int backgroundId);
void FillBackgroundLabels(std::vector<std::wstring> backgroundLabels);
} // End namespace SBF
#endif // End !defined BACKGROUNDS_H__

View File

@@ -0,0 +1,10 @@
#include "Backgrounds.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Backgrounds(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

View File

@@ -2,6 +2,9 @@
namespace SBF { namespace SBF {
using std::wstring;
using std::vector;
int GetNumAttributesInGroup(int groupId) { int GetNumAttributesInGroup(int groupId) {
switch (groupId) { switch (groupId) {
case kAttributeGroupPhysicalId: case kAttributeGroupPhysicalId:
@@ -41,7 +44,7 @@ namespace SBF {
// Arrays/Objects // Arrays/Objects
// Abilities (Talents/Skills/Knowledges) // Abilities (Talents/Skills/Knowledges)
for (int groupId = 1; groupId <= kAbilityGroupsCount; groupId++) { for (int groupId = 1; groupId <= kAbilitiesCount; groupId++) {
const int numAbilities = GetNumItemsForAbilityGroup(groupId); const int numAbilities = GetNumItemsForAbilityGroup(groupId);
for (int abilityId = 1; abilityId <= numAbilities; abilityId++) { for (int abilityId = 1; abilityId <= numAbilities; abilityId++) {
SetAbilityValue(groupId, abilityId, 0); SetAbilityValue(groupId, abilityId, 0);
@@ -408,13 +411,13 @@ namespace SBF {
void CharacterType::SetAbilityValue(int abilityGroupId, int abilityId, int value) { void CharacterType::SetAbilityValue(int abilityGroupId, int abilityId, int value) {
switch (abilityGroupId) { switch (abilityGroupId) {
case kAbilityGroupTalentsId: case kAbilityTalentsId:
SetTalentValue(abilityId, value); SetTalentValue(abilityId, value);
break; break;
case kAbilityGroupSkillsId: case kAbilitySkillsId:
SetSkillValue(abilityId, value); SetSkillValue(abilityId, value);
break; break;
case kAbilityGroupKnowledgesId: case kAbilityKnowledgesId:
SetKnowledgeValue(abilityId, value); SetKnowledgeValue(abilityId, value);
break; break;
} }
@@ -422,11 +425,11 @@ namespace SBF {
int CharacterType::GetAbilityValue(int abilityGroupId, int abilityId) const { int CharacterType::GetAbilityValue(int abilityGroupId, int abilityId) const {
switch(abilityGroupId) { switch(abilityGroupId) {
case kAbilityGroupTalentsId: case kAbilityTalentsId:
return GetTalentValue(abilityId); return GetTalentValue(abilityId);
case kAbilityGroupKnowledgesId: case kAbilityKnowledgesId:
return GetKnowledgeValue(abilityId); return GetKnowledgeValue(abilityId);
case kAbilityGroupSkillsId: case kAbilitySkillsId:
return GetSkillValue(abilityId); return GetSkillValue(abilityId);
} }
return 0; return 0;
@@ -454,43 +457,31 @@ namespace SBF {
int GetNumItemsForAbilityGroup(int abilityGroupId) { int GetNumItemsForAbilityGroup(int abilityGroupId) {
switch (abilityGroupId) { switch (abilityGroupId) {
case kAbilityGroupTalentsId: case kAbilityTalentsId:
return kTalentsCount; return kTalentsCount;
case kAbilityGroupSkillsId: case kAbilitySkillsId:
return kSkillsCount; return kSkillsCount;
case kAbilityGroupKnowledgesId: case kAbilityKnowledgesId:
return kKnowledgesCount; return kKnowledgesCount;
} }
return 0; return 0;
} }
wstring GetAbilityLabel(int abilityGroupId, int abilityId) {
switch (abilityGroupId) {
case kAbilityGroupTalentsId:
return kTalents[abilityId];
case kAbilityGroupSkillsId:
return kSkills[abilityId];
case kAbilityGroupKnowledgesId:
return kKnowledges[abilityId];
}
return L"";
}
void FillAbilitiesForAbilityGroup(std::vector<wstring> abilities, int abilityGroupId) { void FillAbilitiesForAbilityGroup(std::vector<wstring> abilities, int abilityGroupId) {
abilities.clear(); abilities.clear();
int numAbilities = GetNumItemsForAbilityGroup(abilityGroupId); int numAbilities = GetNumItemsForAbilityGroup(abilityGroupId);
switch (abilityGroupId) { switch (abilityGroupId) {
case kAbilityGroupTalentsId: case kAbilityTalentsId:
for (int talentId = 0; talentId <= numAbilities; talentId++) { for (int talentId = 0; talentId <= numAbilities; talentId++) {
abilities[talentId] = kTalents[talentId]; abilities[talentId] = kTalents[talentId];
} }
break; break;
case kAbilityGroupSkillsId: case kAbilitySkillsId:
for (int skillId = 0; skillId <= numAbilities; skillId++) { for (int skillId = 0; skillId <= numAbilities; skillId++) {
abilities[skillId] = kSkills[skillId]; abilities[skillId] = kSkills[skillId];
} }
break; break;
case kAbilityGroupKnowledgesId: case kAbilityKnowledgesId:
for (int knowledgeId = 0; knowledgeId <= numAbilities; knowledgeId++) { for (int knowledgeId = 0; knowledgeId <= numAbilities; knowledgeId++) {
abilities[knowledgeId] = kKnowledges[knowledgeId]; abilities[knowledgeId] = kKnowledges[knowledgeId];
} }

View File

@@ -1,709 +1,21 @@
#ifndef CHARACTER_H__ #ifndef CHARACTER_H__
#define CHARACTER_H__ #define CHARACTER_H__
#include "Colors.h" #include "Colors.h"
#include "Ranks.h"
#include "Clans.h"
#include "Derangements.h"
#include "Disciplines.h"
#include "Virtues.h"
#include "Attributes.h"
#include "Abilities.h"
#include "Backgrounds.h"
#include <string> #include <string>
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
namespace SBF { namespace SBF {
using std::wstring;
const int kRankPrimaryId = 1;
const wstring kRankPrimaryLabel = L"Primary";
const int kRankSecondaryId = 2;
const wstring kRankSecondaryLabel = L"Secondary";
const int kRankTertiaryId = 3;
const wstring kRankTertiaryLabel = L"Tertiary";
const int kRanksCount = 3;
struct RankType {
int id;
wstring label;
};
const RankType kRanks[] {
{0, L""},
{kRankPrimaryId, kRankPrimaryLabel},
{kRankSecondaryId, kRankSecondaryLabel},
{kRankTertiaryId, kRankTertiaryLabel},
};
const int kClanAnarch = 1;
const wstring kClanAnarchLabel = L"Anarch";
const int kClanAssamite = 2;
const wstring kClanAssamiteLabel = L"Assamite";
const int kClanBaali = 3;
const wstring kClanBaaliLabel = L"Baali";
const int kClanBrujah = 4;
const wstring kClanBrujahLabel = L"Brujah";
const int kClanCaitiff = 5;
const wstring kClanCaitiffLabel = L"Caitiff";
const int kClanCappadocian = 6;
const wstring kClanCappadocianLabel = L"Cappadocian";
const int kClanGangrel = 7;
const wstring kClanGangrelLabel = L"Gangrel";
const int kClanGiovanni = 8;
const wstring kClanGiovanniLabel = L"Giovanni";
const int kClanInconnu = 9;
const wstring kClanInconnuLabel = L"Inconnu";
const int kClanLasombra = 10;
const wstring kClanLasombraLabel = L"Lasombra";
const int kClanMalkavian = 11;
const wstring kClanMalkavianLabel = L"Malkavian";
const int kClanNosferatu = 12;
const wstring kClanNosferatuLabel = L"Nosferatu";
const int kClanRavanos = 13;
const wstring kClanRavanosLabel = L"Ravanos";
const int kClanSettite = 14;
const wstring kClanSettiteLabel = L"Settite";
const int kClanToreador = 15;
const wstring kClanToreadorLabel = L"Toreador";
const int kClanTremere = 16;
const wstring kClanTremereLabel = L"Tremere";
const int kClanTzismice = 17;
const wstring kClanTzismiceLabel = L"Tzismice";
const int kClanVentrue = 18;
const wstring kClanVentrueLabel = L"Ventrue";
const int kClansCount = 18;
const wstring kClans[] = {
L"",
kClanAnarchLabel,
kClanAssamiteLabel,
kClanBaaliLabel,
kClanBrujahLabel,
kClanCaitiffLabel,
kClanCappadocianLabel,
kClanGiovanniLabel,
kClanInconnuLabel,
kClanLasombraLabel,
kClanMalkavianLabel,
kClanNosferatuLabel,
kClanRavanosLabel,
kClanSettiteLabel,
kClanToreadorLabel,
kClanTremereLabel,
kClanVentrueLabel,
};
const int kArchetypeArchitectId = 1;
const wstring kArchetypeArchitectLabel = L"Architect";
const int kArchetypeAutocratId = 2;
const wstring kArchetypeAutocratLabel = L"Autocrat";
const int kArchetypeBarbarianId = 3;
const wstring kArchetypeBarbarianLabel = L"Barbarian";
const int kArchetypeBonVivantId = 4;
const wstring kArchetypeBonVivantLabel = L"Bon Vivant";
const int kArchetypeBravoId = 5;
const wstring kArchetypeBravoLabel = L"Bravo";
const int kArchetypeCaregiverId = 6;
const wstring kArchetypeCaregiverLabel = L"Caregiver";
const int kArchetypeCaretakerId = 7;
const wstring kArchetypeCaretakerLabel = L"Caretaker";
const int kArchetypeCelebrantId = 8;
const wstring kArchetypeCelebrantLabel = L"Celebrant";
const int kArchetypeChildId = 9;
const wstring kArchetypeChildLabel = L"Child";
const int kArchetypeConformist = 10;
const wstring kArchetypeConformistLabel = L"Conformist";
const int kArchetypeConniverId = 11;
const wstring kArchetypeConniverLabel = L"Conniver";
const int kArchetypeCurmudgeonId = 12;
const wstring kArchetypeCurmudgeonLabel = L"Curmudgeon";
const int kArchetypeDefenderId = 13;
const wstring kArchetypeDefenderLabel = L"Defender";
const int kArchetypeDeviantId = 14;
const wstring kArchetypeDeviantLabel = L"Deviant";
const int kArchetypeDirectorId = 15;
const wstring kArchetypeDirectorLabel = L"Director";
const int kArchetypeFanaticId = 16;
const wstring kArchetypeFanaticLabel = L"Fanatic";
const int kArchetypeGallantId = 17;
const wstring kArchetypeGallantLabel = L"Gallant";
const int kArchetypeInnovatorId = 18;
const wstring kArchetypeInnovatorLabel = L"Innovator";
const int kArchetypeJesterId = 19;
const wstring kArchetypeJesterLabel = L"Jester";
const int kArchetypeJudgeId = 20;
const wstring kArchetypeJudgeLabel = L"Judge";
const int kArchetypeLoanerId = 21;
const wstring kArchetypeLoanerLabel = L"Loaner";
const int kArchetypeMartyrId = 22;
const wstring kArchetypeMartyrLabel = L"Martyr";
const int kArchetypeMonsterId = 23;
const wstring kArchetypeMonsterLabel = L"Monster";
const int kArchetypePenitentId = 24;
const wstring kArchetypePenitentLabel = L"Penitent";
const int kArchetypeRebelId = 25;
const wstring kArchetypeRebelLabel = L"Rebel";
const int kArchetypeRogueId = 26;
const wstring kArchetypeRogueLabel = L"Rogue";
const int kArchetypeSurvivorId = 27;
const wstring kArchetypeSurvivorLabel = L"Survivor";
const int kArchetypeTraditionalistId = 28;
const wstring kArchetypeTraditionalistLabel = L"Traditionalist";
const int kArchetypeTyrantId = 29;
const wstring kArchetypeTyrantLabel = L"Tyrant";
const int kArchetypeVisionaryId = 30;
const wstring kArchetypeVisionaryLabel = L"Visionary";
const int kArchetypesCount = 30;
const wstring kArchetypes[] = {
L"",
kArchetypeArchitectLabel,
kArchetypeAutocratLabel,
kArchetypeBarbarianLabel,
kArchetypeBonVivantLabel,
kArchetypeBravoLabel,
kArchetypeCaregiverLabel,
kArchetypeCaretakerLabel,
kArchetypeCelebrantLabel,
kArchetypeChildLabel,
kArchetypeConformistLabel,
kArchetypeConniverLabel,
kArchetypeCurmudgeonLabel,
kArchetypeDefenderLabel,
kArchetypeDeviantLabel,
kArchetypeDirectorLabel,
kArchetypeFanaticLabel,
kArchetypeGallantLabel,
kArchetypeInnovatorLabel,
kArchetypeJesterLabel,
kArchetypeJudgeLabel,
kArchetypeLoanerLabel,
kArchetypeMartyrLabel,
kArchetypeMonsterLabel,
kArchetypePenitentLabel,
kArchetypeRebelLabel,
kArchetypeRogueLabel,
kArchetypeSurvivorLabel,
kArchetypeTraditionalistLabel,
kArchetypeTyrantLabel,
kArchetypeVisionaryLabel,
};
const int kDisciplinePoints = 3;
const int kDisciplineAnimalismId = 1;
const wstring kDisciplineAnimalismLabel = L"Animalism";
const int kDisciplineAuspexId = 2;
const wstring kDisciplineAuspexLabel = L"Auspex";
const int kDisciplineBardoId = 3;
const wstring kDisciplineBardoLabel = L"Bardo";
const int kDisciplineCelerityId = 4;
const wstring kDisciplineCelerityLabel = L"Celerity";
const int kDisciplineChimestryId = 5;
const wstring kDisciplineChimestryLabel = L"Chimestry";
const int kDisciplineDementationId = 6;
const wstring kDisciplineDementationLabel = L"Dementation";
const int kDisciplineDominateId = 7;
const wstring kDisciplineDominateLabel = L"Dominate";
const int kDisciplineFortitudeId = 8;
const wstring kDisciplineFortitudeLabel = L"Fortitude";
const int kDisciplineMelpomineeId = 9;
const wstring kDisciplineMelpomineeLabel = L"Melpominee";
const int kDisciplineMortisId = 10;
const wstring kDisciplineMortisLabel = L"Mortis";
const int kDisciplineMytherceriaId = 11;
const wstring kDisciplineMytherceriaLabel = L"Mytherceria";
const int kDisciplineNecromancyId = 12;
const wstring kDisciplineNecromancyLabel = L"Necromancy";
const int kDisciplineObeahId = 13;
const wstring kDisciplineObeahLabel = L"Obeah";
const int kDisciplineObfuscateId = 14;
const wstring kDisciplineObfuscateLabel = L"Obfuscate";
const int kDisciplineObtenebrationId = 15;
const wstring kDisciplineObtenebrationLabel = L"Obtenebration";
const int kDisciplinePotenceId = 16;
const wstring kDisciplinePotenceLabel = L"Potence";
const int kDisciplinePresenceId = 17;
const wstring kDisciplinePresenceLabel = L"Presence";
const int kDisciplineProteanId = 18;
const wstring kDisciplineProteanLabel = L"Protean";
const int kDisciplineQuietusId = 19;
const wstring kDisciplineQuietusLabel = L"Quietus";
const int kDisciplineSerpentisId = 20;
const wstring kDisciplineSerpentisLabel = L"Serpentis";
const int kDisciplineSpiritusId = 21;
const wstring kDisciplineSpiritusLabel = L"Spiritus";
const int kDisciplineThanantosisId = 22;
const wstring kDisciplineThanantosisLabel = L"Thanantosis";
const int kDisciplineThaumaturgyId = 23;
const wstring kDisciplineThaumaturgyLabel = L"Thaumaturgy";
const int kDisciplineVicissitudeId = 24;
const wstring kDisciplineVicissitudeLabel = L"Vicissitude";
const int kDisciplinesCount = 24;
const wstring kDisciplines[] = {
L"",
kDisciplineAnimalismLabel,
kDisciplineAuspexLabel,
kDisciplineBardoLabel,
kDisciplineCelerityLabel,
kDisciplineChimestryLabel,
kDisciplineDementationLabel,
kDisciplineDominateLabel,
kDisciplineFortitudeLabel,
kDisciplineMelpomineeLabel,
kDisciplineMortisLabel,
kDisciplineMytherceriaLabel,
kDisciplineNecromancyLabel,
kDisciplineObeahLabel,
kDisciplineObfuscateLabel,
kDisciplineObtenebrationLabel,
kDisciplinePotenceLabel,
kDisciplinePresenceLabel,
kDisciplineProteanLabel,
kDisciplineQuietusLabel,
kDisciplineSerpentisLabel,
kDisciplineSpiritusLabel,
kDisciplineThanantosisLabel,
kDisciplineThaumaturgyLabel,
kDisciplineVicissitudeLabel,
};
const int kVirtuePoints = 7;
const int kVirtueSelfControlId = 1;
const wstring kVirtueSelfControlLabel = L"Self-Control";
const int kVirtueCourageId = 2;
const wstring kVirtueCourageLabel = L"Courage";
const int kVirtueConscienceId = 3;
const wstring kVirtueConscienceLabel = L"Conscience";
const int kVirtuesCount = 3;
const wstring kVirtues[] = {
L"",
kVirtueSelfControlLabel,
kVirtueCourageLabel,
kVirtueConscienceLabel,
};
const int kPhysicalAttributeStrengthId = 1;
const wstring kPhysicalAttributeStrengthLabel = L"Strength";
const wstring kPhysicalAttributeStrengthAbbreviation = L"Str.";
const int kPhysicalAttributeDexterityId = 2;
const wstring kPhysicalAttributeDexterityLabel = L"Dexterity";
const wstring kPhysicalAttributeDexterityAbbreviation = L"Dex.";
const int kPhysicalAttributeStaminaId = 3;
const wstring kPhysicalAttributeStaminaLabel = L"Stamina";
const wstring kPhysicalAttributeStaminaAbbreviation = L"Sta.";
const int kPhysicalAttributesCount = 3;
const wstring kPhysicalAttributeLabels[] = {
L"",
kPhysicalAttributeStrengthLabel,
kPhysicalAttributeDexterityLabel,
kPhysicalAttributeStaminaLabel,
};
const wstring kPhysicalAttributeAbbreviations[] = {
L"",
kPhysicalAttributeStrengthAbbreviation,
kPhysicalAttributeDexterityAbbreviation,
kPhysicalAttributeStaminaAbbreviation,
};
const int kSocialAttributeCharismaId = 1;
const wstring kSocialAttributeCharismaLabel = L"Charisma";
const wstring kSocialAttributeCharismaAbbreviation = L"Cha.";
const int kSocialAttributeManipulationId = 2;
const wstring kSocialAttributeManipulationLabel = L"Manipulation";
const wstring kSocialAttributeManipulationAbbreviation = L"Man.";
const int kSocialAttributeAppearanceId = 3;
const wstring kSocialAttributeAppearanceLabel = L"Appearance";
const wstring kSocialAttributeAppearanceAbbreviation = L"App.";
const int kSocialAttributesCount = 3;
const wstring kSocialAttributeLabels[] = {
L"",
kSocialAttributeCharismaLabel,
kSocialAttributeManipulationLabel,
kSocialAttributeAppearanceLabel,
};
const wstring kSocialAttributeAbbreviations[] = {
L"",
kSocialAttributeCharismaAbbreviation,
kSocialAttributeManipulationAbbreviation,
kSocialAttributeAppearanceAbbreviation,
};
const int kMentalAttributeIntelligenceId = 1;
const wstring kMentalAttributeIntelligenceLabel = L"Intelligence";
const wstring kMentalAttributeIntelligenceAbbreviation = L"Int.";
const int kMentalAttributePerceptionId = 2;
const wstring kMentalAttributePerceptionLabel = L"Perception";
const wstring kMentalAttributePerceptionAbbreviation = L"Per.";
const int kMentalAttributeWitsId = 3;
const wstring kMentalAttributeWitsLabel = L"Wits";
const wstring kMentalAttributeWitsAbbreviation = L"Wits";
const int kMentalAttributesCount = 3;
const wstring kMentalAttributeLabels[] = {
L"",
kMentalAttributeIntelligenceLabel,
kMentalAttributePerceptionLabel,
kMentalAttributeWitsLabel,
};
const wstring kMentalAttributeAbbreviations[] = {
L"",
kMentalAttributeIntelligenceLabel,
kMentalAttributePerceptionAbbreviation,
kMentalAttributeWitsAbbreviation,
};
const int kAttributeGroupPhysicalId = 1;
const wstring kAttributeGroupPhysicalLabel = L"Physical";
const int kAttributeGroupSocialId = 2;
const wstring kAttributeGroupSocialLabel = L"Social";
const int kAttributeGroupMentalId = 3;
const wstring kAttributeGroupMentalLabel = L"Mental";
const int kAttributeGroupsCount = 3;
const wstring kAttributeGroups[] = {
L"",
kAttributeGroupPhysicalLabel,
kAttributeGroupSocialLabel,
kAttributeGroupMentalLabel,
};
const int kAbilityGroupTalentsId = 1;
const wstring kAbilityGroupTalentsSingular = L"Talent";
const wstring kAbilityGroupTalentsPlural = L"Talents";
const int kAbilityGroupSkillsId = 2;
const wstring kAbilityGroupSkillsSingular = L"Skill";
const wstring kAbilityGroupSkillsPlural = L"Skills";
const int kAbilityGroupKnowledgesId = 3;
const wstring kAbilityGroupKnowledgesSingular = L"Skill";
const wstring kAbilityGroupKnowledgesPlural = L"Skills";
const int kAbilityGroupsCount = 3;
struct AbilityType {
int id;
wstring singular;
wstring plural;
};
const AbilityType kAbilityGroups[] {
{0, L"", L""},
{kAbilityGroupTalentsId, kAbilityGroupTalentsSingular, kAbilityGroupTalentsPlural},
{kAbilityGroupSkillsId, kAbilityGroupSkillsSingular, kAbilityGroupSkillsPlural},
{kAbilityGroupKnowledgesId, kAbilityGroupKnowledgesSingular, kAbilityGroupKnowledgesPlural},
};
const int kTalentActingId = 1;
const wstring kTalentActingLabel = L"Acting";
const int kTalentAlertnessId = 2;
const wstring kTalentAlertnessLabel = L"Alertness";
const int kTalentAthleticsId = 3;
const wstring kTalentAthleticsLabel = L"Athletics";
const int kTalentBrawlId = 4;
const wstring kTalentBrawlLabel = L"Brawl";
const int kTalentDodgeId = 5;
const wstring kTalentDodgeLabel = L"Dodge";
const int kTalentEmpathyId = 6;
const wstring kTalentEmpathyLabel = L"Empathty";
const int kTalentIntimidationId = 7;
const wstring kTalentIntimidationLabel = L"Intimidation";
const int kTalentLeadershipId = 8;
const wstring kTalentLeadershipLabel = L"Leadership";
const int kTalentStreetwiseId = 9;
const wstring kTalentStreetwiseLabel = L"Streetwise";
const int kTalentSubterfugeId = 10;
const wstring kTalentSubterfugeLabel = L"Subterfuge";
const int kTalentsCount = 10;
const wstring kTalents[] = {
L"",
kTalentActingLabel,
kTalentAlertnessLabel,
kTalentAthleticsLabel,
kTalentBrawlLabel,
kTalentDodgeLabel,
kTalentEmpathyLabel,
kTalentIntimidationLabel,
kTalentLeadershipLabel,
kTalentStreetwiseLabel,
kTalentSubterfugeLabel,
};
const int kSkillAnimalKenId = 1;
const wstring kSkillAnimalKenLabel = L"AnimalKen";
const int kSkillDriveId = 2;
const wstring kSkillDriveLabel = L"Drive";
const int kSkillEtiquetteId = 3;
const wstring kSkillEtiquetteLabel = L"Etiquette";
const int kSkillFirearmsId = 4;
const wstring kSkillFirearmsLabel = L"Firearms";
const int kSkillMeleeId = 5;
const wstring kSkillMeleeLabel = L"Melee";
const int kSkillMusicId = 6;
const wstring kSkillMusicLabel = L"Music";
const int kSkillRepairId = 7;
const wstring kSkillRepairLabel = L"Repair";
const int kSkillSecurityId = 8;
const wstring kSkillSecurityLabel = L"Security";
const int kSkillStealthId = 9;
const wstring kSkillStealthLabel = L"Stealth";
const int kSkillSurvivalId = 10;
const wstring kSkillSurvivalLabel = L"Survival";
const int kSkillsCount = 10;
const wstring kSkills[] = {
L"",
kSkillAnimalKenLabel,
kSkillDriveLabel,
kSkillEtiquetteLabel,
kSkillFirearmsLabel,
kSkillMeleeLabel,
kSkillMusicLabel,
kSkillRepairLabel,
kSkillSecurityLabel,
kSkillStealthLabel,
kSkillSurvivalLabel,
};
const int kKnowledgeBureaucracyId = 1;
const wstring kKnowledgeBureaucracyLabel = L"Bureaucracy";
const int kKnowledgeComputerId = 2;
const wstring kKnowledgeComputerLabel = L"Computer";
const int kKnowledgeFinanceId = 3;
const wstring kKnowledgeFinanceLabel = L"Finance";
const int kKnowledgeInvestigationId = 4;
const wstring kKnowledgeInvestigationLabel = L"Investigation";
const int kKnowledgeLawId = 5;
const wstring kKnowledgeLawLabel = L"Law";
const int kKnowledgeLinguisticsId = 6;
const wstring kKnowledgeLinguisticsLabel = L"Linguistics";
const int kKnowledgeMedicineId = 7;
const wstring kKnowledgeMedicineLabel = L"Medicine";
const int kKnowledgeOccultId = 8;
const wstring kKnowledgeOccultLabel = L"Occult";
const int kKnowledgePoliticsId = 9;
const wstring kKnowledgePoliticsLabel = L"Politics";
const int kKnowledgeScienceId = 10;
const wstring kKnowledgeScienceLabel = L"Science";
const int kKnowledgesCount = 10;
const wstring kKnowledges[] = {
L"",
kKnowledgeBureaucracyLabel,
kKnowledgeComputerLabel,
kKnowledgeFinanceLabel,
kKnowledgeInvestigationLabel,
kKnowledgeLawLabel,
kKnowledgeLinguisticsLabel,
kKnowledgeMedicineLabel,
kKnowledgeOccultLabel,
kKnowledgePoliticsLabel,
kKnowledgeScienceLabel,
};
const int kBackgroundPoints = 5;
const int kBackgroundAlliesId = 1;
const wstring kBackgroundAlliesLabel = L"Allies";
const int kBackgroundContactsId = 2;
const wstring kBackgroundContactsLabel = L"Contacts";
const int kBackgroundFameId = 3;
const wstring kBackgroundFameLabel = L"Fame";
const int kBackgroundGenerationId = 4;
const wstring kBackgroundGenerationLabel = L"Generation";
const int kBackgroundHerdId = 5;
const wstring kBackgroundHerdLabel = L"Herd";
const int kBackgroundInfluenceId = 6;
const wstring kBackgroundInfluenceLabel = L"Influence";
const int kBackgroundMentorId = 7;
const wstring kBackgroundMentorLabel = L"Mentor";
const int kBackgroundResourcesId = 8;
const wstring kBackgroundResourcesLabel = L"Resources";
const int kBackgroundRetainersId = 9;
const wstring kBackgroundRetainersLabel = L"Retainers";
const int kBackgroundStatusId = 10;
const wstring kBackgroundStatusLabel = L"Status";
const int kBackgroundsCount = 10;
const wstring kBackgroundLabels[] = {
L"",
kBackgroundAlliesLabel,
kBackgroundContactsLabel,
kBackgroundFameLabel,
kBackgroundGenerationLabel,
kBackgroundHerdLabel,
kBackgroundInfluenceLabel,
kBackgroundMentorLabel,
kBackgroundResourcesLabel,
kBackgroundRetainersLabel,
kBackgroundStatusLabel,
};
const int kGenderMaleId = 1;
const wstring kGenderMaleLabel = L"Male";
const int kGenderFemaleId = 2;
const wstring kGenderFemaleLabel = L"Female";
const int kGenderTransMaleId = 3;
const wstring kGenderTransMaleLabel = L"Trans-Male";
const int kGenderTransFemaleId = 4;
const wstring kGenderTransFemaleLabel = L"Trans-Female";
const int kGenderNonBinaryId = 5;
const wstring kGenderNonBinaryLabel = L"Non-Binary";
const int kGendersCount = 5;
const wstring kGenderLabels[] = {
L"",
kGenderMaleLabel,
kGenderFemaleLabel,
kGenderTransMaleLabel,
kGenderTransFemaleLabel,
kGenderNonBinaryLabel,
};
struct DerangementType {
int id;
wstring label;
wstring description;
uint8_t textColor;
};
const int kDerangementAmnesiaId = 1;
const uint8_t kDerangementAmnesiaTextColor= kColorDarkRed;
const wstring kDerangementAmnesiaLabel = L"Amnesia";
const wstring kDerangementAmnesiaDescription = LR"---(You forget a segment of your past. Additionally in some cases a character can forget abilities and be unable to use them for the duration.)---";
const int kDerangementDelusionsOfGrandeurId = 2;
const uint8_t kDerangementDelusionsOfGrandeurTextColor= kColorDarkMagenta;
const wstring kDerangementDelusionsOfGrandeurLabel = L"Delusions of Grandeur";
const wstring kDerangementDelusionsOfGrandeurDescription = LR"---(You imagine you are better than you are.)---";
const int kDerangementFantasyId = 3;
const uint8_t kDerangementFantasyTextColor= kColorDarkOrange;
const wstring kDerangementFantasyLabel = L"Fantasy";
const wstring kDerangementFantasyDescription = LR"---(You enter a self-created world where you are the forgotten hero.)---";
const int kDerangementManicDepressionId = 4;
const uint8_t kDerangementManicDepressionTextColor= kColorDarkWhite;
const wstring kDerangementManicDepressionLabel = L"Manic-Depression";
const wstring kDerangementManicDepressionDescription = LR"---(You sink into deep and fitful depressions, showing no interest in anything which used to captivate your interests. You will go along with others rather than use the energy to resist. Occasional fits of great energy grab hold of you, and you will work for hours or even days on your projects. During this time you will resist even the need for sleep as you burn up blood and Willpower on your schemes.)---";
const int kDerangementMultiplePersonalitiesId = 5;
const uint8_t kDerangementMultiplePersonalitiesTextColor= kColorDarkBlue;
const wstring kDerangementMultiplePersonalitiesLabel = L"Multiple Personalities";
const wstring kDerangementMultiplePersonalitiesDescription = LR"---(You possess a number of new personalities. You have amore than one Mature, and will switch between them. Thus you regain Willpower points in defferent ways at defferent times)---";
const int kDerangementObsessionId = 6;
const uint8_t kDerangementObsessionTextColor= kColorBrightGreen;
const wstring kDerangementObsessionLabel = L"Obsession";
const wstring kDerangementObsessionDescription = LR"---(You become obsessed with some interest or fetish.)---";
const int kDerangementOvercompensationId = 7;
const uint8_t kDerangementOvercompensationTextColor= kColorBrightCyan;
const wstring kDerangementOvercompensationLabel = L"Overcompensation";
const wstring kDerangementOvercompensationDescription = LR"---(You make up for your moral weaknesses by playing up your strengths to an extreme. You don't think you can frenzy and won't stop it.)---";
const int kDerangementParanoiaId = 8;
const uint8_t kDerangementParanoiaTextColor= kColorBrightRed;
const wstring kDerangementParanoiaLabel = L"Paranoia";
const wstring kDerangementParanoiaDescription = LR"---(You are convinced that you are being hunted. You hold even your closest Friends under suspicion.)---";
const int kDerangementPerfectionId = 9;
const uint8_t kDerangementPerfectionTextColor= kColorBrightMagenta;
const wstring kDerangementPerfectionLabel = L"Perfection";
const wstring kDerangementPerfectionDescription = LR"---(All your energy is directed toward preventing anything from going wong. When it does you must make a self-control roll or frenzy.)---";
const int kDerangementRegressionId = 10;
const uint8_t kDerangementRegressionTextColor= kColorBrightYellow;
const wstring kDerangementRegressionLabel = L"Regression";
const wstring kDerangementRegressionDescription = LR"---(You become childlike retreating to an earlier time when less was expected of you Willpower is regained inthe way a Child's is.)---";
const DerangementType kDerangementAmnesia = {
kDerangementAmnesiaId,
kDerangementAmnesiaLabel,
kDerangementAmnesiaDescription,
kDerangementAmnesiaTextColor,
};
const DerangementType kDerangementDelusionsOfGrandeur = {
kDerangementDelusionsOfGrandeurId,
kDerangementDelusionsOfGrandeurLabel,
kDerangementDelusionsOfGrandeurDescription,
kDerangementDelusionsOfGrandeurTextColor,
};
const DerangementType kDerangementFantasy = {
kDerangementFantasyId,
kDerangementFantasyLabel,
kDerangementFantasyDescription,
kDerangementFantasyTextColor,
};
const DerangementType kDerangementManicDepression = {
kDerangementManicDepressionId,
kDerangementManicDepressionLabel,
kDerangementManicDepressionDescription,
kDerangementManicDepressionTextColor,
};
const DerangementType kDerangementMultiplePersonalities = {
kDerangementMultiplePersonalitiesId,
kDerangementMultiplePersonalitiesLabel,
kDerangementMultiplePersonalitiesDescription,
kDerangementMultiplePersonalitiesTextColor,
};
const DerangementType kDerangementObsession = {
kDerangementObsessionId,
kDerangementObsessionLabel,
kDerangementObsessionDescription,
kDerangementObsessionTextColor,
};
const DerangementType kDerangementOvercompensation = {
kDerangementOvercompensationId,
kDerangementOvercompensationLabel,
kDerangementOvercompensationDescription,
kDerangementOvercompensationTextColor,
};
const DerangementType kDerangementParanoia = {
kDerangementParanoiaId,
kDerangementParanoiaLabel,
kDerangementParanoiaDescription,
kDerangementParanoiaTextColor,
};
const DerangementType kDerangementPerfection = {
kDerangementPerfectionId,
kDerangementPerfectionLabel,
kDerangementPerfectionDescription,
kDerangementPerfectionTextColor,
};
const DerangementType kDerangementRegression = {
kDerangementRegressionId,
kDerangementRegressionLabel,
kDerangementRegressionDescription,
kDerangementRegressionTextColor,
};
const int kDerangementsCount = 10;
const uint8_t kDerangementTextColors[] = {
0,
kDerangementAmnesiaTextColor,
kDerangementDelusionsOfGrandeurTextColor,
kDerangementFantasyTextColor,
kDerangementManicDepressionTextColor,
kDerangementMultiplePersonalitiesTextColor,
kDerangementObsessionTextColor,
kDerangementOvercompensationTextColor,
kDerangementParanoiaTextColor,
kDerangementPerfectionTextColor,
kDerangementRegressionTextColor,
};
const wstring kDerangementLabels[] = {
L"",
kDerangementAmnesiaLabel,
kDerangementDelusionsOfGrandeurLabel,
kDerangementFantasyLabel,
kDerangementManicDepressionLabel,
kDerangementMultiplePersonalitiesLabel,
kDerangementObsessionLabel,
kDerangementOvercompensationLabel,
kDerangementParanoiaLabel,
kDerangementPerfectionLabel,
kDerangementRegressionLabel,
};
const wstring kDerangementDescriptions[] = {
L"",
kDerangementAmnesiaDescription,
kDerangementDelusionsOfGrandeurDescription,
kDerangementFantasyDescription,
kDerangementManicDepressionDescription,
kDerangementMultiplePersonalitiesDescription,
kDerangementObsessionDescription,
kDerangementOvercompensationDescription,
kDerangementParanoiaDescription,
kDerangementPerfectionDescription,
kDerangementRegressionDescription,
};
const DerangementType kDerangements[] = {
{0, L"", L"", 0},
kDerangementAmnesia,
kDerangementDelusionsOfGrandeur,
kDerangementFantasy,
kDerangementManicDepression,
kDerangementMultiplePersonalities,
kDerangementObsession,
kDerangementOvercompensation,
kDerangementParanoia,
kDerangementPerfection,
kDerangementRegression,
};
int GetDisciplinePoints(); int GetDisciplinePoints();
int GetNumItemsForAbilityGroup(int abilityGroupId); int GetVirtuePoints();
class CharacterType { class CharacterType {
public: public:
@@ -717,7 +29,7 @@ namespace SBF {
int GetAbilityValue(int abilityGroupId, int abilityId) const; int GetAbilityValue(int abilityGroupId, int abilityId) const;
int GetAttributeValue(int attributeGroupId, int abilityId) const; int GetAttributeValue(int attributeGroupId, int abilityId) const;
int GetBackgroundValue(int backgroundId) const; int GetBackgroundValue(int backgroundId) const;
wstring GetAllDerangementsLine() const; std::wstring GetAllDerangementsLine() const;
int GetDisciplineValue(int disciplineId) const; int GetDisciplineValue(int disciplineId) const;
int GetKnowledgeValue(int knowledgeId) const; int GetKnowledgeValue(int knowledgeId) const;
int GetSkillValue(int skillId) const; int GetSkillValue(int skillId) const;
@@ -732,12 +44,12 @@ namespace SBF {
void SetTalentValue(int talentId, int value); void SetTalentValue(int talentId, int value);
void SetVirtueValue(int virtueId, int value); void SetVirtueValue(int virtueId, int value);
wstring name; std::wstring name;
wstring player; std::wstring player;
wstring chronicle; std::wstring chronicle;
wstring haven; std::wstring haven;
wstring concept; std::wstring concept;
wstring age; std::wstring age;
int genderId; int genderId;
int clanId; int clanId;
int natureId; int natureId;
@@ -746,7 +58,7 @@ namespace SBF {
int selfControl; int selfControl;
int courage; int courage;
int generation; int generation;
wstring roadName; std::wstring roadName;
int roadValue; int roadValue;
int willpower; int willpower;
int bloodPool; int bloodPool;
@@ -837,10 +149,6 @@ namespace SBF {
int background_resources; int background_resources;
int background_retainers; int background_retainers;
int background_status; int background_status;
}; }; // End class CharacterType
int GetVirtuePoints();
} // End namespace SBF } // End namespace SBF
#endif // !defined CHARACTER_H__ #endif // !defined CHARACTER_H__

View File

@@ -0,0 +1,10 @@
#include "Character.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Character(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Clans.cpp Normal file
View File

66
sbf-cpp/Clans.h Normal file
View File

@@ -0,0 +1,66 @@
#ifndef CLANS_H__
#define CLANS_H__
#include <string>
#include <vector>
namespace SBF {
const int kClanAnarch = 1;
const std::wstring kClanAnarchLabel = L"Anarch";
const int kClanAssamite = 2;
const std::wstring kClanAssamiteLabel = L"Assamite";
const int kClanBaali = 3;
const std::wstring kClanBaaliLabel = L"Baali";
const int kClanBrujah = 4;
const std::wstring kClanBrujahLabel = L"Brujah";
const int kClanCaitiff = 5;
const std::wstring kClanCaitiffLabel = L"Caitiff";
const int kClanCappadocian = 6;
const std::wstring kClanCappadocianLabel = L"Cappadocian";
const int kClanGangrel = 7;
const std::wstring kClanGangrelLabel = L"Gangrel";
const int kClanGiovanni = 8;
const std::wstring kClanGiovanniLabel = L"Giovanni";
const int kClanInconnu = 9;
const std::wstring kClanInconnuLabel = L"Inconnu";
const int kClanLasombra = 10;
const std::wstring kClanLasombraLabel = L"Lasombra";
const int kClanMalkavian = 11;
const std::wstring kClanMalkavianLabel = L"Malkavian";
const int kClanNosferatu = 12;
const std::wstring kClanNosferatuLabel = L"Nosferatu";
const int kClanRavanos = 13;
const std::wstring kClanRavanosLabel = L"Ravanos";
const int kClanSettite = 14;
const std::wstring kClanSettiteLabel = L"Settite";
const int kClanToreador = 15;
const std::wstring kClanToreadorLabel = L"Toreador";
const int kClanTremere = 16;
const std::wstring kClanTremereLabel = L"Tremere";
const int kClanTzismice = 17;
const std::wstring kClanTzismiceLabel = L"Tzismice";
const int kClanVentrue = 18;
const std::wstring kClanVentrueLabel = L"Ventrue";
const int kClansCount = 18;
const std::wstring kClans[] = {
L"",
kClanAnarchLabel,
kClanAssamiteLabel,
kClanBaaliLabel,
kClanBrujahLabel,
kClanCaitiffLabel,
kClanCappadocianLabel,
kClanGiovanniLabel,
kClanInconnuLabel,
kClanLasombraLabel,
kClanMalkavianLabel,
kClanNosferatuLabel,
kClanRavanosLabel,
kClanSettiteLabel,
kClanToreadorLabel,
kClanTremereLabel,
kClanVentrueLabel,
};
const std::wstring& GetClanLabel(int clanId);
void FillClanLabels(std::vector<std::wstring> clans);
} // End namespace SBF
#endif // End !defined CLANS_H__

10
sbf-cpp/Clans_test.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "Clans.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Clans(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

View File

@@ -1,9 +1,9 @@
#ifndef COLORS_H__ #ifndef COLORS_H__
#define COLORS_H__ #define COLORS_H__
#include <cstdint> #include <cstdint>
#include <vector>
namespace SBF { namespace SBF {
const uint8_t kColorDarkBlack = 0; const uint8_t kColorDarkBlack = 0;
const uint8_t kColorDarkBlue = 1; const uint8_t kColorDarkBlue = 1;
const uint8_t kColorDarkGreen = 2; const uint8_t kColorDarkGreen = 2;
@@ -25,9 +25,9 @@ namespace SBF {
void SetForegroundColor(uint8_t foregroundColor); void SetForegroundColor(uint8_t foregroundColor);
uint8_t GetForegroundColor(); uint8_t GetForegroundColor();
// ncurses color pair // TODO: Make this an ncurses color pair
uint16_t GetColor(); uint16_t GetColor();
void FillColors(std::vector<uint8_t> colors);
} // End namespace SBF } // End namespace SBF
#endif // End !defined COLORS_H__
#endif

10
sbf-cpp/Colors_test.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "Colors.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Colors(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Derangements.cpp Normal file
View File

176
sbf-cpp/Derangements.h Normal file
View File

@@ -0,0 +1,176 @@
#ifndef DERANGEMENTS_H__
#define DERANGEMENTS_H__
#include "Colors.h"
#include <string>
#include <vector>
namespace SBF {
struct DerangementType {
int id;
std::wstring label;
std::wstring description;
uint8_t textColor;
};
const int kDerangementAmnesiaId = 1;
const uint8_t kDerangementAmnesiaTextColor= kColorDarkRed;
const std::wstring kDerangementAmnesiaLabel = L"Amnesia";
const std::wstring kDerangementAmnesiaDescription = LR"---(You forget a segment of your past. Additionally in some cases a character can forget abilities and be unable to use them for the duration.)---";
const int kDerangementDelusionsOfGrandeurId = 2;
const uint8_t kDerangementDelusionsOfGrandeurTextColor= kColorDarkMagenta;
const std::wstring kDerangementDelusionsOfGrandeurLabel = L"Delusions of Grandeur";
const std::wstring kDerangementDelusionsOfGrandeurDescription = LR"---(You imagine you are better than you are.)---";
const int kDerangementFantasyId = 3;
const uint8_t kDerangementFantasyTextColor= kColorDarkOrange;
const std::wstring kDerangementFantasyLabel = L"Fantasy";
const std::wstring kDerangementFantasyDescription = LR"---(You enter a self-created world where you are the forgotten hero.)---";
const int kDerangementManicDepressionId = 4;
const uint8_t kDerangementManicDepressionTextColor= kColorDarkWhite;
const std::wstring kDerangementManicDepressionLabel = L"Manic-Depression";
const std::wstring kDerangementManicDepressionDescription = LR"---(You sink into deep and fitful depressions, showing no interest in anything which used to captivate your interests. You will go along with others rather than use the energy to resist. Occasional fits of great energy grab hold of you, and you will work for hours or even days on your projects. During this time you will resist even the need for sleep as you burn up blood and Willpower on your schemes.)---";
const int kDerangementMultiplePersonalitiesId = 5;
const uint8_t kDerangementMultiplePersonalitiesTextColor= kColorDarkBlue;
const std::wstring kDerangementMultiplePersonalitiesLabel = L"Multiple Personalities";
const std::wstring kDerangementMultiplePersonalitiesDescription = LR"---(You possess a number of new personalities. You have amore than one Mature, and will switch between them. Thus you regain Willpower points in defferent ways at defferent times)---";
const int kDerangementObsessionId = 6;
const uint8_t kDerangementObsessionTextColor= kColorBrightGreen;
const std::wstring kDerangementObsessionLabel = L"Obsession";
const std::wstring kDerangementObsessionDescription = LR"---(You become obsessed with some interest or fetish.)---";
const int kDerangementOvercompensationId = 7;
const uint8_t kDerangementOvercompensationTextColor= kColorBrightCyan;
const std::wstring kDerangementOvercompensationLabel = L"Overcompensation";
const std::wstring kDerangementOvercompensationDescription = LR"---(You make up for your moral weaknesses by playing up your strengths to an extreme. You don't think you can frenzy and won't stop it.)---";
const int kDerangementParanoiaId = 8;
const uint8_t kDerangementParanoiaTextColor= kColorBrightRed;
const std::wstring kDerangementParanoiaLabel = L"Paranoia";
const std::wstring kDerangementParanoiaDescription = LR"---(You are convinced that you are being hunted. You hold even your closest Friends under suspicion.)---";
const int kDerangementPerfectionId = 9;
const uint8_t kDerangementPerfectionTextColor= kColorBrightMagenta;
const std::wstring kDerangementPerfectionLabel = L"Perfection";
const std::wstring kDerangementPerfectionDescription = LR"---(All your energy is directed toward preventing anything from going wong. When it does you must make a self-control roll or frenzy.)---";
const int kDerangementRegressionId = 10;
const uint8_t kDerangementRegressionTextColor= kColorBrightYellow;
const std::wstring kDerangementRegressionLabel = L"Regression";
const std::wstring kDerangementRegressionDescription = LR"---(You become childlike retreating to an earlier time when less was expected of you Willpower is regained inthe way a Child's is.)---";
const DerangementType kDerangementAmnesia = {
kDerangementAmnesiaId,
kDerangementAmnesiaLabel,
kDerangementAmnesiaDescription,
kDerangementAmnesiaTextColor,
};
const DerangementType kDerangementDelusionsOfGrandeur = {
kDerangementDelusionsOfGrandeurId,
kDerangementDelusionsOfGrandeurLabel,
kDerangementDelusionsOfGrandeurDescription,
kDerangementDelusionsOfGrandeurTextColor,
};
const DerangementType kDerangementFantasy = {
kDerangementFantasyId,
kDerangementFantasyLabel,
kDerangementFantasyDescription,
kDerangementFantasyTextColor,
};
const DerangementType kDerangementManicDepression = {
kDerangementManicDepressionId,
kDerangementManicDepressionLabel,
kDerangementManicDepressionDescription,
kDerangementManicDepressionTextColor,
};
const DerangementType kDerangementMultiplePersonalities = {
kDerangementMultiplePersonalitiesId,
kDerangementMultiplePersonalitiesLabel,
kDerangementMultiplePersonalitiesDescription,
kDerangementMultiplePersonalitiesTextColor,
};
const DerangementType kDerangementObsession = {
kDerangementObsessionId,
kDerangementObsessionLabel,
kDerangementObsessionDescription,
kDerangementObsessionTextColor,
};
const DerangementType kDerangementOvercompensation = {
kDerangementOvercompensationId,
kDerangementOvercompensationLabel,
kDerangementOvercompensationDescription,
kDerangementOvercompensationTextColor,
};
const DerangementType kDerangementParanoia = {
kDerangementParanoiaId,
kDerangementParanoiaLabel,
kDerangementParanoiaDescription,
kDerangementParanoiaTextColor,
};
const DerangementType kDerangementPerfection = {
kDerangementPerfectionId,
kDerangementPerfectionLabel,
kDerangementPerfectionDescription,
kDerangementPerfectionTextColor,
};
const DerangementType kDerangementRegression = {
kDerangementRegressionId,
kDerangementRegressionLabel,
kDerangementRegressionDescription,
kDerangementRegressionTextColor,
};
const int kDerangementsCount = 10;
const uint8_t kDerangementTextColors[] = {
0,
kDerangementAmnesiaTextColor,
kDerangementDelusionsOfGrandeurTextColor,
kDerangementFantasyTextColor,
kDerangementManicDepressionTextColor,
kDerangementMultiplePersonalitiesTextColor,
kDerangementObsessionTextColor,
kDerangementOvercompensationTextColor,
kDerangementParanoiaTextColor,
kDerangementPerfectionTextColor,
kDerangementRegressionTextColor,
};
const std::wstring kDerangementLabels[] = {
L"",
kDerangementAmnesiaLabel,
kDerangementDelusionsOfGrandeurLabel,
kDerangementFantasyLabel,
kDerangementManicDepressionLabel,
kDerangementMultiplePersonalitiesLabel,
kDerangementObsessionLabel,
kDerangementOvercompensationLabel,
kDerangementParanoiaLabel,
kDerangementPerfectionLabel,
kDerangementRegressionLabel,
};
const std::wstring kDerangementDescriptions[] = {
L"",
kDerangementAmnesiaDescription,
kDerangementDelusionsOfGrandeurDescription,
kDerangementFantasyDescription,
kDerangementManicDepressionDescription,
kDerangementMultiplePersonalitiesDescription,
kDerangementObsessionDescription,
kDerangementOvercompensationDescription,
kDerangementParanoiaDescription,
kDerangementPerfectionDescription,
kDerangementRegressionDescription,
};
const DerangementType kDerangements[] = {
{0, L"", L"", 0},
kDerangementAmnesia,
kDerangementDelusionsOfGrandeur,
kDerangementFantasy,
kDerangementManicDepression,
kDerangementMultiplePersonalities,
kDerangementObsession,
kDerangementOvercompensation,
kDerangementParanoia,
kDerangementPerfection,
kDerangementRegression,
};
const DerangementType& GetDerangement(int derangementId);
void FillDerangements(std::vector<DerangementType> derangements);
} // End namespace SBF
#endif // End !defined DERANGEMENTS_H__

View File

@@ -0,0 +1,10 @@
#include "Derangements.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Derangements(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Disciplines.cpp Normal file
View File

87
sbf-cpp/Disciplines.h Normal file
View File

@@ -0,0 +1,87 @@
#ifndef DISCIPLINES_H__
#define DISCIPLINES_H__
#include <string>
#include <vector>
namespace SBF {
const int kDisciplinePoints = 3;
const int kDisciplineAnimalismId = 1;
const std::wstring kDisciplineAnimalismLabel = L"Animalism";
const int kDisciplineAuspexId = 2;
const std::wstring kDisciplineAuspexLabel = L"Auspex";
const int kDisciplineBardoId = 3;
const std::wstring kDisciplineBardoLabel = L"Bardo";
const int kDisciplineCelerityId = 4;
const std::wstring kDisciplineCelerityLabel = L"Celerity";
const int kDisciplineChimestryId = 5;
const std::wstring kDisciplineChimestryLabel = L"Chimestry";
const int kDisciplineDementationId = 6;
const std::wstring kDisciplineDementationLabel = L"Dementation";
const int kDisciplineDominateId = 7;
const std::wstring kDisciplineDominateLabel = L"Dominate";
const int kDisciplineFortitudeId = 8;
const std::wstring kDisciplineFortitudeLabel = L"Fortitude";
const int kDisciplineMelpomineeId = 9;
const std::wstring kDisciplineMelpomineeLabel = L"Melpominee";
const int kDisciplineMortisId = 10;
const std::wstring kDisciplineMortisLabel = L"Mortis";
const int kDisciplineMytherceriaId = 11;
const std::wstring kDisciplineMytherceriaLabel = L"Mytherceria";
const int kDisciplineNecromancyId = 12;
const std::wstring kDisciplineNecromancyLabel = L"Necromancy";
const int kDisciplineObeahId = 13;
const std::wstring kDisciplineObeahLabel = L"Obeah";
const int kDisciplineObfuscateId = 14;
const std::wstring kDisciplineObfuscateLabel = L"Obfuscate";
const int kDisciplineObtenebrationId = 15;
const std::wstring kDisciplineObtenebrationLabel = L"Obtenebration";
const int kDisciplinePotenceId = 16;
const std::wstring kDisciplinePotenceLabel = L"Potence";
const int kDisciplinePresenceId = 17;
const std::wstring kDisciplinePresenceLabel = L"Presence";
const int kDisciplineProteanId = 18;
const std::wstring kDisciplineProteanLabel = L"Protean";
const int kDisciplineQuietusId = 19;
const std::wstring kDisciplineQuietusLabel = L"Quietus";
const int kDisciplineSerpentisId = 20;
const std::wstring kDisciplineSerpentisLabel = L"Serpentis";
const int kDisciplineSpiritusId = 21;
const std::wstring kDisciplineSpiritusLabel = L"Spiritus";
const int kDisciplineThanantosisId = 22;
const std::wstring kDisciplineThanantosisLabel = L"Thanantosis";
const int kDisciplineThaumaturgyId = 23;
const std::wstring kDisciplineThaumaturgyLabel = L"Thaumaturgy";
const int kDisciplineVicissitudeId = 24;
const std::wstring kDisciplineVicissitudeLabel = L"Vicissitude";
const int kDisciplinesCount = 24;
const std::wstring kDisciplines[] = {
L"",
kDisciplineAnimalismLabel,
kDisciplineAuspexLabel,
kDisciplineBardoLabel,
kDisciplineCelerityLabel,
kDisciplineChimestryLabel,
kDisciplineDementationLabel,
kDisciplineDominateLabel,
kDisciplineFortitudeLabel,
kDisciplineMelpomineeLabel,
kDisciplineMortisLabel,
kDisciplineMytherceriaLabel,
kDisciplineNecromancyLabel,
kDisciplineObeahLabel,
kDisciplineObfuscateLabel,
kDisciplineObtenebrationLabel,
kDisciplinePotenceLabel,
kDisciplinePresenceLabel,
kDisciplineProteanLabel,
kDisciplineQuietusLabel,
kDisciplineSerpentisLabel,
kDisciplineSpiritusLabel,
kDisciplineThanantosisLabel,
kDisciplineThaumaturgyLabel,
kDisciplineVicissitudeLabel,
};
const std::wstring GetDisciplineLabel(int disciplineId);
void FillDisciplineLabels(std::vector<std::wstring> disciplineLabels);
} // End namespace SBF
#endif // End !defined DISCIPLINES_H__

View File

@@ -0,0 +1,10 @@
#include "Disciplines.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Disciplines(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Genders.cpp Normal file
View File

29
sbf-cpp/Genders.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef GENDERS_H__
#define GENDERS_H__
#include <string>
#include <vector>
namespace SBF {
const int kGenderMaleId = 1;
const std::wstring kGenderMaleLabel = L"Male";
const int kGenderFemaleId = 2;
const std::wstring kGenderFemaleLabel = L"Female";
const int kGenderTransMaleId = 3;
const std::wstring kGenderTransMaleLabel = L"Trans-Male";
const int kGenderTransFemaleId = 4;
const std::wstring kGenderTransFemaleLabel = L"Trans-Female";
const int kGenderNonBinaryId = 5;
const std::wstring kGenderNonBinaryLabel = L"Non-Binary";
const int kGendersCount = 5;
const std::wstring kGenderLabels[] = {
L"",
kGenderMaleLabel,
kGenderFemaleLabel,
kGenderTransMaleLabel,
kGenderTransFemaleLabel,
kGenderNonBinaryLabel,
};
const std::wstring& GetGenderLabel(int genderId);
void FillGenderLabels(std::vector<std::wstring> genderLabels);
} // End namespace SBF
#endif // End !defined GENDERS_H__

10
sbf-cpp/Genders_test.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "Genders.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Genders(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Ranks.cpp Normal file
View File

27
sbf-cpp/Ranks.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef RANKS_H__
#define RANKS_H__
#include <string>
#include <vector>
namespace SBF {
const int kRankPrimaryId = 1;
const std::wstring kRankPrimaryLabel = L"Primary";
const int kRankSecondaryId = 2;
const std::wstring kRankSecondaryLabel = L"Secondary";
const int kRankTertiaryId = 3;
const std::wstring kRankTertiaryLabel = L"Tertiary";
const int kRanksCount = 3;
struct RankType {
int id;
std::wstring label;
};
const RankType kRanks[] {
{0, L""},
{kRankPrimaryId, kRankPrimaryLabel},
{kRankSecondaryId, kRankSecondaryLabel},
{kRankTertiaryId, kRankTertiaryLabel},
};
const RankType& GetRank(int rankId);
void FillRanks(std::vector<RankType> ranks);
} // End namespace SBF
#endif // !defined RANKS_H__

10
sbf-cpp/Ranks_test.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "Ranks.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Ranks(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

108
sbf-cpp/Utils.cpp Normal file
View File

@@ -0,0 +1,108 @@
#define _XOPEN_SOURCE_EXTENDED
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdint>
#include <vector>
#include "Utils.h"
#include "test.h"
using namespace SBF;
using namespace Test;
namespace SBF {
using std::wcout;
using std::tuple;
using std::wcerr;
using std::wstring;
using std::endl;
using std::pair;
using std::get;
using std::make_tuple;
using std::vector;
wstring word_wrap(const wstring& text, int maxWidth) {
wstring output = L"";
wstring thisLine = L"";
wstring nextChunk = L"";
int32_t thisLineStartPosition = 0;
int32_t thisLineCurrentPosition = 0;
int32_t nextSpace = -1;
int32_t textLength = text.size();
size_t thisLineLength = 0;
bool done = false;
while (!done) {
nextSpace = get_index_of(text, L" ", thisLineCurrentPosition);
if (nextSpace < 0) {
nextSpace = textLength;
}
nextChunk = get_substring(text, thisLineCurrentPosition, nextSpace - thisLineCurrentPosition);
auto nextChunkLength = nextChunk.size();
if (nextChunkLength > 0) {
auto needsSpace = thisLine.size() > 0;
if (needsSpace) {
thisLine = thisLine + L" ";
}
thisLineLength = thisLine.size();
if (nextChunkLength > maxWidth) {
nextChunk = get_substring(text, thisLineCurrentPosition, maxWidth - thisLineLength);
nextSpace = thisLineStartPosition + maxWidth;
thisLine = thisLine + nextChunk;
thisLineCurrentPosition = nextSpace;
} else if(thisLineLength + nextChunkLength > maxWidth) {
thisLine = make_fit_l(thisLine, maxWidth, L' ');
} else {
thisLine = thisLine + nextChunk;
thisLineCurrentPosition = nextSpace + 1;
}
thisLineLength = thisLine.size();
} else {
thisLineCurrentPosition = nextSpace + 1;
}
if (thisLineLength >= maxWidth || thisLineCurrentPosition > textLength) {
if (thisLineCurrentPosition > textLength) {
done = true;
}
thisLine = make_fit_l(thisLine, maxWidth, L'_');
output += thisLine + (done ? L"" : L"\n");
thisLine = L"";
thisLineLength = thisLine.size();
thisLineStartPosition = thisLineCurrentPosition;
}
}
return output;
}
wstring string_dollar(size_t length, wchar_t ch) {
wstring str = L"";
for (size_t i = 0; i<length; i++) {
str += ch;
}
return str;
}
wstring left(const wstring& text, size_t length) {
return text.substr(0, length);
}
wstring make_fit_l(const wstring& text, size_t length, wchar_t paddCh) {
return left(text + string_dollar(length, paddCh), length);
}
wstring get_substring(const wstring& text, const int32_t var1, const int32_t var2) {
return text.substr(std::min<int32_t>(var1, text.length()-1), std::max(var2, 0));
}
size_t get_index_of(const wstring& text, const wstring& search, size_t start) {
return text.find(search, start);
}
} // End namespace SBF
// test_method_result main_test_Utils(int argc, char** argv) {
// test_method_result results = std::make_tuple(1, 0);
// return results;
// }

16
sbf-cpp/Utils.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef UTILS_H__
#define UTILS_H__
#include <string>
namespace SBF {
using std::wstring;
size_t get_index_of(const wstring& text, const wstring& search, size_t start);
wstring word_wrap(const wstring& text, int maxWidth);
wstring get_substring(const wstring& text, int32_t var1, int32_t var2);
wstring make_fit_l(const wstring& text, size_t length, wchar_t paddCh);
wstring left(const wstring& text, size_t length);
wstring string_dollar(size_t length, wchar_t ch);
} // End namespace SBF
#endif // End !defined UTILS_H__

10
sbf-cpp/Utils_test.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "Utils.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Utils(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

0
sbf-cpp/Virtues.cpp Normal file
View File

24
sbf-cpp/Virtues.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef VIRTUES_H__
#define VIRTUES_H__
#include <string>
#include <vector>
namespace SBF {
const int kVirtuePoints = 7;
const int kVirtueSelfControlId = 1;
const std::wstring kVirtueSelfControlLabel = L"Self-Control";
const int kVirtueCourageId = 2;
const std::wstring kVirtueCourageLabel = L"Courage";
const int kVirtueConscienceId = 3;
const std::wstring kVirtueConscienceLabel = L"Conscience";
const int kVirtuesCount = 3;
const std::wstring kVirtues[] = {
L"",
kVirtueSelfControlLabel,
kVirtueCourageLabel,
kVirtueConscienceLabel,
};
const std::wstring GetVirtueLabel(int virtueId);
void FillVirtueLabels(std::vector<std::wstring> virtueLabels);
} // End namespace SBF
#endif // End !defined VIRTUES_H__

10
sbf-cpp/Virtues_test.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "Virtues.h"
#include "test.h"
using namespace SBF;
using namespace Test;
test_method_result main_test_Virtues(int argc, char** argv) {
test_method_result results = std::make_tuple(1, 0);
return results;
}

View File

@@ -4,6 +4,7 @@
#include <string> #include <string>
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include "test.h"
// using namespace std; // using namespace std;
using std::wcout; using std::wcout;
@@ -15,17 +16,152 @@ using std::pair;
using std::get; using std::get;
using std::make_tuple; using std::make_tuple;
using std::vector; using std::vector;
using Test::test_method_result;
using Test::test_fn;
using Test::operator+;
typedef tuple<size_t, uint32_t> test_method_result; // using namespace Test;
size_t get_index_of(const wstring& text, const wstring& search, size_t start); // size_t get_index_of(const wstring& text, const wstring& search, size_t start);
wstring word_wrap(const wstring& text, int maxWidth); // wstring word_wrap(const wstring& text, int maxWidth);
wstring get_substring(const wstring& text, int32_t var1, int32_t var2); // wstring get_substring(const wstring& text, int32_t var1, int32_t var2);
wstring make_fit_l(const wstring& text, size_t length, wchar_t paddCh); // wstring make_fit_l(const wstring& text, size_t length, wchar_t paddCh);
wstring left(const wstring& text, size_t length); // wstring left(const wstring& text, size_t length);
wstring string_dollar(size_t length, wchar_t ch); // wstring string_dollar(size_t length, wchar_t ch);
void do_pass_fail(bool passed, uint32_t& failureCount);
// int main(int argc, char* argv[]) {
// // TODO: Come up with a good way to enable/disable tests.
// // Maybe replace the expected, params pairs with another tuple for enabled, expected, params.
// // Maybe have the test functions take an enabled bool param.
// setlocale(LC_ALL, "");
// test_method_result results;
// wstring longText = L"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
// results = results + Test::test_fn(L"get_index_of", get_index_of,
// vector<pair<size_t, tuple<wstring, wstring, size_t>>>({
// pair(22, make_tuple(longText, L"dummy", 0)),
// pair(-1, make_tuple(longText, L"acid", 0)),
// pair(120, make_tuple(longText, L"dummy", 100)),
// pair(-1, make_tuple(longText, L"dummy", longText.size())),
// pair(6, make_tuple(L"these are words", L"are", 0)),
// pair(4, make_tuple(L"one two one two", L"two", 0)),
// pair(12, make_tuple(L"one two one two", L"two", 5)),
// }));
// results = results + test_fn(L"get_substring", get_substring, vector({
// pair(L"234", make_tuple(L"1234567890", 1, 3)),
// pair(L"Paris", make_tuple(L"Where is Paris?", 10-1, 5)),
// }));
// results = results + test_fn(L"left", left, vector({
// pair(L"Micro", make_tuple(L"Microsoft QBasic", 5)),
// }));
// results = results + test_fn(L"make_fit_l", make_fit_l, vector({
// pair(L"12___", make_tuple(L"12", 5, L'_')),
// }));
// results = results + test_fn(L"string_dollar", string_dollar, vector({
// pair(L"AAAAA", make_tuple(5, L'A')),
// }));
// results = results + test_fn(L"word_wrap", word_wrap, vector({
// pair(L"0123_", make_tuple(L"0123", 5)),
// pair(L"01234", make_tuple(L"01234", 5)),
// pair(L"01234\n5____", make_tuple(L"012345", 5)),
// pair(L"01234\n56789\n0____", make_tuple(L"01234567890", 5)),
// pair(L"01 23\n45 67\n89 01", make_tuple(L"01 23 45 67 89 01", 5)),
// pair(L"01 34\n67 90\n23 56\n89___", make_tuple(L"01 34 67 90 23 56 89 ", 5)),
// }));
// wcout << "Total tests ran: " << get<0>(results) << endl;
// wcout << "Total failures: " << get<1>(results) << endl;
// return 0;
// }
// wstring word_wrap(const wstring& text, int maxWidth) {
// wstring output = L"";
// wstring thisLine = L"";
// wstring nextChunk = L"";
// int32_t thisLineStartPosition = 0;
// int32_t thisLineCurrentPosition = 0;
// int32_t nextSpace = -1;
// int32_t textLength = text.size();
// size_t thisLineLength = 0;
// bool done = false;
// while (!done) {
// nextSpace = get_index_of(text, L" ", thisLineCurrentPosition);
// if (nextSpace < 0) {
// nextSpace = textLength;
// }
// nextChunk = get_substring(text, thisLineCurrentPosition, nextSpace - thisLineCurrentPosition);
// auto nextChunkLength = nextChunk.size();
// if (nextChunkLength > 0) {
// auto needsSpace = thisLine.size() > 0;
// if (needsSpace) {
// thisLine = thisLine + L" ";
// }
// thisLineLength = thisLine.size();
// if (nextChunkLength > maxWidth) {
// nextChunk = get_substring(text, thisLineCurrentPosition, maxWidth - thisLineLength);
// nextSpace = thisLineStartPosition + maxWidth;
// thisLine = thisLine + nextChunk;
// thisLineCurrentPosition = nextSpace;
// } else if(thisLineLength + nextChunkLength > maxWidth) {
// thisLine = make_fit_l(thisLine, maxWidth, L' ');
// } else {
// thisLine = thisLine + nextChunk;
// thisLineCurrentPosition = nextSpace + 1;
// }
// thisLineLength = thisLine.size();
// } else {
// thisLineCurrentPosition = nextSpace + 1;
// }
// if (thisLineLength >= maxWidth || thisLineCurrentPosition > textLength) {
// if (thisLineCurrentPosition > textLength) {
// done = true;
// }
// thisLine = make_fit_l(thisLine, maxWidth, L'_');
// output += thisLine + (done ? L"" : L"\n");
// thisLine = L"";
// thisLineLength = thisLine.size();
// thisLineStartPosition = thisLineCurrentPosition;
// }
// }
// return output;
// }
// wstring string_dollar(size_t length, wchar_t ch) {
// wstring str = L"";
// for (size_t i = 0; i<length; i++) {
// str += ch;
// }
// return str;
// }
// wstring left(const wstring& text, size_t length) {
// return text.substr(0, length);
// }
// wstring make_fit_l(const wstring& text, size_t length, wchar_t paddCh) {
// return left(text + string_dollar(length, paddCh), length);
// }
// wstring get_substring(const wstring& text, const int32_t var1, const int32_t var2) {
// return text.substr(std::min<int32_t>(var1, text.length()-1), std::max(var2, 0));
// }
// size_t get_index_of(const wstring& text, const wstring& search, size_t start) {
// return text.find(search, start);
// }
namespace Test {
uint32_t do_pass_fail(bool passed) { uint32_t do_pass_fail(bool passed) {
if (passed) { if (passed) {
wcout << "Result: PASS" << endl; wcout << "Result: PASS" << endl;
@@ -62,138 +198,4 @@ test_method_result test_fn(wstring testName, F f, vector<pair<_T1, tuple<T2...>>
test_method_result operator+(const test_method_result& first, const test_method_result second) { test_method_result operator+(const test_method_result& first, const test_method_result second) {
return make_tuple(get<0>(first) + get<0>(second), get<1>(first) + get<1>(second)); return make_tuple(get<0>(first) + get<0>(second), get<1>(first) + get<1>(second));
} }
} // End namespace Test
// TODO: define operator<< for std::tuple
// TODO: Define operator+= for test_method_result
int main(int argc, char* argv[]) {
// TODO: Come up with a good way to enable/disable tests.
// Maybe replace the expected, params pairs with another tuple for enabled, expected, params.
// Maybe have the test functions take an enabled bool param.
setlocale(LC_ALL, "");
test_method_result results;
wstring longText = L"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
results = results + test_fn(L"get_index_of", get_index_of,
vector<pair<size_t, tuple<wstring, wstring, size_t>>>({
pair(22, make_tuple(longText, L"dummy", 0)),
pair(-1, make_tuple(longText, L"acid", 0)),
pair(120, make_tuple(longText, L"dummy", 100)),
pair(-1, make_tuple(longText, L"dummy", longText.size())),
pair(6, make_tuple(L"these are words", L"are", 0)),
pair(4, make_tuple(L"one two one two", L"two", 0)),
pair(12, make_tuple(L"one two one two", L"two", 5)),
}));
results = results + test_fn(L"get_substring", get_substring, vector({
pair(L"234", make_tuple(L"1234567890", 1, 3)),
pair(L"Paris", make_tuple(L"Where is Paris?", 10-1, 5)),
}));
results = results + test_fn(L"left", left, vector({
pair(L"Micro", make_tuple(L"Microsoft QBasic", 5)),
}));
results = results + test_fn(L"make_fit_l", make_fit_l, vector({
pair(L"12___", make_tuple(L"12", 5, L'_')),
}));
results = results + test_fn(L"string_dollar", string_dollar, vector({
pair(L"AAAAA", make_tuple(5, L'A')),
}));
results = results + test_fn(L"word_wrap", word_wrap, vector({
pair(L"0123_", make_tuple(L"0123", 5)),
pair(L"01234", make_tuple(L"01234", 5)),
pair(L"01234\n5____", make_tuple(L"012345", 5)),
pair(L"01234\n56789\n0____", make_tuple(L"01234567890", 5)),
pair(L"01 23\n45 67\n89 01", make_tuple(L"01 23 45 67 89 01", 5)),
pair(L"01 34\n67 90\n23 56\n89___", make_tuple(L"01 34 67 90 23 56 89 ", 5)),
}));
wcout << "Total tests ran: " << get<0>(results) << endl;
wcout << "Total failures: " << get<1>(results) << endl;
return 0;
}
size_t get_index_of(const wstring& text, const wstring& search, size_t start) {
return text.find(search, start);
}
wstring word_wrap(const wstring& text, int maxWidth) {
wstring output = L"";
wstring thisLine = L"";
wstring nextChunk = L"";
int32_t thisLineStartPosition = 0;
int32_t thisLineCurrentPosition = 0;
int32_t nextSpace = -1;
int32_t textLength = text.size();
size_t thisLineLength = 0;
bool done = false;
while (!done) {
nextSpace = get_index_of(text, L" ", thisLineCurrentPosition);
if (nextSpace < 0) {
nextSpace = textLength;
}
nextChunk = get_substring(text, thisLineCurrentPosition, nextSpace - thisLineCurrentPosition);
auto nextChunkLength = nextChunk.size();
if (nextChunkLength > 0) {
auto needsSpace = thisLine.size() > 0;
if (needsSpace) {
thisLine = thisLine + L" ";
}
thisLineLength = thisLine.size();
if (nextChunkLength > maxWidth) {
nextChunk = get_substring(text, thisLineCurrentPosition, maxWidth - thisLineLength);
nextSpace = thisLineStartPosition + maxWidth;
thisLine = thisLine + nextChunk;
thisLineCurrentPosition = nextSpace;
} else if(thisLineLength + nextChunkLength > maxWidth) {
thisLine = make_fit_l(thisLine, maxWidth, L' ');
} else {
thisLine = thisLine + nextChunk;
thisLineCurrentPosition = nextSpace + 1;
}
thisLineLength = thisLine.size();
} else {
thisLineCurrentPosition = nextSpace + 1;
}
if (thisLineLength >= maxWidth || thisLineCurrentPosition > textLength) {
if (thisLineCurrentPosition > textLength) {
done = true;
}
thisLine = make_fit_l(thisLine, maxWidth, L'_');
output += thisLine + (done ? L"" : L"\n");
thisLine = L"";
thisLineLength = thisLine.size();
thisLineStartPosition = thisLineCurrentPosition;
}
}
return output;
}
wstring string_dollar(size_t length, wchar_t ch) {
wstring str = L"";
for (size_t i = 0; i<length; i++) {
str += ch;
}
return str;
}
wstring left(const wstring& text, size_t length) {
return text.substr(0, length);
}
wstring make_fit_l(const wstring& text, size_t length, wchar_t paddCh) {
return left(text + string_dollar(length, paddCh), length);
}
wstring get_substring(const wstring& text, const int32_t var1, const int32_t var2) {
return text.substr(std::min<int32_t>(var1, text.length()-1), std::max(var2, 0));
}

24
sbf-cpp/test.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef TEST_H__
#define TEST_H__
#include <cstdint>
#include <tuple>
#include <utility>
#include <string>
namespace Test {
using std::tuple;
using std::pair;
using std::vector;
using std::wstring;
typedef tuple<size_t, uint32_t> test_method_result;
void do_pass_fail(bool passed, uint32_t& failureCount);
uint32_t do_pass_fail(bool passed);
template<typename _T1, typename F, typename... T2>
test_method_result test_fn(wstring testName, F f, vector<pair<_T1, tuple<T2...>>> tests);
test_method_result operator+(const test_method_result& first, const test_method_result second);
// TODO: define operator<< for std::tuple
// TODO: Define operator+= for test_method_result
} // End namespace Test
#endif // End !defined TEST_H__