refactor: improved target usage, replaced setNotTarget by withNotTarget

This commit is contained in:
Oleg Agafonov 2023-09-06 22:32:28 +04:00
parent dbaa51f462
commit 4b3a19b4d5
385 changed files with 434 additions and 429 deletions

View file

@ -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
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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());

View file

@ -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;
}

View file

@ -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) {

View file

@ -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()) {

View file

@ -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) {