diff --git a/.gitattributes b/.gitattributes index 7450ca714e4..79de22799e1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -112,7 +112,6 @@ forge-game/.settings/org.eclipse.core.resources.prefs -text forge-game/.settings/org.eclipse.jdt.core.prefs -text forge-game/.settings/org.eclipse.m2e.core.prefs -text forge-game/pom.xml -text -forge-game/src/main/java/forge/game/FormatCollection.java -text forge-game/src/main/java/forge/game/GameFormat.java -text forge-game/src/main/java/forge/game/package-info.java -text forge-gui/.classpath -text @@ -15100,10 +15099,10 @@ forge-gui/src/main/java/forge/error/package-info.java svneol=native#text/plain forge-gui/src/main/java/forge/game/Game.java -text forge-gui/src/main/java/forge/game/GameAction.java svneol=native#text/plain forge-gui/src/main/java/forge/game/GameActionUtil.java svneol=native#text/plain -forge-gui/src/main/java/forge/game/GameAge.java -text forge-gui/src/main/java/forge/game/GameEndReason.java -text forge-gui/src/main/java/forge/game/GameNew.java -text forge-gui/src/main/java/forge/game/GameOutcome.java -text +forge-gui/src/main/java/forge/game/GameStage.java -text forge-gui/src/main/java/forge/game/GameType.java -text forge-gui/src/main/java/forge/game/GlobalRuleChange.java -text forge-gui/src/main/java/forge/game/Match.java -text @@ -15201,7 +15200,6 @@ forge-gui/src/main/java/forge/game/player/PlayerOutcome.java -text forge-gui/src/main/java/forge/game/player/PlayerStatistics.java -text forge-gui/src/main/java/forge/game/player/PlayerType.java svneol=native#text/plain forge-gui/src/main/java/forge/game/player/package-info.java svneol=native#text/plain -forge-gui/src/main/java/forge/game/zone/IZone.java svneol=native#text/plain forge-gui/src/main/java/forge/game/zone/MagicStack.java svneol=native#text/plain forge-gui/src/main/java/forge/game/zone/PlayerZone.java svneol=native#text/plain forge-gui/src/main/java/forge/game/zone/PlayerZoneBattlefield.java svneol=native#text/plain diff --git a/forge-core/src/main/java/forge/StaticData.java b/forge-core/src/main/java/forge/StaticData.java index 9d402daa94d..4bac3018372 100644 --- a/forge-core/src/main/java/forge/StaticData.java +++ b/forge-core/src/main/java/forge/StaticData.java @@ -1,8 +1,6 @@ package forge; import java.io.File; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -11,7 +9,6 @@ import forge.card.CardEdition; import forge.card.CardRules; import forge.card.PrintSheet; import forge.item.FatPack; -import forge.item.PaperCard; import forge.item.SealedProduct; import forge.util.storage.IStorage; import forge.util.storage.StorageBase; diff --git a/forge-core/src/main/java/forge/card/CardCharacteristicName.java b/forge-core/src/main/java/forge/card/CardCharacteristicName.java index 92148724514..81571df0f32 100644 --- a/forge-core/src/main/java/forge/card/CardCharacteristicName.java +++ b/forge-core/src/main/java/forge/card/CardCharacteristicName.java @@ -1,7 +1,5 @@ package forge.card; -import org.apache.commons.lang3.StringUtils; - /** * TODO: Write javadoc for this type. * diff --git a/forge-game/src/main/java/forge/game/FormatCollection.java b/forge-game/src/main/java/forge/game/FormatCollection.java deleted file mode 100644 index d2ed383e663..00000000000 --- a/forge-game/src/main/java/forge/game/FormatCollection.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Forge: Play Magic: the Gathering. - * Copyright (C) 2011 Forge Team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package forge.game; - -/** - * The Class FormatUtils. - */ - - -/** - * TODO: Write javadoc for this type. - * - */ diff --git a/forge-gui/src/main/java/forge/card/ability/effects/RestartGameEffect.java b/forge-gui/src/main/java/forge/card/ability/effects/RestartGameEffect.java index cefdc381818..82c71236a6d 100644 --- a/forge-gui/src/main/java/forge/card/ability/effects/RestartGameEffect.java +++ b/forge-gui/src/main/java/forge/card/ability/effects/RestartGameEffect.java @@ -14,7 +14,7 @@ import forge.card.spellability.SpellAbility; import forge.card.trigger.TriggerHandler; import forge.card.trigger.TriggerType; import forge.game.GameAction; -import forge.game.GameAge; +import forge.game.GameStage; import forge.game.GameNew; import forge.game.Game; import forge.game.RegisteredPlayer; @@ -88,7 +88,7 @@ public class RestartGameEffect extends SpellAbilityEffect { trigHandler.clearSuppression(TriggerType.ChangesZone); - game.setAge(GameAge.RestartedByKarn); + game.setAge(GameStage.RestartedByKarn); // Do not need this because ability will resolve only during that player's turn //game.getPhaseHandler().setPlayerTurn(sa.getActivatingPlayer()); diff --git a/forge-gui/src/main/java/forge/game/Game.java b/forge-gui/src/main/java/forge/game/Game.java index 7a1fe46c7af..393f0985a2e 100644 --- a/forge-gui/src/main/java/forge/game/Game.java +++ b/forge-gui/src/main/java/forge/game/Game.java @@ -77,7 +77,7 @@ public class Game { private long timestamp = 0; public final GameAction action; private final Match match; - private GameAge age = GameAge.BeforeMulligan; + private GameStage age = GameStage.BeforeMulligan; private GameOutcome outcome; /** @@ -280,7 +280,7 @@ public class Game { * @return the gameOver */ public synchronized boolean isGameOver() { - return age == GameAge.GameOver; + return age == GameStage.GameOver; } /** @@ -288,7 +288,7 @@ public class Game { * @param go the gameOver to set */ public synchronized void setGameOver(GameEndReason reason) { - this.age = GameAge.GameOver; + this.age = GameStage.GameOver; for (Player p : allPlayers ) { if (p.isMindSlaved()) p.releaseControl(); // for correct totals @@ -562,11 +562,11 @@ public class Game { } } - public GameAge getAge() { + public GameStage getAge() { return age; } - public void setAge(GameAge value) { + public void setAge(GameStage value) { age = value; } diff --git a/forge-gui/src/main/java/forge/game/GameAction.java b/forge-gui/src/main/java/forge/game/GameAction.java index 4a84ebd847f..490d3c60a0e 100644 --- a/forge-gui/src/main/java/forge/game/GameAction.java +++ b/forge-gui/src/main/java/forge/game/GameAction.java @@ -731,7 +731,8 @@ public class GameAction { com.apply(game); } - GameActionUtil.grantBasicLandsManaAbilities(game); + List lands = game.getCardsIn(ZoneType.Battlefield); + GameActionUtil.grantBasicLandsManaAbilities(CardLists.filter(lands, CardPredicates.Presets.LANDS)); // Exclude cards in hidden zones from update Iterator it = affectedCards.iterator(); @@ -1441,14 +1442,14 @@ public class GameAction { // Where there are none, it should bring up speed controls game.fireEvent(new GameEventGameStarted(game.getType(), first, game.getPlayers())); - game.setAge(GameAge.Mulligan); + game.setAge(GameStage.Mulligan); for (final Player p1 : game.getPlayers()) p1.drawCards(p1.getMaxHandSize()); performMulligans(first, game.getType() == GameType.Commander); if ( game.isGameOver() ) break; // conceded during "mulligan" prompt - game.setAge(GameAge.Play); + game.setAge(GameStage.Play); // THIS CODE WILL WORK WITH PHASE = NULL { if(game.getType() == GameType.Planechase) @@ -1465,7 +1466,7 @@ public class GameAction { game.getPhaseHandler().startFirstTurn(first); first = game.getPhaseHandler().getPlayerTurn(); // needed only for restart - } while( game.getAge() == GameAge.RestartedByKarn ); + } while( game.getAge() == GameStage.RestartedByKarn ); // will pull UI dialog, when the UI is listening game.fireEvent(new GameEventGameFinished()); diff --git a/forge-gui/src/main/java/forge/game/GameActionUtil.java b/forge-gui/src/main/java/forge/game/GameActionUtil.java index 41bef8c9e25..d0d47dad4ec 100644 --- a/forge-gui/src/main/java/forge/game/GameActionUtil.java +++ b/forge-gui/src/main/java/forge/game/GameActionUtil.java @@ -31,7 +31,6 @@ import com.google.common.collect.Lists; import forge.Card; import forge.CardLists; import forge.CardPredicates; -import forge.CardPredicates.Presets; import forge.Command; import forge.card.MagicColor; import forge.card.ability.AbilityFactory; @@ -198,10 +197,7 @@ public final class GameActionUtil { * * @return the stLandManaAbilities */ - public static void grantBasicLandsManaAbilities(Game game) { - List lands = game.getCardsIn(ZoneType.Battlefield); - lands = CardLists.filter(lands, Presets.LANDS); - + public static void grantBasicLandsManaAbilities(List lands) { // remove all abilities granted by this Command for (final Card land : lands) { List origManaAbs = Lists.newArrayList(land.getManaAbility()); diff --git a/forge-gui/src/main/java/forge/game/GameAge.java b/forge-gui/src/main/java/forge/game/GameStage.java similarity index 75% rename from forge-gui/src/main/java/forge/game/GameAge.java rename to forge-gui/src/main/java/forge/game/GameStage.java index b6770e03760..75b5b8c4d36 100644 --- a/forge-gui/src/main/java/forge/game/GameAge.java +++ b/forge-gui/src/main/java/forge/game/GameStage.java @@ -1,6 +1,6 @@ package forge.game; -public enum GameAge { +public enum GameStage { BeforeMulligan, Mulligan, Play, diff --git a/forge-gui/src/main/java/forge/game/phase/PhaseHandler.java b/forge-gui/src/main/java/forge/game/phase/PhaseHandler.java index 9b43aace635..9279842e45b 100644 --- a/forge-gui/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-gui/src/main/java/forge/game/phase/PhaseHandler.java @@ -40,7 +40,7 @@ import forge.card.mana.ManaCost; import forge.card.spellability.SpellAbility; import forge.card.staticability.StaticAbility; import forge.card.trigger.TriggerType; -import forge.game.GameAge; +import forge.game.GameStage; import forge.game.Game; import forge.game.GameType; import forge.game.GlobalRuleChange; @@ -1009,7 +1009,7 @@ public class PhaseHandler implements java.io.Serializable { } // If ever the karn's ultimate resolved - if( game.getAge() == GameAge.RestartedByKarn) { + if( game.getAge() == GameStage.RestartedByKarn) { phase = null; game.fireEvent(new GameEventGameRestarted(playerTurn)); return; diff --git a/forge-gui/src/main/java/forge/game/player/Player.java b/forge-gui/src/main/java/forge/game/player/Player.java index ea41f4fd727..bc8d3bdfae0 100644 --- a/forge-gui/src/main/java/forge/game/player/Player.java +++ b/forge-gui/src/main/java/forge/game/player/Player.java @@ -54,7 +54,7 @@ import forge.card.staticability.StaticAbility; import forge.card.trigger.TriggerType; import forge.game.Game; import forge.game.GameActionUtil; -import forge.game.GameAge; +import forge.game.GameStage; import forge.game.GameType; import forge.game.GlobalRuleChange; import forge.game.RegisteredPlayer; @@ -1403,7 +1403,7 @@ public class Player extends GameEntity implements Comparable { // Miracle draws if (this.numDrawnThisTurn == 1 && game.getPhaseHandler().getTurn() != 1 - && game.getAge() != GameAge.Mulligan) { + && game.getAge() != GameStage.Mulligan) { drawMiracle(c); } diff --git a/forge-gui/src/main/java/forge/game/zone/IZone.java b/forge-gui/src/main/java/forge/game/zone/IZone.java deleted file mode 100644 index 2afd410c082..00000000000 --- a/forge-gui/src/main/java/forge/game/zone/IZone.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Forge: Play Magic: the Gathering. - * Copyright (C) 2011 Forge Team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package forge.game.zone; - -import java.util.List; - -import com.google.common.base.Predicate; - -import forge.Card; -import forge.game.player.Player; - -/** - *

