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

Issue/#858 validity in game info #900

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Askaholic
Copy link
Collaborator

@Askaholic Askaholic commented Apr 4, 2022

Adds game validity to the game_info messages. This requires quite a lot of refactoring because the validity needs to be re-evaluated every time any of the attributes that affect validity change. Previously, each of the checks only ran at certain times such as when the game launched or after it was finished. Refactoring this was also made more difficult by the fact that the game handling logic is already such a mess. Hopefully this approach of moving the validation code out of the Game class helps with that, but I'm still not 100% happy with it. There are still some problems with it:

  • The ValidationRules are very tightly coupled to the Game class, some of them even use 'private' variables from Game
  • The validity computation is somewhat expensive as it is likely to be called many times, especially while a game is in the lobby state. It is also extremely difficult to cache because it has so many dependencies that would need to invalidate the cache whenever they change.

Some other issues that came up:

  • Whenever the ScenarioFile game option is set, we need to query the database in order to get the map id and to check if the map is ranked. This is an async operation, but it doesn't otherwise make sense to make set_game_option an async function. So it's a little unclear where exactly the await should happen.
  • Games are marked as dirty quite liberally, even if nothing that affects the to_dict method would actually change
  • We might want to rename some of the validity states since the enum names are used in the protocol

Closes #858

@Eternal-ll
Copy link

Eternal-ll commented Oct 11, 2022

Api returns HAS_AI, but server defined only HAS_AI_PLAYERS

HAS_AI_PLAYERS = 19

image

api: MULTIPLE_TEAMS
server : MULTI_TEAM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add validity to game_info message
2 participants