mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
fix some unnecessary usage of setTargetName
add docs on usage of methods
This commit is contained in:
parent
f2b2c95e4a
commit
723df8f53c
10 changed files with 23 additions and 33 deletions
|
|
@ -8,7 +8,6 @@ import mage.cards.CardSetInfo;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
@ -67,8 +66,7 @@ class BreakthroughEffect extends OneShotEffect {
|
||||||
if (amountToKeep == 0) {
|
if (amountToKeep == 0) {
|
||||||
player.discard(player.getHand(), false, source, game);
|
player.discard(player.getHand(), false, source, game);
|
||||||
} else if (amountToKeep < player.getHand().size()) {
|
} else if (amountToKeep < player.getHand().size()) {
|
||||||
TargetCardInHand target = new TargetCardInHand(amountToKeep, StaticFilters.FILTER_CARD);
|
TargetCardInHand target = new TargetCardInHand(amountToKeep, StaticFilters.FILTER_CARD).withChooseHint("to keep");
|
||||||
target.setTargetName("cards to keep");
|
|
||||||
target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game);
|
target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), source, game);
|
||||||
Cards cards = player.getHand().copy();
|
Cards cards = player.getHand().copy();
|
||||||
cards.removeIf(target.getTargets()::contains);
|
cards.removeIf(target.getTargets()::contains);
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,7 @@ class ChimneyImpEffect extends OneShotEffect {
|
||||||
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (targetOpponent != null) {
|
if (targetOpponent != null) {
|
||||||
if (!targetOpponent.getHand().isEmpty()) {
|
if (!targetOpponent.getHand().isEmpty()) {
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
|
||||||
target.withNotTarget(true);
|
|
||||||
target.setTargetName("a card from your hand to put on top of your library");
|
|
||||||
targetOpponent.choose(Outcome.Detriment, target, source, game);
|
targetOpponent.choose(Outcome.Detriment, target, source, game);
|
||||||
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
|
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,7 @@ class ChitteringRatsEffect extends OneShotEffect {
|
||||||
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (targetOpponent != null) {
|
if (targetOpponent != null) {
|
||||||
if (!targetOpponent.getHand().isEmpty()) {
|
if (!targetOpponent.getHand().isEmpty()) {
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
|
||||||
target.withNotTarget(true);
|
|
||||||
target.setTargetName("a card from your hand to put on top of your library");
|
|
||||||
targetOpponent.choose(Outcome.Detriment, target, source, game);
|
targetOpponent.choose(Outcome.Detriment, target, source, game);
|
||||||
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
|
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,22 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.target.Target;
|
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Loki
|
* @author Loki
|
||||||
*/
|
*/
|
||||||
public final class GoForTheThroat extends CardImpl {
|
public final class GoForTheThroat extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
|
filter.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
|
||||||
|
|
@ -26,10 +25,8 @@ public final class GoForTheThroat extends CardImpl {
|
||||||
public GoForTheThroat(UUID ownerId, CardSetInfo setInfo) {
|
public GoForTheThroat(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}");
|
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}");
|
||||||
|
|
||||||
|
// Destroy target nonartifact creature.
|
||||||
Target target = new TargetCreaturePermanent(filter);
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||||
target.setTargetName("nonartifact creature");
|
|
||||||
this.getSpellAbility().addTarget(target);
|
|
||||||
this.getSpellAbility().addEffect(new DestroyTargetEffect());
|
this.getSpellAbility().addEffect(new DestroyTargetEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.k;
|
package mage.cards.k;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
|
@ -14,10 +13,10 @@ import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.common.FilterControlledLandPermanent;
|
|
||||||
import mage.target.common.TargetControlledPermanent;
|
|
||||||
import mage.target.common.TargetLandPermanent;
|
import mage.target.common.TargetLandPermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author fireshoes
|
* @author fireshoes
|
||||||
|
|
@ -34,9 +33,7 @@ public final class KeldonArsonist extends CardImpl {
|
||||||
// {1}, Sacrifice two lands: Destroy target land.
|
// {1}, Sacrifice two lands: Destroy target land.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new GenericManaCost(1));
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new GenericManaCost(1));
|
||||||
ability.addCost(new SacrificeTargetCost(2, StaticFilters.FILTER_LANDS));
|
ability.addCost(new SacrificeTargetCost(2, StaticFilters.FILTER_LANDS));
|
||||||
TargetLandPermanent target = new TargetLandPermanent();
|
ability.addTarget(new TargetLandPermanent().withChooseHint("to destroy"));
|
||||||
target.setTargetName("land (to destroy)");
|
|
||||||
ability.addTarget(target);
|
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,7 @@ class PryingQuestionsEffect extends OneShotEffect {
|
||||||
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player targetOpponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (targetOpponent != null) {
|
if (targetOpponent != null) {
|
||||||
if (!targetOpponent.getHand().isEmpty()) {
|
if (!targetOpponent.getHand().isEmpty()) {
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
|
||||||
target.withNotTarget(true);
|
|
||||||
target.setTargetName("a card from your hand to put on top of your library");
|
|
||||||
targetOpponent.choose(Outcome.Detriment, target, source, game);
|
targetOpponent.choose(Outcome.Detriment, target, source, game);
|
||||||
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
|
Card card = targetOpponent.getHand().get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,7 @@ class WidespreadPanicEffect extends OneShotEffect {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (!player.getHand().isEmpty()) {
|
if (!player.getHand().isEmpty()) {
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
|
||||||
target.setTargetName("a card from your hand to put on top of your library");
|
|
||||||
player.choose(Outcome.Detriment, target, source, game);
|
player.choose(Outcome.Detriment, target, source, game);
|
||||||
Card card = player.getHand().get(target.getFirstTarget(), game);
|
Card card = player.getHand().get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,7 @@ class TaintedSpecterEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Put a card from your hand on top of your library
|
// Put a card from your hand on top of your library
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
|
||||||
target.setTargetName("a card from your hand to put on top of your library");
|
|
||||||
targetPlayer.choose(Outcome.Detriment, target, source, game);
|
targetPlayer.choose(Outcome.Detriment, target, source, game);
|
||||||
Card card = targetPlayer.getHand().get(target.getFirstTarget(), game);
|
Card card = targetPlayer.getHand().get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
||||||
|
|
@ -96,9 +96,7 @@ class WidespreadPanicEffect extends OneShotEffect {
|
||||||
Player shuffler = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player shuffler = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (shuffler != null) {
|
if (shuffler != null) {
|
||||||
if (!shuffler.getHand().isEmpty()) {
|
if (!shuffler.getHand().isEmpty()) {
|
||||||
TargetCardInHand target = new TargetCardInHand();
|
TargetCardInHand target = new TargetCardInHand().withChooseHint("to put on top of your library");
|
||||||
target.withNotTarget(true);
|
|
||||||
target.setTargetName("a card from your hand to put on top of your library");
|
|
||||||
shuffler.choose(Outcome.Detriment, target, source, game);
|
shuffler.choose(Outcome.Detriment, target, source, game);
|
||||||
Card card = shuffler.getHand().get(target.getFirstTarget(), game);
|
Card card = shuffler.getHand().get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,10 @@ public interface Target extends Serializable {
|
||||||
*/
|
*/
|
||||||
String getTargetName();
|
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);
|
Target setTargetName(String name);
|
||||||
|
|
||||||
String getTargetedName(Game game);
|
String getTargetedName(Game game);
|
||||||
|
|
@ -172,6 +176,10 @@ public interface Target extends Serializable {
|
||||||
// used for cards like Spellskite
|
// used for cards like Spellskite
|
||||||
void setTargetAmount(UUID targetId, int amount, Game game);
|
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);
|
Target withChooseHint(String chooseHint);
|
||||||
|
|
||||||
String getChooseHint();
|
String getChooseHint();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue