- CheckStyle.

This commit is contained in:
Chris
2012-11-21 15:00:55 +00:00
parent 4160d8837b
commit 83e82192aa
19 changed files with 125 additions and 130 deletions

View File

@@ -440,7 +440,7 @@ public class ChangeZoneEffect extends SpellEffect {
tgtC.clearUnEnchantCommand();
}
tgtC.enchantEntity(attachedTo);
} else {// When it should enter the battlefield attached to an illegal permanent it fails
} else { // When it should enter the battlefield attached to an illegal permanent it fails
continue;
}
}

View File

@@ -13,16 +13,16 @@ import forge.card.spellability.Target;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
public class CountersPutAllEffect extends SpellEffect {
public class CountersPutAllEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final Counters cType = Counters.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
final String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield";
sb.append("Put ").append(amount).append(" ").append(cType.getName()).append(" counter");
if (amount != 1) {
sb.append("s");
@@ -33,7 +33,7 @@ public class CountersPutAllEffect extends SpellEffect {
} else {
sb.append("card in ").append(zone).append(".");
}
return sb.toString();
}
@@ -63,4 +63,4 @@ public class CountersPutAllEffect extends SpellEffect {
}
}
}
}

View File

@@ -20,7 +20,7 @@ public class CountersPutEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final Card card = sa.getSourceCard();
final Counters cType = Counters.valueOf(sa.getParam("CounterType"));
final int amount = AbilityFactory.calculateAmount(card, sa.getParam("CounterNum"), sa);
@@ -50,7 +50,7 @@ public class CountersPutEffect extends SpellEffect {
}
}
sb.append(".");
return sb.toString();
}
@@ -101,4 +101,4 @@ public class CountersPutEffect extends SpellEffect {
}
}
}
}

View File

@@ -13,7 +13,7 @@ import forge.card.spellability.Target;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
public class CountersRemoveAllEffect extends SpellEffect {
public class CountersRemoveAllEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
@@ -22,11 +22,11 @@ public class CountersRemoveAllEffect extends SpellEffect {
final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("CounterNum"), sa);
final String zone = sa.hasParam("ValidZone") ? sa.getParam("ValidZone") : "Battlefield";
String amountString = Integer.toString(amount);
if (sa.hasParam("AllCounters")) {
amountString = "all";
}
sb.append("Remove ").append(amount).append(" ").append(cType.getName()).append(" counter");
if (!amountString.equals("1")) {
sb.append("s");
@@ -65,4 +65,4 @@ public class CountersRemoveAllEffect extends SpellEffect {
tgtCard.subtractCounter(Counters.valueOf(type), counterAmount);
}
}
}
}

View File

@@ -22,12 +22,11 @@ public class DamageAllEffect extends SpellEffect {
if (sa.hasParam("ValidDescription")) {
desc = sa.getParam("ValidDescription");
}
final String damage = sa.getParam("NumDmg");
final int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final String damage = sa.getParam("NumDmg");
final int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final ArrayList<Card> definedSources = AbilityFactory.getDefinedCards(sa.getSourceCard(), sa.getParam("DamageSource"), sa);
final Card source = definedSources.get(0);
@@ -50,7 +49,7 @@ public class DamageAllEffect extends SpellEffect {
final Card source = sa.getSourceCard();
final String damage = sa.getParam("NumDmg");
final int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final Target tgt = sa.getTarget();
Player targetPlayer = null;
@@ -90,4 +89,4 @@ public class DamageAllEffect extends SpellEffect {
}
}
}
}
}

View File

@@ -21,7 +21,7 @@ public class DamageDealEffect extends SpellEffect {
// when damageStackDescription is called, just build exactly what is happening
final StringBuilder sb = new StringBuilder();
final String damage = sa.getParam("NumDmg");
final int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
List<Object> tgts = getTargetObjects(sa);
@@ -42,11 +42,11 @@ public class DamageDealEffect extends SpellEffect {
}
sb.append(" ").append(dmg).append(" damage ");
if (sa.hasParam("DivideEvenly")) {
sb.append("divided evenly (rounded down) ");
}
sb.append("to");
for (int i = 0; i < tgts.size(); i++) {
@@ -78,7 +78,7 @@ public class DamageDealEffect extends SpellEffect {
@Override
public void resolve(SpellAbility sa) {
final String damage = sa.getParam("NumDmg");
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
int dmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final boolean noPrevention = sa.hasParam("NoPrevention");
final boolean combatDmg = sa.hasParam("CombatDamage");
@@ -154,4 +154,4 @@ public class DamageDealEffect extends SpellEffect {
}
}
}
}

View File

@@ -14,7 +14,7 @@ import forge.game.player.Player;
import forge.game.zone.ZoneType;
public class DamageEachEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
*/
@@ -22,20 +22,20 @@ public class DamageEachEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final String damage = sa.getParam("NumDmg");
final int iDmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
final int iDmg = AbilityFactory.calculateAmount(sa.getSourceCard(), damage, sa);
String desc = sa.getParam("ValidCards");
if (sa.hasParam("ValidDescription")) {
desc = sa.getParam("ValidDescription");
}
String dmg = "";
if (sa.hasParam("DamageDesc")) {
dmg = sa.getParam("DamageDesc");
} else {
dmg += iDmg + " damage";
}
if (sa.hasParam("StackDescription")) {
sb.append(sa.getParam("StackDescription"));
} else {
@@ -53,7 +53,7 @@ public class DamageEachEffect extends SpellEffect {
return sb.toString();
}
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
*/
@@ -117,4 +117,4 @@ public class DamageEachEffect extends SpellEffect {
}
}
}
}
}

View File

@@ -12,7 +12,7 @@ import forge.game.player.Player;
import forge.game.zone.ZoneType;
public class DamagePreventAllEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
*/
@@ -52,13 +52,13 @@ public class DamagePreventAllEffect extends SpellEffect {
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
String desc = sa.getDescription();
if (desc.contains(":")) {
desc = desc.split(":")[1];
}
sb.append(desc);
return sb.toString();
}
}
}

View File

@@ -10,12 +10,12 @@ import forge.card.abilityfactory.SpellEffect;
import forge.card.spellability.SpellAbility;
import forge.game.player.Player;
public class DamagePreventEffect extends SpellEffect
{
public class DamagePreventEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final List<Object> tgts = getTargetObjects(sa);
sb.append("Prevent the next ");
@@ -25,7 +25,7 @@ public class DamagePreventEffect extends SpellEffect
if (i != 0) {
sb.append(" ");
}
final Object o = tgts.get(i);
if (o instanceof Card) {
final Card tgtC = (Card) o;
@@ -38,7 +38,7 @@ public class DamagePreventEffect extends SpellEffect
sb.append(o.toString());
}
}
if (sa.hasParam("Radiance") && (sa.getTarget() != null)) {
sb.append(" and each other ").append(sa.getParam("ValidTgts"))
.append(" that shares a color with ");
@@ -107,4 +107,4 @@ public class DamagePreventEffect extends SpellEffect
}
}
} // preventDamageResolve
}
}

View File

