mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
refactored adjustTargets that were missed previously
This commit is contained in:
parent
bfd1a76bda
commit
897e41bc94
2 changed files with 40 additions and 57 deletions
|
@ -1,8 +1,6 @@
|
|||
package mage.cards.o;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
@ -16,26 +14,21 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class Outmaneuver extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(BlockedPredicate.instance);
|
||||
}
|
||||
|
||||
public Outmaneuver(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{R}");
|
||||
|
||||
// X target blocked creatures assign their combat damage this turn as though they weren't blocked.
|
||||
this.getSpellAbility().addEffect(new OutmaneuverEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
|
||||
this.getSpellAbility().setTargetAdjuster(OutmaneuverAdjuster.instance);
|
||||
}
|
||||
|
||||
private Outmaneuver(final Outmaneuver card) {
|
||||
|
@ -46,42 +39,38 @@ public final class Outmaneuver extends CardImpl {
|
|||
public Outmaneuver copy() {
|
||||
return new Outmaneuver(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum OutmaneuverAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(BlockedPredicate.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
ability.getTargets().clear();
|
||||
int numberOfTargets = ability.getManaCostsToPay().getX();
|
||||
numberOfTargets = Math.min(game.getBattlefield().getAllActivePermanents(filter,
|
||||
ability.getControllerId(), game).size(), numberOfTargets);
|
||||
ability.addTarget(new TargetCreaturePermanent(numberOfTargets,
|
||||
numberOfTargets, filter, false));
|
||||
}
|
||||
ability.getTargets().clear();
|
||||
int numberOfTargets = ability.getManaCostsToPay().getX();
|
||||
ability.addTarget(new TargetCreaturePermanent(numberOfTargets, numberOfTargets, filter, false));
|
||||
}
|
||||
}
|
||||
|
||||
class OutmaneuverEffect extends AsThoughEffectImpl {
|
||||
|
||||
public OutmaneuverEffect() {
|
||||
OutmaneuverEffect() {
|
||||
super(AsThoughEffectType.DAMAGE_NOT_BLOCKED, Duration.EndOfTurn, Outcome.Damage);
|
||||
this.staticText = "X target blocked creatures assign their combat damage this turn as though they weren't blocked.";
|
||||
}
|
||||
|
||||
public OutmaneuverEffect(OutmaneuverEffect effect) {
|
||||
private OutmaneuverEffect(OutmaneuverEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent blockedCreature = game.getPermanent(sourceId);
|
||||
if (blockedCreature != null) {
|
||||
Player controller = game.getPlayer(blockedCreature.getControllerId());
|
||||
if (controller != null) {
|
||||
return controller.chooseUse(Outcome.Damage, "have "
|
||||
+ blockedCreature.getLogName() + "assign combat damage as though it weren't blocked?", source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return targetPointer.getTargets(game, source).contains(sourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,8 +3,6 @@ package mage.cards.r;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.OpponentsCount;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||
import mage.abilities.keyword.MenaceAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -14,6 +12,7 @@ import mage.constants.SubType;
|
|||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -22,14 +21,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class RotHulk extends CardImpl {
|
||||
|
||||
private static final FilterCard filterZombie = new FilterCard("Zombie cards from your graveyard");
|
||||
|
||||
static {
|
||||
filterZombie.add(SubType.ZOMBIE.getPredicate());
|
||||
}
|
||||
|
||||
private final UUID entersBattlefieldAbilityID;
|
||||
|
||||
public RotHulk(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{B}{B}");
|
||||
this.subtype.add(SubType.ZOMBIE);
|
||||
|
@ -40,28 +31,14 @@ public final class RotHulk extends CardImpl {
|
|||
this.addAbility(new MenaceAbility(false));
|
||||
|
||||
// When Rot Hulk enters the battlefield, return up to X target Zombie cards from your graveyard to the battlefield, where X is the number of opponents you have.
|
||||
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
|
||||
effect.setText("return up to X target Zombie cards from your graveyard to the battlefield, where X is the number of opponents you have.");
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(effect);
|
||||
ability.addTarget(new TargetCardInYourGraveyard());
|
||||
entersBattlefieldAbilityID = ability.getOriginalId(); // adjust targets
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect()
|
||||
.setText("return up to X target Zombie cards from your graveyard to the battlefield, where X is the number of opponents you have."));
|
||||
ability.setTargetAdjuster(RotHulkAdjuster.instance);
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability.getOriginalId().equals(entersBattlefieldAbilityID)) {
|
||||
// up to X target Zombie cards from your graveyard
|
||||
// X is the number of opponents you have.
|
||||
ability.getTargets().clear();
|
||||
int numbTargets = OpponentsCount.instance.calculate(game, ability, null);
|
||||
ability.addTarget(new TargetCardInYourGraveyard(0, numbTargets, filterZombie));
|
||||
}
|
||||
}
|
||||
|
||||
private RotHulk(final RotHulk card) {
|
||||
super(card);
|
||||
this.entersBattlefieldAbilityID = card.entersBattlefieldAbilityID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,3 +46,20 @@ public final class RotHulk extends CardImpl {
|
|||
return new RotHulk(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum RotHulkAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
private static final FilterCard filterZombie = new FilterCard("Zombie cards from your graveyard");
|
||||
|
||||
static {
|
||||
filterZombie.add(SubType.ZOMBIE.getPredicate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
ability.getTargets().clear();
|
||||
ability.addTarget(new TargetCardInYourGraveyard(
|
||||
0, game.getOpponents(ability.getControllerId()).size(), filterZombie
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue