- CheckStyle.

This commit is contained in:
Chris
2012-11-20 14:01:22 +00:00
parent 9fe78f441e
commit b9742e42eb
21 changed files with 174 additions and 171 deletions

View File

@@ -336,7 +336,7 @@ public class ChangeZoneEffect extends SpellEffect {
tgtCards = tgt.getTargetCards(); tgtCards = tgt.getTargetCards();
} else { } else {
tgtCards = new ArrayList<Card>(); tgtCards = new ArrayList<Card>();
for(ZoneType o : origin) { for (ZoneType o : origin) {
for (final Card c : sa.knownDetermineDefined(sa.getParam("Defined"))) { for (final Card c : sa.knownDetermineDefined(sa.getParam("Defined"))) {
tgtCards.add(c); tgtCards.add(c);
} }

View File

@@ -21,7 +21,7 @@ public class CharmEffect extends SpellEffect {
for (final String saChoice : saChoices) { for (final String saChoice : saChoices) {
final String ab = source.getSVar(saChoice); final String ab = source.getSVar(saChoice);
final AbilityFactory charmAF = new AbilityFactory(); final AbilityFactory charmAF = new AbilityFactory();
choices.add((AbilitySub)charmAF.getAbility(ab, source)); choices.add((AbilitySub) charmAF.getAbility(ab, source));
} }
return choices; return choices;
} }
@@ -52,8 +52,8 @@ public class CharmEffect extends SpellEffect {
List<AbilitySub> chosen = null; List<AbilitySub> chosen = null;
Player activator = sa.getActivatingPlayer(); Player activator = sa.getActivatingPlayer();
if ( activator.isHuman() ) if (activator.isHuman()) {
{
chosen = new ArrayList<AbilitySub>(); chosen = new ArrayList<AbilitySub>();
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
AbilitySub a; AbilitySub a;
@@ -69,19 +69,20 @@ public class CharmEffect extends SpellEffect {
choices.remove(a); choices.remove(a);
chosen.add(a); chosen.add(a);
} }
} } else {
else
chosen = CharmAi.chooseOptionsAi(activator, true, choices, num, min); chosen = CharmAi.chooseOptionsAi(activator, true, choices, num, min);
}
chainAbilities(sa, chosen); chainAbilities(sa, chosen);
} }
private static void chainAbilities(SpellAbility sa, List<AbilitySub> chosen) { private static void chainAbilities(SpellAbility sa, List<AbilitySub> chosen) {
SpellAbility saDeepest = sa; SpellAbility saDeepest = sa;
while( saDeepest.getSubAbility() != null) while (saDeepest.getSubAbility() != null) {
saDeepest = saDeepest.getSubAbility(); saDeepest = saDeepest.getSubAbility();
}
for(AbilitySub sub : chosen){ for (AbilitySub sub : chosen) {
saDeepest.setSubAbility(sub); saDeepest.setSubAbility(sub);
sub.setActivatingPlayer(saDeepest.getActivatingPlayer()); sub.setActivatingPlayer(saDeepest.getActivatingPlayer());
sub.setParent(saDeepest); sub.setParent(saDeepest);
@@ -92,5 +93,4 @@ public class CharmEffect extends SpellEffect {
} }
} }

View File

@@ -13,8 +13,7 @@ import forge.card.spellability.Target;
import forge.game.player.Player; import forge.game.player.Player;
import forge.gui.GuiChoose; import forge.gui.GuiChoose;
public class ChooseNumberEffect extends SpellEffect public class ChooseNumberEffect extends SpellEffect {
{
/* (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)

View File

@@ -19,7 +19,6 @@ import forge.gui.GuiChoose;
public class ChooseTypeEffect extends SpellEffect { public class ChooseTypeEffect extends SpellEffect {
@Override @Override
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View File

@@ -278,4 +278,4 @@ public class CloneEffect extends SpellEffect {
} }
} }

View File

@@ -80,20 +80,20 @@ public class ControlGainEffect extends SpellEffect {
List<Card> tgtCards = new ArrayList<Card>(); List<Card> tgtCards = new ArrayList<Card>();
Card source = sa.getSourceCard(); Card source = sa.getSourceCard();
final boolean bUntap = sa.hasParam("Untap"); final boolean bUntap = sa.hasParam("Untap");
final boolean bTapOnLose = sa.hasParam("TapOnLose"); final boolean bTapOnLose = sa.hasParam("TapOnLose");
final boolean bNoRegen = sa.hasParam("NoRegen"); final boolean bNoRegen = sa.hasParam("NoRegen");
final List<String> destroyOn = sa.hasParam("DestroyTgt") ? Arrays.asList(sa.getParam("DestroyTgt").split(",")) : null; 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 List<String> lose = sa.hasParam("LoseControl") ? Arrays.asList(sa.getParam("LoseControl").split(",")) : null;
final Target tgt = sa.getTarget(); final Target tgt = sa.getTarget();
if (sa.hasParam("AllValid")) { if (sa.hasParam("AllValid")) {
tgtCards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield); tgtCards = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
tgtCards = AbilityFactory.filterListByType(tgtCards, sa.getParam("AllValid"), sa); tgtCards = AbilityFactory.filterListByType(tgtCards, sa.getParam("AllValid"), sa);
} else } else {
tgtCards = getTargetCards(sa); tgtCards = getTargetCards(sa);
}
ArrayList<Player> controllers = new ArrayList<Player>(); ArrayList<Player> controllers = new ArrayList<Player>();
@@ -238,7 +238,7 @@ public class ControlGainEffect extends SpellEffect {
* @return a {@link forge.Command} object. * @return a {@link forge.Command} object.
*/ */
private Command getLoseControlCommand(final Card c, final Player originalController, final GameEntity newController, private Command getLoseControlCommand(final Card c, final Player originalController, final GameEntity newController,
final boolean bTapOnLose, final Card hostCard, final List<String> kws ) { final boolean bTapOnLose, final Card hostCard, final List<String> kws) {
final Command loseControl = new Command() { final Command loseControl = new Command() {
private static final long serialVersionUID = 878543373519872418L; private static final long serialVersionUID = 878543373519872418L;

View File

@@ -19,7 +19,7 @@ public class CounterEffect extends SpellEffect {
if (sa.hasParam("AllType")) { if (sa.hasParam("AllType")) {
sas = new ArrayList<SpellAbility>(); 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); SpellAbility spell = Singletons.getModel().getGame().getStack().peekAbility(i);
if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) { if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) {
continue; continue;
@@ -31,8 +31,9 @@ public class CounterEffect extends SpellEffect {
} }
sas.add(spell); sas.add(spell);
} }
} else } else {
sas = getTargetSpellAbilities(sa); sas = getTargetSpellAbilities(sa);
}
sb.append("countering"); sb.append("countering");
@@ -62,7 +63,7 @@ public class CounterEffect extends SpellEffect {
if (sa.hasParam("AllType")) { if (sa.hasParam("AllType")) {
sas = new ArrayList<SpellAbility>(); 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); SpellAbility spell = Singletons.getModel().getGame().getStack().peekAbility(i);
if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) { if (sa.getParam("AllType").equals("Spell") && !spell.isSpell()) {
continue; continue;
@@ -74,8 +75,9 @@ public class CounterEffect extends SpellEffect {
} }
sas.add(spell); sas.add(spell);
} }
} else } else {
sas = getTargetSpellAbilities(sa); sas = getTargetSpellAbilities(sa);
}
if (sa.hasParam("ForgetOtherTargets")) { if (sa.hasParam("ForgetOtherTargets")) {
if (sa.getParam("ForgetOtherTargets").equals("True")) { if (sa.getParam("ForgetOtherTargets").equals("True")) {

View File

@@ -35,10 +35,11 @@ public class CountersProliferateEffect extends SpellEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
Player controller = sa.getSourceCard().getController(); Player controller = sa.getSourceCard().getController();
if (controller.isHuman()) if (controller.isHuman()) {
resolveHuman(sa); resolveHuman(sa);
else } else {
resolveAI(controller, sa); resolveAI(controller, sa);
}
} }
private static void resolveHuman(final SpellAbility sa) { private static void resolveHuman(final SpellAbility sa) {
@@ -84,8 +85,8 @@ public class CountersProliferateEffect extends SpellEffect {
@Override @Override
public void selectPlayer(final Player player) { public void selectPlayer(final Player player) {
if (players.indexOf(player) >= 0) if (players.indexOf(player) >= 0) {
{
players.remove(player); // no second selection players.remove(player); // no second selection
if (player.getPoisonCounters() > 0) { if (player.getPoisonCounters() > 0) {
player.addPoisonCounters(1, sa.getSourceCard()); player.addPoisonCounters(1, sa.getSourceCard());
@@ -96,7 +97,6 @@ public class CountersProliferateEffect extends SpellEffect {
} }
private static void resolveAI(final Player ai, final SpellAbility sa) { private static void resolveAI(final Player ai, final SpellAbility sa) {
final List<Player> allies = ai.getAllies(); final List<Player> allies = ai.getAllies();
allies.add(ai); allies.add(ai);
@@ -105,10 +105,12 @@ public class CountersProliferateEffect extends SpellEffect {
@Override @Override
public boolean apply(Card crd) { public boolean apply(Card crd) {
for (final Entry<Counters, Integer> c1 : crd.getCounters().entrySet()) { 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; return true;
if ( !CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(crd.getController())) }
if (!CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(crd.getController())) {
return true; return true;
}
} }
return false; return false;
} }
@@ -116,9 +118,10 @@ public class CountersProliferateEffect extends SpellEffect {
List<Card> cardsToProliferate = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), predProliferate); List<Card> cardsToProliferate = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), predProliferate);
List<Player> playersToPoison = new ArrayList<Player>(); List<Player> playersToPoison = new ArrayList<Player>();
for( Player e : enemies ) { for (Player e : enemies) {
if ( e.getPoisonCounters() > 0 ) if (e.getPoisonCounters() > 0) {
playersToPoison.add(e); playersToPoison.add(e);
}
} }
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
@@ -126,17 +129,17 @@ public class CountersProliferateEffect extends SpellEffect {
if (cardsToProliferate.isEmpty() && playersToPoison.isEmpty()) { if (cardsToProliferate.isEmpty() && playersToPoison.isEmpty()) {
sb.append("<b>nothing</b>."); sb.append("<b>nothing</b>.");
} else { } else {
for( Card c : cardsToProliferate ) { for (Card c : cardsToProliferate) {
sb.append(c.getController().getName()); sb.append(c.getController().getName());
sb.append("'s <b>"); sb.append("'s <b>");
sb.append(c.getName()); sb.append(c.getName());
sb.append("</b><br>"); sb.append("</b><br>");
} }
if( !playersToPoison.isEmpty() ) { if (!playersToPoison.isEmpty()) {
sb.append("<br>The following players: <br>"); sb.append("<br>The following players: <br>");
} }
for( Player p : playersToPoison ) { for (Player p : playersToPoison) {
sb.append("<b>"); sb.append("<b>");
sb.append(p.getName()); sb.append(p.getName());
sb.append("</b><br>"); sb.append("</b><br>");
@@ -148,12 +151,12 @@ public class CountersProliferateEffect extends SpellEffect {
// computer // computer
for (final Card c : cardsToProliferate) { for (final Card c : cardsToProliferate) {
for (final Entry<Counters, Integer> c1 : c.getCounters().entrySet()) { 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); c.addCounter(c1.getKey(), 1);
break; break;
} }
if ( !CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(c.getController())) if (!CardFactoryUtil.isNegativeCounter(c1.getKey()) && allies.contains(c.getController()))
{ {
c.addCounter(c1.getKey(), 1); c.addCounter(c1.getKey(), 1);
break; break;
@@ -161,7 +164,7 @@ public class CountersProliferateEffect extends SpellEffect {
} }
} }
for(final Player p : playersToPoison ) { for (final Player p : playersToPoison) {
p.addPoisonCounters(1, sa.getSourceCard()); p.addPoisonCounters(1, sa.getSourceCard());
} }
} }