Implemented Ghired, Conclave Exile

This commit is contained in:
Evan Kranzler 2019-08-01 20:07:25 -04:00
parent c1cad4488b
commit 607cef0e79
3 changed files with 76 additions and 20 deletions

View file

@ -1,11 +1,11 @@
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
@ -17,7 +17,6 @@ import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author LevelX2
*/
//
@ -31,6 +30,7 @@ import mage.target.targetpointer.FixedTarget;
//
public class PopulateEffect extends OneShotEffect {
private final boolean tappedAndAttacking;
private static final FilterPermanent filter = new FilterPermanent("token for populate");
static {
@ -43,35 +43,44 @@ public class PopulateEffect extends OneShotEffect {
}
public PopulateEffect(String prefixText) {
super(Outcome.Copy);
this(false);
this.staticText = (!prefixText.isEmpty() ? prefixText + " p" : "P") + "opulate <i>(Create a token that's a copy of a creature token you control.)</i>";
}
public PopulateEffect(boolean tappedAndAttacking) {
super(Outcome.Copy);
this.tappedAndAttacking = tappedAndAttacking;
this.staticText = "populate. The token enters the battlefield tapped and attacking. " +
"<i>(To populate, create a token that's a copy of a creature token you control.)</i>";
}
public PopulateEffect(final PopulateEffect effect) {
super(effect);
this.tappedAndAttacking = effect.tappedAndAttacking;
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (target.canChoose(source.getControllerId(), game)) {
player.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent tokenToCopy = game.getPermanent(target.getFirstTarget());
if (tokenToCopy != null) {
if (!game.isSimulation()) {
game.informPlayers("Token selected for populate: " + tokenToCopy.getLogName());
}
Effect effect = new CreateTokenCopyTargetEffect();
effect.setTargetPointer(new FixedTarget(target.getFirstTarget()));
return effect.apply(game, source);
}
}
if (player == null) {
return false;
}
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (!target.canChoose(source.getControllerId(), game)) {
return true;
}
return false;
player.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent tokenToCopy = game.getPermanent(target.getFirstTarget());
if (tokenToCopy == null) {
return true;
}
game.informPlayers("Token selected for populate: " + tokenToCopy.getLogName());
Effect effect = new CreateTokenCopyTargetEffect(
null, null, false, 1, tappedAndAttacking, tappedAndAttacking
);
effect.setTargetPointer(new FixedTarget(target.getFirstTarget()));
return effect.apply(game, source);
}
@Override