-
Notifications
You must be signed in to change notification settings - Fork 12
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
A new way to change phase #118
Comments
Changing the priority because this will allow to fix #120 |
Checking the phase enum: enum Phase
{
NONE, ## Hello Youston, we are nowhere
GAME_STARTING, ## The game is starting
PLAYER_ATTACKING, ## The player is attacking
PLAYER_FINISHING, ## The player finished its turn (card discard and other stuff starts here)
ENEMY_ATTACKING, ## Enemy turn
SCENE_END, ## The current scene ended
} Not all phases make sense to go to with the
enum GlobalPhase
{
NONE, ## Hello Youston, we are nowhere
GAME_STARTING, ## The game is starting
SCENE_END, ## The current scene ended
} I would also rename enum CombatPhase
{
PLAYER_ATTACKING, ## The player is attacking
PLAYER_FINISHING, ## The player finished its turn (card discard and other stuff starts here)
ENEMY_ATTACKING, ## Enemy turn
} and the Phase manager next phase would be named We would keep |
misslick on that confirmed label. Anyway, taking this and i'm doing it as soon as it's confirmed and #114 has been merged |
I'm trying to think if there's any other way we could go about changing phases in general 🤔 Your idea, if I understand it correctly, will help us track where the phase changes are happening in a simpler way and prevent mistypes of phases, which would be great. But I feel at the same time it could actually make it even harder to figure out what is happening in which phase - the code will do it's magic and then just call a generic advance_to_next_phase - without giving us any visibility into where the current action is happening (at what point during combat, which phase etc) It would work if we had a code for a "phase" in one place - like you say, at the end of a phase, go to next one. And currently, it would probably work, because most if not all phase changes are being handled in the battler if I remember correctly ? But I'm thinking if we add more phases, will it still handled in there ? |
To answer your questions
Now for the implementation I was thinking of this (pseudo-code)
or an alternative (which I prefer)
|
Implemeting this as stated here should help the current state so I think we are good to go with it. My worries were mainly for the future should phases be added and mainly if they were to be controled/switched from various places. That should not really happen and if it does we can't really tell now how it would look so we should probably go with what helps us now and adjust later should it be needed. Second implementation sounds more easily comprehensible to me |
I'll go with the second implementation then, as it's the one I would have done too |
Is your amelioration related to a problem? Please describe.
The way we change phase actually is to call the next phase by name when arriving at the end of the current phase. This makes it error prone because if we somehow write the wrong phase, tracking in the entire codebase where we called the wrong phase won't easy.
Describe the solution you'd like
Instead of calling the next phase by name, create a
advance_to_next_phase
function in the phase manager. At the end of the code of a phase, simply call thisadvance_to_next_phase
function. This function changes phases in the order the phases are written in thePhase
enum inGlobalEnums
Two advantages to this:
Additional context
This might need to wait for #114 to be finished since we are discussing adding phases in there.
Additionally,
set_phase
would not be used directly anymore by other classes outside of thePhaseManager
The text was updated successfully, but these errors were encountered: