tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

[Menu] Class `game_view` should have member of type `view_mode` #494

Closed kausmees closed 2 years ago

kausmees commented 2 years ago

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 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:

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);
  }
TheoPannetier commented 2 years ago

Done!