* Fixed can't counter ability that did not work correctly.

This commit is contained in:
LevelX2 2014-08-16 09:33:31 +02:00
parent 7b16fe8528
commit 57ccef6092
4 changed files with 93 additions and 11 deletions

View file

@ -321,7 +321,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
@Override
public List<String> getSymbols() {
List<String> symbols = new ArrayList<String>();
List<String> symbols = new ArrayList<>();
for (ManaCost cost : this) {
symbols.add(cost.getText());
}

View file

@ -28,16 +28,15 @@
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import java.util.UUID;
import mage.game.stack.StackObject;
/**
*
@ -46,7 +45,7 @@ import java.util.UUID;
public class CantCounterSourceEffect extends ContinuousRuleModifiyingEffectImpl {
public CantCounterSourceEffect() {
super(Duration.WhileOnStack, Outcome.Benefit);
super(Duration.WhileOnStack, Outcome.Benefit, false, true);
staticText = "{this} can't be countered";
}
@ -64,13 +63,22 @@ public class CantCounterSourceEffect extends ContinuousRuleModifiyingEffectImpl
return true;
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (stackObject != null && sourceObject != null) {
return sourceObject.getLogName() + " can't be countered by " + stackObject.getName();
}
return staticText;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.COUNTER) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
UUID spellId = card.getSpellAbility().getSourceId();
if (event.getTargetId().equals(spellId)) {
StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
if (stackObject != null) {
if (stackObject.getSourceId().equals(source.getSourceId())) {
return true;
}
}