refactor: improve method name (related to 86fa9278)

This commit is contained in:
xenohedron 2024-06-13 00:40:07 -04:00
parent 723df8f53c
commit fdd244786b
31 changed files with 44 additions and 45 deletions

View file

@ -1989,7 +1989,7 @@ public class HumanPlayer extends PlayerImpl {
Permanent attacker = game.getPermanent(attackerId);
if (attacker != null) {
sb.append(" (").append(attacker.getName()).append(')');
target.setTargetName(sb.toString());
target.withTargetName(sb.toString());
}
}
if (chooseTarget(Outcome.Damage, target, null, game)) {
@ -2181,7 +2181,7 @@ public class HumanPlayer extends PlayerImpl {
Target target = new TargetAnyTarget();
target.withNotTarget(true);
if (singleTargetName != null) {
target.setTargetName(singleTargetName);
target.withTargetName(singleTargetName);
}
this.choose(Outcome.Damage, target, source, game);
if (targets.isEmpty() || targets.contains(target.getFirstTarget())) {

View file

@ -43,7 +43,7 @@ public final class ChiseiHeartOfOceans extends CardImpl {
// At the beginning of your upkeep, sacrifice Chisei, Heart of Oceans unless you remove a counter from a permanent you control.
TargetPermanent target = new TargetPermanent(1, 1, filter, true);
target.setTargetName("a permanent you control");
target.withTargetName("a permanent you control");
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new RemoveCounterCost(target)), TargetController.YOU, false));
}

View file

@ -58,7 +58,7 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
super();
this.filter = this.filter.copy();
filter.add(Predicates.not(CardType.LAND.getPredicate()));
setTargetName("nonland permanent you control");
withTargetName("nonland permanent you control");
}
private TargetControlledPermanentSharingOpponentPermanentCardType(final TargetControlledPermanentSharingOpponentPermanentCardType target) {
@ -128,7 +128,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
super();
this.filter = this.filter.copy();
filter.add(TargetController.OPPONENT.getControllerPredicate());
setTargetName("permanent an opponent controls that shares a card type with it");
withTargetName("permanent an opponent controls that shares a card type with it");
}
private DaringThiefSecondTarget(final DaringThiefSecondTarget target) {

View file

@ -49,7 +49,7 @@ public final class FabricationFoundry extends CardImpl {
ability.addCost(new TapSourceCost());
ability.addCost(new ExileTargetsTotalManaValueCost());
Target target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_ARTIFACT_FROM_YOUR_GRAVEYARD);
target.setTargetName("artifact card with mana value X or less from your graveyard");
target.withTargetName("artifact card with mana value X or less from your graveyard");
ability.addTarget(target);
this.addAbility(ability);
}

View file

