Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Refactor GameStates #85

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open

Refactor GameStates #85

wants to merge 6 commits into from

Conversation

Aevyz
Copy link
Contributor

@Aevyz Aevyz commented Sep 16, 2018

Merge this after everyone else has finished their end term merges, it's not that pressing.

Why

Games have entry conditions, you can only play them if ROS is enabled (Snapchat) or if the Internet is enabled (Akinator). Future games are likely to also have similar limitations. ChooseGameState must be able to handle this.

What was done

Games now shall extend an abstract class GameState. This is so that we can record the entry conditions, error messages and tags in each class, rather then alter ChooseGameState massively. Hopefully fulfills OO principles a bit better.

Furthermore, only games that can be played shall be suggested and the game shall be checked once again before entering the state.

Stuff Offloaded to GameStates

  • Tags
  • Start conditions
  • Message if cannot start
  • Transition Name
  • Stop checking (code was copy pasted 2x)

Extras

Additionally, some other features were implemented as a byproduct of this PR

  • NetworkUtils that pings 3 different servers to check if the internet is working
  • Map now has two new methods, to "recreate" a bidirectional map
  • Akinator has been fixed to not crash program in no internet connection on startup
  • Improved Logging

Todo

  • Document changes
  • Test to isolate all bugs
  • Improve HashMap creation process, some of it is pretty hacky
  • Write Unit Tests

@Aevyz Aevyz added enhancement feedback wanted Feel free to add some feedback on the current PR status labels Sep 16, 2018
@Aevyz Aevyz self-assigned this Sep 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement feedback wanted Feel free to add some feedback on the current PR status
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant