mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Fix #8808
This commit is contained in:
parent
4b469c8840
commit
92cafbd8b1
3 changed files with 18 additions and 49 deletions
|
@ -3,12 +3,9 @@ package mage.cards.a;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.VariableCostImpl;
|
||||
import mage.abilities.costs.VariableCostType;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.common.TapTargetCost;
|
||||
import mage.abilities.costs.common.TapVariableTargetCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
|
@ -16,13 +13,12 @@ import mage.abilities.keyword.VigilanceAbility;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.KnightToken;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
|
@ -33,6 +29,12 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class AryelKnightOfWindgrace extends CardImpl {
|
||||
|
||||
static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.KNIGHT, "untapped Knights you control");
|
||||
|
||||
static {
|
||||
filter.add(TappedPredicate.UNTAPPED);
|
||||
}
|
||||
|
||||
public AryelKnightOfWindgrace(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{B}");
|
||||
|
||||
|
@ -46,16 +48,16 @@ public final class AryelKnightOfWindgrace extends CardImpl {
|
|||
this.addAbility(VigilanceAbility.getInstance());
|
||||
|
||||
// {2}{W}, {T}: Create a 2/2 white Knight creature token with vigilance.
|
||||
Ability tokenAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new KnightToken()), new ManaCostsImpl<>("{2}{W}"));
|
||||
tokenAbility.addCost(new TapSourceCost());
|
||||
this.addAbility(tokenAbility);
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new KnightToken()), new ManaCostsImpl<>("{2}{W}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
// {B}, {T}, Tap X untapped Knights you control: Destroy target creature with power X or less.
|
||||
//Simple costs
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect()
|
||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect()
|
||||
.setText("Destroy target creature with power X or less"), new ManaCostsImpl<>("{B}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addCost(new AryelTapXTargetCost());
|
||||
ability.addCost(new TapVariableTargetCost(filter));
|
||||
ability.setTargetAdjuster(AryelKnightOfWindgraceAdjuster.instance);
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -70,41 +72,6 @@ public final class AryelKnightOfWindgrace extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AryelTapXTargetCost extends VariableCostImpl {
|
||||
|
||||
static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped Knights you control");
|
||||
|
||||
static {
|
||||
filter.add(TappedPredicate.UNTAPPED);
|
||||
filter.add(SubType.KNIGHT.getPredicate());
|
||||
}
|
||||
|
||||
public AryelTapXTargetCost() {
|
||||
super(VariableCostType.NORMAL, "controlled untapped Knights you would like to tap");
|
||||
this.text = "Tap X untapped Knights you control";
|
||||
}
|
||||
|
||||
public AryelTapXTargetCost(final AryelTapXTargetCost cost) {
|
||||
super(cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AryelTapXTargetCost copy() {
|
||||
return new AryelTapXTargetCost(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxValue(Ability source, Game game) {
|
||||
return game.getBattlefield().count(filter, source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cost getFixedCostsFromAnnouncedValue(int xValue) {
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(xValue, xValue, filter, true);
|
||||
return new TapTargetCost(target);
|
||||
}
|
||||
}
|
||||
|
||||
enum AryelKnightOfWindgraceAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TapTargetCost extends CostImpl {
|
|||
@Override
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
List<Permanent> permanents = new ArrayList<>();
|
||||
if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) {
|
||||
if (target.getMaxNumberOfTargets() > 0 && target.choose(Outcome.Tap, controllerId, source.getSourceId(), source, game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
|
@ -47,6 +47,9 @@ public class TapTargetCost extends CostImpl {
|
|||
permanents.add(permanent);
|
||||
}
|
||||
}
|
||||
if (target.getNumberOfTargets() == 0) {
|
||||
paid = true; // e.g. Aryel with X = 0
|
||||
}
|
||||
source.getEffects().setValue("tappedPermanents", permanents);
|
||||
return paid;
|
||||
}
|
||||
|
@ -64,5 +67,4 @@ public class TapTargetCost extends CostImpl {
|
|||
public TapTargetCost copy() {
|
||||
return new TapTargetCost(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class TapVariableTargetCost extends VariableCostImpl {
|
|||
|
||||
@Override
|
||||
public int getMaxValue(Ability source, Game game) {
|
||||
return game.getBattlefield().countAll(filter, source.getControllerId(), game);
|
||||
return game.getBattlefield().count(filter, source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue