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