-
Notifications
You must be signed in to change notification settings - Fork 319
Feature: Implements 'themes' #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #ifndef THEMES_H | ||
| #define THEMES_H | ||
|
|
||
| #include "color.hpp" | ||
| #include "global.hpp" | ||
| #include <cmath> | ||
| #include <limits> | ||
| #include <vector> | ||
|
|
||
| class Themes { | ||
| public: | ||
| Themes() | ||
| : fibonacci_numbers{1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 377, 610}, | ||
| elements{"H", "He", "Li", "Be", "B", "C", "N", | ||
| "O", "F", "Ne", "Na", "Ca", "Sc"}, | ||
| programming_languages{"C", "C++", "PHP", "C#", "Py", "Bash", "Java", | ||
| "SQL", "CSS", "HTML", "JS", "Go", "Rust"} {} | ||
| std::string themedOutput(ull value); | ||
| void chooseTheme(); | ||
|
|
||
| private: | ||
| int themeCode = 0; | ||
| const int themeCount = 4; | ||
| std::vector<std::string> elements; | ||
| std::vector<std::string> programming_languages; | ||
| std::vector<int> fibonacci_numbers; | ||
| }; | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #include "themes.hpp" | ||
| #include "menu.hpp" | ||
|
|
||
| std::string Themes::themedOutput(ull value) { | ||
| switch (themeCode) { | ||
|
||
| case 1: | ||
| return std::to_string(value); | ||
| case 2: | ||
| return elements[log2(value) - 1]; | ||
| case 3: | ||
| return std::to_string(fibonacci_numbers[log2(value) - 1]); | ||
| case 4: | ||
| return programming_languages[log2(value) - 1]; | ||
| default: | ||
| return "ERR"; | ||
| } | ||
| } | ||
|
|
||
| void Themes::chooseTheme() { | ||
| bool err = false; | ||
| while ((themeCode > themeCount || themeCode < 1)) { | ||
| clearScreen(); | ||
| drawAscii(); | ||
|
|
||
| if (err) { | ||
| std::cout << red | ||
| << " Invalid input. Theme number should range from 1 to " | ||
| << themeCount << "." << def; | ||
| endl(2); | ||
| } | ||
|
|
||
| std::cout << bold_on << " 1. Standard: 2, 4, 8, ..." << std::endl | ||
| << " 2. Elements: H, He, Li, ..." << std::endl | ||
| << " 3. Fibonacci Numbers: 1, 2, 3, ..." << std::endl | ||
| << " 4. Programming Languages: C, C++, PHP, ..." << std::endl | ||
BayMinimum marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| << " Enter theme number: " << bold_off; | ||
|
|
||
| std::cin >> themeCode; | ||
| std::cin.clear(); | ||
| std::cin.ignore(std::numeric_limits<std::int32_t>::max(), '\n'); | ||
| err = true; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask the question: "If I had
400themes, is the[Theme's class constructor]the only way a theme can be added to this game?"[some "x theme" datatype]and add it to[a list of some "x theme" datatypes]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed:
Themedefines just one theme datatype, andThemeControllerhandles the list ofThemeobjects