fix some unnecessary usage of setTargetName

add docs on usage of methods
This commit is contained in:
xenohedron 2024-06-13 00:38:31 -04:00
parent f2b2c95e4a
commit 723df8f53c
10 changed files with 23 additions and 33 deletions

View file

@ -8,7 +8,6 @@ import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
@ -67,8 +66,7 @@ class BreakthroughEffect extends OneShotEffect {
if (amountToKeep == 0) {
player.discard(player.getHand(), false, source, game);
} else if (amountToKeep < player.getHand().size()) {
TargetCardInHand target = new TargetCardInHand(amountToKeep, StaticFilters.FILTER_CARD);
target.setTargetName("cards to keep");
TargetCardInHand target = new TargetCardInHand(amountToKeep, StaticFilters.FILTER_CARD).withChooseHint("to keep");
target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game);
Cards cards = player.getHand().copy();
cards.removeIf(target.getTargets()::contains);

View file

@ -72,9 +72,7 @@ class ChimneyImpEffect extends OneShotEffect {
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetOpponent != null) {
if (!targetOpponent.getHand().isEmpty()) {
TargetCardInHand target = new TargetCardInHand();
target.withNotTarget(true);
target.setTargetName("a card from your hand to put on top of your library");
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
targetOpponent.choose(Outcome.Detriment, target, source, game);
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
if (card != null) {

View file

@ -69,9 +69,7 @@ class ChitteringRatsEffect extends OneShotEffect {
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetOpponent != null) {
if (!targetOpponent.getHand().isEmpty()) {
TargetCardInHand target = new TargetCardInHand();
target.withNotTarget(true);
target.setTargetName("a card from your hand to put on top of your library");
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
targetOpponent.choose(Outcome.Detriment, target, source, game);
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
if (card != null) {

View file

@ -1,23 +1,22 @@
package mage.cards.g;
import java.util.UUID;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Loki
*/
public final class GoForTheThroat extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature");
static {
filter.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
@ -26,10 +25,8 @@ public final class GoForTheThroat extends CardImpl {
public GoForTheThroat(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}");
Target target = new TargetCreaturePermanent(filter);
target.setTargetName("nonartifact creature");
this.getSpellAbility().addTarget(target);
// Destroy target nonartifact creature.
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.getSpellAbility().addEffect(new DestroyTargetEffect());
}

View file

@ -1,7 +1,6 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -14,10 +13,10 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledLandPermanent;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/**
*
* @author fireshoes
@ -34,9 +33,7 @@ public final class KeldonArsonist extends CardImpl {
// {1}, Sacrifice two lands: Destroy target land.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new GenericManaCost(1));
ability.addCost(new SacrificeTargetCost(2, StaticFilters.FILTER_LANDS));
TargetLandPermanent target = new TargetLandPermanent();
target.setTargetName("land (to destroy)");
ability.addTarget(target);
ability.addTarget(new TargetLandPermanent().withChooseHint("to destroy"));
this.addAbility(ability);
}

View file

@ -61,9 +61,7 @@ class PryingQuestionsEffect extends OneShotEffect {
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetOpponent != null) {
if (!targetOpponent.getHand().isEmpty()) {
TargetCardInHand target = new TargetCardInHand();
target.withNotTarget(true);
target.setTargetName("a card from your hand to put on top of your library");
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
targetOpponent.choose(Outcome.Detriment, target, source, game);
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
if (card != null) {

View file

@ -69,8 +69,7 @@ class WidespreadPanicEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (player != null) {
if (!player.getHand().isEmpty()) {
TargetCardInHand target = new TargetCardInHand();
target.setTargetName("a card from your hand to put on top of your library");
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
player.choose(Outcome.Detriment, target, source, game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {

View file

@ -92,8 +92,7 @@ class TaintedSpecterEffect extends OneShotEffect {
}
} else {
// Put a card from your hand on top of your library
TargetCardInHand target = new TargetCardInHand();
target.setTargetName("a card from your hand to put on top of your library");
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
targetPlayer.choose(Outcome.Detriment, target, source, game);
Card card = targetPlayer.getHand().get(target.getFirstTarget(), game);
if (card != null) {

View file

@ -96,9 +96,7 @@ class WidespreadPanicEffect extends OneShotEffect {
Player shuffler = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (shuffler != null) {
if (!shuffler.getHand().isEmpty()) {
TargetCardInHand target = new TargetCardInHand();
target.withNotTarget(true);
target.setTargetName("a card from your hand to put on top of your library");
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
shuffler.choose(Outcome.Detriment, target, source, game);
Card card = shuffler.getHand().get(target.getFirstTarget(), game);
if (card != null) {

View file

@ -108,6 +108,10 @@ public interface Target extends Serializable {
*/
String getTargetName();
/**
* Overwrites the name automatically generated from the filter text.
* If you want to add additional info for usability, use `withChooseHint` instead.
*/
Target setTargetName(String name);
String getTargetedName(Game game);
@ -172,6 +176,10 @@ public interface Target extends Serializable {
// used for cards like Spellskite
void setTargetAmount(UUID targetId, int amount, Game game);
/**
* Adds a clarification during target selection (in parentheses).
* Useful for abilities that have multiple targets and different effects.
*/
Target withChooseHint(String chooseHint);
String getChooseHint();