forked from External/mage
refactor: improved target usage, replaced setNotTarget by withNotTarget
This commit is contained in:
parent
dbaa51f462
commit
4b3a19b4d5
385 changed files with 434 additions and 429 deletions
|
|
@ -28,7 +28,7 @@ public class ExileFromGraveCost extends CostImpl {
|
|||
private boolean setTargetPointer = false;
|
||||
|
||||
public ExileFromGraveCost(TargetCardInYourGraveyard target) {
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
this.addTarget(target);
|
||||
if (target.getMaxNumberOfTargets() > 1) {
|
||||
this.text = "exile "
|
||||
|
|
@ -46,19 +46,19 @@ public class ExileFromGraveCost extends CostImpl {
|
|||
}
|
||||
|
||||
public ExileFromGraveCost(TargetCardInYourGraveyard target, String text) {
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
this.addTarget(target);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public ExileFromGraveCost(TargetCardInASingleGraveyard target, String text) {
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
this.addTarget(target);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public ExileFromGraveCost(TargetCardInASingleGraveyard target) {
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
this.addTarget(target);
|
||||
this.text = "exile " + target.getDescription();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class ExileTargetCost extends CostImpl {
|
|||
List<Permanent> permanents = new ArrayList<>();
|
||||
|
||||
public ExileTargetCost(TargetControlledPermanent target) {
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
this.addTarget(target);
|
||||
this.text = "exile " + target.getDescription();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||
public class ReturnToHandChosenControlledPermanentCost extends CostImpl {
|
||||
|
||||
public ReturnToHandChosenControlledPermanentCost(TargetControlledPermanent target) {
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
this.addTarget(target);
|
||||
if (target.getMaxNumberOfTargets() > 1 && target.getMaxNumberOfTargets() == target.getNumberOfTargets()) {
|
||||
this.text = "return " + CardUtil.numberToText(target.getMaxNumberOfTargets()) + ' '
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class SacrificeTargetCost extends CostImpl implements SacrificeCost {
|
|||
|
||||
public SacrificeTargetCost(TargetControlledPermanent target) {
|
||||
this.addTarget(target);
|
||||
target.setNotTarget(true); // sacrifice is never targeted
|
||||
target.withNotTarget(true); // sacrifice is never targeted
|
||||
target.setRequired(false); // can be canceled
|
||||
this.text = "sacrifice " + makeText(target);
|
||||
target.setTargetName(target.getTargetName() + " (to sacrifice)");
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class TapTargetCost extends CostImpl {
|
|||
|
||||
public TapTargetCost(TargetControlledPermanent target) {
|
||||
this.target = target;
|
||||
this.target.setNotTarget(true); // costs are never targeted
|
||||
this.target.withNotTarget(true); // costs are never targeted
|
||||
this.target.setRequired(false); // can be cancel by user
|
||||
this.text = "tap " + (target.getNumberOfTargets() > 1
|
||||
? CardUtil.numberToText(target.getMaxNumberOfTargets()) + ' ' + target.getTargetName()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class UntapTargetCost extends CostImpl {
|
|||
this.text = makeText(target);
|
||||
|
||||
// It will never target as part of a cost
|
||||
this.target.setNotTarget(true);
|
||||
this.target.withNotTarget(true);
|
||||
}
|
||||
|
||||
protected UntapTargetCost(final UntapTargetCost cost) {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
enchantCardInGraveyard = target instanceof TargetCardInGraveyard;
|
||||
if (target != null) {
|
||||
target.withChooseHint("to attach " + card.getName() + " to");
|
||||
target.setNotTarget(true); // always not target because this way it's not handled targeted
|
||||
target.withNotTarget(true); // always not target because this way it's not handled targeted
|
||||
target.clearChosen(); // necessary if e.g. aura is blinked multiple times
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class CipherEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (target.canChoose(source.getControllerId(), source, game)
|
||||
&& controller.chooseUse(outcome, "Cipher this spell to a creature?", source, game)) {
|
||||
controller.chooseTarget(outcome, target, source, game);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class CopyPermanentEffect extends OneShotEffect {
|
|||
copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
} else {
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (target.canChoose(controller.getId(), source, game)) {
|
||||
controller.choose(Outcome.Copy, target, source, game);
|
||||
copyFromPermanent = game.getPermanent(target.getFirstTarget());
|
||||
|
|
@ -156,7 +156,7 @@ public class CopyPermanentEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
// select new target
|
||||
auraTarget.setNotTarget(true);
|
||||
auraTarget.withNotTarget(true);
|
||||
if (!controller.choose(auraOutcome, auraTarget, source, game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class DrawDiscardOneOfThemEffect extends OneShotEffect {
|
|||
drawnCards.removeAll(initialHand);
|
||||
if (!drawnCards.isEmpty()) {
|
||||
TargetCard cardToDiscard = new TargetCard(Zone.HAND, new FilterCard("card to discard"));
|
||||
cardToDiscard.setNotTarget(true);
|
||||
cardToDiscard.withNotTarget(true);
|
||||
if (controller.choose(Outcome.Discard, drawnCards, cardToDiscard, source, game)) {
|
||||
Card card = controller.getHand().get(cardToDiscard.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class EntersBattlefieldUnderControlOfOpponentOfChoiceEffect extends OneSh
|
|||
return false;
|
||||
}
|
||||
Target target = new TargetOpponent();
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (!controller.choose(Outcome.Benefit, target, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ExileCardFromOwnGraveyardControllerEffect extends OneShotEffect {
|
|||
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(Math.min(
|
||||
amount, player.getGraveyard().size()
|
||||
), StaticFilters.FILTER_CARD);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (!player.chooseTarget(outcome, target, source, game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class MeldEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
TargetPermanent target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
controller.choose(outcome, target, source, game);
|
||||
|
||||
Permanent meldWithPermanent = game.getPermanent(target.getFirstTarget());
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class PopulateEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (!target.canChoose(source.getControllerId(), source, game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class WishEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
TargetCard target = new TargetCard(Zone.ALL, filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (controller.choose(Outcome.Benefit, filteredCards, target, source, game)) {
|
||||
Card card = controller.getSideboard().get(target.getFirstTarget(), game);
|
||||
if (card == null && alsoFromExile) {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
|
|||
if (player.getHand().size() > numberToReveal) {
|
||||
TargetCard chosenCards = new TargetCard(numberToReveal, numberToReveal,
|
||||
Zone.HAND, new FilterCard("card in " + player.getName() + "'s hand"));
|
||||
chosenCards.setNotTarget(true);
|
||||
chosenCards.withNotTarget(true);
|
||||
if (chosenCards.canChoose(player.getId(), source, game)
|
||||
&& player.chooseTarget(Outcome.Discard, player.getHand(), chosenCards, source, game)) {
|
||||
if (!chosenCards.getTargets().isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class AmassEffect extends OneShotEffect {
|
|||
makeToken(subType).putOntoBattlefield(1, game, source);
|
||||
}
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
player.choose(Outcome.BoostCreature, target, source, game);
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent == null) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class EnlistEffect extends ReplacementEffectImpl {
|
|||
return false;
|
||||
}
|
||||
TargetPermanent target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
controller.choose(outcome, target, source, game);
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent == null || !permanent.tap(source, game)) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class HideawayExileEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
controller.choose(Outcome.Detriment, cards, target, source, game);
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class SoulboundEntersSelfEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(permanent.getControllerId());
|
||||
if (controller != null) {
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
target.withNotTarget(true);
|
||||
if (target.canChoose(controller.getId(), source, game)) {
|
||||
if (controller.choose(Outcome.Benefit, target, source, game)) {
|
||||
Permanent chosen = game.getPermanent(target.getFirstTarget());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue