-
Notifications
You must be signed in to change notification settings - Fork 325
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
Feature: Implements 'themes' #52
base: master
Are you sure you want to change the base?
Conversation
Added Themes class to handle theming and applied to game
Thank you for your contribution! 🎉 |
Of course yes! Please do the review 🙏 |
@cawvyoct Thank you! I've been quite busy this week, I would love your help 😄 |
So, I don't know what level of C++ you know so I will try and keep things generic. Again, congratulations on reaching this far with your C++ development! It's a good start to greater things 🥇 ! By the way, questions are highly encouraged! ❔ 😃 👍 ! |
Overall tl:dr: try to imagine if contributors added 400 themes to this game, would the code added in the PR help to abstract all the themes so they can be be easily added without "much" problems. |
Overall tl:dr-2: It is always a challenge to define what is an "interface" (API) and what is "data". For example, one "application" means "generic for programmers" to read (and understand the source code / flow). |
src/themes.cpp
Outdated
#include "menu.hpp" | ||
|
||
std::string Themes::themedOutput(ull value) { | ||
switch (themeCode) { |
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 400
themes, will this switch(...)
statement be the only method/way of adding a [theme]
to [a theme's registry]
?".
Is there a more sustainable "generic" method of doing the action of:
[adding an item (or many items) to a list]
[checking if an item exists in the list]
, and then,[acting (possibly x command) when an item is found in the list]
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.
https://github.com/BayMinimum/2048.cpp/blob/b9920fe5489c427f9112d2216210de1a86afb82a/src/themes.cpp#L61-L72 enables the contributors to add 'X themes' easily
src/headers/themes.hpp
Outdated
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"} {} |
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 400
themes, is the [Theme's class constructor]
the only way a theme can be added to this game?"
- It is possible that if it is not sustainable to do so, you may have to make some API to accept:
[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: Theme
defines just one theme datatype, and ThemeController
handles the list of Theme
objects
For now, the questions asked are very similar, (maybe even related to each other...) However, bit by bit, I think you can do it so you can answer: 😃
Questions of course are encouraged! ❔ 😃 👍 |
Seperated class Themes into Theme and ThemeController to make it more generic and easily expandable
Thanks for your thoughtful comments, @cawvyoct 😃 I've pushed a commit which I believe to solve both problems. Please take a look ✌️ |
Hi @BayMinimum, just saw the changes, they look great! There is one thing that is bugging me 😅. I find it a bit uncomfortable that there are arrays for the possible values, predefined. It seems like we are almost limiting the player from reaching any number or element above the predefined last element of the array. I know it's very rare that a player will ever reach any number above 8192 or the corresponding tiles in the other themes, but we should not limit it to that because of this assumption. I propose that, instead of having an array, we have a callback function that computes the value of the tile at that index. So for example, if the index is |
Hey @plibither8, I really agree to you, and I also had the same uncomfortable feeling 😢 but made the limit since I thought the current implementation of game tiles are enforcing such limit. 🤔 The below is going to happen when number grows beyond 8192: |
Oh! Didn't think about that 😅, you're right, that's definitely an issue! Thanks for #54, we should discuss this there |
This patch allows to create themes that has infinitely-long sequence with function, instead of a vector with finite length
@plibither8 I've pushed a commit to accept both |
Looks great, thanks a lot 😄! Just one thing before we merge this: Right now, just to play a single game, the user has to go through 3 screens to finally start playing: the initial menu, the board-size config and finally choosing the theme. A more easy and simple flow would be to have a fourth option in the settings: "Configuration". Here the user can set the board size and theme. The data can be saved in an external text file ( |
Unfortunately a bit busy at the moment but just to say that keep up the good work @BayMinimum as it seems you understood the hints into refactoring your code so it is a bit more flexible than before. 👍
👍 I also see the need for an "infinite play" mode for the game which has values that go beyond the winning tile value however, this is also a challenge when one adds themes. This is why I do think that, for now, an "hard-defined" array-based points system is the way to go unfortunately. The game needs to be refactored a bit in its API to accommodate between "defined" and "generated" tile scoring. This is why I said in the last code review that this was an iceberg-like challenge 😉 Again, will update soon and leave more feedback. A bit pressed for time at the moment.. 😿 |
Hi @BayMinimum, |
Added Themes class to handle theming and applied to game (#51)