mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
more text gen refactoring
This commit is contained in:
parent
5a5e320542
commit
6eb1cb834d
7 changed files with 31 additions and 61 deletions
|
|
@ -5,7 +5,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.ChancellorAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.common.PlayTargetWithoutPayingManaEffect;
|
||||
import mage.abilities.effects.common.CastTargetForFreeEffect;
|
||||
import mage.abilities.effects.common.MillCardsEachPlayerEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -17,7 +17,6 @@ import mage.filter.FilterCard;
|
|||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.common.TargetCardInOpponentsGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -51,7 +50,7 @@ public final class ChancellorOfTheSpires extends CardImpl {
|
|||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// When Chancellor of the Spires enters the battlefield, you may cast target instant or sorcery card from an opponent's graveyard without paying its mana cost.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new PlayTargetWithoutPayingManaEffect(), true);
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new CastTargetForFreeEffect(), true);
|
||||
ability.addTarget(new TargetCardInOpponentsGraveyard(filter));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package mage.cards.v;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.MutatesSourceTriggeredAbility;
|
||||
import mage.abilities.effects.common.PlayTargetWithoutPayingManaEffect;
|
||||
import mage.abilities.effects.common.CastTargetForFreeEffect;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.abilities.keyword.MutateAbility;
|
||||
|
|
@ -53,7 +53,7 @@ public final class VadrokApexOfThunder extends CardImpl {
|
|||
this.addAbility(FirstStrikeAbility.getInstance());
|
||||
|
||||
// Whenever this creature mutates, you may cast target noncreature card with converted mana cost 3 or less from your graveyard without paying its mana cost.
|
||||
Ability ability = new MutatesSourceTriggeredAbility(new PlayTargetWithoutPayingManaEffect());
|
||||
Ability ability = new MutatesSourceTriggeredAbility(new CastTargetForFreeEffect());
|
||||
ability.addTarget(new TargetCardInYourGraveyard(filter));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,37 +6,34 @@ import mage.abilities.Mode;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class PlayTargetWithoutPayingManaEffect extends OneShotEffect {
|
||||
public class CastTargetForFreeEffect extends OneShotEffect {
|
||||
|
||||
public PlayTargetWithoutPayingManaEffect() {
|
||||
super(Outcome.GainControl);
|
||||
public CastTargetForFreeEffect() {
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
protected PlayTargetWithoutPayingManaEffect(final PlayTargetWithoutPayingManaEffect effect) {
|
||||
protected CastTargetForFreeEffect(final CastTargetForFreeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayTargetWithoutPayingManaEffect copy() {
|
||||
return new PlayTargetWithoutPayingManaEffect(this);
|
||||
public CastTargetForFreeEffect copy() {
|
||||
return new CastTargetForFreeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Card target = (Card) game.getObject(source.getFirstTarget());
|
||||
if (controller != null
|
||||
&& target != null) {
|
||||
if (controller != null && target != null) {
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + target.getId(), Boolean.TRUE);
|
||||
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(target, game, true),
|
||||
boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(target, game, true),
|
||||
game, true, new ApprovingObject(source, game));
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + target.getId(), null);
|
||||
return cardWasCast;
|
||||
|
|
@ -49,15 +46,7 @@ public class PlayTargetWithoutPayingManaEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
Target target = mode.getTargets().get(0);
|
||||
if (mode.getTargets().get(0).getZone() == Zone.HAND) {
|
||||
sb.append("you may put ").append(target.getTargetName()).append(" from your hand onto the battlefield");
|
||||
} else {
|
||||
sb.append("you may cast target ").append(target.getTargetName()).append(" without paying its mana cost");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
return "you may cast " + getTargetPointer().describeTargets(mode.getTargets(), "that card")
|
||||
+ " without paying its mana cost";
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,6 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -20,6 +15,7 @@ public class ExileTargetAndSearchGraveyardHandLibraryEffect extends SearchTarget
|
|||
|
||||
public ExileTargetAndSearchGraveyardHandLibraryEffect(boolean graveyardExileOptional, String searchWhatText, String searchForText) {
|
||||
super(graveyardExileOptional, searchWhatText, searchForText);
|
||||
this.staticText = ""; // since parent class overrides static text but we need to use a target
|
||||
}
|
||||
|
||||
private ExileTargetAndSearchGraveyardHandLibraryEffect(final ExileTargetAndSearchGraveyardHandLibraryEffect effect) {
|
||||
|
|
@ -28,28 +24,14 @@ public class ExileTargetAndSearchGraveyardHandLibraryEffect extends SearchTarget
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean result = false;
|
||||
UUID targetPlayerId = null;
|
||||
// get Target to exile
|
||||
Target exileTarget = null;
|
||||
for (Target target : source.getTargets()) {
|
||||
if (target instanceof TargetPermanent) {
|
||||
exileTarget = target;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null || exileTarget == null) {
|
||||
return result;
|
||||
Permanent permanentToExile = game.getPermanent(source.getFirstTarget());
|
||||
if (player == null || permanentToExile == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanentToExile = game.getPermanent(exileTarget.getFirstTarget());
|
||||
if (permanentToExile != null) {
|
||||
targetPlayerId = permanentToExile.getControllerId();
|
||||
result = player.moveCards(permanentToExile, Zone.EXILED, source, game);
|
||||
this.applySearchAndExile(game, source, permanentToExile.getName(), targetPlayerId);
|
||||
}
|
||||
|
||||
return result;
|
||||
player.moveCards(permanentToExile, Zone.EXILED, source, game);
|
||||
this.applySearchAndExile(game, source, permanentToExile.getName(), permanentToExile.getControllerId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -59,10 +41,10 @@ public class ExileTargetAndSearchGraveyardHandLibraryEffect extends SearchTarget
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
// TODO: Parent class sets static text so it must be overridden here for now
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Exile target ").append(mode.getTargets().get(0).getTargetName()).append(". ");
|
||||
sb.append(CardUtil.getTextWithFirstCharUpperCase(super.getText(mode)));
|
||||
return sb.toString();
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "exile " + getTargetPointer().describeTargets(mode.getTargets(), "that permanent")
|
||||
+ ". Search " + searchWhatText + " graveyard, hand, and library for " + searchForText + " and exile them. Then that player shuffles";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public class GetEmblemTargetPlayerEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "target " + mode.getTargets().get(0).getTargetName() + " gets an emblem with \"" + emblem.getAbilities().getRules(null).stream().collect(Collectors.joining("; ")) + "\"";
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "that player")
|
||||
+ " gets an emblem with \"" + String.join("; ", emblem.getAbilities().getRules(null)) + "\"";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,6 @@ public class PutSourceCountersOnTargetEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "put its counters on target " + mode.getTargets().get(0).getTargetName();
|
||||
return "put its counters on " + getTargetPointer().describeTargets(mode.getTargets(), "that creature");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -32,7 +31,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
|
|||
*/
|
||||
protected boolean graveyardExileOptional;
|
||||
|
||||
public SearchTargetGraveyardHandLibraryForCardNameAndExileEffect(boolean graveyardExileOptional, String searchWhatText, String searchForText) {
|
||||
protected SearchTargetGraveyardHandLibraryForCardNameAndExileEffect(boolean graveyardExileOptional, String searchWhatText, String searchForText) {
|
||||
super(Outcome.Exile);
|
||||
this.searchWhatText = searchWhatText;
|
||||
this.searchForText = searchForText;
|
||||
|
|
@ -55,7 +54,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
|
|||
* or her zones
|
||||
* @return
|
||||
*/
|
||||
public boolean applySearchAndExile(Game game, Ability source, String cardName, UUID targetPlayerId) {
|
||||
protected boolean applySearchAndExile(Game game, Ability source, String cardName, UUID targetPlayerId) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (cardName != null && controller != null) {
|
||||
Player targetPlayer = game.getPlayer(targetPlayerId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue