In order to be able to switch between views (cf #488), we need to tell the game what view should come after the current view. Tjis should change depending on what the user does inside the current view (e.g., if the user clicks "action" in the menu, the next view should be the game, but if they click "options", next should be the options screen).
One possible implementation is to keep track of this inside each _view class, via a member of class view_mode. That way, once we are done running this view (via exec()), we can query the object about what should come next, and change this value from inside but not outside the class. See the while loop in #488
Implement such a member variable, and its getter, for game_view:
[x] Create a test to check that the getter exists and returns a member of class view_mode
[x] Solve this test.
Note 1: I (@TheoPannetier) suggest the ?suggestive names m_next_view and what_next() for the variable and the getter respectively, but feel free to chose anything you deem more appropriate, you're boss.
Note 2: unfortunately, we cannot run the tests inside _view classes on GitHub Actions. So we'll have to rely on the test passing on your local computers as a criterion for solving the issue.
// (494) There should be a member of type view_mode
{
game_view gv;
view_mode expected_next_view = view_mode::quit;
assert(gv.what_next() == expected_next_view);
}
Depends on:
In order to be able to switch between views (cf #488), we need to tell the game what view should come after the current view. Tjis should change depending on what the user does inside the current view (e.g., if the user clicks "action" in the menu, the next view should be the game, but if they click "options", next should be the options screen).
One possible implementation is to keep track of this inside each
_view
class, via a member of classview_mode
. That way, once we are done running this view (viaexec()
), we can query the object about what should come next, and change this value from inside but not outside the class. See the while loop in #488Implement such a member variable, and its getter, for
game_view
:view_mode
Note 1: I (@TheoPannetier) suggest the ?suggestive names
m_next_view
andwhat_next()
for the variable and the getter respectively, but feel free to chose anything you deem more appropriate, you're boss.Note 2: unfortunately, we cannot run the tests inside
_view
classes on GitHub Actions. So we'll have to rely on the test passing on your local computers as a criterion for solving the issue.