mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Merge pull request #1639 from spjspj/master
spjspj - Fix for Reconnaissance
This commit is contained in:
commit
16be1b00e9
1 changed files with 13 additions and 25 deletions
|
@ -27,8 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.exodus;
|
package mage.sets.exodus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -40,13 +38,11 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -54,12 +50,19 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
*/
|
*/
|
||||||
public class Reconnaissance extends CardImpl {
|
public class Reconnaissance extends CardImpl {
|
||||||
|
|
||||||
|
private static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("attacking creature controlled by you");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(new AttackingPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
public Reconnaissance(UUID ownerId) {
|
public Reconnaissance(UUID ownerId) {
|
||||||
super(ownerId, 17, "Reconnaissance", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
super(ownerId, 17, "Reconnaissance", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
this.expansionSetCode = "EXO";
|
this.expansionSetCode = "EXO";
|
||||||
|
|
||||||
// {0}: Remove target attacking creature you control from combat and untap it.
|
// {0}: Remove target attacking creature you control from combat and untap it.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReconnaissanceRemoveFromCombatEffect(), new ManaCostsImpl("{0}"));
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReconnaissanceRemoveFromCombatEffect(), new ManaCostsImpl("{0}"));
|
||||||
|
ability.addTarget(new TargetControlledCreaturePermanent(filter));
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,28 +94,13 @@ class ReconnaissanceRemoveFromCombatEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
List<UUID> attackers = game.getCombat().getAttackers();
|
Permanent creature = game.getPermanent(source.getFirstTarget());
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
|
||||||
if (!attackers.isEmpty() && player != null) {
|
if (creature != null && player != null && creature.isAttacking()) {
|
||||||
List<PermanentIdPredicate> uuidPredicates = new ArrayList<>();
|
creature.removeFromCombat(game);
|
||||||
for (UUID creatureId : attackers) {
|
creature.untap(game);
|
||||||
uuidPredicates.add(new PermanentIdPredicate(creatureId));
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("attacking creature controlled by you");
|
|
||||||
filter.add(Predicates.or(uuidPredicates));
|
|
||||||
|
|
||||||
Target target = new TargetControlledCreaturePermanent(0, 1, filter, false);
|
|
||||||
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
|
|
||||||
player.choose(Outcome.Benefit, target, source.getSourceId(), game);
|
|
||||||
Permanent creature = game.getPermanent(target.getFirstTarget());
|
|
||||||
if (creature != null) {
|
|
||||||
creature.removeFromCombat(game);
|
|
||||||
creature.untap(game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue