Skip to content
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

Improve MVC interface #12

Open
ben-ryder opened this issue Feb 23, 2020 · 1 comment
Open

Improve MVC interface #12

ben-ryder opened this issue Feb 23, 2020 · 1 comment
Assignees
Labels
feature New feature or request improvement Improve an existing feature

Comments

@ben-ryder
Copy link
Owner

Describe your feature
I suggest improving the MVC interface between the different game classes.

Is your suggestion related to any problems?
This was brought to light because of GH-11 and fixing GH-10.
The cause of both of these is that links between the Model and View are quite blurred, and both are having to interact with each other in ways they shouldn't.
For example:

  • The View is performing logic that should be done somewhere in the Model (such as checking if a player has died)
  • The Model currently has knowledge it shouldn't need about the View (for example so that it can update the city tiles when needed).

This has become an issue for working on GH-2 as some logic needed for the game is processed in the view, but the computer player's actions take place in the Model.

Suggested Implementation
Whatever happens, this will require some large scale refactors of the code!
I will have to decide the exact framework I want to employ but a few things to think about are:

  • I should really be able to play the game in the terminal by instantiating the game model and using the interface.
  • It is not up to the caller of the model interface to do lots of state checking first, the model interface should be robust enough and return appropriate errors/states for the caller to handle. This is of course within reason, if the errors can be caused by interface based input then this should be handled in the interface where possible too.
  • The model should be able to perform multiple related actions at once. (Such as conquering a city, and then killing the player if they have no more cities). It should then create some sort of report/event stack about what occurred which the interface can then query and interpret in order to display state change.
  • The use of a type of "event & state change stack" would allow the user interface to become totally separate from the Model. This has the benefit of offering potential performance improvements, as the Model processing does not have to be throttled by visual updates.
@ben-ryder ben-ryder added the feature New feature or request label Feb 23, 2020
@ben-ryder ben-ryder self-assigned this Feb 23, 2020
@ben-ryder ben-ryder added the improvement Improve an existing feature label Feb 23, 2020
@ben-ryder
Copy link
Owner Author

Just to add another idea: event listeners could be added. These would effectively hook controller methods into the user interface. When the hooks are triggered this causes the method to run which could then update the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request improvement Improve an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant