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

Store GameStatus in a redis db #52

Open
antonioalonzi opened this issue Apr 18, 2020 · 3 comments
Open

Store GameStatus in a redis db #52

antonioalonzi opened this issue Apr 18, 2020 · 3 comments
Assignees

Comments

@antonioalonzi
Copy link
Member

No description provided.

@antonioalonzi antonioalonzi changed the title Game: Store GameStatus in a redis db Store GameStatus in a redis db Apr 28, 2020
@TheGrizzlyDev TheGrizzlyDev self-assigned this May 4, 2020
@antonioalonzi
Copy link
Member Author

nice pick... let me give you access to heroku

@TheGrizzlyDev
Copy link
Contributor

@antonioalonzi looking at the current implementation of GameStatus it looks like GameStatus not only holds the state of the game but also contains all the GameLogic and you can see that by all the services nested inside the GameStatus. Maybe a first step to this should be to just separate that logic from the actual state. After that it could be as easy as setting up spring-data with redis. What do you think about it?

@antonioalonzi
Copy link
Member Author

antonioalonzi commented May 6, 2020

Totally agree.

I did a shit design on it.
There's another option that you just serialise to String... basically the same that I'm doing when I sent the event out (well, I serialise not GameStatus but all its attribute, but it should be quite okay to serialise the GameStatus itself).

If you want to do, removing all the logic in the service is a good good thing to do... Just extremely tedious. I'll leave it to you if you want to take the burden or not.

If you do just watch for:

  @JsonProperty
  public List<CardInstanceAbility> getAbilities() {
    List<CardInstanceAbility> abilities = getFixedAbilities();
    abilities.addAll(getAbilitiesFormOtherPermanents());
    return abilities;
  }

This method is a bitch... split it 2.
getFixedAbilities() gets all the abilities for a card including the one added by spells (until end of turn), attachments, equipments.
getAbilitiesFromOtherPermanents() is the tricky one. Add abilities to a permanent from another permanent (e.g. all other zombies have menace). This is a big recursion and it's easy to get overflow if there's a small bug. And if you get overflow during serialisation is very hard to debug.

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

No branches or pull requests

2 participants