From 81c4259cfe6ed887c2e825791478cdc5fab2d2f0 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 20 Oct 2013 16:46:23 +0200 Subject: [PATCH] * Fixed must be blocked by all creatures if able effects to take only place if the creature with the effect also attacks (fixes #361). --- .../MustBeBlockedByAllAttachedEffect.java | 7 +- .../MustBeBlockedByAllSourceEffect.java | 6 +- .../MustBeBlockedByAllTargetEffect.java | 84 +++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java diff --git a/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java b/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java index db9c5afc6f..2209c62b66 100644 --- a/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java +++ b/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java @@ -62,9 +62,12 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect { + + public MustBeBlockedByAllTargetEffect(Duration duration) { + super(duration); + staticText = new StringBuilder("All creatures able to block target creature ") + .append(this.getDuration().equals(Duration.EndOfTurn) ? "this turn ":"") + .append("do so").toString(); + } + + public MustBeBlockedByAllTargetEffect(final MustBeBlockedByAllTargetEffect effect) { + super(effect); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + Permanent sourceCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); + if (sourceCreature != null && sourceCreature.isAttacking()) { + return permanent.canBlock(this.getTargetPointer().getFirst(game, source), game); + } + return false; + } + + @Override + public boolean mustAttack(Game game) { + return false; + } + + @Override + public boolean mustBlock(Game game) { + return true; + } + + @Override + public UUID mustBlockAttacker(Ability source, Game game) { + return this.getTargetPointer().getFirst(game, source); + } + + @Override + public MustBeBlockedByAllTargetEffect copy() { + return new MustBeBlockedByAllTargetEffect(this); + } + +}