Improved target handling of Executioners Swing and fixed buf of FrontlineMedic.

This commit is contained in:
LevelX2 2013-03-13 17:01:49 +01:00
parent 8759db2fd6
commit 987bfb588f
3 changed files with 29 additions and 3 deletions

View file

@ -33,6 +33,7 @@ import java.util.UUID;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Duration; import mage.Constants.Duration;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -77,6 +78,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn<T extends TargetCreaturePer
public TargetCreaturePermanentThatDealtDamageThisTurn() { public TargetCreaturePermanentThatDealtDamageThisTurn() {
super(1, 1, new FilterCreaturePermanent(), false); super(1, 1, new FilterCreaturePermanent(), false);
setRequired(true);
targetName = "creature that dealt damage this turn"; targetName = "creature that dealt damage this turn";
} }
@ -95,6 +97,30 @@ class TargetCreaturePermanentThatDealtDamageThisTurn<T extends TargetCreaturePer
return false; return false;
} }
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int remainingTargets = this.minNumberOfTargets - targets.size();
if (remainingTargets <= 0) {
return true;
}
int count = 0;
MageObject targetSource = game.getObject(sourceId);
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher");
if (watcher != null) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && watcher.damageSources.contains(permanent.getId())) {
if (!notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
count++;
if (count >= remainingTargets) {
return true;
}
}
}
}
}
return false;
}
@Override @Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
@ -103,7 +129,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn<T extends TargetCreaturePer
if (watcher != null) { if (watcher != null) {
for (UUID targetId : availablePossibleTargets) { for (UUID targetId : availablePossibleTargets) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (permanent != null && watcher.damageSources.contains(targetId)) { if (permanent != null && !targets.containsKey(permanent.getId()) && watcher.damageSources.contains(targetId)) {
possibleTargets.add(targetId); possibleTargets.add(targetId);
} }
} }

View file

@ -71,7 +71,7 @@ public class FrontlineMedic extends CardImpl<FrontlineMedic> {
this.addAbility(new BattalionAbility(new IndestructibleAllEffect(new FilterControlledCreaturePermanent(), Constants.Duration.EndOfTurn))); this.addAbility(new BattalionAbility(new IndestructibleAllEffect(new FilterControlledCreaturePermanent(), Constants.Duration.EndOfTurn)));
// Sacrifice Frontline Medic: Counter target spell with {X} in its mana cost unless its controller pays 3. // Sacrifice Frontline Medic: Counter target spell with {X} in its mana cost unless its controller pays 3.
Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CounterUnlessPaysEffect(new CounterUnlessPaysEffect(new GenericManaCost(3))), new SacrificeSourceCost()); Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CounterUnlessPaysEffect(new GenericManaCost(3)), new SacrificeSourceCost());
ability.addTarget(new TargetSpell(filter)); ability.addTarget(new TargetSpell(filter));
this.addAbility(ability); this.addAbility(ability);

View file

@ -112,7 +112,7 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
/** /**
* Checks if there are enough {@link Permanent} that can be chosen. * Checks if there are enough {@link Permanent} that can be chosen.
* *
* Takes into account notTarget parameter, it case it's true doesn't check for protection, shroud etc. * Takes into account notTarget parameter, in case it's true doesn't check for protection, shroud etc.
* *
* @param sourceId - the target event source * @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source * @param sourceControllerId - controller of the target event source