mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- CheckStyle.
This commit is contained in:
@@ -7939,7 +7939,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noPrevention)) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
|
||||
for (final Card ca : Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||
HashMap<String, String> params = re.getMapParams();
|
||||
|
||||
@@ -64,11 +64,11 @@ public class ChangeZoneAllEffect extends SpellEffect {
|
||||
final String remember = sa.getParam("RememberChanged");
|
||||
|
||||
final int libraryPos = sa.hasParam("LibraryPosition") ? Integer.parseInt(sa.getParam("LibraryPosition")) : 0;
|
||||
|
||||
|
||||
if (sa.getActivatingPlayer().isHuman() && destination.equals(ZoneType.Library) && !sa.hasParam("Shuffle")) {
|
||||
cards = GuiChoose.getOrderChoices("Choose order of cards to put into the library", "Put first", 0, cards, null, null);
|
||||
}
|
||||
|
||||
|
||||
for (final Card c : cards) {
|
||||
if (destination.equals(ZoneType.Battlefield)) {
|
||||
// Auras without Candidates stay in their current location
|
||||
|
||||
@@ -336,7 +336,7 @@ public class ChangeZoneEffect extends SpellEffect {
|
||||
tgtCards = tgt.getTargetCards();
|
||||
} else {
|
||||
tgtCards = new ArrayList<Card>();
|
||||
for(ZoneType o : origin) {
|
||||
for (ZoneType o : origin) {
|
||||
for (final Card c : sa.knownDetermineDefined(sa.getParam("Defined"))) {
|
||||
tgtCards.add(c);
|
||||
}
|
||||
@@ -601,7 +601,7 @@ public class ChangeZoneEffect extends SpellEffect {
|
||||
}
|
||||
|
||||
if (!defined) {
|
||||
if (origin.contains(ZoneType.Library) && !defined && !sa.hasParam("NoLooking")) {
|
||||
if (origin.contains(ZoneType.Library) && !defined && !sa.hasParam("NoLooking")) {
|
||||
// Look at whole library before moving onto choosing a card
|
||||
GuiChoose.oneOrNone(sa.getSourceCard().getName() + " - Looking at Library",
|
||||
player.getCardsIn(ZoneType.Library));
|
||||
@@ -783,4 +783,4 @@ public class ChangeZoneEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ import forge.game.player.Player;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class CharmEffect extends SpellEffect {
|
||||
|
||||
|
||||
public static List<AbilitySub> makePossibleOptions(final SpellAbility sa) {
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
|
||||
final String[] saChoices = sa.getParam("Choices").split(",");
|
||||
List<AbilitySub> choices = new ArrayList<AbilitySub>();
|
||||
for (final String saChoice : saChoices) {
|
||||
final String ab = source.getSVar(saChoice);
|
||||
final AbilityFactory charmAF = new AbilityFactory();
|
||||
choices.add((AbilitySub)charmAF.getAbility(ab, source));
|
||||
choices.add((AbilitySub) charmAF.getAbility(ab, source));
|
||||
}
|
||||
return choices;
|
||||
}
|
||||
@@ -37,23 +37,23 @@ public class CharmEffect extends SpellEffect {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
// nothing stack specific for Charm
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public static void makeChoices(SpellAbility sa) {
|
||||
//this resets all previous choices
|
||||
sa.setSubAbility(null);
|
||||
|
||||
|
||||
final int num = Integer.parseInt(sa.hasParam("CharmNum") ? sa.getParam("CharmNum") : "1");
|
||||
final int min = sa.hasParam("MinCharmNum") ? Integer.parseInt(sa.getParam("MinCharmNum")) : num;
|
||||
final List<AbilitySub> choices = makePossibleOptions(sa);
|
||||
|
||||
|
||||
List<AbilitySub> chosen = null;
|
||||
|
||||
|
||||
Player activator = sa.getActivatingPlayer();
|
||||
if ( activator.isHuman() )
|
||||
{
|
||||
if (activator.isHuman()) {
|
||||
|
||||
chosen = new ArrayList<AbilitySub>();
|
||||
for (int i = 0; i < num; i++) {
|
||||
AbilitySub a;
|
||||
@@ -69,28 +69,28 @@ public class CharmEffect extends SpellEffect {
|
||||
choices.remove(a);
|
||||
chosen.add(a);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
chosen = CharmAi.chooseOptionsAi(activator, true, choices, num, min);
|
||||
|
||||
}
|
||||
|
||||
chainAbilities(sa, chosen);
|
||||
}
|
||||
|
||||
private static void chainAbilities(SpellAbility sa, List<AbilitySub> chosen) {
|
||||
SpellAbility saDeepest = sa;
|
||||
while( saDeepest.getSubAbility() != null)
|
||||
while (saDeepest.getSubAbility() != null) {
|
||||
saDeepest = saDeepest.getSubAbility();
|
||||
|
||||
for(AbilitySub sub : chosen){
|
||||
}
|
||||
|
||||
for (AbilitySub sub : chosen) {
|
||||
saDeepest.setSubAbility(sub);
|
||||
sub.setActivatingPlayer(saDeepest.getActivatingPlayer());
|
||||
sub.setParent(saDeepest);
|
||||
|
||||
|
||||
// to chain the next one
|
||||
saDeepest = sub;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ChooseCardEffect extends SpellEffect {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("chooses a card.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -110,4 +110,4 @@ public class ChooseCardEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ public class ChooseCardNameEffect extends SpellEffect {
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("names a card.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -112,4 +112,4 @@ public class ChooseCardNameEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class ChooseColorEffect extends SpellEffect {
|
||||
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
@@ -111,4 +111,4 @@ public class ChooseColorEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ import forge.card.spellability.Target;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class ChooseGenericEffect extends SpellEffect {
|
||||
|
||||
public class ChooseGenericEffect extends SpellEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
@@ -61,4 +61,4 @@ public class ChooseGenericEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,31 +13,30 @@ import forge.card.spellability.Target;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class ChooseNumberEffect extends SpellEffect
|
||||
{
|
||||
|
||||
public class ChooseNumberEffect extends SpellEffect {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("chooses a number.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
//final int min = sa.containsKey("Min") ? Integer.parseInt(sa.get("Min")) : 0;
|
||||
//final int max = sa.containsKey("Max") ? Integer.parseInt(sa.get("Max")) : 99;
|
||||
final boolean random = sa.hasParam("Random");
|
||||
|
||||
|
||||
final int min;
|
||||
if (!sa.hasParam("Min")) {
|
||||
min = Integer.parseInt("0");
|
||||
@@ -46,7 +45,7 @@ public class ChooseNumberEffect extends SpellEffect
|
||||
} else {
|
||||
min = CardFactoryUtil.xCount(card, card.getSVar(sa.getParam("Min")));
|
||||
} // Allow variables for Min
|
||||
|
||||
|
||||
final int max;
|
||||
if (!sa.hasParam("Max")) {
|
||||
max = Integer.parseInt("99");
|
||||
@@ -55,7 +54,7 @@ public class ChooseNumberEffect extends SpellEffect
|
||||
} else {
|
||||
max = CardFactoryUtil.xCount(card, card.getSVar(sa.getParam("Max")));
|
||||
} // Allow variables for Max
|
||||
|
||||
|
||||
final String[] choices = new String[max + 1];
|
||||
if (!random) {
|
||||
// initialize the array
|
||||
@@ -63,10 +62,10 @@ public class ChooseNumberEffect extends SpellEffect
|
||||
choices[i] = Integer.toString(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
@@ -90,7 +89,7 @@ public class ChooseNumberEffect extends SpellEffect
|
||||
chosen = Integer.parseInt((String) o);
|
||||
}
|
||||
card.setChosenNumber(chosen);
|
||||
|
||||
|
||||
} else {
|
||||
// TODO - not implemented
|
||||
}
|
||||
@@ -98,4 +97,4 @@ public class ChooseNumberEffect extends SpellEffect
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import forge.game.player.Player;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class ChoosePlayerEffect extends SpellEffect {
|
||||
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -22,23 +22,23 @@ public class ChoosePlayerEffect extends SpellEffect {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("chooses a player.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
|
||||
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
|
||||
final ArrayList<Player> choices = sa.hasParam("Choices") ? AbilityFactory.getDefinedPlayers(
|
||||
sa.getSourceCard(), sa.getParam("Choices"), sa) : new ArrayList<Player>(Singletons.getModel().getGame().getPlayers());
|
||||
|
||||
|
||||
final String choiceDesc = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : "Choose a player";
|
||||
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
if (p.isHuman()) {
|
||||
@@ -51,7 +51,7 @@ public class ChoosePlayerEffect extends SpellEffect {
|
||||
}
|
||||
final Player chosen = (Player) o;
|
||||
card.setChosenPlayer(chosen);
|
||||
|
||||
|
||||
} else {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
if (sa.getParam("AILogic").equals("Curse")) {
|
||||
@@ -66,4 +66,4 @@ public class ChoosePlayerEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ChooseSourceEffect extends SpellEffect {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("chooses a source.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ChooseSourceEffect extends SpellEffect {
|
||||
if (threatApi != ApiType.DealDamage && threatApi != ApiType.DamageAll) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
final Card source = topStack.getSourceCard();
|
||||
ArrayList<Object> objects = new ArrayList<Object>();
|
||||
final Target threatTgt = topStack.getTarget();
|
||||
|
||||
@@ -18,8 +18,7 @@ import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class ChooseTypeEffect extends SpellEffect {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -28,10 +27,10 @@ public class ChooseTypeEffect extends SpellEffect {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("chooses a type.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getSourceCard();
|
||||
@@ -40,7 +39,7 @@ public class ChooseTypeEffect extends SpellEffect {
|
||||
if (sa.hasParam("InvalidTypes")) {
|
||||
invalidTypes.addAll(Arrays.asList(sa.getParam("InvalidTypes").split(",")));
|
||||
}
|
||||
|
||||
|
||||
final ArrayList<String> validTypes = new ArrayList<String>();
|
||||
if (sa.hasParam("ValidTypes")) {
|
||||
validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(",")));
|
||||
@@ -48,10 +47,10 @@ public class ChooseTypeEffect extends SpellEffect {
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
|
||||
|
||||
if (type.equals("Card")) {
|
||||
if (validTypes.isEmpty()) {
|
||||
validTypes.addAll(Constant.CardTypes.CARD_TYPES);
|
||||
@@ -170,4 +169,4 @@ public class ChooseTypeEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.trigger.TriggerType;
|
||||
|
||||
public class ClashEffect extends SpellEffect {
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@@ -18,7 +18,7 @@ public class ClashEffect extends SpellEffect {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
return sa.getSourceCard().getName() + " - Clash with an opponent.";
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@@ -56,4 +56,4 @@ public class ClashEffect extends SpellEffect {
|
||||
Singletons.getModel().getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ public class CloneEffect extends SpellEffect {
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
final List<Card> tgts = getTargetCards(sa);
|
||||
|
||||
|
||||
sb.append(sa.getSourceCard());
|
||||
sb.append(" becomes a copy of ");
|
||||
if (!tgts.isEmpty()) {
|
||||
@@ -278,4 +278,4 @@ public class CloneEffect extends SpellEffect {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.game.player.Player;
|
||||
|
||||
|
||||
public class ControlExchangeEffect extends SpellEffect {
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@@ -61,4 +61,4 @@ public class ControlExchangeEffect extends SpellEffect {
|
||||
object1.addController(player2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,17 @@ import forge.card.spellability.Target;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class ControlGainEffect extends SpellEffect {
|
||||
public class ControlGainEffect extends SpellEffect {
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
|
||||
|
||||
ArrayList<Player> newController = AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
|
||||
sa.getParam("NewController"), sa);
|
||||
if ((tgt != null) && tgt.getTargetPlayers() != null && !tgt.getTargetPlayers().isEmpty()) {
|
||||
@@ -35,9 +35,9 @@ public class ControlGainEffect extends SpellEffect {
|
||||
if (newController.size() == 0) {
|
||||
newController.add(sa.getActivatingPlayer());
|
||||
}
|
||||
|
||||
|
||||
sb.append(newController).append(" gains control of ");
|
||||
|
||||
|
||||
for (final Card c : getTargetCards(sa)) {
|
||||
sb.append(" ");
|
||||
if (c.isFaceDown()) {
|
||||
@@ -47,7 +47,7 @@ public class ControlGainEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
sb.append(".");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ public class ControlGainEffect extends SpellEffect {
|
||||
c.removeController(newController);
|
||||
// Singletons.getModel().getGameAction().changeController(new ArrayList<Card>(c),
|
||||
// c.getController(), originalController);
|
||||
|
||||
|
||||
if (tapOnLose) {
|
||||
c.tap();
|
||||
}
|
||||
|
||||
|
||||
if (null != addedKeywords) {
|
||||
for (final String kw : addedKeywords) {
|
||||
c.removeExtrinsicKeyword(kw);
|
||||
@@ -79,32 +79,32 @@ public class ControlGainEffect extends SpellEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
List<Card> tgtCards = new ArrayList<Card>();
|
||||
Card source = sa.getSourceCard();
|
||||
|
||||
|
||||
|
||||
final boolean bUntap = sa.hasParam("Untap");
|
||||
final boolean bTapOnLose = sa.hasParam("TapOnLose");
|
||||
final boolean bNoRegen = sa.hasParam("NoRegen");
|
||||
final List<String> destroyOn = sa.hasParam("DestroyTgt") ? Arrays.asList(sa.getParam("DestroyTgt").split(",")) : null;
|
||||
final List<String> kws = sa.hasParam("AddKWs") ? Arrays.asList(sa.getParam("AddKWs").split(" & ")) : null ;
|
||||
final List<String> kws = sa.hasParam("AddKWs") ? Arrays.asList(sa.getParam("AddKWs").split(" & ")) : null;
|
||||
final List<String> lose = sa.hasParam("LoseControl") ? Arrays.asList(sa.getParam("LoseControl").split(",")) : null;
|
||||
|
||||
final Target tgt = sa.getTarget();
|
||||
if (sa.hasParam("AllValid")) {
|
||||
tgtCards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
tgtCards = AbilityFactory.filterListByType(tgtCards, sa.getParam("AllValid"), sa);
|
||||
} else
|
||||
} else {
|
||||
tgtCards = getTargetCards(sa);
|
||||
|
||||
}
|
||||
|
||||
ArrayList<Player> controllers = new ArrayList<Player>();
|
||||
|
||||
|
||||
if (sa.hasParam("NewController")) {
|
||||
controllers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("NewController"), sa);
|
||||
} else if ((tgt != null) && (tgt.getTargetPlayers() != null) && tgt.canTgtPlayer()) {
|
||||
controllers = tgt.getTargetPlayers();
|
||||
}
|
||||
|
||||
|
||||
GameEntity newController;
|
||||
|
||||
|
||||
if (controllers.size() == 0) {
|
||||
if (sa.isSpell()) {
|
||||
newController = sa.getActivatingPlayer();
|
||||
@@ -121,38 +121,38 @@ public class ControlGainEffect extends SpellEffect {
|
||||
if (lose != null && lose.contains("Untap") && !source.isTapped()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final int size = tgtCards.size();
|
||||
for (int j = 0; j < size; j++) {
|
||||
final Card tgtC = tgtCards.get(j);
|
||||
final Player originalController = tgtC.getController();
|
||||
|
||||
|
||||
if (!tgtC.equals(sa.getSourceCard()) && !sa.getSourceCard().getGainControlTargets().contains(tgtC)) {
|
||||
sa.getSourceCard().addGainControlTarget(tgtC);
|
||||
}
|
||||
|
||||
|
||||
if (tgtC.isInPlay()) {
|
||||
|
||||
|
||||
if (!tgtC.equals(newController)) {
|
||||
tgtC.addController(newController);
|
||||
}
|
||||
// Singletons.getModel().getGameAction().changeController(new ArrayList<Card>(tgtC),
|
||||
// tgtC.getController(), newController.get(0));
|
||||
|
||||
|
||||
if (bUntap) {
|
||||
tgtC.untap();
|
||||
}
|
||||
|
||||
|
||||
if (null != kws) {
|
||||
for (final String kw : kws) {
|
||||
tgtC.addExtrinsicKeyword(kw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// end copied
|
||||
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
|
||||
final Card hostCard = sa.getSourceCard();
|
||||
if (lose != null) {
|
||||
if (lose.contains("LeavesPlay")) {
|
||||
sa.getSourceCard().addLeavesPlayCommand(this.getLoseControlCommand(tgtC, originalController, newController, bTapOnLose, hostCard, kws));
|
||||
@@ -167,7 +167,7 @@ public class ControlGainEffect extends SpellEffect {
|
||||
Singletons.getModel().getGame().getEndOfTurn().addAt(this.getLoseControlCommand(tgtC, originalController, newController, bTapOnLose, hostCard, kws));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (destroyOn != null) {
|
||||
if (destroyOn.contains("LeavesPlay")) {
|
||||
sa.getSourceCard().addLeavesPlayCommand(this.getDestroyCommand(tgtC, hostCard, bNoRegen));
|
||||
@@ -179,10 +179,10 @@ public class ControlGainEffect extends SpellEffect {
|
||||
sa.getSourceCard().addChangeControllerCommand(this.getDestroyCommand(tgtC, hostCard, bNoRegen));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sa.getSourceCard().clearGainControlReleaseCommands();
|
||||
sa.getSourceCard().addGainControlReleaseCommand(this.getLoseControlCommand(tgtC, originalController, newController, bTapOnLose, hostCard, kws));
|
||||
|
||||
|
||||
} // end foreach target
|
||||
}
|
||||
|
||||
@@ -198,13 +198,13 @@ public class ControlGainEffect extends SpellEffect {
|
||||
private Command getDestroyCommand(final Card c, final Card hostCard, final boolean bNoRegen) {
|
||||
final Command destroy = new Command() {
|
||||
private static final long serialVersionUID = 878543373519872418L;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
final Ability ability = new Ability(hostCard, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
|
||||
|
||||
if (bNoRegen) {
|
||||
Singletons.getModel().getGame().getAction().destroyNoRegeneration(c);
|
||||
} else {
|
||||
@@ -218,10 +218,10 @@ public class ControlGainEffect extends SpellEffect {
|
||||
sb.append(" It can't be regenerated.");
|
||||
}
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
|
||||
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
return destroy;
|
||||
}
|
||||
@@ -237,16 +237,16 @@ public class ControlGainEffect extends SpellEffect {
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a {@link forge.Command} object.
|
||||
*/
|
||||
private Command getLoseControlCommand(final Card c, final Player originalController, final GameEntity newController,
|
||||
final boolean bTapOnLose, final Card hostCard, final List<String> kws ) {
|
||||
private Command getLoseControlCommand(final Card c, final Player originalController, final GameEntity newController,
|
||||
final boolean bTapOnLose, final Card hostCard, final List<String> kws) {
|
||||
final Command loseControl = new Command() {
|
||||
private static final long serialVersionUID = 878543373519872418L;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() { doLoseControl(c, hostCard, bTapOnLose, kws, newController); } // execute()
|
||||
};
|
||||
|
||||
|
||||
return loseControl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import forge.game.player.Player;
|
||||
import forge.item.CardDb;
|
||||
|
||||
public class CopyPermanentEffect extends SpellEffect {
|
||||
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -57,7 +57,7 @@ public class CopyPermanentEffect extends SpellEffect {
|
||||
if (controller == null) {
|
||||
controller = sa.getActivatingPlayer();
|
||||
}
|
||||
|
||||
|
||||
hostCard.clearClones();
|
||||
|
||||
for (final Card c : tgtCards) {
|
||||
@@ -188,4 +188,4 @@ public class CopyPermanentEffect extends SpellEffect {
|
||||
} // end foreach Card
|
||||
} // end resolve
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import forge.game.player.Player;
|
||||
import forge.gui.GuiChoose;
|
||||
|
||||
public class CopySpellEffect extends SpellEffect {
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
// ************************* CopySpell *************************************
|
||||
// *************************************************************************
|
||||
@@ -22,7 +22,7 @@ public class CopySpellEffect extends SpellEffect {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<SpellAbility> tgtSpells = getTargetSpellAbilities(sa);
|
||||
|
||||
|
||||
sb.append("Copy ");
|
||||
// TODO Someone fix this Description when Copying Charms
|
||||
final Iterator<SpellAbility> it = tgtSpells.iterator();
|
||||
@@ -120,4 +120,4 @@ public class CopySpellEffect extends SpellEffect {
|
||||
}
|
||||
} // end resolve
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ import forge.card.spellability.SpellPermanent;
|
||||
public class CounterEffect extends SpellEffect {
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<SpellAbility> sas;
|
||||
|
||||
|
||||
if (sa.hasParam("AllType")) {
|
||||
sas = new ArrayList<SpellAbility>();
|
||||
for (int i=0; i < Singletons.getModel().getGame().getStack().size(); i++) {
|
||||
for (int i = 0; i < Singletons.getModel().getGame().getStack().size(); i++) {
|
||||
SpellAbility spell = Singletons.getModel().getGame().getStack().peekAbility(i);
|
||||
if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) {
|
||||
continue;
|
||||
@@ -31,11 +31,12 @@ public class CounterEffect extends SpellEffect {
|
||||
}
|
||||
sas.add(spell);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
sas = getTargetSpellAbilities(sa);
|
||||
|
||||
}
|
||||
|
||||
sb.append("countering");
|
||||
|
||||
|
||||
boolean isAbility = false;
|
||||
for (final SpellAbility tgtSA : sas) {
|
||||
sb.append(" ");
|
||||
@@ -45,11 +46,11 @@ public class CounterEffect extends SpellEffect {
|
||||
sb.append("'s ability");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isAbility && sa.hasParam("DestroyPermanent")) {
|
||||
sb.append(" and destroy it");
|
||||
}
|
||||
|
||||
|
||||
sb.append(".");
|
||||
return sb.toString();
|
||||
} // end counterStackDescription
|
||||
@@ -59,10 +60,10 @@ public class CounterEffect extends SpellEffect {
|
||||
// TODO Before this resolves we should see if any of our targets are
|
||||
// still on the stack
|
||||
final List<SpellAbility> sas;
|
||||
|
||||
|
||||
if (sa.hasParam("AllType")) {
|
||||
sas = new ArrayList<SpellAbility>();
|
||||
for (int i=0; i < Singletons.getModel().getGame().getStack().size(); i++) {
|
||||
for (int i = 0; i < Singletons.getModel().getGame().getStack().size(); i++) {
|
||||
SpellAbility spell = Singletons.getModel().getGame().getStack().peekAbility(i);
|
||||
if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) {
|
||||
continue;
|
||||
@@ -74,34 +75,35 @@ public class CounterEffect extends SpellEffect {
|
||||
}
|
||||
sas.add(spell);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
sas = getTargetSpellAbilities(sa);
|
||||
|
||||
}
|
||||
|
||||
if (sa.hasParam("ForgetOtherTargets")) {
|
||||
if (sa.getParam("ForgetOtherTargets").equals("True")) {
|
||||
sa.getSourceCard().clearRemembered();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (final SpellAbility tgtSA : sas) {
|
||||
final Card tgtSACard = tgtSA.getSourceCard();
|
||||
|
||||
|
||||
if (tgtSA.isSpell() && !CardFactoryUtil.isCounterableBy(tgtSACard, sa)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
final SpellAbilityStackInstance si = Singletons.getModel().getGame().getStack().getInstanceFromSpellAbility(tgtSA);
|
||||
if (si == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
this.removeFromStack(tgtSA, sa, si);
|
||||
|
||||
|
||||
// Destroy Permanent may be able to be turned into a SubAbility
|
||||
if (tgtSA.isAbility() && sa.hasParam("DestroyPermanent")) {
|
||||
Singletons.getModel().getGame().getAction().destroy(tgtSACard);
|
||||
}
|
||||
|
||||
|
||||
if (sa.hasParam("RememberTargets")) {
|
||||
if (sa.getParam("RememberTargets").equals("True")) {
|
||||
sa.getSourceCard().addRemembered(tgtSACard);
|
||||
@@ -122,11 +124,11 @@ public class CounterEffect extends SpellEffect {
|
||||
* @param si
|
||||
* a {@link forge.card.spellability.SpellAbilityStackInstance}
|
||||
* object.
|
||||
* @param sa
|
||||
* @param sa
|
||||
*/
|
||||
private void removeFromStack(final SpellAbility tgtSA, final SpellAbility srcSA, final SpellAbilityStackInstance si) {
|
||||
Singletons.getModel().getGame().getStack().remove(si);
|
||||
|
||||
|
||||
String destination = srcSA.hasParam("Destination") ? srcSA.getParam("Destination") : "Graveyard";
|
||||
|
||||
if (tgtSA.isAbility()) {
|
||||
@@ -167,4 +169,4 @@ public class CounterEffect extends SpellEffect {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import forge.card.abilityfactory.SpellEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
|
||||
public class CountersMoveEffect extends SpellEffect {
|
||||
public class CountersMoveEffect extends SpellEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final Card host = sa.getSourceCard();
|
||||
|
||||
|
||||
Card source = null;
|
||||
ArrayList<Card> srcCards;
|
||||
final Target tgt = sa.getTarget();
|
||||
@@ -29,17 +29,17 @@ public class CountersMoveEffect extends SpellEffect {
|
||||
source = srcCards.get(0);
|
||||
}
|
||||
final List<Card> tgtCards = getTargetCards(sa);
|
||||
|
||||
|
||||
final Counters cType = Counters.valueOf(sa.getParam("CounterType"));
|
||||
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
|
||||
|
||||
|
||||
sb.append("Move ").append(amount).append(" ").append(cType.getName()).append(" counter");
|
||||
if (amount != 1) {
|
||||
sb.append("s");
|
||||
}
|
||||
sb.append(" from ");
|
||||
sb.append(source).append(" to ").append(tgtCards.get(0));
|
||||
|
||||
|
||||
sb.append(".");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -83,4 +83,4 @@ public class CountersMoveEffect extends SpellEffect {
|
||||
}
|
||||
} // moveCounterResolve
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,13 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
Player controller = sa.getSourceCard().getController();
|
||||
if (controller.isHuman())
|
||||
if (controller.isHuman()) {
|
||||
resolveHuman(sa);
|
||||
else
|
||||
} else {
|
||||
resolveAI(controller, sa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void resolveHuman(final SpellAbility sa) {
|
||||
final List<Card> unchosen = Lists.newArrayList(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield));
|
||||
final List<Player> players = new ArrayList<Player>(Singletons.getModel().getGame().getPlayers());
|
||||
@@ -84,8 +85,8 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
|
||||
@Override
|
||||
public void selectPlayer(final Player player) {
|
||||
if (players.indexOf(player) >= 0)
|
||||
{
|
||||
if (players.indexOf(player) >= 0) {
|
||||
|
||||
players.remove(player); // no second selection
|
||||
if (player.getPoisonCounters() > 0) {
|
||||
player.addPoisonCounters(1, sa.getSourceCard());
|
||||
@@ -94,9 +95,8 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static void resolveAI(final Player ai, final SpellAbility sa) {
|
||||
final List<Player> allies = ai.getAllies();
|
||||
allies.add(ai);
|
||||
@@ -105,10 +105,12 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
@Override
|
||||
public boolean apply(Card crd) {
|
||||
for (final Entry<Counters, Integer> c1 : crd.getCounters().entrySet()) {
|
||||
if ( CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(crd.getController()))
|
||||
if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(crd.getController())) {
|
||||
return true;
|
||||
if ( !CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(crd.getController()))
|
||||
}
|
||||
if (!CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(crd.getController())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -116,9 +118,10 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
|
||||
List<Card> cardsToProliferate = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), predProliferate);
|
||||
List<Player> playersToPoison = new ArrayList<Player>();
|
||||
for( Player e : enemies ) {
|
||||
if ( e.getPoisonCounters() > 0 )
|
||||
for (Player e : enemies) {
|
||||
if (e.getPoisonCounters() > 0) {
|
||||
playersToPoison.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -126,17 +129,17 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
if (cardsToProliferate.isEmpty() && playersToPoison.isEmpty()) {
|
||||
sb.append("<b>nothing</b>.");
|
||||
} else {
|
||||
for( Card c : cardsToProliferate ) {
|
||||
for (Card c : cardsToProliferate) {
|
||||
sb.append(c.getController().getName());
|
||||
sb.append("'s <b>");
|
||||
sb.append(c.getName());
|
||||
sb.append("</b><br>");
|
||||
}
|
||||
|
||||
if( !playersToPoison.isEmpty() ) {
|
||||
|
||||
if (!playersToPoison.isEmpty()) {
|
||||
sb.append("<br>The following players: <br>");
|
||||
}
|
||||
for( Player p : playersToPoison ) {
|
||||
for (Player p : playersToPoison) {
|
||||
sb.append("<b>");
|
||||
sb.append(p.getName());
|
||||
sb.append("</b><br>");
|
||||
@@ -148,22 +151,22 @@ public class CountersProliferateEffect extends SpellEffect {
|
||||
// computer
|
||||
for (final Card c : cardsToProliferate) {
|
||||
for (final Entry<Counters, Integer> c1 : c.getCounters().entrySet()) {
|
||||
if ( CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(c.getController()))
|
||||
if (CardFactoryUtil.isNegativeCounter(c1.getKey()) && enemies.contains(c.getController()))
|
||||
{
|
||||
c.addCounter(c1.getKey(), 1);
|
||||
break;
|
||||
}
|
||||
if ( !CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(c.getController()))
|
||||
if (!CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(c.getController()))
|
||||
{
|
||||
c.addCounter(c1.getKey(), 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(final Player p : playersToPoison ) {
|
||||
|
||||
for (final Player p : playersToPoison) {
|
||||
p.addPoisonCounters(1, sa.getSourceCard());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user