if (!effect.checksEventType(event, game)) { continue; if (event.getAppliedEffects() != null && event.getAppliedEffects().contains(effect.getId())) { Set<Ability> abilities = preventionEffects.getAbility(effect.getId()); Set<Ability> applicableAbilities = new HashSet<>(); for (Ability ability : abilities) { if (ability.getAbilityType() != AbilityType.STATIC || ability.isInUseableZone(game, null, event)) { if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) { if (effect.applies(event, ability, game)) { applicableAbilities.add(ability);
public UUID getControllerOfSourceId(UUID sourceId) { UUID controllerFound = null; for (PreventionEffect effect : preventionEffects) { Set<Ability> abilities = preventionEffects.getAbility(effect.getId()); for (Ability ability : abilities) { if (ability.getSourceId().equals(sourceId)) {
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (controller != null && creature != null) { for (CombatGroup combatGroup : game.getCombat().getGroups()) { if (combatGroup.getAttackers().contains(creature.getId())) { for (UUID blockerId : combatGroup.getBlockers()) { Permanent blocker = game.getPermanent(blockerId); if (blocker != null) { blocker.tap(game); PreventionEffect effect = new PreventDamageByTargetEffect(Duration.EndOfTurn, true); effect.setTargetPointer(new FixedTarget(blocker.getId())); game.addEffect(effect, source); } } } } return true; } return false; } }