[NEO] Implemented Bronze Cudgels

This commit is contained in:
Evan Kranzler 2022-02-05 18:22:42 -05:00
parent dece8da0ad
commit b92128dd41
5 changed files with 96 additions and 15 deletions

View file

@ -15,11 +15,7 @@ public enum AbilityResolutionCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
AbilityResolvedWatcher watcher = game.getState().getWatcher(AbilityResolvedWatcher.class);
if (watcher != null) {
return watcher.getResolutionCount(game, sourceAbility);
}
return 0;
return AbilityResolvedWatcher.getResolutionCount(game, sourceAbility);
}
@Override

View file

@ -38,15 +38,13 @@ public class IfAbilityHasResolvedXTimesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
AbilityResolvedWatcher watcher = game.getState().getWatcher(AbilityResolvedWatcher.class);
if (watcher != null && watcher.getResolutionCount(game, source) == resolutionNumber) {
if (effect instanceof OneShotEffect) {
return effect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) effect, source);
return true;
}
if (AbilityResolvedWatcher.getResolutionCount(game, source) != resolutionNumber) {
return true;
}
if (effect instanceof OneShotEffect) {
return effect.apply(game, source);
}
game.addEffect((ContinuousEffect) effect, source);
return true;
}
}

View file

@ -33,7 +33,11 @@ public class AbilityResolvedWatcher extends Watcher {
resolutionMap.clear();
}
public int getResolutionCount(Game game, Ability source) {
return resolutionMap.getOrDefault(source.getOriginalId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()), 0);
public static int getResolutionCount(Game game, Ability source) {
return game
.getState()
.getWatcher(AbilityResolvedWatcher.class)
.resolutionMap
.getOrDefault(source.getOriginalId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()), 0);
}
}