- CheckStyle.

This commit is contained in:
Chris
2012-12-18 18:01:02 +00:00
parent 48666ed8e6
commit a0c8e7a50c
19 changed files with 113 additions and 107 deletions

View File

@@ -656,6 +656,9 @@ public class Card extends GameEntity implements Comparable<Card> {
this.imprintedCards.addAll(list);
}
/**
* TODO: Write javadoc for this method.
*/
public final void removeImprinted(final Object o) {
this.imprintedCards.remove(o);
}

View File

@@ -1527,7 +1527,7 @@ public class GameAction {
return false;
}
if (c.canBeShielded()
if (c.canBeShielded()
&& (c.getShield() > 0 || c.hasKeyword("If CARDNAME would be destroyed, regenerate it."))) {
c.subtractShield();
c.setDamage(0);

View File

@@ -84,7 +84,7 @@ public class DiscardAi extends SpellAiLogic {
}
// TODO: Implement support for Discard AI for cards with AnyNumber set to true.
// Don't use draw abilities before main 2 if possible
if (Singletons.getModel().getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
&& !sa.hasParam("ActivationPhases")) {

View File

@@ -133,7 +133,7 @@ public abstract class PumpAiBase extends SpellAiLogic {
if (card.getShield() > 0) {
return true;
}
if (card.hasKeyword("If CARDNAME would be destroyed, regenerate it.")
if (card.hasKeyword("If CARDNAME would be destroyed, regenerate it.")
&& (card.isBlocked() || card.isBlocking())) {
return true;
}

View File

@@ -419,7 +419,7 @@ public class ChangeZoneEffect extends SpellEffect {
tgtC.clearUnEnchantCommand();
}
tgtC.enchantEntity(attachedTo);
} else {//Equipment
} else { //Equipment
if (tgtC.isEquipping()) {
final Card oldEquiped = tgtC.getEquippingCard();
tgtC.removeEquipping(oldEquiped);
@@ -689,7 +689,7 @@ public class ChangeZoneEffect extends SpellEffect {
c.clearUnEnchantCommand();
}
c.enchantEntity(attachedTo);
} else {//Equipment
} else { //Equipment
if (c.isEquipping()) {
final Card oldEquiped = c.getEquippingCard();
c.removeEquipping(oldEquiped);

View File

@@ -52,8 +52,8 @@ public class DiscardEffect extends RevealEffectBase {
sb.append("All");
} else if (sa.hasParam("AnyNumber")) {
sb.append("any number");
} else if (sa.hasParam("NumCards") && sa.getParam("NumCards").equals("X") &&
sa.getSVar("X").equals("Remembered$Amount")) {
} else if (sa.hasParam("NumCards") && sa.getParam("NumCards").equals("X")
&& sa.getSVar("X").equals("Remembered$Amount")) {
sb.append("that many");
} else {
sb.append(numCards);

View File

@@ -322,7 +322,7 @@ public class Cost {
final String description = splitStr.length > 2 ? splitStr[2] : null;
this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, ZoneType.Library));
}
while (parse.contains(Cost.EXILE_SAME_GRAVE_STR)) {
final String[] splitStr = this.abCostParse(parse, Cost.EXILE_SAME_GRAVE_STR, 3);
parse = this.abUpdateParse(parse, Cost.EXILE_SAME_GRAVE_STR);

View File

@@ -81,7 +81,7 @@ public class CostExile extends CostPartWithList {
this.from = from;
}
}
public CostExile(final String amount, final String type, final String description, final ZoneType from, final boolean sameZone) {
this(amount, type, description, from);
this.sameZone = sameZone;
@@ -131,13 +131,13 @@ public class CostExile extends CostPartWithList {
if ((i == null) || (i > 1)) {
sb.append("s");
}
if (this.sameZone) {
sb.append(" from the same ");
} else {
sb.append(" from your ");
}
sb.append(this.from);
return sb.toString();
@@ -186,11 +186,11 @@ public class CostExile extends CostPartWithList {
if ((amount != null) && (typeList.size() < amount)) {
return false;
}
if (this.sameZone && amount != null) {
boolean foundPayable = false;
List<Player> players = game.getPlayers();
for(Player p : players) {
for (Player p : players) {
if (CardLists.filter(typeList, CardPredicates.isController(p)).size() >= amount) {
foundPayable = true;
break;
@@ -243,13 +243,13 @@ public class CostExile extends CostPartWithList {
final GameState game = Singletons.getModel().getGame();
final Player activator = ability.getActivatingPlayer();
List<Card> list;
if (this.sameZone) {
list = new ArrayList<Card>(game.getCardsIn(this.getFrom()));
} else {
list = new ArrayList<Card>(activator.getCardsIn(this.getFrom()));
}
if (this.getType().equals("All")) {
this.setList(list);
for (final Card card : list) {
@@ -283,7 +283,7 @@ public class CostExile extends CostPartWithList {
} else if (this.sameZone) {
List<Player> players = game.getPlayers();
List<Player> payableZone = new ArrayList<Player>();
for(Player p : players) {
for (Player p : players) {
List<Card> enoughType = CardLists.filter(list, CardPredicates.isOwner(p));
if (enoughType.size() < c) {
list.removeAll(enoughType);
@@ -291,7 +291,7 @@ public class CostExile extends CostPartWithList {
payableZone.add(p);
}
}
final Input inp = CostExile.exileFromSame(ability, this, this.getType(), payment, list, payableZone, c);
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
} else {
@@ -335,7 +335,7 @@ public class CostExile extends CostPartWithList {
this.setList(ai.getCardsIn(ZoneType.Library, c));
} else if (this.sameZone) {
// TODO Determine exile from same zone for AI
return false;
return false;
} else {
this.setList(ComputerUtil.chooseExileFrom(ai, this.getFrom(), this.getType(), source,
ability.getTargetCard(), c));
@@ -490,12 +490,12 @@ public class CostExile extends CostPartWithList {
sb.append("Exile from whose ");
sb.append(part.getFrom().toString());
sb.append("?");
final Player p = GuiChoose.oneOrNone(sb.toString(), payableZone);
if (p == null) {
this.cancel();
}
typeList = CardLists.filter(list, CardPredicates.isOwner(p));
for (int i = 0; i < nNeeded; i++) {
@@ -537,8 +537,8 @@ public class CostExile extends CostPartWithList {
};
return target;
} // exileFrom()
/**
* Exile from Stack.
*

View File

@@ -190,7 +190,7 @@ public class ManaPool {
return numRemoved;
}
if (isEndOfPhase && this.owner.hasKeyword("Green mana doesn't empty from your mana pool as steps and phases end.")){
if (isEndOfPhase && this.owner.hasKeyword("Green mana doesn't empty from your mana pool as steps and phases end.")) {
// Omnath in play, clear all non-green mana
int i = 0;
while (i < this.floatingMana.size()) {

View File

@@ -482,8 +482,8 @@ public class SpellPermanent extends Spell {
}
final SpellAbility exSA = af.getAbility(card.getSVar(execute), card);
if (api != null) {
if(exSA.getApi() != api) {
if (api != null) {
if (exSA.getApi() != api) {
continue;
} else {
rightapi = true;

View File

@@ -267,9 +267,9 @@ public class TriggerHandler {
if (this.suppressedModes.contains(mode)) {
return;
}
final GameState game = Singletons.getModel().getGame();
runWaitingTrigger(new TriggerWaiting(mode, runParams));
/* Temporarily commented out while timing kinks with some other cards are worked out
if (game.getStack().isFrozen()) {
@@ -277,10 +277,10 @@ public class TriggerHandler {
} else {
runWaitingTrigger(new TriggerWaiting(mode, runParams));
}
*/
}
public final boolean runWaitingTriggers() {
ArrayList<TriggerWaiting> waiting = new ArrayList<TriggerWaiting>(waitingTriggers);
waitingTriggers.clear();
@@ -288,10 +288,10 @@ public class TriggerHandler {
for (TriggerWaiting wt : waiting) {
runWaitingTrigger(wt);
}
return haveWaiting;
}
public final void runWaitingTrigger(TriggerWaiting wt) {
final TriggerType mode = wt.getMode();
final Map<String, Object> runParams = wt.getParams();

View File

@@ -3,21 +3,21 @@ package forge.card.trigger;
import java.util.Map;
/**
* TriggerWaiting is just a small object to keep track of things that occurred that need to be run
* TriggerWaiting is just a small object to keep track of things that occurred that need to be run.
*/
public class TriggerWaiting {
private TriggerType mode;
private Map<String, Object> params;
public TriggerWaiting(TriggerType m, Map<String, Object> p) {
mode = m;
params = p;
}
public TriggerType getMode() {
return mode;
}
public Map<String, Object> getParams() {
return params;
}

View File

@@ -176,12 +176,12 @@ public class InputMulligan extends Input {
ga.checkStateEffects();
Singletons.getModel().getMatch().getInput().clearInput();
//Set Field shown to current player.
Player next = game.getPhaseHandler().getPlayerTurn();
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(next);
SDisplayUtil.showTab(nextField);
game.getPhaseHandler().nextPhase();
}

View File

@@ -162,11 +162,12 @@ public class Deck extends DeckBase {
result.sideboard.addAll(this.sideboard);
result.avatar = this.avatar;
result.commander = this.commander;
//This if clause is really only necessary when cloning decks that were
//around before schemes.
if(this.schemes != null)
if (this.schemes != null) {
result.schemes.addAll(this.schemes);
}
}
/*
@@ -369,7 +370,7 @@ public class Deck extends DeckBase {
public boolean meetsGameTypeRequirements(GameType type) {
return meetsGameTypeRequirements(type, true);
}
public boolean meetsGameTypeRequirements(GameType type, boolean silent) {
int deckSize = getMain().countAll();
int deckDistinct = getMain().countDistinct();
@@ -380,12 +381,12 @@ public class Deck extends DeckBase {
StringBuilder errMsg = new StringBuilder("Current deck doesn't meet the requirements (minimum ");
errMsg.append(type.getDeckMinimum());
errMsg.append(" cards), please correct or choose another deck.");
JOptionPane.showMessageDialog(null, errMsg.toString(), "Invalid deck", JOptionPane.ERROR_MESSAGE);
}
return false;
}
if ((max != null && deckSize > max) || (type.isSingleton() && deckDistinct != deckSize)) {
return false;
}
@@ -437,12 +438,12 @@ public class Deck extends DeckBase {
}
}
}
else if (type == GameType.Constructed || type == GameType.Quest) {
else if (type == GameType.Constructed || type == GameType.Quest) {
//Must contain no more than 4 of the same card
//shared among the main deck and sideboard, except
//basic lands and Relentless Rats
TreeMap<CardPrinted, Integer> cardCounts = new TreeMap<CardPrinted, Integer>();
DeckSection tmp = new DeckSection(this.getMain());
tmp.addAll(this.getSideboard());
@@ -456,7 +457,7 @@ public class Deck extends DeckBase {
StringBuilder errMsg = new StringBuilder("More than four \"");
errMsg.append(cp.getName());
errMsg.append("\" cards are placed in your deck, please correct or choose another deck.");
JOptionPane.showMessageDialog(null, errMsg.toString(), "Invalid deck", JOptionPane.ERROR_MESSAGE);
}
return false;
@@ -471,7 +472,7 @@ public class Deck extends DeckBase {
}
return false;
}
}
return true;
@@ -525,7 +526,7 @@ public class Deck extends DeckBase {
sideboardEdited = new DeckSection();
}
}
public void startDeckEdits() {
isEdited = true;
if (mainEdited.countAll() == 0) {

View File

@@ -248,11 +248,13 @@ public class DeckgenUtil {
final String dName = deck.getName();
deckList.append(dName == null ? "" : dName + nl + nl);
if(deck.getAvatar() != null)
if (deck.getAvatar() != null) {
deckList.append("Avatar: " + deck.getAvatar().getName() + nl + nl);
if(deck.getCommander() != null)
}
if (deck.getCommander() != null) {
deckList.append("Commander: " + deck.getCommander().getName() + nl + nl);
}
for (final Entry<String, Integer> ev : deckMap.entrySet()) {
deckList.append(ev.getValue() + " x " + ev.getKey() + nl);
@@ -307,32 +309,31 @@ public class DeckgenUtil {
}
return result;
}
public static Deck generateSchemeDeck() {
Deck res = new Deck();
Iterable<CardPrinted> allSchemes = Iterables.filter(CardDb.instance().getAllNonTraditionalCards(),CardPrinted.Predicates.type("Scheme"));
for(int i=0;i<20;i++) {
Iterable<CardPrinted> allSchemes = Iterables.filter(CardDb.instance().getAllNonTraditionalCards(), CardPrinted.Predicates.type("Scheme"));
for (int i = 0; i < 20; i++) {
CardPrinted cp = Iterables.get(allSchemes, MyRandom.getRandom().nextInt(Iterables.size(allSchemes)));
int appearances = 0;
for(CardPrinted added : res.getSchemes().toFlatList()) {
if(added.getName().equals(cp.getName()))
{
for (CardPrinted added : res.getSchemes().toFlatList()) {
if (added.getName().equals(cp.getName())) {
appearances++;
}
}
if(appearances < 2)
{
if (appearances < 2) {
res.getSchemes().add(cp);
}
else
{
} else {
i--;
}
}
return res;
}
}

View File

@@ -47,8 +47,8 @@ import forge.util.MyRandom;
* All of these methods can and should be static.
*/
public class GameNew {
private static void prepareGameLibrary(Player player, Deck deck, Map<Player, List<String>> removedAnteCards, List<String> rAICards, boolean canRandomFoil, Random generator, boolean useAnte) {
private static void prepareGameLibrary(Player player, Deck deck, Map<Player, List<String>> removedAnteCards, List<String> rAICards, boolean canRandomFoil, Random generator, boolean useAnte) {
PlayerZone library = player.getZone(ZoneType.Library);
PlayerZone sideboard = player.getZone(ZoneType.Sideboard);
for (final Entry<CardPrinted, Integer> stackOfCards : deck.getMain()) {
@@ -119,14 +119,14 @@ public class GameNew {
sideboard.add(card);
}
// TODO: Enable the code below for Limited modes only when the AI can play all the
// TODO: Enable the code below for Limited modes only when the AI can play all the
// cards in the sideboard (probably means all cards in Forge because in Limited mode,
// any cards can end up in the AI sideboard?)
// mark card as difficult for AI to play
if (player.isComputer() && card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
if (Singletons.getModel().getMatch().getGameType() != GameType.Draft &&
Singletons.getModel().getMatch().getGameType() != GameType.Sealed) {
if (Singletons.getModel().getMatch().getGameType() != GameType.Draft
&& Singletons.getModel().getMatch().getGameType() != GameType.Sealed) {
rAICards.add(card.getName());
// get card picture so that it is in the image cache
// ImageCache.getImage(card);
@@ -162,15 +162,15 @@ public class GameNew {
private static boolean sideboardAndPrepareLibrary(final Player player, final Deck deck, boolean canRandomFoil, Random generator, boolean useAnte) {
final GameType gameType = Singletons.getModel().getMatch().getGameType();
boolean hasSideboard = (deck.getSideboard().countAll() > 0);
PlayerZone library = player.getZone(ZoneType.Library);
DeckSection sideboard = deck.getSideboard();
int sideboardSize = (gameType == GameType.Draft || gameType == GameType.Sealed) ? -1 : sideboard.countAll();
if (!hasSideboard) {
return false;
}
if (player.isComputer()) {
// Here is where the AI could sideboard, but needs to gather hints during the first game about what to SB
@@ -193,7 +193,7 @@ public class GameNew {
JOptionPane.showMessageDialog(null, errMsg.toString(), "Invalid deck", JOptionPane.ERROR_MESSAGE);
}
}
}
return true;
}
@@ -243,17 +243,17 @@ public class GameNew {
if (inCommand != null) {
for (final Card c : inCommand) {
c.setOwner(player);
com.add(c, false);
c.refreshUniqueNumber();
}
}
Iterable<Card> schemes = p.getValue().getSchemes();
if(schemes != null) {
if (schemes != null) {
player.setSchemeDeck(schemes);
}
prepareSingleLibrary(player, p.getValue().getDeck(), removedAnteCards, rAICards, canRandomFoil);
player.updateObservers();

View File

@@ -49,25 +49,25 @@ public class MatchStartHelper {
players.put(player, start);
}
public void addArchenemy(final LobbyPlayer player, final Deck deck, final Iterable<CardPrinted> schemes) {
PlayerStartConditions start = new PlayerStartConditions(deck);
start.setSchemes(new Supplier<Iterable<Card>>() {
@Override
public Iterable<Card> get() {
List<Card> res = new ArrayList<Card>();
for(CardPrinted cp : schemes)
{
for (CardPrinted cp : schemes) {
res.add(cp.toForgeCard());
}
return res;
}
});
players.put(player, start);
}

View File

@@ -270,10 +270,11 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
this.getPlayerTurn().drawCards(1, true);
}
break;
case MAIN1:
if(this.getPlayerTurn().isArchenemy())
if (this.getPlayerTurn().isArchenemy()) {
this.getPlayerTurn().setSchemeInMotion();
}
break;
case COMBAT_BEGIN:
@@ -540,7 +541,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
Player next = getNextActivePlayer();
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(next);
SDisplayUtil.showTab(nextField);
return next;
}
@@ -717,32 +718,32 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
if (game.isGameOver()) {
return;
}
//904.10. If a non-ongoing scheme card is face up in the
//command zone, and it isn't the source of a triggered ability
//that has triggered but not yet left the stack, that scheme card
//is turned face down and put on the bottom of its owner's scheme
//deck the next time a player would receive priority.
//904.10. If a non-ongoing scheme card is face up in the
//command zone, and it isn't the source of a triggered ability
//that has triggered but not yet left the stack, that scheme card
//is turned face down and put on the bottom of its owner's scheme
//deck the next time a player would receive priority.
//(This is a state-based action. See rule 704.)
for (int i=0; i<game.getCardsIn(ZoneType.Command).size();i++) {
for (int i = 0; i < game.getCardsIn(ZoneType.Command).size(); i++) {
Card c = game.getCardsIn(ZoneType.Command).get(i);
if(c.isScheme() && !c.isType("Ongoing"))
{
if (c.isScheme() && !c.isType("Ongoing")) {
boolean foundonstack = false;
for(SpellAbilityStackInstance si : game.getStack().getStack()) {
if(si.getSourceCard().equals(c))
{
for (SpellAbilityStackInstance si : game.getStack().getStack()) {
if (si.getSourceCard().equals(c)) {
foundonstack = true;
break;
}
}
if(!foundonstack)
{
if (!foundonstack) {
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
c.getController().getZone(ZoneType.Command).remove(c);
i--;
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
c.getController().getSchemeDeck().add(c);
}
}

View File

@@ -618,11 +618,11 @@ public class Upkeep extends Phase {
for (int i = 0; i < cards.size(); i++) {
final Card c = cards.get(i);
final Ability cost = new Ability(c, "B B B") {
@Override
public void resolve() {
}
}
}; // end cost ability
final Ability noPay = new Ability(c, "0") {
@@ -634,7 +634,7 @@ public class Upkeep extends Phase {
if (c.getController().isComputer()) {
if (playerLand.size() > 0) {
final Card target = GuiChoose.one("Select a card to sacrifice", playerLand);
Singletons.getModel().getGame().getAction().sacrifice(target, null);
}
} else {