Fixed Protection from color. Fixed spell fizzling.

This commit is contained in:
magenoxx 2011-08-14 22:19:22 +04:00
parent 8e13ebffcd
commit 3521c7dd08
4 changed files with 17 additions and 11 deletions

View file

@ -65,11 +65,12 @@ public class GainProtectionFromColorTargetEffect extends GainAbilityTargetEffect
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature != null) {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
protectionFilter.setColor(choice.getColor());
protectionFilter.setMessage(choice.getChoice());
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature != null) {
((ProtectionAbility)ability).setFilter(protectionFilter);
creature.addAbility(ability);
return true;
}

View file

@ -101,6 +101,7 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
return result;
}
//20091005 - 608.2b
game.informPlayers(getName() + " has been fizzled.");
counter(null, game);
return false;
}

View file

@ -243,12 +243,12 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
public boolean isLegal(Ability source, Game game) {
//20101001 - 608.2b
for (UUID targetId: targets.keySet()) {
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId())))
return true;
if (canTarget(targetId, source, game))
return true;
}
if (game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId())))
return false;
if (!canTarget(targetId, source, game))
return false;
}
return true;
}
@Override

View file

@ -99,12 +99,16 @@ public class Targets extends ArrayList<Target> {
}
public boolean stillLegal(Ability source, Game game) {
// 608.2
// The spell or ability is countered if all its targets, for every instance of the word "target," are now illegal
int illegalCount = 0;
for (Target target: this) {
if (!target.isLegal(source, game)) {
return false;
if (target.isLegal(source, game)) {
illegalCount++;
}
}
return true;
// check all are illegal
return this.size() == illegalCount;
}
/**