matag-the-game
matag-the-game copied to clipboard
Store GameStatus in a redis db
nice pick... let me give you access to heroku
@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?
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.