use of mage.watchers.common.WasBlockedThisTurnWatcher in project mage by magefree.
the class HeatStrokeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
BlockedThisTurnWatcher blockedWatcher = game.getState().getWatcher(BlockedThisTurnWatcher.class);
WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = game.getState().getWatcher(WasBlockedThisTurnWatcher.class);
Set<Permanent> inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game));
boolean toRet = false;
Set<MageObjectReference> toDestroy = new HashSet<>();
if (blockedWatcher != null) {
toDestroy.addAll(blockedWatcher.getBlockedThisTurnCreatures());
}
if (wasBlockedThisTurnWatcher != null) {
toDestroy.addAll(wasBlockedThisTurnWatcher.getWasBlockedThisTurnCreatures());
}
for (MageObjectReference mor : toDestroy) {
Permanent permanent = mor.getPermanent(game);
if (permanent != null && permanent.isCreature(game) && inROI.contains(permanent)) {
permanent.destroy(source, game, false);
toRet = true;
}
}
return toRet;
}
use of mage.watchers.common.WasBlockedThisTurnWatcher in project mage by magefree.
the class SourceWasBlockedThisTurnCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
WasBlockedThisTurnWatcher watcher = game.getState().getWatcher(WasBlockedThisTurnWatcher.class);
return sourcePermanent != null && watcher != null && watcher.getWasBlockedThisTurnCreatures().contains(new MageObjectReference(sourcePermanent, game));
}
Aggregations