@ -61,7 +61,7 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
CardType.ARTIFACT.getPredicate(),
CardType.CREATURE.getPredicate(),
CardType.LAND.getPredicate()));
setTargetName("artifact, creature, or land you control");
withTargetName("artifact, creature, or land you control");
}
private GauntletsOfChaosFirstTarget(final GauntletsOfChaosFirstTarget target) {
@ -131,7 +131,7 @@ class GauntletsOfChaosSecondTarget extends TargetPermanent {
super();
this.filter = this.filter.copy();
filter.add(TargetController.OPPONENT.getControllerPredicate());
setTargetName("permanent an opponent controls that shares one of those types with it");
withTargetName("permanent an opponent controls that shares one of those types with it");
}
private GauntletsOfChaosSecondTarget(final GauntletsOfChaosSecondTarget target) {

View file

@ -87,7 +87,7 @@ class GluntchTheBestowerEffect extends OneShotEffect {
TargetPlayer playerChoice = new TargetPlayer();
playerChoice.withNotTarget(true);
playerChoice.setTargetName("a player that will put two +1/+1 counters on a creature they control");
playerChoice.withTargetName("a player that will put two +1/+1 counters on a creature they control");
controller.choose(Outcome.BoostCreature, playerChoice, source, game);
UUID firstChosenPlayerId = playerChoice.getFirstTarget();
@ -99,7 +99,7 @@ class GluntchTheBestowerEffect extends OneShotEffect {
game.informPlayers(firstChosenPlayer.getLogName() + " has been chosen for the first effect.");
TargetPermanent targetChosenCreature = new TargetControlledCreaturePermanent();
targetChosenCreature.withNotTarget(true);
playerChoice.setTargetName("a creature you control to add two +1/+1 counters on it");
playerChoice.withTargetName("a creature you control to add two +1/+1 counters on it");
firstChosenPlayer.choose(Outcome.BoostCreature, targetChosenCreature, source, game);
Permanent chosenCreature = game.getPermanent(targetChosenCreature.getFirstTarget());
@ -116,7 +116,7 @@ class GluntchTheBestowerEffect extends OneShotEffect {
filterNotFirst.add(Predicates.not(new PlayerIdPredicate(firstChosenPlayerId)));
playerChoice = new TargetPlayer(filterNotFirst);
playerChoice.withNotTarget(true);
playerChoice.setTargetName("a player that will draw a card");
playerChoice.withTargetName("a player that will draw a card");
controller.choose(Outcome.DrawCard, playerChoice, source, game);
UUID secondChosenPlayerId = playerChoice.getFirstTarget();
@ -138,7 +138,7 @@ class GluntchTheBestowerEffect extends OneShotEffect {
filterNotFirstNorSecond.add(Predicates.not(new PlayerIdPredicate(secondChosenPlayerId)));
playerChoice = new TargetPlayer(filterNotFirstNorSecond);
playerChoice.withNotTarget(true);
playerChoice.setTargetName("a player that will create two Treasure tokens");
playerChoice.withTargetName("a player that will create two Treasure tokens");
controller.choose(Outcome.DrawCard, playerChoice, source, game);
UUID thirdChosenPlayerId = playerChoice.getFirstTarget();

View file

@ -64,7 +64,7 @@ class GlyphOfDelusionSecondTarget extends TargetPermanent {
public GlyphOfDelusionSecondTarget() {
super();
setTargetName("target creature that target Wall blocked this turn");
withTargetName("target creature that target Wall blocked this turn");
}
private GlyphOfDelusionSecondTarget(final GlyphOfDelusionSecondTarget target) {

View file

@ -19,7 +19,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetSacrifice;
@ -44,12 +43,12 @@ public final class GrabTheReins extends CardImpl {
effect.setText("and it gains haste");
this.getSpellAbility().addEffect(effect);
TargetCreaturePermanent target = new TargetCreaturePermanent();
target.setTargetName("a creature to take control of");
target.withTargetName("a creature to take control of");
this.getSpellAbility().addTarget(target);
// or sacrifice a creature, then Grab the Reins deals damage equal to that creature's power to any target.
Mode mode = new Mode(new GrabTheReinsEffect());
TargetAnyTarget target2 = new TargetAnyTarget();
target2.setTargetName("a creature or player to damage");
target2.withTargetName("a creature or player to damage");
mode.addTarget(target2);
this.getSpellAbility().getModes().addMode(mode);

View file

@ -97,7 +97,7 @@ class KaitoDancingShadowEffect extends OneShotEffect {
filter.add(new PermanentReferenceInCollectionPredicate(
watcher.getPermanents(controller.getId(),damagedPlayer.getId())));
TargetPermanent target = new TargetPermanent(0, 1, filter, true);
target.setTargetName("creature to return to hand?");
target.withTargetName("creature to return to hand?");
if (target.chooseTarget(Outcome.ReturnToHand, source.getControllerId(), source, game)) {
Card card = game.getPermanent(target.getFirstTarget());
if (card != null) {

View file

@ -72,7 +72,7 @@ class MarchFromTheTombTarget extends TargetCardInYourGraveyard {
leftPossibleTargets.add(targetId);
}
}
setTargetName("any number of target Ally creature cards with total mana value of 8 or less (" + cmcLeft + " left) from your graveyard");
withTargetName("any number of target Ally creature cards with total mana value of 8 or less (" + cmcLeft + " left) from your graveyard");
return leftPossibleTargets;
}

View file

@ -68,7 +68,7 @@ class PolymorphousRushCopyEffect extends OneShotEffect {
if (controller != null) {
Target target = new TargetCreaturePermanent(new FilterCreaturePermanent(""));
target.withNotTarget(true);
target.setTargetName("a creature on the battlefield (creature to copy)");
target.withTargetName("a creature on the battlefield (creature to copy)");
if (target.canChoose(controller.getId(), source, game) && controller.chooseTarget(outcome, target, source, game)) {
Permanent copyFromCreature = game.getPermanent(target.getFirstTarget());
if (copyFromCreature != null) {

View file

@ -55,7 +55,7 @@ class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends
super();
this.filter = this.filter.copy();
filter.add(Predicates.not(CardType.LAND.getPredicate()));
setTargetName("nonland permanent you control");
withTargetName("nonland permanent you control");
}
private TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent(final TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent target) {
@ -91,7 +91,7 @@ class PucasMischiefSecondTarget extends TargetPermanent {
this.filter = this.filter.copy();
filter.add(TargetController.OPPONENT.getControllerPredicate());
filter.add(Predicates.not(CardType.LAND.getPredicate()));
setTargetName("permanent an opponent controls with an equal or lesser mana value");
withTargetName("permanent an opponent controls with an equal or lesser mana value");
}
private PucasMischiefSecondTarget(final PucasMischiefSecondTarget target) {

View file

@ -101,7 +101,7 @@ class RetetherEffect extends OneShotEffect {
target.getFilter().add(CardType.CREATURE.getPredicate());
target.withNotTarget(true);
if (target.canChoose(controller.getId(), source, game)) {
target.setTargetName("creature to enchant (" + aura.getLogName() + ')');
target.withTargetName("creature to enchant (" + aura.getLogName() + ')');
if (controller.choose(Outcome.PutCardInPlay, target, source, game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null && !permanent.cantBeAttachedBy(aura, source, game, true)) {

View file

@ -190,7 +190,7 @@ class MoveAuraEffect extends OneShotEffect {
Filter filterChoice = chosenPermanentToAttachAuras.getFilter();
filterChoice.add(new ControllerIdPredicate(fromPermanent.getControllerId()));
filterChoice.add(Predicates.not(new PermanentIdPredicate(fromPermanent.getId())));
chosenPermanentToAttachAuras.setTargetName("a different " + filterChoice.getMessage() + " with the same controller as the " + filterChoice.getMessage() + " the target aura is attached to");
chosenPermanentToAttachAuras.withTargetName("a different " + filterChoice.getMessage() + " with the same controller as the " + filterChoice.getMessage() + " the target aura is attached to");
if (chosenPermanentToAttachAuras.canChoose(source.getControllerId(), source, game)
&& controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source, game)) {
Permanent permanentToAttachAura = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget());

View file

@ -56,7 +56,7 @@ class TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent extend
super();
this.filter = this.filter.copy();
filter.add(CardType.CREATURE.getPredicate());
setTargetName("creature you control");
withTargetName("creature you control");
}
private TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent(final TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent target) {
@ -92,7 +92,7 @@ class SpawnbrokerSecondTarget extends TargetPermanent {
this.filter = this.filter.copy();
filter.add(TargetController.OPPONENT.getControllerPredicate());
filter.add(CardType.CREATURE.getPredicate());
setTargetName("creature with power less than or equal to that creature's power an opponent controls");
withTargetName("creature with power less than or equal to that creature's power an opponent controls");
}
private SpawnbrokerSecondTarget(final SpawnbrokerSecondTarget target) {

View file

@ -42,7 +42,7 @@ class ToppleTargetCreature extends TargetCreaturePermanent {
public ToppleTargetCreature() {
super();
setTargetName("creature with the greatest power among creatures on the battlefield");
withTargetName("creature with the greatest power among creatures on the battlefield");
}
private ToppleTargetCreature(final ToppleTargetCreature target) {

View file

@ -90,7 +90,7 @@ class WormfangCrabExileEffect extends OneShotEffect {
filter.add(new ControllerIdPredicate(controller.getId()));
TargetPermanent target = new TargetPermanent(filter);
target.withNotTarget(true);
target.setTargetName("a permanent that player controls");
target.withTargetName("a permanent that player controls");
if (!opponent.choose(outcome, target, source, game)) {
return false;
}

View file

@ -42,7 +42,7 @@ public class ChooseSecretOpponentEffect extends OneShotEffect {
return false;
}
TargetOpponent targetOpponent = new TargetOpponent(true);
targetOpponent.setTargetName("opponent (secretly)");
targetOpponent.withTargetName("opponent (secretly)");
controller.choose(outcome, targetOpponent, source, game);
if (targetOpponent.getFirstTarget() == null) {
return false;

View file

@ -80,7 +80,7 @@ public class ClashEffect extends OneShotEffect {
}
// choose opponent
Target target = new TargetOpponent(true);
target.setTargetName("an opponent to clash with");
target.withTargetName("an opponent to clash with");
if (!controller.choose(Outcome.Benefit, target, source, game)) {
return false;
}

View file

@ -132,7 +132,7 @@ public class ConvokeAbility extends SimpleStaticAbility implements AlternateMana
filter.add(Predicates.or(colorPredicates));
}
Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
target.setTargetName("creature to tap for convoke");
target.withTargetName("creature to tap for convoke");
specialAction.addTarget(target);
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);

View file

@ -89,7 +89,7 @@ public class ImproviseAbility extends SimpleStaticAbility implements AlternateMa
specialAction.setSourceId(source.getSourceId());
// create filter for possible artifacts to tap
Target target = new TargetControlledPermanent(1, unpaid.getMana().getGeneric(), filterUntapped, true);
target.setTargetName("artifact to tap as Improvise's pay");
target.withTargetName("artifact to tap as Improvise's pay");
specialAction.addTarget(target);
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);

View file

@ -1276,7 +1276,7 @@ public abstract class GameImpl implements Game {
Player choosingPlayer = null;
if (startingPlayerId == null) {
TargetPlayer targetPlayer = new TargetPlayer();
targetPlayer.setTargetName("starting player");
targetPlayer.withTargetName("starting player");
if (choosingPlayerId != null) {
choosingPlayer = this.getPlayer(choosingPlayerId);
if (choosingPlayer != null && !choosingPlayer.canRespond()) {
@ -2869,7 +2869,7 @@ public abstract class GameImpl implements Game {
}
Target targetLegendaryToKeep = new TargetPermanent(filterLegendName);
targetLegendaryToKeep.withNotTarget(true);
targetLegendaryToKeep.setTargetName(legend.getName() + " to keep (Legendary Rule)?");
targetLegendaryToKeep.withTargetName(legend.getName() + " to keep (Legendary Rule)?");
controller.choose(Outcome.Benefit, targetLegendaryToKeep, null, this);
for (Permanent dupLegend : getBattlefield().getActivePermanents(filterLegendName, legend.getControllerId(), this)) {
if (!targetLegendaryToKeep.getTargets().contains(dupLegend.getId())) {

View file

@ -562,7 +562,7 @@ public class Combat implements Serializable, Copyable<Combat> {
}
TargetDefender target = new TargetDefender(defendersToChooseFrom);
target.setRequired(true);
target.setTargetName("permanent or player for " + creature.getLogName() + " to attack (must attack effect)");
target.withTargetName("permanent or player for " + creature.getLogName() + " to attack (must attack effect)");
if (player.chooseTarget(Outcome.Damage, target, null, game)) {
player.declareAttacker(creature.getId(), target.getFirstTarget(), game, false);
}

View file

@ -2957,7 +2957,7 @@ public abstract class PlayerImpl implements Player, Serializable {
boolean casted = false;
TargetCard targetCard = new TargetCard(0, 1, Zone.LIBRARY, StaticFilters.FILTER_CARD);
targetCard.setTargetName("card to cast from library");
targetCard.withTargetName("card to cast from library");
targetCard.withNotTarget(true);
while (!castableCards.isEmpty()) {
targetCard.clearChosen();

View file

@ -112,7 +112,7 @@ public interface Target extends Serializable {
* 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 withTargetName(String name);
String getTargetedName(Game game);

View file

@ -177,7 +177,7 @@ public abstract class TargetImpl implements Target {
}
@Override
public TargetImpl setTargetName(String name) {
public TargetImpl withTargetName(String name) {
this.targetName = name;
return this;
}

View file

@ -38,7 +38,7 @@ public class EachOpponentPermanentTargetsAdjuster implements TargetAdjuster {
Filter<Permanent> filter = newTarget.getFilter();
filter.add(new ControllerIdPredicate(opponentId));
if (!newTarget.possibleTargets(ability.getControllerId(), ability, game).isEmpty()) {
newTarget.setTargetName(filter.getMessage() + " controlled by " + opponent.getLogName());
newTarget.withTargetName(filter.getMessage() + " controlled by " + opponent.getLogName());
ability.addTarget(newTarget);
}
}

View file

@ -38,7 +38,7 @@ public class ManaValueTargetAdjuster implements TargetAdjuster {
int amount = dynamicValue.calculate(game, ability, ability.getEffects().get(0));
Filter<MageObject> filter = newTarget.getFilter();
filter.add(new ManaValuePredicate(comparison, amount));
newTarget.setTargetName(filter.getMessage() + " (Mana Value " + comparison + " " + amount + ")");
newTarget.withTargetName(filter.getMessage() + " (Mana Value " + comparison + " " + amount + ")");
ability.getTargets().clear();
ability.addTarget(newTarget);
}

View file

@ -43,7 +43,7 @@ public class PowerTargetAdjuster implements TargetAdjuster {
int amount = dynamicValue.calculate(game, ability, ability.getEffects().get(0));
Filter<MageObject> filter = newTarget.getFilter();
filter.add(new PowerPredicate(comparison, amount));
newTarget.setTargetName(filter.getMessage() + " (Power " + comparison + " " + amount + ")");
newTarget.withTargetName(filter.getMessage() + " (Power " + comparison + " " + amount + ")");
ability.getTargets().clear();
ability.addTarget(newTarget);
}

View file

@ -36,9 +36,9 @@ public class TargetsCountAdjuster implements TargetAdjuster {
Filter filter = newTarget.getFilter();
if (blueprintTarget.getMinNumberOfTargets() != 0) {
newTarget.setMinNumberOfTargets(count);
newTarget.setTargetName(filter.getMessage() + " (" + count + " targets)");
newTarget.withTargetName(filter.getMessage() + " (" + count + " targets)");
} else {
newTarget.setTargetName(filter.getMessage() + " (up to " + count + " targets)");
newTarget.withTargetName(filter.getMessage() + " (up to " + count + " targets)");
}
ability.getTargets().clear();
if (count > 0) {

View file

@ -43,7 +43,7 @@ public class ToughnessTargetAdjuster implements TargetAdjuster {
int amount = dynamicValue.calculate(game, ability, ability.getEffects().get(0));
Filter<MageObject> filter = newTarget.getFilter();
filter.add(new ToughnessPredicate(comparison, amount));
newTarget.setTargetName(filter.getMessage() + " (Toughness " + comparison + " " + amount + ")");
newTarget.withTargetName(filter.getMessage() + " (Toughness " + comparison + " " + amount + ")");
ability.getTargets().clear();
ability.addTarget(newTarget);
}