Implements CGGetDerangement.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#include "Derangements.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace SBF {
|
||||
namespace {
|
||||
using std::ostream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
} // End namespace
|
||||
|
||||
bool operator==(const DerangementType& left, const DerangementType& right) {
|
||||
return left.description == right.description && left.id == right.id && left.label == right.label
|
||||
@@ -28,10 +31,30 @@ DerangementType GetDerangement(int derangementId) {
|
||||
return kDerangementUnknown;
|
||||
}
|
||||
|
||||
void FillDerangements(std::vector<DerangementType>& derangements) {
|
||||
void FillDerangements(vector<DerangementType>& derangements) {
|
||||
derangements.clear();
|
||||
for (int id = 1; id <= kDerangementsCount; id++) {
|
||||
derangements.push_back(GetDerangement(id));
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> GetDerangementLabels() {
|
||||
vector<string> labels;
|
||||
|
||||
for (int id = 1; id <= kDerangementsCount; id++) {
|
||||
labels.push_back(kDerangementLabels[id]);
|
||||
}
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
vector<uint8_t> GetDerangementColors() {
|
||||
vector<uint8_t> colors;
|
||||
|
||||
for (int id = 1; id <= kDerangementsCount; id++) {
|
||||
colors.push_back(kDerangementTextColors[id]);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
} // End namespace SBF
|
||||
|
||||
@@ -216,6 +216,10 @@ DerangementType GetDerangement(int derangement_id);
|
||||
/// @brief Fills the provided vector with all valid derangements.
|
||||
/// @param derangements The vector to fill. It will be emptied first.
|
||||
void FillDerangements(std::vector<DerangementType>& derangements);
|
||||
|
||||
std::vector<std::string> GetDerangementLabels();
|
||||
|
||||
std::vector<uint8_t> GetDerangementColors();
|
||||
} // End namespace SBF
|
||||
|
||||
/** @}*/
|
||||
|
||||
@@ -39,7 +39,7 @@ void CGSpendFreebiePoints(CharacterType& ch);
|
||||
void CGSpendVirtuePoints(CharacterType& ch);
|
||||
void CharacterGenerator();
|
||||
void CharacterGeneratorForDummies();
|
||||
int ChooseStringId(vector<string> labels, MenuStyle style, string prompt);
|
||||
int ChooseStringId(vector<string> labels, MenuStyle style, const string& prompt);
|
||||
void CombatComputer();
|
||||
void DiceRoller();
|
||||
int GetChoice(int min, int max);
|
||||
@@ -54,8 +54,9 @@ void ShowCharacterSheet(CharacterType& ch);
|
||||
void ShowSplashScreen();
|
||||
void VehicleGenerator();
|
||||
void WaitForKeypress();
|
||||
int ChooseStringIdWithValues(vector<string> labels, vector<int> values, MenuStyle style, string prompt);
|
||||
int ChooseStringIdWithValues(vector<string> labels, vector<int> values, MenuStyle style, const string& prompt);
|
||||
int ChooseMenuItemId(vector<MenuItem> menu_items, MenuStyle style, const string& prompt, bool ignore_value);
|
||||
int ChooseStringIdWithColors(vector<string> labels, vector<uint8_t> colors, MenuStyle style, const string& prompt);
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
setlocale(LC_ALL, "");
|
||||
@@ -333,8 +334,13 @@ void CGSpendVirtuePoints(CharacterType& ch) {
|
||||
}
|
||||
|
||||
void CGGetDerangement(CharacterType& ch) {
|
||||
// TODO: Fill this in.
|
||||
cout << "// TODO: CGGetDerangement(CharacterType&)" << endl;
|
||||
if (ch.clanId == kClanMalkavian) {
|
||||
// If the clan is malkavian then pick a derangement.
|
||||
MenuStyle ms;
|
||||
ms.use_colors = true;
|
||||
ch.derangementId =
|
||||
ChooseStringIdWithColors(GetDerangementLabels(), GetDerangementColors(), ms, "Which derangement do you want?");
|
||||
}
|
||||
}
|
||||
|
||||
void CGSpendFreebiePoints(CharacterType& ch) {
|
||||
@@ -523,7 +529,7 @@ string GetString(string prompt) {
|
||||
return response;
|
||||
}
|
||||
|
||||
int ChooseStringId(vector<string> labels, MenuStyle style, string prompt) {
|
||||
int ChooseStringId(vector<string> labels, MenuStyle style, const string& prompt) {
|
||||
MaybeClearScreen();
|
||||
vector<MenuItem> menu_items = BuildMenu(labels);
|
||||
style.Adjust(menu_items);
|
||||
@@ -554,7 +560,7 @@ int GetMenuChoice(vector<MenuItem> menu_items, MenuStyle style) {
|
||||
}
|
||||
}
|
||||
|
||||
int ChooseStringIdWithValues(vector<string> labels, vector<int> values, MenuStyle style, string prompt) {
|
||||
int ChooseStringIdWithValues(vector<string> labels, vector<int> values, MenuStyle style, const string& prompt) {
|
||||
MaybeClearScreen();
|
||||
vector<MenuItem> menu_items = BuildMenuWithValues(labels, values);
|
||||
style.Adjust(menu_items, false);
|
||||
@@ -567,6 +573,20 @@ int ChooseStringIdWithValues(vector<string> labels, vector<int> values, MenuStyl
|
||||
return choice;
|
||||
}
|
||||
|
||||
int ChooseStringIdWithColors(vector<string> labels, vector<uint8_t> colors, MenuStyle style, const string& prompt) {
|
||||
MaybeClearScreen();
|
||||
// Check array bounds
|
||||
vector<MenuItem> menu_items = BuildMenuWithColors(labels, colors);
|
||||
style.Adjust(menu_items);
|
||||
cout << prompt << endl;
|
||||
PrintMenu(cout, menu_items, style);
|
||||
int choice = GetMenuChoice(menu_items, style);
|
||||
if (choice == style.random_item_id) {
|
||||
choice = GetRandomMenuItemId(menu_items);
|
||||
}
|
||||
return choice;
|
||||
}
|
||||
|
||||
int ChooseMenuItemId(vector<MenuItem> menu_items, MenuStyle style, const string& prompt, bool ignore_value) {
|
||||
MaybeClearScreen();
|
||||
style.Adjust(menu_items, ignore_value);
|
||||
|
||||
Reference in New Issue
Block a user