* Fixed some cards/effects that checked for permanents with the same name and did not work correctly with face down creatures.

This commit is contained in:
LevelX2 2014-12-13 16:47:24 +01:00
parent 062ce8dd41
commit bc7a64677e
19 changed files with 214 additions and 115 deletions

View file

@ -28,10 +28,13 @@
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -56,16 +59,19 @@ public class DestroyAllNamedPermanentsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
String name = permanent.getName();
permanent.destroy(source.getSourceId(), game, false);
for (Permanent perm: game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (perm.getName().equals(name)) {
perm.destroy(source.getSourceId(), game, false);
}
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetPermanent == null) {
return false;
}
FilterPermanent filter = new FilterPermanent();
if (targetPermanent.getName().isEmpty()) {
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(targetPermanent.getName()));
}
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
perm.destroy(source.getSourceId(), game, false);
}
return true;
}

View file

@ -27,9 +27,9 @@
*/
package mage.filter.predicate.mageobject;
import mage.constants.SpellAbilityType;
import mage.MageObject;
import mage.cards.SplitCard;
import mage.constants.SpellAbilityType;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.Spell;
@ -51,12 +51,12 @@ public class NamePredicate implements Predicate<MageObject> {
// If a player names a card, the player may name either half of a split card, but not both.
// A split card has the chosen name if one of its two names matches the chosen name.
if (input instanceof SplitCard) {
return name.equals(((SplitCard)input).getLeftHalfCard().getLogName()) || name.equals(((SplitCard)input).getRightHalfCard().getLogName());
return name.equals(((SplitCard)input).getLeftHalfCard().getName()) || name.equals(((SplitCard)input).getRightHalfCard().getLogName());
} else if (input instanceof Spell && ((Spell)input).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)){
SplitCard card = (SplitCard) ((Spell)input).getCard();
return name.equals(card.getLeftHalfCard().getLogName()) || name.equals(card.getRightHalfCard().getLogName());
return name.equals(card.getLeftHalfCard().getName()) || name.equals(card.getRightHalfCard().getLogName());
} else {
return name.equals(input.getLogName());
return name.equals(input.getName());
}
}

View file

@ -40,25 +40,20 @@ public class TraceUtil {
* @param combat
*/
public static void traceCombatIfNeeded(Game game, Combat combat) {
// trace non-flying vs flying
// trace non-flying vs flying
for (CombatGroup group : combat.getGroups()) {
for (UUID attackerId : group.getAttackers()) {
Permanent attacker = game.getPermanent(attackerId);
if (attacker != null) {
if (hasFlying(attacker)) {
// boolean traceDone = false;
// traceCombat(game, attacker, null);
for (UUID blockerId : group.getBlockers()) {
Permanent blocker = game.getPermanent(blockerId);
if (blocker != null && !hasFlying(blocker) && !hasReach(blocker)) {
log.warn("Found non-flying non-reach creature blocking creature with flying");
traceCombat(game, attacker, blocker);
// traceDone = true;
}
}
// if (!traceDone) {
// traceCombat(game, attacker, null);
// }
}
if (hasIntimidate(attacker)) {
for (UUID blockerId : group.getBlockers()) {
@ -70,7 +65,6 @@ public class TraceUtil {
}
}
}
if (hasUnblockable(attacker)) {
if (group.getBlockers().size() > 0) {
Permanent blocker = game.getPermanent(group.getBlockers().get(0));