- * IPlayerZone interface. - *

- * - * @author Forge - * @version $Id$ - */ -interface IZone { - - int size(); - boolean isEmpty(); - - boolean contains(Card c); - boolean contains(final Predicate condition); - - void add(Card o); - void add(Card c, Integer index); - void remove(Card o); - void setCards(Iterable c); - - Card get(int index); - List getCards(boolean filter); - List getCards(); - - ZoneType getZoneType(); - Player getPlayer(); - boolean is(ZoneType zone); - boolean is(ZoneType zone, Player player); - - - void resetCardsAddedThisTurn(); -} diff --git a/forge-gui/src/main/java/forge/game/zone/Zone.java b/forge-gui/src/main/java/forge/game/zone/Zone.java index 9013926ed73..beabcbc3644 100644 --- a/forge-gui/src/main/java/forge/game/zone/Zone.java +++ b/forge-gui/src/main/java/forge/game/zone/Zone.java @@ -45,7 +45,7 @@ import forge.util.maps.MapOfLists; * @author Forge * @version $Id: PlayerZone.java 17582 2012-10-19 22:39:09Z Max mtg $ */ -public class Zone implements IZone, java.io.Serializable, Iterable { +public class Zone implements java.io.Serializable, Iterable { /** Constant serialVersionUID=-5687652485777639176L. */ private static final long serialVersionUID = -5687652485777639176L; @@ -66,17 +66,16 @@ public class Zone implements IZone, java.io.Serializable, Iterable { //System.out.println(zoneName + " (ct) " + Integer.toHexString(System.identityHashCode(roCardList))); } - @Override public Player getPlayer() { // generic zones like stack have no player associated return null; } - @Override + public final void add(final Card c) { add(c, null); } - @Override + public void add(final Card c, final Integer index) { // Immutable cards are usually emblems and effects @@ -99,7 +98,7 @@ public class Zone implements IZone, java.io.Serializable, Iterable { game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.Added, c)); } - @Override + public final boolean contains(final Card c) { return this.cardList.contains(c); } @@ -108,13 +107,12 @@ public class Zone implements IZone, java.io.Serializable, Iterable { return Iterables.any(this.cardList, condition); } - @Override public void remove(final Card c) { this.cardList.remove(c); game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.Removed, c)); } - @Override + public final void setCards(final Iterable cards) { cardList.clear(); for (Card c : cards) { @@ -125,39 +123,37 @@ public class Zone implements IZone, java.io.Serializable, Iterable { } - @Override + public final boolean is(final ZoneType zone) { return zone == this.zoneType; } // PlayerZone should override it with a correct implementation - @Override + public final boolean is(final ZoneType zone, final Player player) { return zoneType == zone && player == getPlayer(); } - @Override + public final ZoneType getZoneType() { return this.zoneType; } - @Override public final int size() { return this.cardList.size(); } - @Override + public final Card get(final int index) { return this.cardList.get(index); } - @Override public final List getCards() { //System.out.println(zoneName + ": " + Integer.toHexString(System.identityHashCode(roCardList))); return this.getCards(true); } - @Override + public List getCards(final boolean filter) { // Non-Battlefield PlayerZones don't care about the filter return this.roCardList; @@ -168,7 +164,7 @@ public class Zone implements IZone, java.io.Serializable, Iterable { * * @see forge.IPlayerZone#isEmpty() */ - @Override + public final boolean isEmpty() { return this.cardList.isEmpty(); } @@ -210,7 +206,6 @@ public class Zone implements IZone, java.io.Serializable, Iterable { * resetCardsAddedThisTurn. *

*/ - @Override public final void resetCardsAddedThisTurn() { this.cardsAddedThisTurn.clear(); }