mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Cleanup ControlGainEffect and fix its Stack description.
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -12,9 +15,6 @@ import forge.game.spellability.Ability;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ControlGainEffect extends SpellAbilityEffect {
|
public class ControlGainEffect extends SpellAbilityEffect {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||||
@@ -23,20 +23,25 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
|||||||
protected String getStackDescription(SpellAbility sa) {
|
protected String getStackDescription(SpellAbility sa) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
List<Player> newController = getTargetPlayers(sa, "NewController");
|
final List<Player> newController = getTargetPlayers(sa, "NewController");
|
||||||
if (newController.isEmpty()) {
|
if (newController.isEmpty()) {
|
||||||
newController.add(sa.getActivatingPlayer());
|
newController.add(sa.getActivatingPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(newController).append(" gains control of ");
|
sb.append(newController).append(" gains control of");
|
||||||
|
|
||||||
for (final Card c : getTargetCards(sa)) {
|
final List<Card> tgts = getDefinedCards(sa);
|
||||||
sb.append(" ");
|
if (tgts.isEmpty()) {
|
||||||
if (c.isFaceDown()) {
|
sb.append(" (nothing)");
|
||||||
sb.append("Morph");
|
} else {
|
||||||
} else {
|
for (final Card c : getDefinedCards(sa)) {
|
||||||
sb.append(c);
|
sb.append(" ");
|
||||||
}
|
if (c.isFaceDown()) {
|
||||||
|
sb.append("Face-down creature (").append(c.getUniqueNumber()).append(')');
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
@@ -83,11 +88,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
|||||||
final Player newController = controllers.isEmpty() ? sa.getActivatingPlayer() : controllers.get(0);
|
final Player newController = controllers.isEmpty() ? sa.getActivatingPlayer() : controllers.get(0);
|
||||||
final Game game = newController.getGame();
|
final Game game = newController.getGame();
|
||||||
|
|
||||||
List<Card> tgtCards;
|
List<Card> tgtCards = this.getDefinedCards(sa);
|
||||||
if (sa.hasParam("AllValid")) {
|
|
||||||
tgtCards = AbilityUtils.filterListByType(game.getCardsIn(ZoneType.Battlefield), sa.getParam("AllValid"), sa);
|
|
||||||
} else
|
|
||||||
tgtCards = getTargetCards(sa);
|
|
||||||
|
|
||||||
if (sa.hasParam("ControlledByTarget")) {
|
if (sa.hasParam("ControlledByTarget")) {
|
||||||
tgtCards = CardLists.filterControlledBy(tgtCards, getTargetPlayers(sa));
|
tgtCards = CardLists.filterControlledBy(tgtCards, getTargetPlayers(sa));
|
||||||
@@ -242,4 +243,12 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
|||||||
return loseControl;
|
return loseControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Card> getDefinedCards(final SpellAbility sa) {
|
||||||
|
final Game game = sa.getHostCard().getGame();
|
||||||
|
if (sa.hasParam("AllValid")) {
|
||||||
|
return AbilityUtils.filterListByType(game.getCardsIn(ZoneType.Battlefield), sa.getParam("AllValid"), sa);
|
||||||
|
}
|
||||||
|
return getTargetCards(sa);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user