rewrite watchers to GameState.getWatcher(), rather than getWatchers().get(). This hides away the implementation of the watchers. Accepts the class rather than the name. Always returns the specific subclass, so there is no more casting needed. Only 1 line in the common library remains, that is still using the old 'deprecated' method. Needs a new version release to do that.

This commit is contained in:
Ingmar Goudt 2019-01-06 20:58:51 +01:00
parent f01b3d3ca3
commit 9a310732d8
324 changed files with 573 additions and 586 deletions

View file

@ -40,7 +40,7 @@ public class SpectacleAbility extends SpellAbility {
@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
if (watcher != null && watcher.getAllOppLifeLost(playerId, game) > 0) {
return super.canActivate(playerId, game);
}