@@ -13,7 +13,7 @@ import forge.card.spellability.SpellAbility;
import forge.game.zone.ZoneType;
public class DebuffAllEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
*/
@@ -35,21 +35,21 @@ public class DebuffAllEffect extends SpellEffect {
* @param af
* a {@link forge.card.abilityfactory.AbilityFactory} object.
*/
@Override
public void resolve(SpellAbility sa) {
public void resolve(SpellAbility sa) {
final Card hostCard = sa.getSourceCard();
final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>();
String valid = "";
if (sa.hasParam("ValidCards")) {
valid = sa.getParam("ValidCards");
}
List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, valid.split(","), hostCard.getController(), hostCard);
for (final Card tgtC : list) {
final ArrayList<String> hadIntrinsic = new ArrayList<String>();
if (tgtC.isInPlay() && tgtC.canBeTargetedBy(sa)) {
@@ -64,7 +64,7 @@ public class DebuffAllEffect extends SpellEffect {
if (!sa.hasParam("Permanent")) {
Singletons.getModel().getGame().getEndOfTurn().addUntil(new Command() {
private static final long serialVersionUID = 7486231071095628674L;
@Override
public void execute() {
if (tgtC.isInPlay()) {
@@ -78,4 +78,4 @@ public class DebuffAllEffect extends SpellEffect {
}
} // debuffAllResolve()
}
}

View File

@@ -12,18 +12,18 @@ import forge.card.abilityfactory.SpellEffect;
import forge.card.spellability.SpellAbility;
public class DebuffEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final List<String> kws = sa.hasParam("Keywords") ? Arrays.asList(sa.getParam("Keywords").split(" & ")) : new ArrayList<String>();
final StringBuilder sb = new StringBuilder();
final List<Card> tgtCards = getTargetCards(sa);
if (tgtCards.size() > 0) {
final Iterator<Card> it = tgtCards.iterator();
while (it.hasNext()) {
final Card tgtC = it.next();
@@ -32,7 +32,7 @@ public class DebuffEffect extends SpellEffect {
} else {
sb.append(tgtC);
}
if (it.hasNext()) {
sb.append(" ");
}
@@ -86,4 +86,4 @@ public class DebuffEffect extends SpellEffect {
} // debuffResolve
}
}

View File

@@ -10,7 +10,7 @@ import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
public class DelayedTriggerEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
*/
@@ -27,7 +27,7 @@ public class DelayedTriggerEffect extends SpellEffect {
@Override
public void resolve(SpellAbility sa) {
Map<String, String> mapParams = new HashMap<String, String>();
Map<String, String> mapParams = new HashMap<String, String>();
sa.copyParamsToMap(mapParams);
if (mapParams.containsKey("Cost")) {
mapParams.remove("Cost");
@@ -42,4 +42,4 @@ public class DelayedTriggerEffect extends SpellEffect {
Singletons.getModel().getGame().getTriggerHandler().registerDelayedTrigger(delTrig);
}
}
}

View File

@@ -14,13 +14,13 @@ import forge.game.player.Player;
import forge.game.zone.ZoneType;
public class DestroyAllEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final boolean noRegen = sa.hasParam("NoRegen");
final String conditionDesc = sa.getParam("ConditionDescription");
if (conditionDesc != null) {
@@ -51,7 +51,7 @@ public class DestroyAllEffect extends SpellEffect {
*/
@Override
public void resolve(SpellAbility sa) {
final boolean noRegen = sa.hasParam("NoRegen");
final Card card = sa.getSourceCard();
@@ -106,4 +106,4 @@ public class DestroyAllEffect extends SpellEffect {
}
}
}
}

View File

@@ -132,4 +132,4 @@ public class DestroyEffect extends SpellEffect {
}
}
}
}

View File

@@ -21,15 +21,14 @@ import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
public class DigEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final Card host = sa.getSourceCard();
final StringBuilder sb = new StringBuilder();
final int numToDig = AbilityFactory.calculateAmount(host, sa.getParam("DigNum"), sa);
final List<Player> tgtPlayers = getTargetPlayers(sa);
sb.append(host.getController()).append(" looks at the top ").append(numToDig);
sb.append(" card");
if (numToDig != 1) {
@@ -355,4 +354,4 @@ public class DigEffect extends SpellEffect {
return toReturn;
}
}
}

View File

@@ -16,7 +16,6 @@ import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
public class DigUntilEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
@@ -24,12 +23,12 @@ public class DigUntilEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
String desc = "Card";
if (sa.hasParam("ValidDescription")) {
desc = sa.getParam("ValidDescription");
}
int untilAmount = 1;
if (sa.hasParam("Amount")) {
untilAmount = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("Amount"), sa);
@@ -38,25 +37,25 @@ public class DigUntilEffect extends SpellEffect {
for (final Player pl : getTargetPlayers(sa)) {
sb.append(pl).append(" ");
}
sb.append("reveals cards from his or her library until revealing ");
sb.append(untilAmount).append(" ").append(desc).append(" card");
if (untilAmount != 1) {
sb.append("s");
}
sb.append(". Put ");
final ZoneType found = ZoneType.smartValueOf(sa.getParam("FoundDestination"));
final ZoneType revealed = ZoneType.smartValueOf(sa.getParam("RevealedDestination"));
if (found != null) {
sb.append(untilAmount > 1 ? "those cards" : "that card");
sb.append(" ");
if (found.equals(ZoneType.Hand)) {
sb.append("into his or her hand ");
}
if (revealed.equals(ZoneType.Graveyard)) {
sb.append("and all other cards into his or her graveyard.");
}
@@ -160,4 +159,4 @@ public class DigUntilEffect extends SpellEffect {
}
} // end resolve
}
}

View File

@@ -24,21 +24,20 @@ public class DiscardEffect extends RevealEffectBase {
protected String getStackDescription(SpellAbility sa) {
final String mode = sa.getParam("Mode");
final StringBuilder sb = new StringBuilder();
final List<Player> tgtPlayers = getTargetPlayers(sa);
final String conditionDesc = sa.getParam("ConditionDescription");
if (conditionDesc != null) {
sb.append(conditionDesc).append(" ");
}
if (tgtPlayers.size() > 0) {
for (final Player p : tgtPlayers) {
sb.append(p.toString()).append(" ");
}
if (mode.equals("RevealYouChoose")) {
sb.append("reveals his or her hand.").append(" You choose (");
} else if (mode.equals("RevealDiscardAll")) {
@@ -46,12 +45,12 @@ public class DiscardEffect extends RevealEffectBase {
} else {
sb.append("discards (");
}
int numCards = 1;
if (sa.hasParam("NumCards")) {
numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
}
if (mode.equals("Hand")) {
sb.append("his or her hand");
} else if (mode.equals("RevealDiscardAll")) {
@@ -59,9 +58,9 @@ public class DiscardEffect extends RevealEffectBase {
} else {
sb.append(numCards);
}
sb.append(")");
if (mode.equals("RevealYouChoose")) {
sb.append(" to discard");
} else if (mode.equals("RevealDiscardAll")) {
@@ -71,11 +70,11 @@ public class DiscardEffect extends RevealEffectBase {
}
sb.append(" of type: ").append(valid);
}
if (mode.equals("Defined")) {
sb.append(" defined cards");
}
if (mode.equals("Random")) {
sb.append(" at random.");
} else {
@@ -89,11 +88,11 @@ public class DiscardEffect extends RevealEffectBase {
public void resolve(SpellAbility sa) {
final Card source = sa.getSourceCard();
final String mode = sa.getParam("Mode");
final Target tgt = sa.getTarget();
final List<Card> discarded = new ArrayList<Card>();
for (final Player p : getTargetPlayers(sa)) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
if (mode.equals("Defined")) {
@@ -109,7 +108,7 @@ public class DiscardEffect extends RevealEffectBase {
}
continue;
}
if (mode.equals("Hand")) {
final List<Card> list = p.discardHand(sa);
if (sa.hasParam("RememberDiscarded")) {
@@ -119,16 +118,16 @@ public class DiscardEffect extends RevealEffectBase {
}
continue;
}
if (mode.equals("NotRemembered")) {
final List<Card> dPHand =
final List<Card> dPHand =
CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), "Card.IsNotRemembered", source.getController(), source);
for (final Card c : dPHand) {
p.discard(c, sa);
discarded.add(c);
}
}
int numCards = 1;
if (sa.hasParam("NumCards")) {
numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
@@ -138,7 +137,7 @@ public class DiscardEffect extends RevealEffectBase {
numCards = p.getCardsIn(ZoneType.Hand).size();
}
}
if (mode.equals("Random")) {
boolean runDiscard = true;
if (sa.hasParam("Optional")) {
@@ -153,7 +152,7 @@ public class DiscardEffect extends RevealEffectBase {
// Balduvian Horde and similar cards
}
}
if (runDiscard) {
final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";
discarded.addAll(p.discardRandom(numCards, sa, valid));
@@ -163,22 +162,22 @@ public class DiscardEffect extends RevealEffectBase {
} else if (mode.equals("RevealDiscardAll")) {
// Reveal
final List<Card> dPHand = p.getCardsIn(ZoneType.Hand);
if (p.isHuman()) {
// "reveal to computer" for information gathering
} else {
GuiChoose.oneOrNone("Revealed computer hand", dPHand);
}
String valid = sa.getParam("DiscardValid");
if (valid == null) {
valid = "Card";
}
if (valid.contains("X")) {
valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(source, "X", sa)));
}
final List<Card> dPChHand = CardLists.getValidCards(dPHand, valid.split(","), source.getController(), source);
// Reveal cards that will be discarded?
for (final Card c : dPChHand) {
@@ -208,7 +207,7 @@ public class DiscardEffect extends RevealEffectBase {
} else if (mode.equals("RevealOppChoose")) {
chooser = source.getController().getOpponent();
}
if (chooser.isComputer()) {
// AI
if (p.isComputer()) { // discard AI cards
@@ -230,8 +229,8 @@ public class DiscardEffect extends RevealEffectBase {
List<Card> goodChoices = CardLists.filter(dPChHand, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
if (c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME," +
" put it onto the battlefield instead of putting it into your graveyard.")
if (c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME,"
+ " put it onto the battlefield instead of putting it into your graveyard.")
|| !c.getSVar("DiscardMe").equals("")) {
return false;
}
@@ -251,15 +250,15 @@ public class DiscardEffect extends RevealEffectBase {
}
}
}
Collections.sort(goodChoices, CardLists.TextLenReverseComparator);
CardLists.sortCMC(goodChoices);
dChoices.add(goodChoices.get(0));
final Card dC = goodChoices.get(CardUtil.getRandomIndex(goodChoices));
dPChHand.remove(dC);
if (mode.startsWith("Reveal")) {
final List<Card> dCs = new ArrayList<Card>();
dCs.add(dC);
@@ -274,7 +273,7 @@ public class DiscardEffect extends RevealEffectBase {
if (mode.startsWith("Reveal")) {
GuiChoose.oneOrNone("Revealed " + p + " hand", dPHand);
}
for (int i = 0; i < numCards; i++) {
if (dPChHand.size() > 0) {
Card dC = null;
@@ -294,13 +293,13 @@ public class DiscardEffect extends RevealEffectBase {
}
}
}
if (sa.hasParam("RememberDiscarded")) {
for (final Card c : discarded) {
source.addRemembered(c);
}
}
} // discardResolve()
}
}

View File

@@ -13,19 +13,19 @@ public class DrainManaEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final List<Player> tgtPlayers = getTargetPlayers(sa);
sb.append(StringUtils.join(tgtPlayers, ", "));
sb.append(" empties his or her mana pool.");
return sb.toString();
}
@Override
public void resolve(SpellAbility sa) {
final Target tgt = sa.getTarget();
for (final Player p : getTargetPlayers(sa)) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
p.getManaPool().clearPool(false);
@@ -33,4 +33,4 @@ public class DrainManaEffect extends SpellEffect {
}
}
}
}

View File

@@ -18,24 +18,23 @@ public class DrawEffect extends SpellEffect {
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
final String conditionDesc = sa.getParam("ConditionDescription");
if (conditionDesc != null) {
sb.append(conditionDesc).append(" ");
}
final List<Player> tgtPlayers = getDefinedPlayersBeforeTargetOnes(sa);
if (!tgtPlayers.isEmpty()) {
sb.append(StringUtils.join(tgtPlayers, " and "));
int numCards = 1;
if (sa.hasParam("NumCards")) {
numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), sa.getParam("NumCards"), sa);
}
if (tgtPlayers.size() > 1) {
sb.append(" each");
}
@@ -44,14 +43,14 @@ public class DrawEffect extends SpellEffect {
sb.append("s");
}
sb.append(" (").append(numCards).append(")");
if (sa.hasParam("NextUpkeep")) {
sb.append(" at the beginning of the next upkeep");
}
sb.append(".");
}
return sb.toString();
}
@@ -112,4 +111,4 @@ public class DrawEffect extends SpellEffect {
}
}
} // drawResolve()
}
}