All new game methods consolidated into forge.game.GameNew.

GameAction moved from AllZone into FModel.
Singleton pattern enforced on FModel.
Match/game state reset persist bug fixed.
This commit is contained in:
Doublestrike
2012-02-20 13:20:41 +00:00
parent 755639e4cc
commit 6ffe3479c3
74 changed files with 1321 additions and 1440 deletions

4
.gitattributes vendored
View File

@@ -11251,7 +11251,9 @@ src/main/java/forge/error/package-info.java svneol=native#text/plain
src/main/java/forge/game/GameEndReason.java -text src/main/java/forge/game/GameEndReason.java -text
src/main/java/forge/game/GameFormat.java -text src/main/java/forge/game/GameFormat.java -text
src/main/java/forge/game/GameLossReason.java -text src/main/java/forge/game/GameLossReason.java -text
src/main/java/forge/game/GameNew.java -text
src/main/java/forge/game/GamePlayerRating.java -text src/main/java/forge/game/GamePlayerRating.java -text
src/main/java/forge/game/GameState.java -text
src/main/java/forge/game/GameSummary.java svneol=native#text/plain src/main/java/forge/game/GameSummary.java svneol=native#text/plain
src/main/java/forge/game/GameType.java -text src/main/java/forge/game/GameType.java -text
src/main/java/forge/game/limited/BoosterDraft.java svneol=native#text/plain src/main/java/forge/game/limited/BoosterDraft.java svneol=native#text/plain
@@ -11317,7 +11319,6 @@ src/main/java/forge/item/ItemPoolView.java -text
src/main/java/forge/item/PreconDeck.java -text src/main/java/forge/item/PreconDeck.java -text
src/main/java/forge/item/package-info.java -text src/main/java/forge/item/package-info.java -text
src/main/java/forge/model/BuildInfo.java -text src/main/java/forge/model/BuildInfo.java -text
src/main/java/forge/model/FGameState.java -text
src/main/java/forge/model/FMatchState.java svneol=native#text/plain src/main/java/forge/model/FMatchState.java svneol=native#text/plain
src/main/java/forge/model/FModel.java svneol=native#text/plain src/main/java/forge/model/FModel.java svneol=native#text/plain
src/main/java/forge/model/MultipleForgeJarsFoundError.java -text src/main/java/forge/model/MultipleForgeJarsFoundError.java -text
@@ -11472,7 +11473,6 @@ src/test/java/forge/BoosterDraft1Test.java svneol=native#text/plain
src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain
src/test/java/forge/CardColorTest.java svneol=native#text/plain src/test/java/forge/CardColorTest.java svneol=native#text/plain
src/test/java/forge/CardReaderTest.java svneol=native#text/plain src/test/java/forge/CardReaderTest.java svneol=native#text/plain
src/test/java/forge/GameActionTest.java svneol=native#text/plain
src/test/java/forge/GuiDownloadPicturesLQTest.java svneol=native#text/plain src/test/java/forge/GuiDownloadPicturesLQTest.java svneol=native#text/plain
src/test/java/forge/GuiDownloadSetPicturesLQTest.java svneol=native#text/plain src/test/java/forge/GuiDownloadSetPicturesLQTest.java svneol=native#text/plain
src/test/java/forge/GuiMigrateLocalMWSSetPicturesHQTest.java svneol=native#text/plain src/test/java/forge/GuiMigrateLocalMWSSetPicturesHQTest.java svneol=native#text/plain

View File

@@ -112,7 +112,7 @@ public class AIPlayer extends Player {
// ////////////////////////////// // //////////////////////////////
// / // /
// / replaces AllZone.getGameAction().draw* methods // / replaces Singletons.getModel().getGameAction().draw* methods
// / // /
// ////////////////////////////// // //////////////////////////////
@@ -151,11 +151,11 @@ public class AIPlayer extends Player {
// rule 702.49a // rule 702.49a
if (this.getDredgeNumber(c) <= this.getCardsIn(Zone.Library).size()) { if (this.getDredgeNumber(c) <= this.getCardsIn(Zone.Library).size()) {
// dredge library, put card in hand // dredge library, put card in hand
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
// put dredge number in graveyard // put dredge number in graveyard
for (int i = 0; i < this.getDredgeNumber(c); i++) { for (int i = 0; i < this.getDredgeNumber(c); i++) {
final Card c2 = this.getCardsIn(Zone.Library).get(0); final Card c2 = this.getCardsIn(Zone.Library).get(0);
AllZone.getGameAction().moveToGraveyard(c2); Singletons.getModel().getGameAction().moveToGraveyard(c2);
} }
return true; return true;
} }
@@ -165,7 +165,7 @@ public class AIPlayer extends Player {
// ////////////////////////////// // //////////////////////////////
// / // /
// / replaces AllZone.getGameAction().discard* methods // / replaces Singletons.getModel().getGameAction().discard* methods
// / // /
// ////////////////////////////// // //////////////////////////////
@@ -230,17 +230,17 @@ public class AIPlayer extends Player {
if (blIH.size() > 0) { if (blIH.size() > 0) {
final Card card = blIH.get(CardUtil.getRandomIndex(blIH)); final Card card = blIH.get(CardUtil.getRandomIndex(blIH));
AllZone.getGameAction().moveToLibrary(card, position); Singletons.getModel().getGameAction().moveToLibrary(card, position);
} else { } else {
CardListUtil.sortAttackLowFirst(hand); CardListUtil.sortAttackLowFirst(hand);
CardListUtil.sortNonFlyingFirst(hand); CardListUtil.sortNonFlyingFirst(hand);
AllZone.getGameAction().moveToLibrary(hand.get(0), position); Singletons.getModel().getGameAction().moveToLibrary(hand.get(0), position);
} }
} else { } else {
CardListUtil.sortCMC(hand); CardListUtil.sortCMC(hand);
AllZone.getGameAction().moveToLibrary(hand.get(0), position); Singletons.getModel().getGameAction().moveToLibrary(hand.get(0), position);
} }
} }
} }
@@ -286,7 +286,7 @@ public class AIPlayer extends Player {
} }
if (bottom) { if (bottom) {
final Card c = topN.get(i); final Card c = topN.get(i);
AllZone.getGameAction().moveToBottomOfLibrary(c); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
// topN.remove(c); // topN.remove(c);
} }
} }
@@ -296,7 +296,7 @@ public class AIPlayer extends Player {
final Random rndm = MyRandom.getRandom(); final Random rndm = MyRandom.getRandom();
final int r = rndm.nextInt(topN.size()); final int r = rndm.nextInt(topN.size());
final Card c = topN.get(r); final Card c = topN.get(r);
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
topN.remove(r); topN.remove(r);
} }
} }
@@ -307,7 +307,7 @@ public class AIPlayer extends Player {
if (choices.size() > 0) { if (choices.size() > 0) {
// TODO - this could probably use better AI // TODO - this could probably use better AI
final Card c = CardFactoryUtil.getWorstPermanentAI(choices, false, false, false, false); final Card c = CardFactoryUtil.getWorstPermanentAI(choices, false, false, false, false);
AllZone.getGameAction().sacrificeDestroy(c); Singletons.getModel().getGameAction().sacrificeDestroy(c);
} }
} }
@@ -316,7 +316,7 @@ public class AIPlayer extends Player {
protected final void clashMoveToTopOrBottom(final Card c) { protected final void clashMoveToTopOrBottom(final Card c) {
// computer just puts the card back until such time it can make a // computer just puts the card back until such time it can make a
// smarter decision // smarter decision
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
} }
/* /*

View File

@@ -26,11 +26,10 @@ import forge.card.cardfactory.CardFactoryInterface;
import forge.card.cardfactory.PreloadingCardFactory; import forge.card.cardfactory.PreloadingCardFactory;
import forge.card.replacement.ReplacementHandler; import forge.card.replacement.ReplacementHandler;
import forge.card.trigger.TriggerHandler; import forge.card.trigger.TriggerHandler;
import forge.deck.CardCollections;
import forge.control.input.InputControl; import forge.control.input.InputControl;
import forge.deck.CardCollections;
import forge.game.GameState;
import forge.game.limited.CardRatings; import forge.game.limited.CardRatings;
import forge.model.FGameState;
import forge.model.FMatchState;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.data.QuestData; import forge.quest.data.QuestData;
@@ -78,9 +77,6 @@ public final class AllZone {
/** Constant <code>inputControl</code>. */ /** Constant <code>inputControl</code>. */
private static InputControl inputControl = null; private static InputControl inputControl = null;
/** */
private static FMatchState matchState = new FMatchState();
// initialized at Runtime since it has to be the last object constructed // initialized at Runtime since it has to be the last object constructed
// shared between Input_Attack, Input_Block, Input_CombatDamage , // shared between Input_Attack, Input_Block, Input_CombatDamage ,
@@ -110,10 +106,8 @@ public final class AllZone {
* @since 1.0.15 * @since 1.0.15
*/ */
public static Player getHumanPlayer() { public static Player getHumanPlayer() {
final FGameState gameState = Singletons.getModel().getGameState(); if (Singletons.getModel() != null) {
return Singletons.getModel().getGameState().getHumanPlayer();
if (gameState != null) {
return gameState.getHumanPlayer();
} }
return null; return null;
@@ -294,10 +288,8 @@ public final class AllZone {
* @since 1.0.15 * @since 1.0.15
*/ */
public static PhaseHandler getPhaseHandler() { public static PhaseHandler getPhaseHandler() {
final FGameState gameState = Singletons.getModel().getGameState(); if (Singletons.getModel() != null) {
return Singletons.getModel().getGameState().getPhaseHandler();
if (gameState != null) {
return gameState.getPhaseHandler();
} }
return null; return null;
@@ -312,7 +304,7 @@ public final class AllZone {
* @since 1.2.0 * @since 1.2.0
*/ */
public static GameLog getGameLog() { public static GameLog getGameLog() {
final FGameState gameState = Singletons.getModel().getGameState(); final GameState gameState = Singletons.getModel().getGameState();
if (gameState != null) { if (gameState != null) {
return gameState.getGameLog(); return gameState.getGameLog();
@@ -360,10 +352,8 @@ public final class AllZone {
* @since 1.0.15 * @since 1.0.15
*/ */
public static MagicStack getStack() { public static MagicStack getStack() {
final FGameState gameState = Singletons.getModel().getGameState(); if (Singletons.getModel() != null) {
return Singletons.getModel().getGameState().getStack();
if (gameState != null) {
return gameState.getStack();
} }
return null; return null;
@@ -386,26 +376,6 @@ public final class AllZone {
AllZone.inputControl = i0; AllZone.inputControl = i0;
} }
/**
* <p>
* getGameAction.
* </p>
*
* Will eventually be marked deprecated.
*
* @return a {@link forge.GameAction} object.
* @since 1.0.15
*/
public static GameAction getGameAction() {
final FGameState gameState = Singletons.getModel().getGameState();
if (gameState != null) {
return gameState.getGameAction();
}
return null;
}
/** /**
* <p> * <p>
* getStaticEffects. * getStaticEffects.
@@ -417,7 +387,7 @@ public final class AllZone {
* @since 1.0.15 * @since 1.0.15
*/ */
public static StaticEffects getStaticEffects() { public static StaticEffects getStaticEffects() {
final FGameState gameState = Singletons.getModel().getGameState(); final GameState gameState = Singletons.getModel().getGameState();
if (gameState != null) { if (gameState != null) {
return gameState.getStaticEffects(); return gameState.getStaticEffects();
@@ -502,7 +472,7 @@ public final class AllZone {
* @return a {@link forge.PlayerZone} object. * @return a {@link forge.PlayerZone} object.
*/ */
public static PlayerZone getZoneOf(final Card c) { public static PlayerZone getZoneOf(final Card c) {
final FGameState gameState = Singletons.getModel().getGameState(); final GameState gameState = Singletons.getModel().getGameState();
if (gameState == null) { if (gameState == null) {
return null; return null;
} }
@@ -534,7 +504,7 @@ public final class AllZone {
* @return boolean * @return boolean
*/ */
public static boolean isCardInZone(final Card c, final Constant.Zone zone) { public static boolean isCardInZone(final Card c, final Constant.Zone zone) {
final FGameState gameState = Singletons.getModel().getGameState(); final GameState gameState = Singletons.getModel().getGameState();
if (gameState == null) { if (gameState == null) {
return false; return false;
} }
@@ -560,7 +530,7 @@ public final class AllZone {
* </p> * </p>
*/ */
public static void resetZoneMoveTracking() { public static void resetZoneMoveTracking() {
final FGameState gameState = Singletons.getModel().getGameState(); final GameState gameState = Singletons.getModel().getGameState();
if (gameState == null) { if (gameState == null) {
return; return;
} }
@@ -582,30 +552,6 @@ public final class AllZone {
return Singletons.getModel().getGameState().getNextTimestamp(); return Singletons.getModel().getGameState().getNextTimestamp();
} }
/**
* <p>
* Resets everything possible to set a new game.
* </p>
*/
public static void newGameCleanup() {
Singletons.getModel().getGameState().newGameCleanup();
Singletons.getControl().getControlMatch().showCombat("");
Singletons.getModel().loadPrefs();
AllZone.getInputControl().clearInput();
AllZone.getColorChanger().reset();
Singletons.getControl().getControlMatch().showStack();
}
/**
* Getter for matchState.
*
* @return the matchState
*/
public static FMatchState getMatchState() {
return AllZone.matchState;
}
/** /**
* Getter for colorChanger. * Getter for colorChanger.
* *

View File

@@ -1557,7 +1557,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1; final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1;
if (hasVanish && AllZoneUtil.isCardInPlay(this)) { if (hasVanish && AllZoneUtil.isCardInPlay(this)) {
AllZone.getGameAction().sacrifice(this); Singletons.getModel().getGameAction().sacrifice(this);
} }
if (this.hasSuspend() && AllZoneUtil.isCardExiled(this)) { if (this.hasSuspend() && AllZoneUtil.isCardExiled(this)) {
@@ -1569,7 +1569,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Any trigger should cause the phase not to skip // Any trigger should cause the phase not to skip
AllZone.getPhaseHandler().setSkipPhase(false); AllZone.getPhaseHandler().setSkipPhase(false);
if (c.getOwner().isHuman()) { if (c.getOwner().isHuman()) {
AllZone.getGameAction().playCardNoCost(c); Singletons.getModel().getGameAction().playCardNoCost(c);
} else { } else {
final ArrayList<SpellAbility> choices = this.getBasicSpells(); final ArrayList<SpellAbility> choices = this.getBasicSpells();
@@ -3852,8 +3852,8 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} }
this.controllerObjects.add(controllerObject); this.controllerObjects.add(controllerObject);
if ((AllZone.getGameAction() != null) && (prevController != null)) { if ((Singletons.getModel().getGameAction() != null) && (prevController != null)) {
AllZone.getGameAction().controllerChangeZoneCorrection(this); Singletons.getModel().getGameAction().controllerChangeZoneCorrection(this);
} }
if (prevController != null) { if (prevController != null) {
@@ -3878,7 +3878,7 @@ public class Card extends GameEntity implements Comparable<Card> {
this.controllerObjects.remove(controllerObject); this.controllerObjects.remove(controllerObject);
if (!currentController.equals(this.getController())) { if (!currentController.equals(this.getController())) {
AllZone.getGameAction().controllerChangeZoneCorrection(this); Singletons.getModel().getGameAction().controllerChangeZoneCorrection(this);
for (final Command c : this.changeControllerCommandList) { for (final Command c : this.changeControllerCommandList) {
c.execute(); c.execute();
@@ -6276,7 +6276,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Suppressed Exiling is as close as we can get to // Suppressed Exiling is as close as we can get to
// "ceasing to exist" // "ceasing to exist"
AllZone.getTriggerHandler().suppressMode("ChangesZone"); AllZone.getTriggerHandler().suppressMode("ChangesZone");
AllZone.getGameAction().exile(this); Singletons.getModel().getGameAction().exile(this);
AllZone.getTriggerHandler().clearSuppression("ChangesZone"); AllZone.getTriggerHandler().clearSuppression("ChangesZone");
} }
return true; return true;
@@ -7462,7 +7462,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// //////////////////////// // ////////////////////////
// all damage to cards is now handled in Card.java, no longer // all damage to cards is now handled in Card.java, no longer
// AllZone.getGameAction()... // Singletons.getModel().getGameAction()...
/** /**
* <p> * <p>
* addReceivedDamageFromThisTurn. * addReceivedDamageFromThisTurn.
@@ -8203,7 +8203,7 @@ public class Card extends GameEntity implements Comparable<Card> {
this.addCounter(Counters.M1M1, damageToAdd); this.addCounter(Counters.M1M1, damageToAdd);
} }
if (source.hasKeyword("Deathtouch") && this.isCreature()) { if (source.hasKeyword("Deathtouch") && this.isCreature()) {
AllZone.getGameAction().destroy(this); Singletons.getModel().getGameAction().destroy(this);
} else if (AllZoneUtil.isCardInPlay(this) && !wither) { } else if (AllZoneUtil.isCardInPlay(this) && !wither) {
this.damage += damageToAdd; this.damage += damageToAdd;
} }

View File

@@ -2495,7 +2495,7 @@ public class CombatUtil {
enchantments.toArray()); enchantments.toArray());
if (o != null) { if (o != null) {
final Card crd = (Card) o; final Card crd = (Card) o;
AllZone.getGameAction().moveToPlay(crd); Singletons.getModel().getGameAction().moveToPlay(crd);
if (crd.isAura()) { if (crd.isAura()) {
Object obj = null; Object obj = null;
@@ -2535,7 +2535,7 @@ public class CombatUtil {
}); });
if (enchantments.size() > 0) { if (enchantments.size() > 0) {
final Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, null, false); final Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, null, false);
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
c.getController().shuffle(); c.getController().shuffle();
} }
} }
@@ -2609,7 +2609,7 @@ public class CombatUtil {
player.gainLife(top.getBaseDefense(), c); player.gainLife(top.getBaseDefense(), c);
player.loseLife(top.getBaseAttack(), c); player.loseLife(top.getBaseAttack(), c);
AllZone.getGameAction().moveToHand(top); Singletons.getModel().getGameAction().moveToHand(top);
} }
} }
} // Sapling of Colfenor } // Sapling of Colfenor

View File

@@ -170,7 +170,7 @@ public class ComputerUtil {
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
final Cost cost = sa.getPayCosts(); final Cost cost = sa.getPayCosts();
@@ -333,7 +333,7 @@ public class ComputerUtil {
final Card source = bestSA.getSourceCard(); final Card source = bestSA.getSourceCard();
if (bestSA.isSpell() && !source.isCopiedSpell()) { if (bestSA.isSpell() && !source.isCopiedSpell()) {
bestSA.setSourceCard(AllZone.getGameAction().moveToStack(source)); bestSA.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
final Cost cost = bestSA.getPayCosts(); final Cost cost = bestSA.getPayCosts();
@@ -367,7 +367,7 @@ public class ComputerUtil {
if (ComputerUtil.canPayCost(sa)) { if (ComputerUtil.canPayCost(sa)) {
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
sa.setActivatingPlayer(AllZone.getComputerPlayer()); sa.setActivatingPlayer(AllZone.getComputerPlayer());
@@ -391,7 +391,7 @@ public class ComputerUtil {
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
AllZone.getStack().add(sa); AllZone.getStack().add(sa);
@@ -426,7 +426,7 @@ public class ComputerUtil {
final Card source = newSA.getSourceCard(); final Card source = newSA.getSourceCard();
if (newSA.isSpell() && !source.isCopiedSpell()) { if (newSA.isSpell() && !source.isCopiedSpell()) {
newSA.setSourceCard(AllZone.getGameAction().moveToStack(source)); newSA.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
final CostPayment pay = new CostPayment(cost, newSA); final CostPayment pay = new CostPayment(cost, newSA);
@@ -449,7 +449,7 @@ public class ComputerUtil {
if (ComputerUtil.canPayCost(sa)) { if (ComputerUtil.canPayCost(sa)) {
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
sa.setActivatingPlayer(AllZone.getComputerPlayer()); sa.setActivatingPlayer(AllZone.getComputerPlayer());
@@ -465,7 +465,7 @@ public class ComputerUtil {
AbilityFactory.resolve(sa, false); AbilityFactory.resolve(sa, false);
// destroys creatures if they have lethal damage, etc.. // destroys creatures if they have lethal damage, etc..
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
} }
} // play() } // play()
@@ -625,7 +625,7 @@ public class ComputerUtil {
ManaCost cost = new ManaCost(mana); ManaCost cost = new ManaCost(mana);
if ((sa.getPayCosts() == null) || !sa.getPayCosts().getNoManaCostChange()) { if ((sa.getPayCosts() == null) || !sa.getPayCosts().getNoManaCostChange()) {
cost = AllZone.getGameAction().getSpellCostChange(sa, cost); cost = Singletons.getModel().getGameAction().getSpellCostChange(sa, cost);
} }
final ManaPool manapool = player.getManaPool(); final ManaPool manapool = player.getManaPool();
@@ -1821,11 +1821,11 @@ public class ComputerUtil {
} }
} }
if (destroy) { if (destroy) {
if (!AllZone.getGameAction().destroy(c)) { if (!Singletons.getModel().getGameAction().destroy(c)) {
continue; continue;
} }
} else { } else {
if (!AllZone.getGameAction().sacrifice(c)) { if (!Singletons.getModel().getGameAction().sacrifice(c)) {
continue; continue;
} }
} }

View File

@@ -64,7 +64,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
@Override @Override
public void resolve() { public void resolve() {
if (AllZoneUtil.isCardInPlay(card)) { if (AllZoneUtil.isCardInPlay(card)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} }
}; };
@@ -81,7 +81,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
@Override @Override
public void resolve() { public void resolve() {
if (AllZoneUtil.isCardInPlay(card)) { if (AllZoneUtil.isCardInPlay(card)) {
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
} }
} }
}; };
@@ -98,7 +98,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
@Override @Override
public void resolve() { public void resolve() {
if (AllZoneUtil.isCardInPlay(card)) { if (AllZoneUtil.isCardInPlay(card)) {
AllZone.getGameAction().destroy(card); Singletons.getModel().getGameAction().destroy(card);
} }
} }
}; };
@@ -117,7 +117,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
@Override @Override
public void resolve() { public void resolve() {
if (AllZoneUtil.isCardInPlay(card)) { if (AllZoneUtil.isCardInPlay(card)) {
AllZone.getGameAction().destroy(card); Singletons.getModel().getGameAction().destroy(card);
} }
} }
}; };
@@ -139,7 +139,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
public void resolve() { public void resolve() {
if (AllZoneUtil.isCardInPlay(vale)) { if (AllZoneUtil.isCardInPlay(vale)) {
vale.addController(vale.getController().getOpponent()); vale.addController(vale.getController().getOpponent());
// AllZone.getGameAction().changeController( // Singletons.getModel().getGameAction().changeController(
// new CardList(vale), vale.getController(), // new CardList(vale), vale.getController(),
// vale.getController().getOpponent()); // vale.getController().getOpponent());
@@ -180,7 +180,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
@Override @Override
public void resolve() { public void resolve() {
if (AllZoneUtil.isCardInPlay(source)) { if (AllZoneUtil.isCardInPlay(source)) {
AllZone.getGameAction().moveToHand(source); Singletons.getModel().getGameAction().moveToHand(source);
} }
} }
}; };

View File

@@ -20,17 +20,13 @@ package forge;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.AbilityFactoryAttach; import forge.card.abilityfactory.AbilityFactoryAttach;
import forge.card.abilityfactory.AbilityFactoryCharm; import forge.card.abilityfactory.AbilityFactoryCharm;
import forge.card.cardfactory.CardFactoryInterface;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostMana; import forge.card.cost.CostMana;
@@ -46,38 +42,21 @@ import forge.card.spellability.Target;
import forge.card.spellability.TargetSelection; import forge.card.spellability.TargetSelection;
import forge.card.staticability.StaticAbility; import forge.card.staticability.StaticAbility;
import forge.card.trigger.Trigger; import forge.card.trigger.Trigger;
import forge.control.input.InputMulligan;
import forge.control.input.InputPayManaCost; import forge.control.input.InputPayManaCost;
import forge.control.input.InputPayManaCostAbility; import forge.control.input.InputPayManaCostAbility;
import forge.control.input.InputPayManaCostUtil; import forge.control.input.InputPayManaCostUtil;
import forge.deck.Deck;
import forge.game.GameEndReason; import forge.game.GameEndReason;
import forge.game.GameSummary; import forge.game.GameSummary;
import forge.game.GameType;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import forge.item.CardPrinted;
import forge.properties.ForgePreferences.FPref;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.Lang.GameAction.GameActionText;
import forge.util.MyRandom;
import forge.view.match.ViewWinLose; import forge.view.match.ViewWinLose;
/** /**
* <p> * Methods for common actions performed during a game.
* GameAction class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class GameAction { public class GameAction {
/**
* This variable prevents WinLose dialog from popping several times, ie on
* each state effect check after a win.
*/
private boolean canShowWinLose = true;
/** /**
* <p> * <p>
* resetActivationsPerTurn. * resetActivationsPerTurn.
@@ -135,7 +114,7 @@ public class GameAction {
if (AllZone.getReplacementHandler().run(repParams)) { if (AllZone.getReplacementHandler().run(repParams)) {
if (AllZone.getStack().isResolving(c) && !zone.is(Constant.Zone.Graveyard)) { if (AllZone.getStack().isResolving(c) && !zone.is(Constant.Zone.Graveyard)) {
return AllZone.getGameAction().moveToGraveyard(c); return Singletons.getModel().getGameAction().moveToGraveyard(c);
} }
return c; return c;
} }
@@ -449,7 +428,7 @@ public class GameAction {
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().moveToHand(recoverable); Singletons.getModel().getGameAction().moveToHand(recoverable);
} }
}; };
@@ -458,14 +437,14 @@ public class GameAction {
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().exile(recoverable); Singletons.getModel().getGameAction().exile(recoverable);
} }
}; };
final SpellAbility abRecover = new Ability(recoverable, recoverCost) { final SpellAbility abRecover = new Ability(recoverable, recoverCost) {
@Override @Override
public void resolve() { public void resolve() {
AllZone.getGameAction().moveToHand(recoverable); Singletons.getModel().getGameAction().moveToHand(recoverable);
} }
@Override @Override
@@ -490,7 +469,7 @@ public class GameAction {
if (ComputerUtil.canPayCost(abRecover)) { if (ComputerUtil.canPayCost(abRecover)) {
ComputerUtil.playNoStack(abRecover); ComputerUtil.playNoStack(abRecover);
} else { } else {
AllZone.getGameAction().exile(recoverable); Singletons.getModel().getGameAction().exile(recoverable);
} }
} }
} }
@@ -652,7 +631,7 @@ public class GameAction {
final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile);
return AllZone.getGameAction().moveTo(removed, c); return Singletons.getModel().getGameAction().moveTo(removed, c);
} }
/** /**
@@ -819,7 +798,7 @@ public class GameAction {
game.getPlayerRating(computer.getName()).setLossReason(computer.getLossState(), game.getPlayerRating(computer.getName()).setLossReason(computer.getLossState(),
computer.getLossConditionSource()); computer.getLossConditionSource());
game.getPlayerRating(human.getName()).setLossReason(human.getLossState(), human.getLossConditionSource()); game.getPlayerRating(human.getName()).setLossReason(human.getLossState(), human.getLossConditionSource());
AllZone.getMatchState().addGamePlayed(game); Singletons.getModel().getMatchState().addGamePlayed(game);
} }
return isGameDone; return isGameDone;
@@ -900,10 +879,8 @@ public class GameAction {
return; return;
} }
if (this.canShowWinLose && this.checkEndGameState()) { if (this.checkEndGameState()) {
new ViewWinLose(); new ViewWinLose();
this.canShowWinLose = false;
return;
} }
// do this twice, sometimes creatures/permanents will survive when they // do this twice, sometimes creatures/permanents will survive when they
@@ -1057,7 +1034,7 @@ public class GameAction {
c = list.get(i); c = list.get(i);
if (c.getCounters(Counters.LOYALTY) <= 0) { if (c.getCounters(Counters.LOYALTY) <= 0) {
AllZone.getGameAction().moveToGraveyard(c); Singletons.getModel().getGameAction().moveToGraveyard(c);
} }
final ArrayList<String> types = c.getType(); final ArrayList<String> types = c.getType();
@@ -1070,7 +1047,7 @@ public class GameAction {
if (cl.size() > 1) { if (cl.size() > 1) {
for (final Card crd : cl) { for (final Card crd : cl) {
AllZone.getGameAction().moveToGraveyard(crd); Singletons.getModel().getGameAction().moveToGraveyard(crd);
} }
} }
} }
@@ -1097,7 +1074,7 @@ public class GameAction {
a.remove(0); a.remove(0);
if (1 < b.size()) { if (1 < b.size()) {
for (int i = 0; i < b.size(); i++) { for (int i = 0; i < b.size(); i++) {
AllZone.getGameAction().sacrificeDestroy(b.get(i)); Singletons.getModel().getGameAction().sacrificeDestroy(b.get(i));
} }
} }
} }
@@ -1356,485 +1333,10 @@ public class GameAction {
return this.sacrificeDestroy(c); return this.sacrificeDestroy(c);
} }
/**
* Constructor for new game allowing card lists to be put into play
* immediately, and life totals to be adjusted, for computer and human.
*
* @param humanDeck
* &emsp; {@link forge.deck.Deck} object.
* @param computerDeck
* &emsp; {@link forge.deck.Deck} object.
* @param human
* &emsp; {@link forge.CardList} object.
* @param computer
* &emsp; {@link forge.CardList} object.
* @param humanLife
* &emsp; int.
* @param computerLife
* &emsp; int.
*/
public final void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
final CardList computer, final int humanLife, final int computerLife) {
AllZone.newGameCleanup();
AllZone.getComputerPlayer().setStartingLife(computerLife);
AllZone.getHumanPlayer().setStartingLife(humanLife);
AllZone.getHumanPlayer().updateObservers();
for (final Card c : human) {
AllZone.getHumanPlayer().getZone(Zone.Battlefield).add(c);
c.setSickness(true);
}
for (final Card c : computer) {
AllZone.getComputerPlayer().getZone(Zone.Battlefield).add(c);
c.setSickness(true);
}
Constant.Quest.FANTASY_QUEST[0] = true;
this.actuateGame(humanDeck, computerDeck);
}
private boolean startCut = false; private boolean startCut = false;
/**
* The default constructor for a new game.
*
* @param humanDeck
* &emsp; {@link forge.deck.Deck} object.
* @param computerDeck
* &emsp; {@link forge.deck.Deck} object.
*/
public final void newGame(final Deck humanDeck, final Deck computerDeck) {
// AllZone.getComputer() = new ComputerAI_Input(new
// ComputerAI_General());
Constant.Quest.FANTASY_QUEST[0] = false;
AllZone.newGameCleanup();
AllZone.getComputerPlayer().setStartingLife(20);
AllZone.getHumanPlayer().setStartingLife(20);
this.actuateGame(humanDeck, computerDeck);
}
/**
* This must be separated from the newGame method since life totals and
* player details could be adjusted before the game is started.
*
* That process (also cleanup and observer updates) should be done in
* newGame, then when all is ready, call this function.
*/
private void actuateGame(final Deck humanDeck, final Deck computerDeck) {
this.canShowWinLose = true;
forge.card.trigger.Trigger.resetIDs();
AllZone.getTriggerHandler().clearTriggerSettings();
AllZone.getTriggerHandler().clearDelayedTrigger();
Singletons.getControl().getControlMatch().getMessageControl().updateGameCount();
// friendliness
final CardFactoryInterface c = AllZone.getCardFactory();
Card.resetUniqueNumber();
final boolean canRandomFoil = Constant.Runtime.RANDOM_FOIL[0]
&& Constant.Runtime.getGameType().equals(GameType.Constructed);
final Random generator = MyRandom.getRandom();
final ArrayList<String> hAnteRemoved = new ArrayList<String>();
final ArrayList<String> cAnteRemoved = new ArrayList<String>();
AllZone.getTriggerHandler().suppressMode("Transformed");
for (final Entry<CardPrinted, Integer> stackOfCards : humanDeck.getMain()) {
final CardPrinted cardPrinted = stackOfCards.getKey();
for (int i = 0; i < stackOfCards.getValue(); i++) {
final Card card = c.getCard(cardPrinted.getName(), AllZone.getHumanPlayer());
card.setCurSetCode(cardPrinted.getSet());
final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount();
if (cntVariants > 1) {
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
}
card.setImageFilename(CardUtil.buildFilename(card));
// Assign random foiling on approximately 1:20 cards
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
card.setFoil(iFoil);
}
if (card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
hAnteRemoved.add(card.getName());
} else {
AllZone.getHumanPlayer().getZone(Zone.Library).add(card);
}
if (card.hasAlternateState()) {
if (card.isDoubleFaced()) {
card.setState("Transformed");
}
if (card.isFlip()) {
card.setState("Flipped");
}
card.setImageFilename(CardUtil.buildFilename(card));
card.setState("Original");
}
}
}
final ArrayList<String> rAICards = new ArrayList<String>();
for (final Entry<CardPrinted, Integer> stackOfCards : computerDeck.getMain()) {
final CardPrinted cardPrinted = stackOfCards.getKey();
for (int i = 0; i < stackOfCards.getValue(); i++) {
final Card card = c.getCard(cardPrinted.getName(), AllZone.getComputerPlayer());
card.setCurSetCode(cardPrinted.getSet());
final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount();
if (cntVariants > 1) {
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
}
card.setImageFilename(CardUtil.buildFilename(card));
// Assign random foiling on approximately 1:20 cards
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
card.setFoil(iFoil);
}
if (card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
cAnteRemoved.add(card.getName());
} else {
AllZone.getComputerPlayer().getZone(Zone.Library).add(card);
}
if (card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
rAICards.add(card.getName());
// get card picture so that it is in the image cache
// ImageCache.getImage(card);
}
if (card.hasAlternateState()) {
if (card.isDoubleFaced()) {
card.setState("Transformed");
}
if (card.isFlip()) {
card.setState("Flipped");
}
card.setImageFilename(CardUtil.buildFilename(card));
card.setState("Original");
}
}
}
AllZone.getTriggerHandler().clearSuppression("Transformed");
if (rAICards.size() > 0) {
final StringBuilder sb = new StringBuilder(
"AI deck contains the following cards that it can't play or may be buggy:\n");
for (int i = 0; i < rAICards.size(); i++) {
sb.append(rAICards.get(i));
if (((i % 4) == 0) && (i > 0)) {
sb.append("\n");
} else if (i != (rAICards.size() - 1)) {
sb.append(", ");
}
}
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
if (hAnteRemoved.size() > 0) {
final StringBuilder sb = new StringBuilder("The following ante cards were removed from the human's deck:\n");
for (int i = 0; i < hAnteRemoved.size(); i++) {
sb.append(hAnteRemoved.get(i));
if (((i % 4) == 0) && (i > 0)) {
sb.append("\n");
} else if (i != (hAnteRemoved.size() - 1)) {
sb.append(", ");
}
}
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
if (cAnteRemoved.size() > 0) {
final StringBuilder sb = new StringBuilder(
"The following ante cards were removed from the computer's deck:\n");
for (int i = 0; i < cAnteRemoved.size(); i++) {
sb.append(cAnteRemoved.get(i));
if (((i % 4) == 0) && (i > 0)) {
sb.append("\n");
} else if (i != (cAnteRemoved.size() - 1)) {
sb.append(", ");
}
}
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
for (int i = 0; i < 100; i++) {
AllZone.getHumanPlayer().shuffle();
}
// do this instead of shuffling Computer's deck
final boolean smoothLand = Constant.Runtime.SMOOTH[0];
if (smoothLand) {
final Card[] c1 = this.smoothComputerManaCurve(AllZone.getComputerPlayer().getCardsIn(Zone.Library)
.toArray());
AllZone.getComputerPlayer().getZone(Zone.Library).setCards(c1);
} else {
// WTF? (it was so before refactor)
AllZone.getComputerPlayer().getZone(Zone.Library)
.setCards(AllZone.getComputerPlayer().getCardsIn(Zone.Library).toArray());
AllZone.getComputerPlayer().shuffle();
}
// Only cut/coin toss if it's the first game of the match
if (AllZone.getMatchState().getGamesPlayedCount() == 0) {
// New code to determine who goes first. Delete this if it doesn't
// work properly
if (this.isStartCut()) {
this.seeWhoPlaysFirst();
} else {
this.seeWhoPlaysFirstCoinToss();
}
} else if (AllZone.getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) {
// if player won last, AI starts
this.computerStartsGame();
}
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
final String nl = System.getProperty("line.separator");
final StringBuilder msg = new StringBuilder();
for (final Player p : AllZone.getPlayersInGame()) {
final CardList lib = p.getCardsIn(Zone.Library);
Card ante;
if ((lib.size() > 0) && (lib.getNotType("Basic").size() > 1)) {
ante = CardUtil.getRandom(lib.toArray());
while (ante.isBasicLand()) {
ante = CardUtil.getRandom(lib.toArray());
}
} else if (lib.size() > 1) {
ante = lib.get(0);
} else {
throw new RuntimeException(p + " library is empty.");
}
AllZone.getGameLog().add("Ante", p + " anted " + ante, 0);
this.moveTo(Zone.Ante, ante);
msg.append(p.getName()).append(" ante: ").append(ante).append(nl);
}
JOptionPane.showConfirmDialog(null, msg, "Ante", JOptionPane.OK_CANCEL_OPTION);
}
for (int i = 0; i < 7; i++) {
AllZone.getHumanPlayer().drawCard();
AllZone.getComputerPlayer().drawCard();
}
Singletons.getControl().getControlMatch().setCard(AllZone.getHumanPlayer().getCardsIn(Zone.Hand).get(0));
AllZone.getInputControl().setInput(new InputMulligan());
PhaseHandler.setGameBegins(1);
AllZone.getGameLog().add("Turn",
"Turn " + AllZone.getPhaseHandler().getTurn() + " (" + AllZone.getPhaseHandler().getPlayerTurn() + ")",
0);
} // newGame()
// this is where the computer cheats
// changes AllZone.getComputerPlayer().getZone(Zone.Library)
/**
* <p>
* smoothComputerManaCurve.
* </p>
*
* @param in
* an array of {@link forge.Card} objects.
* @return an array of {@link forge.Card} objects.
*/
final Card[] smoothComputerManaCurve(final Card[] in) {
final CardList library = new CardList(in);
library.shuffle();
// remove all land, keep non-basicland in there, shuffled
CardList land = library.getType("Land");
for (int i = 0; i < land.size(); i++) {
if (land.get(i).isLand()) {
library.remove(land.get(i));
}
}
try {
// mana weave, total of 7 land
// The Following have all been reduced by 1, to account for the
// computer starting first.
library.add(5, land.get(0));
library.add(6, land.get(1));
library.add(8, land.get(2));
library.add(9, land.get(3));
library.add(10, land.get(4));
library.add(12, land.get(5));
library.add(15, land.get(6));
} catch (final IndexOutOfBoundsException e) {
System.err.println("Error: cannot smooth mana curve, not enough land");
return in;
}
// add the rest of land to the end of the deck
for (int i = 0; i < land.size(); i++) {
if (!library.contains(land.get(i))) {
library.add(land.get(i));
}
}
// check
for (int i = 0; i < library.size(); i++) {
System.out.println(library.get(i));
}
return library.toArray();
} // smoothComputerManaCurve()
// decides who goes first when starting another game, used by newGame()
/**
* <p>
* seeWhoPlaysFirstCoinToss.
* </p>
*/
public final void seeWhoPlaysFirstCoinToss() {
final Object[] possibleValues = { ForgeProps.getLocalized(GameActionText.HEADS),
ForgeProps.getLocalized(GameActionText.TAILS) };
final Object q = JOptionPane.showOptionDialog(null, ForgeProps.getLocalized(GameActionText.HEADS_OR_TAILS),
ForgeProps.getLocalized(GameActionText.COIN_TOSS), JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
final int flip = MyRandom.getRandom().nextInt(2);
String humanFlip = " ";
String computerFlip = " ";
// JOptionPane.showMessageDialog(null, q, "",
// JOptionPane.INFORMATION_MESSAGE);
if (q.equals(0)) {
humanFlip = ForgeProps.getLocalized(GameActionText.HEADS);
computerFlip = ForgeProps.getLocalized(GameActionText.TAILS);
} else {
humanFlip = ForgeProps.getLocalized(GameActionText.TAILS);
computerFlip = ForgeProps.getLocalized(GameActionText.HEADS);
}
if (((flip == 0) && q.equals(0)) || ((flip == 1) && q.equals(1))) {
JOptionPane.showMessageDialog(null, humanFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN),
"", JOptionPane.INFORMATION_MESSAGE);
} else {
this.computerStartsGame();
JOptionPane.showMessageDialog(null,
computerFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.COMPUTER_WIN), "",
JOptionPane.INFORMATION_MESSAGE);
}
} // seeWhoPlaysFirst_CoinToss()
private Card humanCut = null;
private Card computerCut = null;
/**
* <p>
* seeWhoPlaysFirst.
* </p>
*/
public final void seeWhoPlaysFirst() {
CardList hLibrary = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
hLibrary = hLibrary.filter(CardListFilter.NON_LANDS);
CardList cLibrary = AllZone.getComputerPlayer().getCardsIn(Zone.Library);
cLibrary = cLibrary.filter(CardListFilter.NON_LANDS);
final boolean starterDetermined = false;
int cutCount = 0;
final int cutCountMax = 20;
for (int i = 0; i < cutCountMax; i++) {
if (starterDetermined) {
break;
}
if (hLibrary.size() > 0) {
this.setHumanCut(hLibrary.get(MyRandom.getRandom().nextInt(hLibrary.size())));
} else {
this.computerStartsGame();
JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.HUMAN_MANA_COST) + "\r\n"
+ ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (cLibrary.size() > 0) {
this.setComputerCut(cLibrary.get(MyRandom.getRandom().nextInt(cLibrary.size())));
} else {
JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.COMPUTER_MANA_COST) + "\r\n"
+ ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "", JOptionPane.INFORMATION_MESSAGE);
return;
}
cutCount = cutCount + 1;
AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library),
AllZone.getGameAction().getHumanCut());
AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library),
AllZone.getGameAction().getComputerCut());
final StringBuilder sb = new StringBuilder();
sb.append(ForgeProps.getLocalized(GameActionText.HUMAN_CUT) + this.getHumanCut().getName() + " ("
+ this.getHumanCut().getManaCost() + ")" + "\r\n");
sb.append(ForgeProps.getLocalized(GameActionText.COMPUTER_CUT) + this.getComputerCut().getName() + " ("
+ this.getComputerCut().getManaCost() + ")" + "\r\n");
sb.append("\r\n" + "Number of times the deck has been cut: " + cutCount + "\r\n");
if (CardUtil.getConvertedManaCost(this.getComputerCut().getManaCost()) > CardUtil.getConvertedManaCost(this
.getHumanCut().getManaCost())) {
this.computerStartsGame();
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "",
JOptionPane.INFORMATION_MESSAGE);
return;
} else if (CardUtil.getConvertedManaCost(this.getComputerCut().getManaCost()) < CardUtil
.getConvertedManaCost(this.getHumanCut().getManaCost())) {
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "",
JOptionPane.INFORMATION_MESSAGE);
return;
} else {
sb.append(ForgeProps.getLocalized(GameActionText.EQUAL_CONVERTED_MANA) + "\r\n");
if (i == (cutCountMax - 1)) {
sb.append(ForgeProps.getLocalized(GameActionText.RESOLVE_STARTER));
if (MyRandom.getRandom().nextInt(2) == 1) {
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), "",
JOptionPane.INFORMATION_MESSAGE);
} else {
this.computerStartsGame();
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.COMPUTER_WIN),
"", JOptionPane.INFORMATION_MESSAGE);
}
return;
} else {
sb.append(ForgeProps.getLocalized(GameActionText.CUTTING_AGAIN));
}
JOptionPane.showMessageDialog(null, sb, "", JOptionPane.INFORMATION_MESSAGE);
}
} // for-loop for multiple card cutting
} // seeWhoPlaysFirst()
/**
* <p>
* computerStartsGame.
* </p>
*/
public final void computerStartsGame() {
final Player computer = AllZone.getComputerPlayer();
AllZone.getPhaseHandler().setPlayerTurn(computer);
// AllZone.getGameInfo().setPlayerWhoGotFirstTurn(computer.getName());
}
// if Card had the type "Aura" this method would always return true, since // if Card had the type "Aura" this method would always return true, since
// local enchantments are always attached to something // local enchantments are always attached to something
@@ -1992,7 +1494,7 @@ public class GameAction {
if (sa.isSpell()) { if (sa.isSpell()) {
final Card c = sa.getSourceCard(); final Card c = sa.getSourceCard();
if (!c.isCopiedSpell()) { if (!c.isCopiedSpell()) {
sa.setSourceCard(AllZone.getGameAction().moveToStack(c)); sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(c));
} }
} }
boolean x = false; boolean x = false;
@@ -2739,7 +2241,7 @@ public class GameAction {
if (sa.getAfterPayMana() == null) { if (sa.getAfterPayMana() == null) {
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
if (sa.isSpell() && !source.isCopiedSpell()) { if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
AllZone.getStack().add(sa); AllZone.getStack().add(sa);
@@ -2885,6 +2387,9 @@ public class GameAction {
return this.startCut; return this.startCut;
} }
private Card humanCut = null;
private Card computerCut = null;
/** /**
* <p> * <p>
* setHumanCut. * setHumanCut.
@@ -2937,7 +2442,7 @@ public class GameAction {
} }
/** /**
* Sets the cost cutting get multi micker mana cost paid colored. * Sets the cost cutting get multi kicker mana cost paid colored.
* *
* @param costCuttingGetMultiMickerManaCostPaidColored0 * @param costCuttingGetMultiMickerManaCostPaidColored0
* the costCuttingGetMultiMickerManaCostPaidColored to set * the costCuttingGetMultiMickerManaCostPaidColored to set

View File

@@ -152,7 +152,7 @@ public final class GameActionUtil {
title.toString(), JOptionPane.YES_NO_OPTION); title.toString(), JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) { if (answer == JOptionPane.YES_OPTION) {
AllZone.getGameAction().playCardNoCost(cascadedCard); Singletons.getModel().getGameAction().playCardNoCost(cascadedCard);
revealed.remove(cascadedCard); revealed.remove(cascadedCard);
} }
} else { } else {
@@ -178,7 +178,7 @@ public final class GameActionUtil {
} }
revealed.shuffle(); revealed.shuffle();
for (final Card bottom : revealed) { for (final Card bottom : revealed) {
AllZone.getGameAction().moveToBottomOfLibrary(bottom); Singletons.getModel().getGameAction().moveToBottomOfLibrary(bottom);
} }
} }
}; };
@@ -279,7 +279,7 @@ public final class GameActionUtil {
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
possibleValues, possibleValues[0]); possibleValues, possibleValues[0]);
if (q.equals(0)) { if (q.equals(0)) {
AllZone.getGameAction().playCardNoCost(rippledCards[i]); Singletons.getModel().getGameAction().playCardNoCost(rippledCards[i]);
revealed.remove(rippledCards[i]); revealed.remove(rippledCards[i]);
} }
} else { } else {
@@ -306,7 +306,7 @@ public final class GameActionUtil {
} }
revealed.shuffle(); revealed.shuffle();
for (final Card bottom : revealed) { for (final Card bottom : revealed) {
AllZone.getGameAction().moveToBottomOfLibrary(bottom); Singletons.getModel().getGameAction().moveToBottomOfLibrary(bottom);
} }
} }
}; };
@@ -580,14 +580,14 @@ public final class GameActionUtil {
final Ability ability = new Ability(source, "0") { final Ability ability = new Ability(source, "0") {
@Override @Override
public void resolve() { public void resolve() {
AllZone.getGameAction().destroy(affected); Singletons.getModel().getGameAction().destroy(affected);
} }
}; };
final Ability ability2 = new Ability(source, "0") { final Ability ability2 = new Ability(source, "0") {
@Override @Override
public void resolve() { public void resolve() {
AllZone.getGameAction().destroyNoRegeneration(affected); Singletons.getModel().getGameAction().destroyNoRegeneration(affected);
} }
}; };
@@ -863,7 +863,7 @@ public final class GameActionUtil {
private static void playerCombatDamageTreva(final Card c) { private static void playerCombatDamageTreva(final Card c) {
final SpellAbility[] sa = c.getSpellAbility(); final SpellAbility[] sa = c.getSpellAbility();
if (c.getController().isHuman()) { if (c.getController().isHuman()) {
AllZone.getGameAction().playSpellAbility(sa[1]); Singletons.getModel().getGameAction().playSpellAbility(sa[1]);
} else { } else {
ComputerUtil.playNoStack(sa[1]); ComputerUtil.playNoStack(sa[1]);
} }
@@ -1001,7 +1001,7 @@ public final class GameActionUtil {
for (int j = 0; j < max; j++) { for (int j = 0; j < max; j++) {
final Card c = libList.get(j); final Card c = libList.get(j);
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
} }
}; // ability }; // ability

View File

@@ -1353,13 +1353,13 @@ public final class GuiDisplayUtil {
AllZone.getCombat().reset(); AllZone.getCombat().reset();
for (final Card c : humanDevSetup) { for (final Card c : humanDevSetup) {
AllZone.getHumanPlayer().getZone(Zone.Hand).add(c); AllZone.getHumanPlayer().getZone(Zone.Hand).add(c);
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
c.setSickness(false); c.setSickness(false);
} }
for (final Card c : computerDevSetup) { for (final Card c : computerDevSetup) {
AllZone.getComputerPlayer().getZone(Zone.Hand).add(c); AllZone.getComputerPlayer().getZone(Zone.Hand).add(c);
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
c.setSickness(false); c.setSickness(false);
} }
@@ -1400,7 +1400,7 @@ public final class GuiDisplayUtil {
AllZone.getHumanPlayer().setLife(setHumanLife, null); AllZone.getHumanPlayer().setLife(setHumanLife, null);
} }
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
AllZone.getPhaseHandler().updateObservers(); AllZone.getPhaseHandler().updateObservers();
AllZone.getHumanPlayer().getZone(Zone.Exile).updateObservers(); AllZone.getHumanPlayer().getZone(Zone.Exile).updateObservers();
AllZone.getComputerPlayer().getZone(Zone.Exile).updateObservers(); AllZone.getComputerPlayer().getZone(Zone.Exile).updateObservers();
@@ -1475,7 +1475,7 @@ public final class GuiDisplayUtil {
return; return;
} else { } else {
final Card c = (Card) o; final Card c = (Card) o;
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
} }
} }

View File

@@ -143,11 +143,11 @@ public class HumanPlayer extends Player {
// might have to make this more sophisticated // might have to make this more sophisticated
// dredge library, put card in hand // dredge library, put card in hand
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
for (int i = 0; i < this.getDredgeNumber(c); i++) { for (int i = 0; i < this.getDredgeNumber(c); i++) {
final Card c2 = AllZone.getHumanPlayer().getZone(Zone.Library).get(0); final Card c2 = AllZone.getHumanPlayer().getZone(Zone.Library).get(0);
AllZone.getGameAction().moveToGraveyard(c2); Singletons.getModel().getGameAction().moveToGraveyard(c2);
} }
dredged = true; dredged = true;
} else { } else {
@@ -214,7 +214,7 @@ public class HumanPlayer extends Player {
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;
topN.remove(c); topN.remove(c);
AllZone.getGameAction().moveToBottomOfLibrary(c); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
} else { } else {
// no card chosen for the bottom // no card chosen for the bottom
break; break;
@@ -227,7 +227,7 @@ public class HumanPlayer extends Player {
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;
topN.remove(c); topN.remove(c);
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
} }
// no else - a card must have been chosen // no else - a card must have been chosen
} }
@@ -249,9 +249,9 @@ public class HumanPlayer extends Player {
choice = GuiUtils.getChoice(c.getName() + " - Top or bottom of Library", choices); choice = GuiUtils.getChoice(c.getName() + " - Top or bottom of Library", choices);
if (choice.equals("bottom")) { if (choice.equals("bottom")) {
AllZone.getGameAction().moveToBottomOfLibrary(c); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
} else { } else {
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
} }
} }

View File

@@ -182,7 +182,7 @@ public class MagicStack extends MyObservable {
if (ability.isSpell()) { if (ability.isSpell()) {
final Card source = ability.getSourceCard(); final Card source = ability.getSourceCard();
if (!source.isCopiedSpell() && !source.isInZone(Constant.Zone.Stack)) { if (!source.isCopiedSpell() && !source.isInZone(Constant.Zone.Stack)) {
ability.setSourceCard(AllZone.getGameAction().moveToStack(source)); ability.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
} }
} }
@@ -204,7 +204,7 @@ public class MagicStack extends MyObservable {
this.add(sa); this.add(sa);
} }
if (checkState) { if (checkState) {
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
} }
} }
@@ -294,7 +294,7 @@ public class MagicStack extends MyObservable {
ManaCost manaCost = new ManaCost(sa.getManaCost()); ManaCost manaCost = new ManaCost(sa.getManaCost());
String mana = manaCost.toString(); String mana = manaCost.toString();
int multiKickerPaid = AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaid(); int multiKickerPaid = Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid();
String numberManaCost = " "; String numberManaCost = " ";
@@ -313,12 +313,12 @@ public class MagicStack extends MyObservable {
if ((check - multiKickerPaid) < 0) { if ((check - multiKickerPaid) < 0) {
multiKickerPaid = multiKickerPaid - check; multiKickerPaid = multiKickerPaid - check;
AllZone.getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid); Singletons.getModel().getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid);
mana = mana.replaceFirst(String.valueOf(check), "0"); mana = mana.replaceFirst(String.valueOf(check), "0");
} else { } else {
mana = mana.replaceFirst(String.valueOf(check), String.valueOf(check - multiKickerPaid)); mana = mana.replaceFirst(String.valueOf(check), String.valueOf(check - multiKickerPaid));
multiKickerPaid = 0; multiKickerPaid = 0;
AllZone.getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid); Singletons.getModel().getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid);
} }
} }
mana = mana.trim(); mana = mana.trim();
@@ -327,15 +327,15 @@ public class MagicStack extends MyObservable {
} }
manaCost = new ManaCost(mana); manaCost = new ManaCost(mana);
} }
final String colorCut = AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored(); final String colorCut = Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored();
for (int colorCutIx = 0; colorCutIx < colorCut.length(); colorCutIx++) { for (int colorCutIx = 0; colorCutIx < colorCut.length(); colorCutIx++) {
if ("WUGRB".contains(colorCut.substring(colorCutIx, colorCutIx + 1)) if ("WUGRB".contains(colorCut.substring(colorCutIx, colorCutIx + 1))
&& !mana.equals(mana.replaceFirst((colorCut.substring(colorCutIx, colorCutIx + 1)), ""))) { && !mana.equals(mana.replaceFirst((colorCut.substring(colorCutIx, colorCutIx + 1)), ""))) {
mana = mana.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""); mana = mana.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), "");
AllZone.getGameAction().setCostCuttingGetMultiMickerManaCostPaidColored( Singletons.getModel().getGameAction().setCostCuttingGetMultiMickerManaCostPaidColored(
AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored() Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored()
.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), "")); .replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""));
mana = mana.trim(); mana = mana.trim();
@@ -537,8 +537,8 @@ public class MagicStack extends MyObservable {
if (manaCost.isPaid()) { if (manaCost.isPaid()) {
this.execute(); this.execute();
} else { } else {
if ((AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0) if ((Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0)
&& AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored() && Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored()
.equals("")) { .equals("")) {
AllZone.getInputControl().setInput( AllZone.getInputControl().setInput(
@@ -553,13 +553,12 @@ public class MagicStack extends MyObservable {
+ sa.getSourceCard() + sa.getSourceCard()
+ "\r\n" + "\r\n"
+ "Mana in Reserve: " + "Mana in Reserve: "
+ ((AllZone.getGameAction() + ((Singletons.getModel().getGameAction()
.getCostCuttingGetMultiMickerManaCostPaid() != 0) ? AllZone .getCostCuttingGetMultiMickerManaCostPaid() != 0) ?
.getGameAction() Singletons.getModel().getGameAction()
.getCostCuttingGetMultiMickerManaCostPaid() .getCostCuttingGetMultiMickerManaCostPaid()
: "") : "")
+ AllZone + Singletons.getModel().getGameAction()
.getGameAction()
.getCostCuttingGetMultiMickerManaCostPaidColored() .getCostCuttingGetMultiMickerManaCostPaidColored()
+ "\r\n" + "Times Kicked: " + "\r\n" + "Times Kicked: "
+ sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n",
@@ -575,8 +574,8 @@ public class MagicStack extends MyObservable {
if (manaCost.isPaid()) { if (manaCost.isPaid()) {
paidCommand.execute(); paidCommand.execute();
} else { } else {
if ((AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0) if ((Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0)
&& AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored().equals("")) { && Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored().equals("")) {
AllZone.getInputControl().setInput( AllZone.getInputControl().setInput(
new InputPayManaCostAbility("Multikicker for " + sa.getSourceCard() + "\r\n" new InputPayManaCostAbility("Multikicker for " + sa.getSourceCard() + "\r\n"
+ "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", + "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n",
@@ -588,11 +587,11 @@ public class MagicStack extends MyObservable {
+ sa.getSourceCard() + sa.getSourceCard()
+ "\r\n" + "\r\n"
+ "Mana in Reserve: " + "Mana in Reserve: "
+ ((AllZone.getGameAction() + ((Singletons.getModel().getGameAction()
.getCostCuttingGetMultiMickerManaCostPaid() != 0) ? AllZone .getCostCuttingGetMultiMickerManaCostPaid() != 0) ?
.getGameAction().getCostCuttingGetMultiMickerManaCostPaid() Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid()
: "") : "")
+ AllZone.getGameAction() + Singletons.getModel().getGameAction()
.getCostCuttingGetMultiMickerManaCostPaidColored() + "\r\n" .getCostCuttingGetMultiMickerManaCostPaidColored() + "\r\n"
+ "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude()
+ "\r\n", manaCost.toString(), paidCommand, unpaidCommand)); + "\r\n", manaCost.toString(), paidCommand, unpaidCommand));
@@ -753,14 +752,14 @@ public class MagicStack extends MyObservable {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getStack().pop(); AllZone.getStack().pop();
AllZone.getGameAction().moveToGraveyard(sp.getSourceCard()); Singletons.getModel().getGameAction().moveToGraveyard(sp.getSourceCard());
this.stop(); this.stop();
} }
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() && c.isLand()) { if (zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() && c.isLand()) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
this.stop(); this.stop();
} }
} }
@@ -775,7 +774,7 @@ public class MagicStack extends MyObservable {
AllZone.getComputerPlayer().sacrificePermanent("prompt", lands); AllZone.getComputerPlayer().sacrificePermanent("prompt", lands);
} else { } else {
AllZone.getStack().pop(); AllZone.getStack().pop();
AllZone.getGameAction().moveToGraveyard(sp.getSourceCard()); Singletons.getModel().getGameAction().moveToGraveyard(sp.getSourceCard());
} }
} }
} }
@@ -920,7 +919,7 @@ public class MagicStack extends MyObservable {
final Ability haunterDiesWork = new Ability(source, "0") { final Ability haunterDiesWork = new Ability(source, "0") {
@Override @Override
public void resolve() { public void resolve() {
AllZone.getGameAction().exile(source); Singletons.getModel().getGameAction().exile(source);
this.getTargetCard().addHauntedBy(source); this.getTargetCard().addHauntedBy(source);
} }
}; };
@@ -992,9 +991,9 @@ public class MagicStack extends MyObservable {
} }
// Handle cards that need to be moved differently // Handle cards that need to be moved differently
else if (sa.isBuyBackAbility() && !fizzle) { else if (sa.isBuyBackAbility() && !fizzle) {
AllZone.getGameAction().moveToHand(source); Singletons.getModel().getGameAction().moveToHand(source);
} else if (sa.isFlashBackAbility()) { } else if (sa.isFlashBackAbility()) {
AllZone.getGameAction().exile(source); Singletons.getModel().getGameAction().exile(source);
sa.setFlashBackAbility(false); sa.setFlashBackAbility(false);
} else if (source.hasKeyword("Rebound") } else if (source.hasKeyword("Rebound")
&& source.getCastFrom() == Zone.Hand && source.getCastFrom() == Zone.Hand
@@ -1003,7 +1002,7 @@ public class MagicStack extends MyObservable {
{ {
//Move rebounding card to exile //Move rebounding card to exile
AllZone.getGameAction().exile(source); Singletons.getModel().getGameAction().exile(source);
System.out.println("rebound1: " + source); System.out.println("rebound1: " + source);
//Setup a Rebound-trigger //Setup a Rebound-trigger
@@ -1041,7 +1040,7 @@ public class MagicStack extends MyObservable {
return; return;
} }
if (source.getOwner().isHuman()) { if (source.getOwner().isHuman()) {
AllZone.getGameAction().playCardNoCost(source); Singletons.getModel().getGameAction().playCardNoCost(source);
} else { } else {
System.out.println("rebound: " + source); System.out.println("rebound: " + source);
for (SpellAbility s : source.getSpells()) { for (SpellAbility s : source.getSpells()) {
@@ -1055,7 +1054,7 @@ public class MagicStack extends MyObservable {
} }
} }
AllZone.getGameAction().moveToGraveyard(source); Singletons.getModel().getGameAction().moveToGraveyard(source);
} }
}; };
@@ -1068,7 +1067,7 @@ public class MagicStack extends MyObservable {
// replace its own movement // replace its own movement
else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle) else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle)
&& source.isInZone(Constant.Zone.Stack)) { && source.isInZone(Constant.Zone.Stack)) {
AllZone.getGameAction().moveToGraveyard(source); Singletons.getModel().getGameAction().moveToGraveyard(source);
} }
} }
@@ -1093,7 +1092,7 @@ public class MagicStack extends MyObservable {
this.unfreezeStack(); this.unfreezeStack();
sa.resetOnceResolved(); sa.resetOnceResolved();
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
AllZone.getPhaseHandler().setNeedToNextPhase(false); AllZone.getPhaseHandler().setNeedToNextPhase(false);
@@ -1391,18 +1390,18 @@ public class MagicStack extends MyObservable {
activePlayerSAs.remove(next); activePlayerSAs.remove(next);
if (next.isTrigger()) { if (next.isTrigger()) {
AllZone.getGameAction().playSpellAbility(next); Singletons.getModel().getGameAction().playSpellAbility(next);
} else { } else {
this.add(next); this.add(next);
} }
} }
if (activePlayerSAs.get(0).isTrigger()) { if (activePlayerSAs.get(0).isTrigger()) {
AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0)); Singletons.getModel().getGameAction().playSpellAbility(activePlayerSAs.get(0));
} else { } else {
this.add(activePlayerSAs.get(0)); this.add(activePlayerSAs.get(0));
} }
// AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0)); // Singletons.getModel().getGameAction().playSpellAbility(activePlayerSAs.get(0));
} }
} }

View File

@@ -314,7 +314,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
final String phase = AllZone.getPhaseHandler().getPhase(); final String phase = AllZone.getPhaseHandler().getPhase();
final Player turn = AllZone.getPhaseHandler().getPlayerTurn(); final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
AllZone.getPhaseHandler().setSkipPhase(true); AllZone.getPhaseHandler().setSkipPhase(true);
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
// UNTAP // UNTAP
if (phase.equals(Constant.Phase.UNTAP)) { if (phase.equals(Constant.Phase.UNTAP)) {
@@ -383,7 +383,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
Combat.dealAssignedDamage(); Combat.dealAssignedDamage();
} }
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
CombatUtil.showCombat(); CombatUtil.showCombat();
} }
} }
@@ -401,7 +401,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
Combat.dealAssignedDamage(); Combat.dealAssignedDamage();
} }
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
CombatUtil.showCombat(); CombatUtil.showCombat();
} }
} }
@@ -579,6 +579,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
// When consecutively skipping phases (like in combat) this section // When consecutively skipping phases (like in combat) this section
// pushes through that block // pushes through that block
this.updateObservers(); this.updateObservers();
if ((AllZone.getPhaseHandler() != null) && AllZone.getPhaseHandler().isNeedToNextPhase()) { if ((AllZone.getPhaseHandler() != null) && AllZone.getPhaseHandler().isNeedToNextPhase()) {
AllZone.getPhaseHandler().setNeedToNextPhase(false); AllZone.getPhaseHandler().setNeedToNextPhase(false);
AllZone.getPhaseHandler().nextPhase(); AllZone.getPhaseHandler().nextPhase();

View File

@@ -86,7 +86,7 @@ public class PhaseUtil {
} }
turn.incrementTurn(); turn.incrementTurn();
AllZone.getGameAction().resetActivationsPerTurn(); Singletons.getModel().getGameAction().resetActivationsPerTurn();
final CardList lands = AllZoneUtil.getPlayerLandsInPlay(turn).filter(CardListFilter.UNTAPPED); final CardList lands = AllZoneUtil.getPlayerLandsInPlay(turn).filter(CardListFilter.UNTAPPED);
turn.setNumPowerSurgeLands(lands.size()); turn.setNumPowerSurgeLands(lands.size());

View File

@@ -760,7 +760,7 @@ public abstract class Player extends GameEntity {
for (int i = 0; i < damage; i++) { for (int i = 0; i < damage; i++) {
final CardList lib = this.getCardsIn(Zone.Library); final CardList lib = this.getCardsIn(Zone.Library);
if (lib.size() > 0) { if (lib.size() > 0) {
AllZone.getGameAction().exile(lib.get(0)); Singletons.getModel().getGameAction().exile(lib.get(0));
} }
} }
// return so things like Lifelink, etc do not trigger. This is a // return so things like Lifelink, etc do not trigger. This is a
@@ -1108,7 +1108,7 @@ public abstract class Player extends GameEntity {
// ////////////////////////////// // //////////////////////////////
// / // /
// / replaces AllZone.getGameAction().draw* methods // / replaces Singletons.getModel().getGameAction().draw* methods
// / // /
// ////////////////////////////// // //////////////////////////////
@@ -1258,7 +1258,7 @@ public abstract class Player extends GameEntity {
if (library.size() != 0) { if (library.size() != 0) {
Card c = library.get(0); Card c = library.get(0);
c = AllZone.getGameAction().moveToHand(c); c = Singletons.getModel().getGameAction().moveToHand(c);
drawn.add(c); drawn.add(c);
if ((this.numDrawnThisTurn == 0) && this.isComputer()) { if ((this.numDrawnThisTurn == 0) && this.isComputer()) {
@@ -1291,7 +1291,7 @@ public abstract class Player extends GameEntity {
// Condition // Condition
if (!this.cantLose()) { if (!this.cantLose()) {
this.loseConditionMet(GameLossReason.Milled, null); this.loseConditionMet(GameLossReason.Milled, null);
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
} }
} }
return drawn; return drawn;
@@ -1458,7 +1458,7 @@ public abstract class Player extends GameEntity {
// ////////////////////////////// // //////////////////////////////
// / // /
// / replaces AllZone.getGameAction().discard* methods // / replaces Singletons.getModel().getGameAction().discard* methods
// / // /
// ////////////////////////////// // //////////////////////////////
@@ -1527,7 +1527,7 @@ public abstract class Player extends GameEntity {
sa.addCostToHashList(c, "Discarded"); sa.addCostToHashList(c, "Discarded");
} }
AllZone.getGameAction().discardMadness(c); Singletons.getModel().getGameAction().discardMadness(c);
if ((c.hasKeyword("If a spell or ability an opponent controls causes " 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 + "you to discard CARDNAME, put it onto the battlefield instead of putting it into your graveyard.") || c
@@ -1535,9 +1535,9 @@ public abstract class Player extends GameEntity {
+ "you to discard CARDNAME, put it onto the battlefield with two +1/+1 " + "you to discard CARDNAME, put it onto the battlefield with two +1/+1 "
+ "counters on it instead of putting it into your graveyard.")) + "counters on it instead of putting it into your graveyard."))
&& (null != sa) && !c.getController().equals(sa.getSourceCard().getController())) { && (null != sa) && !c.getController().equals(sa.getSourceCard().getController())) {
AllZone.getGameAction().discardPutIntoPlayInstead(c); Singletons.getModel().getGameAction().discardPutIntoPlayInstead(c);
} else { } else {
AllZone.getGameAction().moveToGraveyard(c); Singletons.getModel().getGameAction().moveToGraveyard(c);
} }
// Run triggers // Run triggers
@@ -1673,9 +1673,9 @@ public abstract class Player extends GameEntity {
for (int i = 0; i < max; i++) { for (int i = 0; i < max; i++) {
if (bottom) { if (bottom) {
milled.add(AllZone.getGameAction().moveTo(destination, lib.get(lib.size() - 1))); milled.add(Singletons.getModel().getGameAction().moveTo(destination, lib.get(lib.size() - 1)));
} else { } else {
milled.add(AllZone.getGameAction().moveTo(destination, lib.get(i))); milled.add(Singletons.getModel().getGameAction().moveTo(destination, lib.get(i)));
} }
} }
@@ -1786,13 +1786,13 @@ public abstract class Player extends GameEntity {
public final void playLand(final Card land) { public final void playLand(final Card land) {
if (this.canPlayLand()) { if (this.canPlayLand()) {
land.addController(this); land.addController(this);
AllZone.getGameAction().moveTo(this.getZone(Constant.Zone.Battlefield), land); Singletons.getModel().getGameAction().moveTo(this.getZone(Constant.Zone.Battlefield), land);
CardFactoryUtil.playLandEffects(land); CardFactoryUtil.playLandEffects(land);
this.numLandsPlayed++; this.numLandsPlayed++;
// check state effects for static animate (Living Lands, Conversion, // check state effects for static animate (Living Lands, Conversion,
// etc...) // etc...)
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
// add to log // add to log
AllZone.getGameLog().add("Land", this + " played " + land, 2); AllZone.getGameLog().add("Land", this + " played " + land, 2);

View File

@@ -288,7 +288,7 @@ public final class PlayerUtil {
@Override @Override
public void selectCard(final Card card, final PlayerZone zone) { public void selectCard(final Card card, final PlayerZone zone) {
if (zone.equals(AllZone.getHumanPlayer().getZone(Zone.Battlefield)) && list.contains(card)) { if (zone.equals(AllZone.getHumanPlayer().getZone(Zone.Battlefield)) && list.contains(card)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.n++; this.n++;
list.remove(card); list.remove(card);
@@ -345,7 +345,7 @@ public final class PlayerUtil {
position = -1; position = -1;
} }
AllZone.getGameAction().moveToLibrary(card, position); Singletons.getModel().getGameAction().moveToLibrary(card, position);
this.n++; this.n++;
if (this.n == num) { if (this.n == num) {

View File

@@ -98,7 +98,7 @@ public class Untap extends Phase implements java.io.Serializable {
for (final Card c : list) { for (final Card c : list) {
if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) { if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
} }
} }

View File

@@ -135,7 +135,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
} else if (GameActionUtil.showYesNoDialog(c, sb.toString())) { } else if (GameActionUtil.showYesNoDialog(c, sb.toString())) {
abMana.produceMana(); abMana.produceMana();
} else { } else {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
} }
@@ -172,7 +172,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
}; };
@@ -191,7 +191,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (ComputerUtil.canPayCost(aiPaid)) { if (ComputerUtil.canPayCost(aiPaid)) {
ComputerUtil.playNoStack(aiPaid); ComputerUtil.playNoStack(aiPaid);
} else { } else {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
} }
} }
@@ -290,7 +290,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (c.getName().equals("Cosmic Horror")) { if (c.getName().equals("Cosmic Horror")) {
controller.addDamage(7, c); controller.addDamage(7, c);
} }
AllZone.getGameAction().destroy(c); Singletons.getModel().getGameAction().destroy(c);
} }
}; };
@@ -313,7 +313,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (c.getName().equals("Cosmic Horror")) { if (c.getName().equals("Cosmic Horror")) {
controller.addDamage(7, c); controller.addDamage(7, c);
} }
AllZone.getGameAction().destroy(c); Singletons.getModel().getGameAction().destroy(c);
} }
} }
} }
@@ -350,7 +350,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
}; };
@@ -368,7 +368,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (ComputerUtil.canPayCost(aiPaid)) { if (ComputerUtil.canPayCost(aiPaid)) {
ComputerUtil.playNoStack(aiPaid); ComputerUtil.playNoStack(aiPaid);
} else { } else {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
} }
} }
@@ -499,7 +499,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
// probably need to restrict by controller // probably need to restrict by controller
// also // also
if (targets.contains(selected)) { if (targets.contains(selected)) {
AllZone.getGameAction().destroyNoRegeneration(selected); Singletons.getModel().getGameAction().destroyNoRegeneration(selected);
this.stop(); this.stop();
} }
} // selectCard() } // selectCard()
@@ -509,13 +509,13 @@ public class Upkeep extends Phase implements java.io.Serializable {
final CardList indestruct = targets.getKeyword("Indestructible"); final CardList indestruct = targets.getKeyword("Indestructible");
if (indestruct.size() > 0) { if (indestruct.size() > 0) {
AllZone.getGameAction().destroyNoRegeneration(indestruct.get(0)); Singletons.getModel().getGameAction().destroyNoRegeneration(indestruct.get(0));
} else if (targets.size() > 0) { } else if (targets.size() > 0) {
final Card target = CardFactoryUtil.getWorstCreatureAI(targets); final Card target = CardFactoryUtil.getWorstCreatureAI(targets);
if (null == target) { if (null == target) {
// must be nothing valid to destroy // must be nothing valid to destroy
} else { } else {
AllZone.getGameAction().destroyNoRegeneration(target); Singletons.getModel().getGameAction().destroyNoRegeneration(target);
} }
} }
} }
@@ -576,7 +576,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
// probably need to restrict by controller also // probably need to restrict by controller also
if (artifact.isArtifact() && zone.is(Constant.Zone.Battlefield) if (artifact.isArtifact() && zone.is(Constant.Zone.Battlefield)
&& zone.getPlayer().isHuman()) { && zone.getPlayer().isHuman()) {
AllZone.getGameAction().sacrifice(artifact); Singletons.getModel().getGameAction().sacrifice(artifact);
this.stop(); this.stop();
} }
} // selectCard() } // selectCard()
@@ -586,7 +586,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (null == target) { if (null == target) {
this.tapAndDamage(player); this.tapAndDamage(player);
} else { } else {
AllZone.getGameAction().sacrifice(target); Singletons.getModel().getGameAction().sacrifice(target);
} }
} }
} // resolve } // resolve
@@ -635,7 +635,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
* PlayerUtil.inputSacrificePermanent(creatures, c.getName() + * PlayerUtil.inputSacrificePermanent(creatures, c.getName() +
* " - Select a creature to sacrifice.")); } else { // computer final Card * " - Select a creature to sacrifice.")); } else { // computer final Card
* target = CardFactoryUtil.getWorstCreatureAI(creatures); * target = CardFactoryUtil.getWorstCreatureAI(creatures);
* AllZone.getGameAction().sacrifice(target); } } // resolve }; * Singletons.getModel().getGameAction().sacrifice(target); } } // resolve };
* *
* final Ability sevenDamage = new Ability(c, "") { * final Ability sevenDamage = new Ability(c, "") {
* *
@@ -693,7 +693,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
"Select creature with power: " + power + " to sacrifice.")); "Select creature with power: " + power + " to sacrifice."));
} else { // computer } else { // computer
final Card compyTarget = this.getCompyCardToDestroy(creatures); final Card compyTarget = this.getCompyCardToDestroy(creatures);
AllZone.getGameAction().destroyNoRegeneration(compyTarget); Singletons.getModel().getGameAction().destroyNoRegeneration(compyTarget);
} }
} }
} // resolve } // resolve
@@ -770,7 +770,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
} else { } else {
final Card target = CardFactoryUtil.getBestLandAI(playerLand); final Card target = CardFactoryUtil.getBestLandAI(playerLand);
AllZone.getGameAction().sacrifice(target); Singletons.getModel().getGameAction().sacrifice(target);
} }
} // end resolve() } // end resolve()
}; // end noPay ability }; // end noPay ability
@@ -1083,7 +1083,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (wantToPlayCard) { if (wantToPlayCard) {
if (player.isHuman()) { if (player.isHuman()) {
final Card c = library.get(0); final Card c = library.get(0);
AllZone.getGameAction().playCardNoCost(c); Singletons.getModel().getGameAction().playCardNoCost(c);
} }
// player isComputer() // player isComputer()
else { else {
@@ -2029,7 +2029,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
public void resolve() { public void resolve() {
final int fadeCounters = card.getCounters(Counters.FADE); final int fadeCounters = card.getCounters(Counters.FADE);
if (fadeCounters <= 0) { if (fadeCounters <= 0) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} else { } else {
card.subtractCounter(Counters.FADE, 1); card.subtractCounter(Counters.FADE, 1);
} }
@@ -2100,10 +2100,10 @@ public class Upkeep extends Phase implements java.io.Serializable {
final Card c = libraryList.get(i); final Card c = libraryList.get(i);
cardsToReveal.add(c); cardsToReveal.add(c);
if (c.isCreature()) { if (c.isCreature()) {
AllZone.getGameAction().moveTo(battlefield, c); Singletons.getModel().getGameAction().moveTo(battlefield, c);
break; break;
} else { } else {
AllZone.getGameAction().moveToGraveyard(c); Singletons.getModel().getGameAction().moveToGraveyard(c);
} }
} // for loop } // for loop
if (cardsToReveal.size() > 0) { if (cardsToReveal.size() > 0) {
@@ -2155,12 +2155,12 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (o != null) { if (o != null) {
final Card card = (Card) o; final Card card = (Card) o;
AllZone.getGameAction().moveToHand(card); Singletons.getModel().getGameAction().moveToHand(card);
} }
} else if (player.isComputer()) { } else if (player.isComputer()) {
final Card card = graveyardCreatures.get(0); final Card card = graveyardCreatures.get(0);
AllZone.getGameAction().moveToHand(card); Singletons.getModel().getGameAction().moveToHand(card);
} }
} }
} }
@@ -2456,7 +2456,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(crd); Singletons.getModel().getGameAction().sacrifice(crd);
this.stop(); this.stop();
} }
}; // Input }; // Input
@@ -2466,7 +2466,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
public void resolve() { public void resolve() {
if (crd.getController().isHuman()) { if (crd.getController().isHuman()) {
if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) {
AllZone.getGameAction().sacrifice(crd); Singletons.getModel().getGameAction().sacrifice(crd);
} else { } else {
AllZone.getInputControl().setInput(discard); AllZone.getInputControl().setInput(discard);
} }
@@ -2476,7 +2476,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (list.size() != 0) { if (list.size() != 0) {
list.get(0).getController().discard(list.get(0), this); list.get(0).getController().discard(list.get(0), this);
} else { } else {
AllZone.getGameAction().sacrifice(crd); Singletons.getModel().getGameAction().sacrifice(crd);
} }
} // else } // else
} // resolve() } // resolve()
@@ -2511,7 +2511,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
final CardList creats = AllZoneUtil.getCreaturesInPlay(player); final CardList creats = AllZoneUtil.getCreaturesInPlay(player);
if (creats.size() < 1) { if (creats.size() < 1) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
return; return;
} }
@@ -2522,10 +2522,10 @@ public class Upkeep extends Phase implements java.io.Serializable {
creats.shuffle(); creats.shuffle();
sac = creats.get(0); sac = creats.get(0);
} }
AllZone.getGameAction().sacrifice(sac); Singletons.getModel().getGameAction().sacrifice(sac);
} else { // computer } else { // computer
CardListUtil.sortAttackLowFirst(creats); CardListUtil.sortAttackLowFirst(creats);
AllZone.getGameAction().sacrifice(creats.get(0)); Singletons.getModel().getGameAction().sacrifice(creats.get(0));
} }
} }
}; // ability }; // ability

View File

@@ -36,6 +36,7 @@ import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GameEntity; import forge.GameEntity;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
@@ -91,7 +92,7 @@ public class AbilityFactoryAttach {
public void resolve() { public void resolve() {
// The Spell_Permanent (Auras) version of this AF needs to // The Spell_Permanent (Auras) version of this AF needs to
// move the card into play before Attaching // move the card into play before Attaching
final Card c = AllZone.getGameAction().moveToPlay(this.getSourceCard()); final Card c = Singletons.getModel().getGameAction().moveToPlay(this.getSourceCard());
this.setSourceCard(c); this.setSourceCard(c);
AbilityFactoryAttach.attachResolve(this.af, this); AbilityFactoryAttach.attachResolve(this.af, this);
} }

View File

@@ -32,11 +32,12 @@ import forge.CardUtil;
import forge.CombatUtil; import forge.CombatUtil;
import forge.ComputerUtil; import forge.ComputerUtil;
import forge.Constant; import forge.Constant;
import forge.GameEntity;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.GameEntity;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostUtil; import forge.card.cost.CostUtil;
@@ -887,7 +888,7 @@ public final class AbilityFactoryChangeZone {
if (origin.contains(Zone.Library) && (i < 1)) { if (origin.contains(Zone.Library) && (i < 1)) {
player.shuffle(); player.shuffle();
} }
movedCard = AllZone.getGameAction().moveToLibrary(c, libraryPos); movedCard = Singletons.getModel().getGameAction().moveToLibrary(c, libraryPos);
} else if (destination.equals(Zone.Battlefield)) { } else if (destination.equals(Zone.Battlefield)) {
if (params.containsKey("Tapped")) { if (params.containsKey("Tapped")) {
c.setTapped(true); c.setTapped(true);
@@ -916,14 +917,14 @@ public final class AbilityFactoryChangeZone {
AllZone.getCombat().addAttacker(c); AllZone.getCombat().addAttacker(c);
} }
movedCard = AllZone.getGameAction().moveTo(c.getController().getZone(destination), c); movedCard = Singletons.getModel().getGameAction().moveTo(c.getController().getZone(destination), c);
} else if (destination.equals(Zone.Exile)) { } else if (destination.equals(Zone.Exile)) {
movedCard = AllZone.getGameAction().exile(c); movedCard = Singletons.getModel().getGameAction().exile(c);
if (params.containsKey("ExileFaceDown")) { if (params.containsKey("ExileFaceDown")) {
movedCard.setState("FaceDown"); movedCard.setState("FaceDown");
} }
} else { } else {
movedCard = AllZone.getGameAction().moveTo(destZone, c); movedCard = Singletons.getModel().getGameAction().moveTo(destZone, c);
} }
if (remember != null) { if (remember != null) {
@@ -1071,7 +1072,7 @@ public final class AbilityFactoryChangeZone {
if (Zone.Library.equals(destination)) { if (Zone.Library.equals(destination)) {
final int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params final int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params
.get("LibraryPosition")) : 0; .get("LibraryPosition")) : 0;
AllZone.getGameAction().moveToLibrary(c, libraryPos); Singletons.getModel().getGameAction().moveToLibrary(c, libraryPos);
} else if (Zone.Battlefield.equals(destination)) { } else if (Zone.Battlefield.equals(destination)) {
if (params.containsKey("Tapped")) { if (params.containsKey("Tapped")) {
c.tap(); c.tap();
@@ -1107,14 +1108,14 @@ public final class AbilityFactoryChangeZone {
} }
} }
newCard = AllZone.getGameAction().moveTo(c.getController().getZone(destination), c); newCard = Singletons.getModel().getGameAction().moveTo(c.getController().getZone(destination), c);
} else if (destination.equals(Zone.Exile)) { } else if (destination.equals(Zone.Exile)) {
newCard = AllZone.getGameAction().exile(c); newCard = Singletons.getModel().getGameAction().exile(c);
if (params.containsKey("ExileFaceDown")) { if (params.containsKey("ExileFaceDown")) {
newCard.setState("FaceDown"); newCard.setState("FaceDown");
} }
} else { } else {
newCard = AllZone.getGameAction().moveTo(destZone, c); newCard = Singletons.getModel().getGameAction().moveTo(destZone, c);
} }
if (remember != null) { if (remember != null) {
@@ -1885,7 +1886,7 @@ public final class AbilityFactoryChangeZone {
final int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params final int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params
.get("LibraryPosition")) : 0; .get("LibraryPosition")) : 0;
movedCard = AllZone.getGameAction().moveToLibrary(tgtC, libraryPosition); movedCard = Singletons.getModel().getGameAction().moveToLibrary(tgtC, libraryPosition);
// for things like Gaea's Blessing // for things like Gaea's Blessing
if (params.containsKey("Shuffle")) { if (params.containsKey("Shuffle")) {
@@ -1923,14 +1924,14 @@ public final class AbilityFactoryChangeZone {
} }
} }
movedCard = AllZone.getGameAction().moveTo(tgtC.getController().getZone(destination), tgtC); movedCard = Singletons.getModel().getGameAction().moveTo(tgtC.getController().getZone(destination), tgtC);
if (params.containsKey("Ninjutsu") || params.containsKey("Attacking")) { if (params.containsKey("Ninjutsu") || params.containsKey("Attacking")) {
AllZone.getCombat().addAttacker(tgtC); AllZone.getCombat().addAttacker(tgtC);
AllZone.getCombat().addUnblockedAttacker(tgtC); AllZone.getCombat().addUnblockedAttacker(tgtC);
} }
} else { } else {
movedCard = AllZone.getGameAction().moveTo(pl.getZone(destination), tgtC); movedCard = Singletons.getModel().getGameAction().moveTo(pl.getZone(destination), tgtC);
if (params.containsKey("ExileFaceDown")) { if (params.containsKey("ExileFaceDown")) {
movedCard.setState("FaceDown"); movedCard.setState("FaceDown");
} }
@@ -2349,9 +2350,9 @@ public final class AbilityFactoryChangeZone {
if (params.containsKey("GainControl")) { if (params.containsKey("GainControl")) {
c.addController(af.getHostCard()); c.addController(af.getHostCard());
AllZone.getGameAction().moveToPlay(c, sa.getActivatingPlayer()); Singletons.getModel().getGameAction().moveToPlay(c, sa.getActivatingPlayer());
} else { } else {
final Card movedCard = AllZone.getGameAction().moveTo(destination, c, libraryPos); final Card movedCard = Singletons.getModel().getGameAction().moveTo(destination, c, libraryPos);
if (params.containsKey("ExileFaceDown")) { if (params.containsKey("ExileFaceDown")) {
movedCard.setState("FaceDown"); movedCard.setState("FaceDown");
} }

View File

@@ -33,6 +33,7 @@ import forge.ComputerUtil;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
@@ -431,7 +432,7 @@ public final class AbilityFactoryCopy {
if (c.isFaceDown()) { if (c.isFaceDown()) {
c.setState("FaceDown"); c.setState("FaceDown");
} }
copy = AllZone.getGameAction().moveToPlay(copy); copy = Singletons.getModel().getGameAction().moveToPlay(copy);
copy.setCloneOrigin(hostCard); copy.setCloneOrigin(hostCard);
sa.getSourceCard().addClone(copy); sa.getSourceCard().addClone(copy);
@@ -456,9 +457,9 @@ public final class AbilityFactoryCopy {
if (params.get("AtEOT").equals("Sacrifice")) { if (params.get("AtEOT").equals("Sacrifice")) {
// maybe do a setSacrificeAtEOT, but // maybe do a setSacrificeAtEOT, but
// probably not. // probably not.
AllZone.getGameAction().sacrifice(target[index]); Singletons.getModel().getGameAction().sacrifice(target[index]);
} else if (params.get("AtEOT").equals("Exile")) { } else if (params.get("AtEOT").equals("Exile")) {
AllZone.getGameAction().exile(target[index]); Singletons.getModel().getGameAction().exile(target[index]);
} }
} }

View File

@@ -23,6 +23,7 @@ import java.util.HashMap;
import forge.AllZone; import forge.AllZone;
import forge.Card; import forge.Card;
import forge.ComputerUtil; import forge.ComputerUtil;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostUtil; import forge.card.cost.CostUtil;
@@ -418,7 +419,7 @@ public class AbilityFactoryCounterMagic {
// Destroy Permanent may be able to be turned into a SubAbility // Destroy Permanent may be able to be turned into a SubAbility
if (tgtSA.isAbility() && this.params.containsKey("DestroyPermanent")) { if (tgtSA.isAbility() && this.params.containsKey("DestroyPermanent")) {
AllZone.getGameAction().destroy(tgtSACard); Singletons.getModel().getGameAction().destroy(tgtSACard);
} }
if (this.params.containsKey("RememberTargets")) { if (this.params.containsKey("RememberTargets")) {
@@ -505,17 +506,17 @@ public class AbilityFactoryCounterMagic {
// For Ability-targeted counterspells - do not move it anywhere, // For Ability-targeted counterspells - do not move it anywhere,
// even if Destination$ is specified. // even if Destination$ is specified.
} else if (this.destination.equals("Graveyard")) { } else if (this.destination.equals("Graveyard")) {
AllZone.getGameAction().moveToGraveyard(tgtSA.getSourceCard()); Singletons.getModel().getGameAction().moveToGraveyard(tgtSA.getSourceCard());
} else if (this.destination.equals("Exile")) { } else if (this.destination.equals("Exile")) {
AllZone.getGameAction().exile(tgtSA.getSourceCard()); Singletons.getModel().getGameAction().exile(tgtSA.getSourceCard());
} else if (this.destination.equals("TopOfLibrary")) { } else if (this.destination.equals("TopOfLibrary")) {
AllZone.getGameAction().moveToLibrary(tgtSA.getSourceCard()); Singletons.getModel().getGameAction().moveToLibrary(tgtSA.getSourceCard());
} else if (this.destination.equals("Hand")) { } else if (this.destination.equals("Hand")) {
AllZone.getGameAction().moveToHand(tgtSA.getSourceCard()); Singletons.getModel().getGameAction().moveToHand(tgtSA.getSourceCard());
} else if (this.destination.equals("BottomOfLibrary")) { } else if (this.destination.equals("BottomOfLibrary")) {
AllZone.getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard()); Singletons.getModel().getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
} else if (this.destination.equals("ShuffleIntoLibrary")) { } else if (this.destination.equals("ShuffleIntoLibrary")) {
AllZone.getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard()); Singletons.getModel().getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
tgtSA.getSourceCard().getController().shuffle(); tgtSA.getSourceCard().getController().shuffle();
} else { } else {
throw new IllegalArgumentException("AbilityFactory_CounterMagic: Invalid Destination argument for card " throw new IllegalArgumentException("AbilityFactory_CounterMagic: Invalid Destination argument for card "

View File

@@ -31,6 +31,7 @@ import forge.CardUtil;
import forge.ComputerUtil; import forge.ComputerUtil;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostUtil; import forge.card.cost.CostUtil;
@@ -542,11 +543,11 @@ public class AbilityFactoryDestroy {
for (final Card tgtC : tgtCards) { for (final Card tgtC : tgtCards) {
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) { if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
if (sac) { if (sac) {
AllZone.getGameAction().sacrifice(tgtC); Singletons.getModel().getGameAction().sacrifice(tgtC);
} else if (noRegen) { } else if (noRegen) {
AllZone.getGameAction().destroyNoRegeneration(tgtC); Singletons.getModel().getGameAction().destroyNoRegeneration(tgtC);
} else { } else {
AllZone.getGameAction().destroy(tgtC); Singletons.getModel().getGameAction().destroy(tgtC);
} if (remDestroyed) { } if (remDestroyed) {
card.addRemembered(tgtC); card.addRemembered(tgtC);
} }
@@ -556,11 +557,11 @@ public class AbilityFactoryDestroy {
for (final Card unTgtC : untargetedCards) { for (final Card unTgtC : untargetedCards) {
if (AllZoneUtil.isCardInPlay(unTgtC)) { if (AllZoneUtil.isCardInPlay(unTgtC)) {
if (sac) { if (sac) {
AllZone.getGameAction().sacrifice(unTgtC); Singletons.getModel().getGameAction().sacrifice(unTgtC);
} else if (noRegen) { } else if (noRegen) {
AllZone.getGameAction().destroyNoRegeneration(unTgtC); Singletons.getModel().getGameAction().destroyNoRegeneration(unTgtC);
} else { } else {
AllZone.getGameAction().destroy(unTgtC); Singletons.getModel().getGameAction().destroy(unTgtC);
} if (remDestroyed) { } if (remDestroyed) {
card.addRemembered(unTgtC); card.addRemembered(unTgtC);
} }
@@ -896,13 +897,13 @@ public class AbilityFactoryDestroy {
if (noRegen) { if (noRegen) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (AllZone.getGameAction().destroyNoRegeneration(list.get(i)) && remDestroyed) { if (Singletons.getModel().getGameAction().destroyNoRegeneration(list.get(i)) && remDestroyed) {
card.addRemembered(list.get(i)); card.addRemembered(list.get(i));
} }
} }
} else { } else {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (AllZone.getGameAction().destroy(list.get(i)) && remDestroyed) { if (Singletons.getModel().getGameAction().destroy(list.get(i)) && remDestroyed) {
card.addRemembered(list.get(i)); card.addRemembered(list.get(i));
} }
} }

View File

@@ -32,6 +32,7 @@ import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.PhaseHandler; import forge.PhaseHandler;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
import forge.card.spellability.AbilitySub; import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell; import forge.card.spellability.Spell;
@@ -470,7 +471,7 @@ public class AbilityFactoryEffect {
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().exile(e); Singletons.getModel().getGameAction().exile(e);
} }
}; };
@@ -481,7 +482,7 @@ public class AbilityFactoryEffect {
// TODO: Add targeting to the effect so it knows who it's dealing with // TODO: Add targeting to the effect so it knows who it's dealing with
AllZone.getTriggerHandler().suppressMode("ChangesZone"); AllZone.getTriggerHandler().suppressMode("ChangesZone");
AllZone.getGameAction().moveToPlay(eff); Singletons.getModel().getGameAction().moveToPlay(eff);
AllZone.getTriggerHandler().clearSuppression("ChangesZone"); AllZone.getTriggerHandler().clearSuppression("ChangesZone");
} }

View File

@@ -33,6 +33,7 @@ import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GameEntity; import forge.GameEntity;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
@@ -429,7 +430,7 @@ public class AbilityFactoryGainControl {
if (AllZoneUtil.isCardInPlay(tgtC) && tgtC.canBeTargetedBy(sa)) { if (AllZoneUtil.isCardInPlay(tgtC) && tgtC.canBeTargetedBy(sa)) {
tgtC.addController(newController); tgtC.addController(newController);
// AllZone.getGameAction().changeController(new CardList(tgtC), // Singletons.getModel().getGameAction().changeController(new CardList(tgtC),
// tgtC.getController(), newController.get(0)); // tgtC.getController(), newController.get(0));
if (this.bUntap) { if (this.bUntap) {
@@ -547,9 +548,9 @@ public class AbilityFactoryGainControl {
public void resolve() { public void resolve() {
if (AbilityFactoryGainControl.this.bNoRegen) { if (AbilityFactoryGainControl.this.bNoRegen) {
AllZone.getGameAction().destroyNoRegeneration(c); Singletons.getModel().getGameAction().destroyNoRegeneration(c);
} else { } else {
AllZone.getGameAction().destroy(c); Singletons.getModel().getGameAction().destroy(c);
} }
} }
}; };
@@ -601,7 +602,7 @@ public class AbilityFactoryGainControl {
} }
if (AllZoneUtil.isCardInPlay(c)) { if (AllZoneUtil.isCardInPlay(c)) {
c.removeController(host); c.removeController(host);
// AllZone.getGameAction().changeController(new CardList(c), // Singletons.getModel().getGameAction().changeController(new CardList(c),
// c.getController(), originalController); // c.getController(), originalController);
if (tapOnLose) { if (tapOnLose) {

View File

@@ -31,6 +31,7 @@ import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Counters; import forge.Counters;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
@@ -368,7 +369,7 @@ public class AbilityFactoryMana {
final int num = card.getCounters(Counters.getType(deplete)); final int num = card.getCounters(Counters.getType(deplete));
if (num == 0) { if (num == 0) {
abMana.setUndoable(false); abMana.setUndoable(false);
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} }

View File

@@ -28,9 +28,10 @@ import forge.Card;
import forge.CardList; import forge.CardList;
import forge.CardListFilter; import forge.CardListFilter;
import forge.ComputerUtil; import forge.ComputerUtil;
import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Player; import forge.Player;
import forge.Constant.Zone; import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostMana; import forge.card.cost.CostMana;
@@ -432,7 +433,7 @@ public final class AbilityFactoryPlay {
newSA.setPayCosts(cost); newSA.setPayCosts(cost);
newSA.setManaCost(""); newSA.setManaCost("");
newSA.setDescription(sa.getDescription() + " (without paying its mana cost)"); newSA.setDescription(sa.getDescription() + " (without paying its mana cost)");
AllZone.getGameAction().playSpellAbility(newSA); Singletons.getModel().getGameAction().playSpellAbility(newSA);
} else { } else {
if (tgtSA instanceof Spell) { if (tgtSA instanceof Spell) {
Spell spell = (Spell) tgtSA; Spell spell = (Spell) tgtSA;
@@ -444,7 +445,7 @@ public final class AbilityFactoryPlay {
} }
} else { } else {
if (controller.isHuman()) { if (controller.isHuman()) {
AllZone.getGameAction().playSpellAbility(tgtSA); Singletons.getModel().getGameAction().playSpellAbility(tgtSA);
} else if (tgtSA.canPlayAI()) { } else if (tgtSA.canPlayAI()) {
ComputerUtil.playStack(tgtSA); ComputerUtil.playStack(tgtSA);
} }

View File

@@ -36,6 +36,7 @@ import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostUtil; import forge.card.cost.CostUtil;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
@@ -398,7 +399,7 @@ public final class AbilityFactoryReveal {
if (params.containsKey("Reveal")) { if (params.containsKey("Reveal")) {
GuiUtils.getChoice("Revealing cards from library", top.toArray()); GuiUtils.getChoice("Revealing cards from library", top.toArray());
cardsRevealed = true; cardsRevealed = true;
// AllZone.getGameAction().revealToCopmuter(top.toArray()); // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
// - for when it exists // - for when it exists
} else if (params.containsKey("RevealOptional")) { } else if (params.containsKey("RevealOptional")) {
String question = "Reveal: "; String question = "Reveal: ";
@@ -407,7 +408,7 @@ public final class AbilityFactoryReveal {
} }
if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) { if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) {
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray()); GuiUtils.getChoice(host + "Revealing cards from library", top.toArray());
// AllZone.getGameAction().revealToCopmuter(top.toArray()); // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
cardsRevealed = true; cardsRevealed = true;
} else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) { } else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) {
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray()); GuiUtils.getChoice(host + "Revealing cards from library", top.toArray());
@@ -424,7 +425,7 @@ public final class AbilityFactoryReveal {
} }
} }
} }
// AllZone.getGameAction().revealToCopmuter(top.toArray()); // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
// - for when it exists // - for when it exists
} else if (choser.isHuman()) { } else if (choser.isHuman()) {
// show the user the revealed cards // show the user the revealed cards
@@ -470,9 +471,9 @@ public final class AbilityFactoryReveal {
} }
final PlayerZone zone = c.getOwner().getZone(destZone1); final PlayerZone zone = c.getOwner().getZone(destZone1);
if (zone.is(Zone.Library)) { if (zone.is(Zone.Library)) {
AllZone.getGameAction().moveToLibrary(c, libraryPosition); Singletons.getModel().getGameAction().moveToLibrary(c, libraryPosition);
} else { } else {
AllZone.getGameAction().moveTo(zone, c); Singletons.getModel().getGameAction().moveTo(zone, c);
if (destZone1.equals(Zone.Battlefield) && params.containsKey("Tapped")) { if (destZone1.equals(Zone.Battlefield) && params.containsKey("Tapped")) {
c.setTapped(true); c.setTapped(true);
} }
@@ -509,9 +510,9 @@ public final class AbilityFactoryReveal {
final PlayerZone zone = chosen.getOwner().getZone(destZone1); final PlayerZone zone = chosen.getOwner().getZone(destZone1);
if (zone.is(Zone.Library)) { if (zone.is(Zone.Library)) {
// System.out.println("Moving to lib position: "+libraryPosition); // System.out.println("Moving to lib position: "+libraryPosition);
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition); Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition);
} else { } else {
final Card c = AllZone.getGameAction().moveTo(zone, chosen); final Card c = Singletons.getModel().getGameAction().moveTo(zone, chosen);
if (destZone1.equals(Zone.Battlefield) && !keywords.isEmpty()) { if (destZone1.equals(Zone.Battlefield) && !keywords.isEmpty()) {
for (final String kw : keywords) { for (final String kw : keywords) {
c.addExtrinsicKeyword(kw); c.addExtrinsicKeyword(kw);
@@ -521,7 +522,7 @@ public final class AbilityFactoryReveal {
} }
} }
} }
// AllZone.getGameAction().revealToComputer() // Singletons.getModel().getGameAction().revealToComputer()
// - for when this exists // - for when this exists
j++; j++;
} }
@@ -538,9 +539,9 @@ public final class AbilityFactoryReveal {
} }
final PlayerZone zone = chosen.getOwner().getZone(destZone1); final PlayerZone zone = chosen.getOwner().getZone(destZone1);
if (zone.is(Zone.Library)) { if (zone.is(Zone.Library)) {
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition); Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition);
} else { } else {
final Card c = AllZone.getGameAction().moveTo(zone, chosen); final Card c = Singletons.getModel().getGameAction().moveTo(zone, chosen);
if (destZone1.equals(Zone.Battlefield) && !keywords.isEmpty()) { if (destZone1.equals(Zone.Battlefield) && !keywords.isEmpty()) {
for (final String kw : keywords) { for (final String kw : keywords) {
chosen.addExtrinsicKeyword(kw); chosen.addExtrinsicKeyword(kw);
@@ -582,12 +583,12 @@ public final class AbilityFactoryReveal {
} else { } else {
chosen = rest.get(0); chosen = rest.get(0);
} }
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition2); Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition2);
rest.remove(chosen); rest.remove(chosen);
} }
} else { // Computer } else { // Computer
for (int i = 0; i < rest.size(); i++) { for (int i = 0; i < rest.size(); i++) {
AllZone.getGameAction().moveToLibrary(rest.get(i), libraryPosition2); Singletons.getModel().getGameAction().moveToLibrary(rest.get(i), libraryPosition2);
} }
} }
} else { } else {
@@ -595,7 +596,7 @@ public final class AbilityFactoryReveal {
for (int i = 0; i < rest.size(); i++) { for (int i = 0; i < rest.size(); i++) {
Card c = rest.get(i); Card c = rest.get(i);
final PlayerZone toZone = c.getOwner().getZone(destZone2); final PlayerZone toZone = c.getOwner().getZone(destZone2);
c = AllZone.getGameAction().moveTo(toZone, c); c = Singletons.getModel().getGameAction().moveTo(toZone, c);
if (destZone2.equals(Zone.Battlefield) && !keywords.isEmpty()) { if (destZone2.equals(Zone.Battlefield) && !keywords.isEmpty()) {
for (final String kw : keywords) { for (final String kw : keywords) {
c.addExtrinsicKeyword(kw); c.addExtrinsicKeyword(kw);
@@ -984,9 +985,9 @@ public final class AbilityFactoryReveal {
final Card c = itr.next(); final Card c = itr.next();
if (params.containsKey("GainControl") && foundDest.equals(Zone.Battlefield)) { if (params.containsKey("GainControl") && foundDest.equals(Zone.Battlefield)) {
c.addController(af.getHostCard()); c.addController(af.getHostCard());
AllZone.getGameAction().moveTo(c.getController().getZone(foundDest), c); Singletons.getModel().getGameAction().moveTo(c.getController().getZone(foundDest), c);
} else { } else {
AllZone.getGameAction().moveTo(foundDest, c, foundLibPos); Singletons.getModel().getGameAction().moveTo(foundDest, c, foundLibPos);
} }
revealed.remove(c); revealed.remove(c);
} }
@@ -1001,7 +1002,7 @@ public final class AbilityFactoryReveal {
final Iterator<Card> itr = revealed.iterator(); final Iterator<Card> itr = revealed.iterator();
while (itr.hasNext()) { while (itr.hasNext()) {
final Card c = itr.next(); final Card c = itr.next();
AllZone.getGameAction().moveTo(revealedDest, c, revealedLibPos); Singletons.getModel().getGameAction().moveTo(revealedDest, c, revealedLibPos);
} }
if (params.containsKey("Shuffle")) { if (params.containsKey("Shuffle")) {
@@ -1921,7 +1922,7 @@ public final class AbilityFactoryReveal {
} }
final Card c1 = (Card) o; final Card c1 = (Card) o;
topCards.remove(c1); topCards.remove(c1);
AllZone.getGameAction().moveToLibrary(c1, i - 1); Singletons.getModel().getGameAction().moveToLibrary(c1, i - 1);
} }
if (mayshuffle) { if (mayshuffle) {
if (GameActionUtil.showYesNoDialog(src, "Do you want to shuffle the library?")) { if (GameActionUtil.showYesNoDialog(src, "Do you want to shuffle the library?")) {

View File

@@ -29,6 +29,7 @@ import forge.ComputerUtil;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostUtil; import forge.card.cost.CostUtil;
@@ -455,7 +456,7 @@ public class AbilityFactorySacrifice {
if (valid.equals("Self")) { if (valid.equals("Self")) {
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)) { if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
if (remSacrificed) { if (remSacrificed) {
card.addRemembered(card); card.addRemembered(card);
@@ -465,7 +466,7 @@ public class AbilityFactorySacrifice {
else if (valid.equals("Card.AttachedBy")) { else if (valid.equals("Card.AttachedBy")) {
final Card toSac = card.getEnchantingCard(); final Card toSac = card.getEnchantingCard();
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) { if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) {
AllZone.getGameAction().sacrifice(toSac); Singletons.getModel().getGameAction().sacrifice(toSac);
if (remSacrificed) { if (remSacrificed) {
card.addRemembered(toSac); card.addRemembered(toSac);
} }
@@ -473,7 +474,7 @@ public class AbilityFactorySacrifice {
} else if (valid.equals("TriggeredCard")) { } else if (valid.equals("TriggeredCard")) {
final Card equipee = (Card) sa.getTriggeringObject("Card"); final Card equipee = (Card) sa.getTriggeringObject("Card");
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) { if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
AllZone.getGameAction().sacrifice(equipee); Singletons.getModel().getGameAction().sacrifice(equipee);
if (remSacrificed) { if (remSacrificed) {
card.addRemembered(equipee); card.addRemembered(equipee);
} }
@@ -561,11 +562,11 @@ public class AbilityFactorySacrifice {
final Card c = (Card) o; final Card c = (Card) o;
if (destroy) { if (destroy) {
if (AllZone.getGameAction().destroy(c)) { if (Singletons.getModel().getGameAction().destroy(c)) {
saccedList.add(c); saccedList.add(c);
} }
} else { } else {
if (AllZone.getGameAction().sacrifice(c)) { if (Singletons.getModel().getGameAction().sacrifice(c)) {
saccedList.add(c); saccedList.add(c);
} }
} }
@@ -857,7 +858,7 @@ public class AbilityFactorySacrifice {
list = AbilityFactory.filterListByType(list, valid, sa); list = AbilityFactory.filterListByType(list, valid, sa);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (AllZone.getGameAction().sacrifice(list.get(i)) && remSacrificed) { if (Singletons.getModel().getGameAction().sacrifice(list.get(i)) && remSacrificed) {
card.addRemembered(list.get(i)); card.addRemembered(list.get(i));
} }
} }

View File

@@ -24,6 +24,7 @@ import forge.AllZone;
import forge.Card; import forge.Card;
import forge.Constant; import forge.Constant;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
import forge.card.spellability.AbilitySub; import forge.card.spellability.AbilitySub;
import forge.card.spellability.Spell; import forge.card.spellability.Spell;
@@ -409,7 +410,7 @@ public class AbilityFactoryTurns {
// Time Stop, though it will continue to resolve. It also includes // Time Stop, though it will continue to resolve. It also includes
// spells and abilities that can't be countered. // spells and abilities that can't be countered.
for (final Card c : AllZone.getStackZone().getCards()) { for (final Card c : AllZone.getStackZone().getCards()) {
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
AllZone.getStack().getStack().clear(); AllZone.getStack().getStack().clear();
@@ -419,7 +420,7 @@ public class AbilityFactoryTurns {
// 3) State-based actions are checked. No player gets priority, and no // 3) State-based actions are checked. No player gets priority, and no
// triggered abilities are put onto the stack. // triggered abilities are put onto the stack.
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
// 4) The current phase and/or step ends. The game skips straight to the // 4) The current phase and/or step ends. The game skips straight to the
// cleanup step. The cleanup step happens in its entirety. // cleanup step. The cleanup step happens in its entirety.

View File

@@ -294,7 +294,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} }
if (controller.isHuman()) { if (controller.isHuman()) {
AllZone.getGameAction().playSpellAbilityForFree(copySA); Singletons.getModel().getGameAction().playSpellAbilityForFree(copySA);
} else if (copySA.canPlayAI()) { } else if (copySA.canPlayAI()) {
ComputerUtil.playStackFree(copySA); ComputerUtil.playStackFree(copySA);
} }
@@ -386,7 +386,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} }
if (source.getController().isHuman()) { if (source.getController().isHuman()) {
AllZone.getGameAction().playSpellAbilityForFree(copySA); Singletons.getModel().getGameAction().playSpellAbilityForFree(copySA);
} else if (copySA.canPlayAI()) { } else if (copySA.canPlayAI()) {
ComputerUtil.playStackFree(copySA); ComputerUtil.playStackFree(copySA);
} }
@@ -701,8 +701,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
if (o2 != null) { if (o2 != null) {
final Card c2 = (Card) o2; final Card c2 = (Card) o2;
newGrave.remove(c2); newGrave.remove(c2);
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
AllZone.getGameAction().exile(c2); Singletons.getModel().getGameAction().exile(c2);
this.once = true; this.once = true;
AllZone.getStack().addSimultaneousStackEntry(nightSoil); AllZone.getStack().addSimultaneousStackEntry(nightSoil);
@@ -798,7 +798,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
* targetHand.toArray()); * targetHand.toArray());
* *
* final Card card = (Card) discard; * final Card card = (Card) discard;
* AllZone.getGameAction().moveToLibrary(card); } else if * Singletons.getModel().getGameAction().moveToLibrary(card); } else if
* (target.isComputer()) { AllZone.getComputerPlayer().handToLibrary(1, * (target.isComputer()) { AllZone.getComputerPlayer().handToLibrary(1,
* "Top"); } } * "Top"); } }
* *
@@ -814,7 +814,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
* private static final long serialVersionUID = -8990402917139817175L; * private static final long serialVersionUID = -8990402917139817175L;
* *
* @Override public void resolve() { * @Override public void resolve() {
* AllZone.getGameAction().destroy(card); } * Singletons.getModel().getGameAction().destroy(card); }
* *
* @Override public boolean canPlay() { return super.canPlay(); } * @Override public boolean canPlay() { return super.canPlay(); }
* *
@@ -862,7 +862,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
AllZone.getHumanPlayer().discard(c, null); AllZone.getHumanPlayer().discard(c, null);
this.stop(); this.stop();
} else if (c.equals(card)) { } else if (c.equals(card)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
} }
@@ -873,7 +873,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
public void resolve() { public void resolve() {
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
if (AllZone.getHumanPlayer().getZone(Zone.Hand).isEmpty()) { if (AllZone.getHumanPlayer().getZone(Zone.Hand).isEmpty()) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} else { } else {
AllZone.getInputControl().setInput(discard); AllZone.getInputControl().setInput(discard);
} }
@@ -991,7 +991,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} // while } // while
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray()); GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray());
for (final Card revealedCard : revealed) { for (final Card revealedCard : revealed) {
AllZone.getGameAction().moveToBottomOfLibrary(revealedCard); Singletons.getModel().getGameAction().moveToBottomOfLibrary(revealedCard);
} }
if (this.getTargetCard() != null) { if (this.getTargetCard() != null) {
@@ -1072,7 +1072,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} }
final Card c1 = (Card) o; final Card c1 = (Card) o;
lands.remove(c1); // remove from the display list lands.remove(c1); // remove from the display list
AllZone.getGameAction().moveToLibrary(c1, i - 1); Singletons.getModel().getGameAction().moveToLibrary(c1, i - 1);
} }
} else { // Computer } else { // Computer
// based on current AI, computer should always target // based on current AI, computer should always target
@@ -1084,7 +1084,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} }
for (int i = 0; i < max; i++) { for (int i = 0; i < max; i++) {
AllZone.getGameAction().moveToLibrary(list.get(i)); Singletons.getModel().getGameAction().moveToLibrary(list.get(i));
} }
} }
@@ -1244,7 +1244,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
public void done() { public void done() {
// exile those cards // exile those cards
for (final Card c : this.exiled) { for (final Card c : this.exiled) {
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
// Put that many cards from the top of your // Put that many cards from the top of your
@@ -1253,7 +1253,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
final PlayerZone lib = AllZone.getHumanPlayer().getZone(Constant.Zone.Library); final PlayerZone lib = AllZone.getHumanPlayer().getZone(Constant.Zone.Library);
int numCards = 0; int numCards = 0;
while ((lib.size() > 0) && (numCards < this.exiled.size())) { while ((lib.size() > 0) && (numCards < this.exiled.size())) {
AllZone.getGameAction().moveToHand(lib.get(0)); Singletons.getModel().getGameAction().moveToHand(lib.get(0));
numCards++; numCards++;
} }
@@ -1267,7 +1267,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
final Object o = GuiUtils.getChoice("Put a card on top of your library.", final Object o = GuiUtils.getChoice("Put a card on top of your library.",
this.exiled.toArray()); this.exiled.toArray());
final Card c1 = (Card) o; final Card c1 = (Card) o;
AllZone.getGameAction().moveToLibrary(c1); Singletons.getModel().getGameAction().moveToLibrary(c1);
this.exiled.remove(c1); this.exiled.remove(c1);
} }
@@ -1327,7 +1327,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
JOptionPane.INFORMATION_MESSAGE); JOptionPane.INFORMATION_MESSAGE);
} }
} else { } else {
AllZone.getGameAction().playCardNoCost(freeCard); Singletons.getModel().getGameAction().playCardNoCost(freeCard);
} }
} else { } else {
JOptionPane.showMessageDialog(null, "Error in " + cardName + ". freeCard is null", "", JOptionPane.showMessageDialog(null, "Error in " + cardName + ". freeCard is null", "",
@@ -1567,7 +1567,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
AllZone.getTriggerHandler().clearSuppression("Transformed"); AllZone.getTriggerHandler().clearSuppression("Transformed");
} }
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
} }
private void grantExtras() { private void grantExtras() {
@@ -1649,7 +1649,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
player.payLife(4, card); player.payLife(4, card);
// card stays in hand // card stays in hand
} else { } else {
AllZone.getGameAction().moveToLibrary(card); Singletons.getModel().getGameAction().moveToLibrary(card);
} }
this.stop(); this.stop();
} }

View File

@@ -33,6 +33,7 @@ import forge.Command;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.Spell; import forge.card.spellability.Spell;
@@ -127,7 +128,7 @@ class CardFactoryAuras {
newType[0] = GuiUtils.getChoice("Select land type.", "Plains", "Island", "Swamp", "Mountain", newType[0] = GuiUtils.getChoice("Select land type.", "Plains", "Island", "Swamp", "Mountain",
"Forest"); "Forest");
} }
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
final Card c = this.getTargetCard(); final Card c = this.getTargetCard();
@@ -291,7 +292,7 @@ class CardFactoryAuras {
@Override @Override
public void resolve() { public void resolve() {
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
final Card c = this.getTargetCard(); final Card c = this.getTargetCard();
@@ -398,7 +399,7 @@ class CardFactoryAuras {
@Override @Override
public void resolve() { public void resolve() {
final Card aura = AllZone.getGameAction().moveToPlay(card); final Card aura = Singletons.getModel().getGameAction().moveToPlay(card);
final Card c = this.getTargetCard(); final Card c = this.getTargetCard();
@@ -480,14 +481,14 @@ class CardFactoryAuras {
if (!grave.is(Constant.Zone.Graveyard)) { if (!grave.is(Constant.Zone.Graveyard)) {
// Animated Creature got removed before ability resolved // Animated Creature got removed before ability resolved
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
return; return;
} }
// Bring creature onto the battlefield under your control // Bring creature onto the battlefield under your control
// (should trigger etb Abilities) // (should trigger etb Abilities)
animated.addController(card.getController()); animated.addController(card.getController());
AllZone.getGameAction().moveToPlay(animated, card.getController()); Singletons.getModel().getGameAction().moveToPlay(animated, card.getController());
if (cardName.equals("Dance of the Dead")) { if (cardName.equals("Dance of the Dead")) {
animated.tap(); animated.tap();
} }
@@ -496,7 +497,7 @@ class CardFactoryAuras {
if (CardFactoryUtil.hasProtectionFrom(card, animated)) { if (CardFactoryUtil.hasProtectionFrom(card, animated)) {
// Animated a creature with protection // Animated a creature with protection
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
return; return;
} }
@@ -515,7 +516,7 @@ class CardFactoryAuras {
// note: this should be a state-based action, but it doesn't work currently. // note: this should be a state-based action, but it doesn't work currently.
// I don't know if that because it's hard-coded or what, but this fixes // I don't know if that because it's hard-coded or what, but this fixes
// these cards being put on the battlefield not attached to anything. // these cards being put on the battlefield not attached to anything.
AllZone.getGameAction().moveToGraveyard(card); Singletons.getModel().getGameAction().moveToGraveyard(card);
} }
} }
}; };
@@ -529,7 +530,7 @@ class CardFactoryAuras {
final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield);
if (play.contains(c)) { if (play.contains(c)) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
} }
}; // Detach }; // Detach

View File

@@ -335,7 +335,7 @@ public class CardFactoryCreatures {
public void resolve() { public void resolve() {
final CardList hand = card.getController().getCardsIn(Zone.Hand); final CardList hand = card.getController().getCardsIn(Zone.Hand);
if (hand.size() == 0) { if (hand.size() == 0) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} else { } else {
card.getController().discardRandom(this); card.getController().discardRandom(this);
} }
@@ -509,7 +509,7 @@ public class CardFactoryCreatures {
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (zone.is(Constant.Zone.Hand) && !c.isLand()) { if (zone.is(Constant.Zone.Hand) && !c.isLand()) {
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
chosen.push(c); chosen.push(c);
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(card.toString()).append(" - Suspending ").append(c.toString()); sb.append(card.toString()).append(" - Suspending ").append(c.toString());
@@ -692,7 +692,7 @@ public class CardFactoryCreatures {
@Override @Override
public void execute() { public void execute() {
if (AllZoneUtil.isCardInPlay(card)) { if (AllZoneUtil.isCardInPlay(card)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} }
}); });
@@ -722,7 +722,7 @@ public class CardFactoryCreatures {
final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Stangg Twin"); final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Stangg Twin");
if (list.size() == 1) { if (list.size() == 1) {
AllZone.getGameAction().exile(list.get(0)); Singletons.getModel().getGameAction().exile(list.get(0));
} }
} }
}); });
@@ -744,7 +744,7 @@ public class CardFactoryCreatures {
if (card.getController().getZone(Zone.Graveyard).contains(c)) { if (card.getController().getZone(Zone.Graveyard).contains(c)) {
final PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield); final PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield);
AllZone.getGameAction().moveTo(play, c); Singletons.getModel().getGameAction().moveTo(play, c);
} }
} // resolve() } // resolve()
@@ -977,7 +977,7 @@ public class CardFactoryCreatures {
@Override @Override
public void execute() { public void execute() {
getTargetCard().addDamage(1, target); getTargetCard().addDamage(1, target);
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
} }
})); }));
} }
@@ -1068,7 +1068,7 @@ public class CardFactoryCreatures {
@Override @Override
public void resolve() { public void resolve() {
int xCounters = card.getXManaCostPaid(); int xCounters = card.getXManaCostPaid();
final Card c = AllZone.getGameAction().moveToPlay(this.getSourceCard()); final Card c = Singletons.getModel().getGameAction().moveToPlay(this.getSourceCard());
if (xCounters >= 5) { if (xCounters >= 5) {
xCounters = 2 * xCounters; xCounters = 2 * xCounters;
@@ -1172,7 +1172,7 @@ public class CardFactoryCreatures {
if (GameActionUtil.showYesNoDialog(card, question.toString())) { if (GameActionUtil.showYesNoDialog(card, question.toString())) {
if (card.getName().equals("Academy Rector")) { if (card.getName().equals("Academy Rector")) {
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
} }
CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Library); CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
list = list.getType("Enchantment"); list = list.getType("Enchantment");
@@ -1184,7 +1184,7 @@ public class CardFactoryCreatures {
if (objectSelected != null) { if (objectSelected != null) {
final Card c = (Card) objectSelected; final Card c = (Card) objectSelected;
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
if (c.isAura()) { if (c.isAura()) {
@@ -1295,9 +1295,9 @@ public class CardFactoryCreatures {
if (list.size() > 0) { if (list.size() > 0) {
final Card c = CardFactoryUtil.getBestEnchantmentAI(list, this, false); final Card c = CardFactoryUtil.getBestEnchantmentAI(list, this, false);
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
if (card.getName().equals("Academy Rector")) { if (card.getName().equals("Academy Rector")) {
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
} }
card.getController().shuffle(); card.getController().shuffle();
} }
@@ -1527,7 +1527,7 @@ public class CardFactoryCreatures {
for (int m = 0; m < selection.size(); m++) { for (int m = 0; m < selection.size(); m++) {
intermSumPower += selection.get(m).getBaseAttack(); intermSumPower += selection.get(m).getBaseAttack();
intermSumToughness += selection.get(m).getBaseDefense(); intermSumToughness += selection.get(m).getBaseDefense();
AllZone.getGameAction().exile(selection.get(m)); Singletons.getModel().getGameAction().exile(selection.get(m));
} }
} }
@@ -1539,7 +1539,7 @@ public class CardFactoryCreatures {
if ((c.getNetAttack() <= 2) && (c.getNetDefense() <= 3)) { if ((c.getNetAttack() <= 2) && (c.getNetDefense() <= 3)) {
intermSumPower += c.getBaseAttack(); intermSumPower += c.getBaseAttack();
intermSumToughness += c.getBaseDefense(); intermSumToughness += c.getBaseDefense();
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
count++; count++;
} }
// is this needed? // is this needed?
@@ -1730,7 +1730,7 @@ public class CardFactoryCreatures {
@Override @Override
public void resolve() { public void resolve() {
card.setKicked(true); card.setKicked(true);
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
card.addCounterFromNonEffect(Counters.P1P1, 2); card.addCounterFromNonEffect(Counters.P1P1, 2);
} }
@@ -1890,7 +1890,7 @@ public class CardFactoryCreatures {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
toSac.clear(); toSac.clear();
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@@ -1906,10 +1906,10 @@ public class CardFactoryCreatures {
private void done() { private void done() {
if (getTotalPower() >= 12) { if (getTotalPower() >= 12) {
for (final Card sac : toSac) { for (final Card sac : toSac) {
AllZone.getGameAction().sacrifice(sac); Singletons.getModel().getGameAction().sacrifice(sac);
} }
} else { } else {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
toSac.clear(); toSac.clear();
this.stop(); this.stop();
@@ -2037,7 +2037,7 @@ public class CardFactoryCreatures {
//keep the Clone card image for the cloned card //keep the Clone card image for the cloned card
card.setImageFilename(imageFileName); card.setImageFilename(imageFileName);
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
} }
private void grantExtras() { private void grantExtras() {
@@ -2342,14 +2342,14 @@ public class CardFactoryCreatures {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (zone.is(Constant.Zone.Battlefield) && arts.contains(c)) { if (zone.is(Constant.Zone.Battlefield) && arts.contains(c)) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
this.stop(); this.stop();
} }
} // selectCard() } // selectCard()

View File

@@ -29,6 +29,7 @@ import forge.Constant.Zone;
import forge.PhaseUtil; import forge.PhaseUtil;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.AbilitySub; import forge.card.spellability.AbilitySub;
@@ -139,10 +140,10 @@ public class CardFactoryInstants {
JOptionPane JOptionPane
.showMessageDialog(null, sbMsgP1.toString(), "", JOptionPane.INFORMATION_MESSAGE); .showMessageDialog(null, sbMsgP1.toString(), "", JOptionPane.INFORMATION_MESSAGE);
for (int i = 0; i < pile1.size(); i++) { for (int i = 0; i < pile1.size(); i++) {
AllZone.getGameAction().moveTo(hand, pile1.get(i)); Singletons.getModel().getGameAction().moveTo(hand, pile1.get(i));
} }
for (int i = 0; i < pile2.size(); i++) { for (int i = 0; i < pile2.size(); i++) {
AllZone.getGameAction().moveToGraveyard(pile2.get(i)); Singletons.getModel().getGameAction().moveToGraveyard(pile2.get(i));
} }
} else { } else {
final StringBuilder sbMsgP2 = new StringBuilder(); final StringBuilder sbMsgP2 = new StringBuilder();
@@ -151,10 +152,10 @@ public class CardFactoryInstants {
JOptionPane JOptionPane
.showMessageDialog(null, sbMsgP2.toString(), "", JOptionPane.INFORMATION_MESSAGE); .showMessageDialog(null, sbMsgP2.toString(), "", JOptionPane.INFORMATION_MESSAGE);
for (int i = 0; i < pile2.size(); i++) { for (int i = 0; i < pile2.size(); i++) {
AllZone.getGameAction().moveTo(hand, pile2.get(i)); Singletons.getModel().getGameAction().moveTo(hand, pile2.get(i));
} }
for (int i = 0; i < pile1.size(); i++) { for (int i = 0; i < pile1.size(); i++) {
AllZone.getGameAction().moveToGraveyard(pile1.get(i)); Singletons.getModel().getGameAction().moveToGraveyard(pile1.get(i));
} }
} }
@@ -198,17 +199,17 @@ public class CardFactoryInstants {
possibleValues[0]); possibleValues[0]);
if (q.equals(0)) { if (q.equals(0)) {
for (int i = 0; i < pile1.size(); i++) { for (int i = 0; i < pile1.size(); i++) {
AllZone.getGameAction().moveTo(hand, pile1.get(i)); Singletons.getModel().getGameAction().moveTo(hand, pile1.get(i));
} }
for (int i = 0; i < pile2.size(); i++) { for (int i = 0; i < pile2.size(); i++) {
AllZone.getGameAction().moveToGraveyard(pile2.get(i)); Singletons.getModel().getGameAction().moveToGraveyard(pile2.get(i));
} }
} else { } else {
for (int i = 0; i < pile2.size(); i++) { for (int i = 0; i < pile2.size(); i++) {
AllZone.getGameAction().moveTo(hand, pile2.get(i)); Singletons.getModel().getGameAction().moveTo(hand, pile2.get(i));
} }
for (int i = 0; i < pile1.size(); i++) { for (int i = 0; i < pile1.size(); i++) {
AllZone.getGameAction().moveToGraveyard(pile1.get(i)); Singletons.getModel().getGameAction().moveToGraveyard(pile1.get(i));
} }
} }
} }
@@ -259,7 +260,7 @@ public class CardFactoryInstants {
Card thisArtifact = artifacts.get(i); Card thisArtifact = artifacts.get(i);
if (thisArtifact.getOwner().equals(player)) { if (thisArtifact.getOwner().equals(player)) {
//moveToHand handles tokens //moveToHand handles tokens
AllZone.getGameAction().moveToHand(thisArtifact); Singletons.getModel().getGameAction().moveToHand(thisArtifact);
} }
} }
} //resolve() } //resolve()
@@ -318,10 +319,10 @@ public class CardFactoryInstants {
final Card choice = selectedCards.get(MyRandom.getRandom().nextInt(2)); final Card choice = selectedCards.get(MyRandom.getRandom().nextInt(2));
selectedCards.remove(choice); selectedCards.remove(choice);
AllZone.getGameAction().moveToHand(choice); Singletons.getModel().getGameAction().moveToHand(choice);
for (final Card trash : selectedCards) { for (final Card trash : selectedCards) {
AllZone.getGameAction().moveToGraveyard(trash); Singletons.getModel().getGameAction().moveToGraveyard(trash);
} }
} }
@@ -358,10 +359,10 @@ public class CardFactoryInstants {
final Card choice = (Card) o; final Card choice = (Card) o;
selectedCards.remove(choice); selectedCards.remove(choice);
AllZone.getGameAction().moveToHand(choice); Singletons.getModel().getGameAction().moveToHand(choice);
for (final Card trash : selectedCards) { for (final Card trash : selectedCards) {
AllZone.getGameAction().moveToGraveyard(trash); Singletons.getModel().getGameAction().moveToGraveyard(trash);
} }
} }
@@ -407,13 +408,13 @@ public class CardFactoryInstants {
final Card c1 = (Card) o; final Card c1 = (Card) o;
graveList.remove(c1); // remove from the display graveList.remove(c1); // remove from the display
// list // list
AllZone.getGameAction().exile(c1); Singletons.getModel().getGameAction().exile(c1);
} }
} else { // Computer } else { // Computer
// Random random = MyRandom.random; // Random random = MyRandom.random;
for (int j = 0; j < x; j++) { for (int j = 0; j < x; j++) {
// int index = random.nextInt(X-j); // int index = random.nextInt(X-j);
AllZone.getGameAction().exile(graveList.get(j)); Singletons.getModel().getGameAction().exile(graveList.get(j));
} }
} }
@@ -497,7 +498,7 @@ public class CardFactoryInstants {
if (AllZoneUtil.isCardInPlay(creature)) { if (AllZoneUtil.isCardInPlay(creature)) {
// System.out.println("Siren's Call - destroying "+creature.getName()); // System.out.println("Siren's Call - destroying "+creature.getName());
// this should probably go on the stack // this should probably go on the stack
AllZone.getGameAction().destroy(creature); Singletons.getModel().getGameAction().destroy(creature);
} }
} }
creature.setSirenAttackOrDestroy(false); creature.setSirenAttackOrDestroy(false);
@@ -555,11 +556,11 @@ public class CardFactoryInstants {
final Object o = GuiUtils.getChoice(this.prompt[i], choices.toArray()); final Object o = GuiUtils.getChoice(this.prompt[i], choices.toArray());
final Card c1 = (Card) o; final Card c1 = (Card) o;
if (i == 0) { if (i == 0) {
AllZone.getGameAction().moveToHand(c1); Singletons.getModel().getGameAction().moveToHand(c1);
} else if (i == 1) { } else if (i == 1) {
AllZone.getGameAction().moveToLibrary(c1); Singletons.getModel().getGameAction().moveToLibrary(c1);
} else if (i == 2) { } else if (i == 2) {
AllZone.getGameAction().moveToBottomOfLibrary(c1); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c1);
} }
choices.remove(c1); choices.remove(c1);
@@ -600,12 +601,12 @@ public class CardFactoryInstants {
} }
}); });
for (final Card c : toReturn) { for (final Card c : toReturn) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
} }
for (final Card c : ens) { for (final Card c : ens) {
if (!toReturn.contains(c)) { if (!toReturn.contains(c)) {
AllZone.getGameAction().destroy(c); Singletons.getModel().getGameAction().destroy(c);
} }
} }
} }

View File

@@ -215,14 +215,14 @@ class CardFactoryLands {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
if (paid[0] < 1) { if (paid[0] < 1) {
paid[0]++; paid[0]++;
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
@@ -236,7 +236,7 @@ class CardFactoryLands {
}; // Input }; // Input
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED) if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED)
.size() < 2)) { .size() < 2)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
return; return;
} else { } else {
AllZone.getInputControl().setInput(target); AllZone.getInputControl().setInput(target);
@@ -285,12 +285,12 @@ class CardFactoryLands {
// if any are tapped, sacrifice it // if any are tapped, sacrifice it
// else sacrifice random // else sacrifice random
if (tappedLand.size() > 0) { if (tappedLand.size() > 0) {
AllZone.getGameAction().sacrifice(tappedLand.get(0)); Singletons.getModel().getGameAction().sacrifice(tappedLand.get(0));
} else { } else {
AllZone.getGameAction().sacrifice(land.get(0)); Singletons.getModel().getGameAction().sacrifice(land.get(0));
} }
} else { } else {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
final Input target = new Input() { final Input target = new Input() {
@@ -305,14 +305,14 @@ class CardFactoryLands {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) { if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
this.stop(); this.stop();
} }
} // selectCard() } // selectCard()
@@ -344,7 +344,7 @@ class CardFactoryLands {
if (land.size() > 0) { if (land.size() > 0) {
for (final Card c : land) { for (final Card c : land) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
} }
} }
@@ -369,21 +369,21 @@ class CardFactoryLands {
CardList tappedPlains = new CardList(plains.toArray()); CardList tappedPlains = new CardList(plains.toArray());
tappedPlains = tappedPlains.getType("Basic"); tappedPlains = tappedPlains.getType("Basic");
for (final Card c : tappedPlains) { for (final Card c : tappedPlains) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
for (int i = 0; i < tappedPlains.size(); i++) { for (int i = 0; i < tappedPlains.size(); i++) {
AllZone.getGameAction().sacrifice(plains.get(i)); Singletons.getModel().getGameAction().sacrifice(plains.get(i));
} }
// if any are tapped, sacrifice it // if any are tapped, sacrifice it
// else sacrifice random // else sacrifice random
} else { } else {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
final int[] paid = { 0 }; final int[] paid = { 0 };
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED) if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED)
.size() < 2)) { .size() < 2)) {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
return; return;
} }
final Input target = new Input() { final Input target = new Input() {
@@ -398,14 +398,14 @@ class CardFactoryLands {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
if (paid[0] < 1) { if (paid[0] < 1) {
paid[0]++; paid[0]++;
Singletons.getControl().getControlMatch().showMessage( Singletons.getControl().getControlMatch().showMessage(
@@ -656,12 +656,12 @@ class CardFactoryLands {
CardList tappedLand = new CardList(land.toArray()); CardList tappedLand = new CardList(land.toArray());
tappedLand = tappedLand.filter(CardListFilter.TAPPED); tappedLand = tappedLand.filter(CardListFilter.TAPPED);
if (tappedLand.size() > 0) { if (tappedLand.size() > 0) {
AllZone.getGameAction().moveToHand(CardFactoryUtil.getWorstLand(tappedLand)); Singletons.getModel().getGameAction().moveToHand(CardFactoryUtil.getWorstLand(tappedLand));
} else { } else {
AllZone.getGameAction().moveToHand(CardFactoryUtil.getWorstLand(land)); Singletons.getModel().getGameAction().moveToHand(CardFactoryUtil.getWorstLand(land));
} }
} else { } else {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
final Input target = new Input() { final Input target = new Input() {
@@ -678,7 +678,7 @@ class CardFactoryLands {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@@ -686,7 +686,7 @@ class CardFactoryLands {
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer())
&& !c.isType("Lair")) { && !c.isType("Lair")) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
this.stop(); this.stop();
} }
} // selectCard() } // selectCard()
@@ -728,9 +728,9 @@ class CardFactoryLands {
if (player.isComputer()) { if (player.isComputer()) {
if (land.size() > 0) { if (land.size() > 0) {
final Card c = CardFactoryUtil.getWorstLand(land); final Card c = CardFactoryUtil.getWorstLand(land);
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
} else { } else {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
final Input target = new Input() { final Input target = new Input() {
@@ -747,14 +747,14 @@ class CardFactoryLands {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
} }
@Override @Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) { if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
this.stop(); this.stop();
} }
} // selectCard() } // selectCard()

View File

@@ -31,6 +31,7 @@ import forge.Counters;
import forge.PhaseHandler; import forge.PhaseHandler;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilityActivated;
@@ -95,7 +96,7 @@ public class CardFactoryPlaneswalkers {
GuiUtils.getChoiceOptional("Revealed top card: ", showTop.toArray()); GuiUtils.getChoiceOptional("Revealed top card: ", showTop.toArray());
// now, move it to player's hand // now, move it to player's hand
AllZone.getGameAction().moveToHand(topCard); Singletons.getModel().getGameAction().moveToHand(topCard);
// now, do X damage to Sarkhan // now, do X damage to Sarkhan
card.addDamage(convertedManaTopCard, card); card.addDamage(convertedManaTopCard, card);
@@ -145,7 +146,7 @@ public class CardFactoryPlaneswalkers {
turn[0] = AllZone.getPhaseHandler().getTurn(); turn[0] = AllZone.getPhaseHandler().getTurn();
final Card target = this.getTargetCard(); final Card target = this.getTargetCard();
AllZone.getGameAction().sacrifice(target); Singletons.getModel().getGameAction().sacrifice(target);
// in makeToken, use target for source, so it goes into the // in makeToken, use target for source, so it goes into the
// correct Zone // correct Zone
CardFactoryUtil.makeToken("Dragon", "R 5 5 Dragon", target.getController(), "R", new String[] { CardFactoryUtil.makeToken("Dragon", "R 5 5 Dragon", target.getController(), "R", new String[] {

View File

@@ -101,9 +101,9 @@ public class CardFactorySorceries {
final Player p1 = crd1.getController(); final Player p1 = crd1.getController();
crd0.addController(p1); crd0.addController(p1);
crd1.addController(p0); crd1.addController(p0);
// AllZone.getGameAction().changeController(new // Singletons.getModel().getGameAction().changeController(new
// CardList(crd0), p0, p1); // CardList(crd0), p0, p1);
// AllZone.getGameAction().changeController(new // Singletons.getModel().getGameAction().changeController(new
// CardList(crd1), p1, p0); // CardList(crd1), p1, p0);
} }
@@ -199,7 +199,7 @@ public class CardFactorySorceries {
} }
target.removeController(card); target.removeController(card);
// AllZone.getGameAction().changeController(new // Singletons.getModel().getGameAction().changeController(new
// CardList(target), card.getController(), // CardList(target), card.getController(),
// controllerEOT.get(i)); // controllerEOT.get(i));
@@ -225,7 +225,7 @@ public class CardFactorySorceries {
targets.add(i, target); targets.add(i, target);
target.addController(card); target.addController(card);
// AllZone.getGameAction().changeController(new // Singletons.getModel().getGameAction().changeController(new
// CardList(target), target.getController(), // CardList(target), target.getController(),
// card.getController()); // card.getController());
@@ -275,7 +275,7 @@ public class CardFactorySorceries {
} }
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
exiled.add(lib.get(i)); exiled.add(lib.get(i));
AllZone.getGameAction().exile(lib.get(i)); Singletons.getModel().getGameAction().exile(lib.get(i));
} }
final CardList pile1 = new CardList(); final CardList pile1 = new CardList();
final CardList pile2 = new CardList(); final CardList pile2 = new CardList();
@@ -415,7 +415,7 @@ public class CardFactorySorceries {
JOptionPane.INFORMATION_MESSAGE); JOptionPane.INFORMATION_MESSAGE);
} }
} else { } else {
AllZone.getGameAction().playCardNoCost(playing); Singletons.getModel().getGameAction().playCardNoCost(playing);
} }
chosen.remove(playing); chosen.remove(playing);
} }
@@ -454,7 +454,7 @@ public class CardFactorySorceries {
for (int i = 0; i < all.size(); i++) { for (int i = 0; i < all.size(); i++) {
final Card c = all.get(i); final Card c = all.get(i);
if (c.isCreature()) { if (c.isCreature()) {
AllZone.getGameAction().destroy(c); Singletons.getModel().getGameAction().destroy(c);
} }
} }
} }
@@ -579,7 +579,7 @@ public class CardFactorySorceries {
// selected are sacrificed. // selected are sacrificed.
for (int i = 0; i < target.size(); i++) { for (int i = 0; i < target.size(); i++) {
if (AllZoneUtil.isCardInPlay(target.get(i)) && !saveList.contains(target.get(i))) { if (AllZoneUtil.isCardInPlay(target.get(i)) && !saveList.contains(target.get(i))) {
AllZone.getGameAction().sacrifice(target.get(i)); Singletons.getModel().getGameAction().sacrifice(target.get(i));
} }
} }
} // resolve() } // resolve()
@@ -738,10 +738,10 @@ public class CardFactorySorceries {
for (final Card c : grave) { for (final Card c : grave) {
final CardList remLib = lib.getName(c.getName()); final CardList remLib = lib.getName(c.getName());
for (final Card rem : remLib) { for (final Card rem : remLib) {
AllZone.getGameAction().exile(rem); Singletons.getModel().getGameAction().exile(rem);
lib.remove(rem); lib.remove(rem);
} }
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
} }
}; // SpellAbility }; // SpellAbility
@@ -811,7 +811,7 @@ public class CardFactorySorceries {
if (compLand.size() > humLand.size()) { if (compLand.size() > humLand.size()) {
compLand.shuffle(); compLand.shuffle();
for (int i = 0; i < (compLand.size() - humLand.size()); i++) { for (int i = 0; i < (compLand.size() - humLand.size()); i++) {
AllZone.getGameAction().sacrifice(compLand.get(i)); Singletons.getModel().getGameAction().sacrifice(compLand.get(i));
} }
} else if (humLand.size() > compLand.size()) { } else if (humLand.size() > compLand.size()) {
final int diff = humLand.size() - compLand.size(); final int diff = humLand.size() - compLand.size();
@@ -838,7 +838,7 @@ public class CardFactorySorceries {
CardListUtil.sortCMC(compCreats); CardListUtil.sortCMC(compCreats);
compCreats.reverse(); compCreats.reverse();
for (int i = 0; i < (compCreats.size() - humCreats.size()); i++) { for (int i = 0; i < (compCreats.size() - humCreats.size()); i++) {
AllZone.getGameAction().sacrifice(compCreats.get(i)); Singletons.getModel().getGameAction().sacrifice(compCreats.get(i));
} }
} else if (humCreats.size() > compCreats.size()) { } else if (humCreats.size() > compCreats.size()) {
final int diff = humCreats.size() - compCreats.size(); final int diff = humCreats.size() - compCreats.size();
@@ -1168,12 +1168,12 @@ public class CardFactorySorceries {
/* /*
* else { //computer * else { //computer
* card.getControler().discardRandom(numCards); * card.getControler().discardRandom(numCards);
* AllZone.getGameAction().exile(card); CardList grave = * Singletons.getModel().getGameAction().exile(card); CardList grave =
* AllZoneUtil.getPlayerGraveyard(card.getController()); * AllZoneUtil.getPlayerGraveyard(card.getController());
* for(int i = 1; i <= numCards; i ++) { Card t1 = * for(int i = 1; i <= numCards; i ++) { Card t1 =
* CardFactoryUtil.AI_getBestCreature(grave); if(null != t1) * CardFactoryUtil.AI_getBestCreature(grave); if(null != t1)
* { t1 = grave.get(0); grave.remove(t1); * { t1 = grave.get(0); grave.remove(t1);
* AllZone.getGameAction().moveToHand(t1); } } } * Singletons.getModel().getGameAction().moveToHand(t1); } } }
* *
} // resolve() } // resolve()
}; // SpellAbility }; // SpellAbility
@@ -1286,7 +1286,7 @@ public class CardFactorySorceries {
bidded = bidded.getType("Creature"); bidded = bidded.getType("Creature");
for (final Card c : bidded) { for (final Card c : bidded) {
if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) { if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) {
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
} }
} }
} // resolve() } // resolve()
@@ -1376,7 +1376,7 @@ public class CardFactorySorceries {
// then, move revealed cards to bottom of library // then, move revealed cards to bottom of library
for (final Card c : topCards) { for (final Card c : topCards) {
AllZone.getGameAction().moveToBottomOfLibrary(c); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
} }
} // resolve() } // resolve()
@@ -1408,7 +1408,7 @@ public class CardFactorySorceries {
final CardList hand = player.getCardsIn(Zone.Hand); final CardList hand = player.getCardsIn(Zone.Hand);
for (final Card c : hand) { for (final Card c : hand) {
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
} }
// Shuffle library // Shuffle library
@@ -1460,7 +1460,7 @@ public class CardFactorySorceries {
// move hand to library // move hand to library
for (final Card c : hand) { for (final Card c : hand) {
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
} }
// Shuffle library // Shuffle library
@@ -1498,10 +1498,10 @@ public class CardFactorySorceries {
public void resolve() { public void resolve() {
final Player player = card.getController(); final Player player = card.getController();
for (final Card c : player.getCardsIn(Zone.Graveyard)) { for (final Card c : player.getCardsIn(Zone.Graveyard)) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
} }
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
card.setSVar("HSStamp", "" + Player.getHandSizeStamp()); card.setSVar("HSStamp", "" + Player.getHandSizeStamp());
player.addHandSizeOperation(new HandSizeOp("=", -1, Integer.parseInt(card.getSVar("HSStamp")))); player.addHandSizeOperation(new HandSizeOp("=", -1, Integer.parseInt(card.getSVar("HSStamp"))));
@@ -1557,7 +1557,7 @@ public class CardFactorySorceries {
final Card c = ab1card[0]; final Card c = ab1card[0];
if (c != null) { if (c != null) {
if (card.getController().getZone(Zone.Graveyard).contains(c) && c.canBeTargetedBy(this)) { if (card.getController().getZone(Zone.Graveyard).contains(c) && c.canBeTargetedBy(this)) {
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
} }
} }
} }
@@ -1970,7 +1970,7 @@ public class CardFactorySorceries {
tgt.addDamage(5, card); tgt.addDamage(5, card);
final CardList equipment = new CardList(tgt.getEquippedBy()); final CardList equipment = new CardList(tgt.getEquippedBy());
for (final Card eq : equipment) { for (final Card eq : equipment) {
AllZone.getGameAction().destroy(eq); Singletons.getModel().getGameAction().destroy(eq);
} }
} }
} // resolve() } // resolve()
@@ -2018,7 +2018,7 @@ public class CardFactorySorceries {
if (toSac != null) { if (toSac != null) {
final Card c = (Card) toSac; final Card c = (Card) toSac;
baseCMC = CardUtil.getConvertedManaCost(c); baseCMC = CardUtil.getConvertedManaCost(c);
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} else { } else {
return; return;
} }
@@ -2038,7 +2038,7 @@ public class CardFactorySorceries {
// if <= baseCMC, put it onto the battlefield // if <= baseCMC, put it onto the battlefield
if (newCMC <= baseCMC) { if (newCMC <= baseCMC) {
AllZone.getGameAction().moveToPlay(newArtifact[0]); Singletons.getModel().getGameAction().moveToPlay(newArtifact[0]);
} else { } else {
final String diffCost = String.valueOf(newCMC - baseCMC); final String diffCost = String.valueOf(newCMC - baseCMC);
AllZone.getInputControl().setInput(new InputPayManaCostAbility(diffCost, new Command() { AllZone.getInputControl().setInput(new InputPayManaCostAbility(diffCost, new Command() {
@@ -2046,14 +2046,14 @@ public class CardFactorySorceries {
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().moveToPlay(newArtifact[0]); Singletons.getModel().getGameAction().moveToPlay(newArtifact[0]);
} }
}, new Command() { }, new Command() {
private static final long serialVersionUID = -246036834856971935L; private static final long serialVersionUID = -246036834856971935L;
@Override @Override
public void execute() { public void execute() {
AllZone.getGameAction().moveToGraveyard(newArtifact[0]); Singletons.getModel().getGameAction().moveToGraveyard(newArtifact[0]);
} }
})); }));
} }

View File

@@ -863,7 +863,7 @@ public class CardFactoryUtil {
@Override @Override
public void selectCard(final Card card, final PlayerZone zone) { public void selectCard(final Card card, final PlayerZone zone) {
if (choices.contains(card)) { if (choices.contains(card)) {
AllZone.getGameAction().destroyNoRegeneration(card); Singletons.getModel().getGameAction().destroyNoRegeneration(card);
this.stop(); this.stop();
} }
} }
@@ -890,7 +890,7 @@ public class CardFactoryUtil {
@Override @Override
public void resolve() { public void resolve() {
final Card card = AllZone.getGameAction().moveToPlay(sourceCard); final Card card = Singletons.getModel().getGameAction().moveToPlay(sourceCard);
card.addIntrinsicKeyword("At the beginning of the end step, exile CARDNAME."); card.addIntrinsicKeyword("At the beginning of the end step, exile CARDNAME.");
card.addIntrinsicKeyword("Haste"); card.addIntrinsicKeyword("Haste");
@@ -937,7 +937,7 @@ public class CardFactoryUtil {
sourceCard.comesIntoPlay(); sourceCard.comesIntoPlay();
AllZone.getGameAction().moveToPlay(sourceCard); Singletons.getModel().getGameAction().moveToPlay(sourceCard);
} }
@Override @Override
@@ -1138,7 +1138,7 @@ public class CardFactoryUtil {
sourceCard.getController().discard(sourceCard, this); sourceCard.getController().discard(sourceCard, this);
final Card c1 = (Card) o; final Card c1 = (Card) o;
AllZone.getGameAction().moveToHand(c1); Singletons.getModel().getGameAction().moveToHand(c1);
} }
sourceCard.getController().shuffle(); sourceCard.getController().shuffle();
@@ -1218,7 +1218,7 @@ public class CardFactoryUtil {
sourceCard.getController().discard(sourceCard, this); sourceCard.getController().discard(sourceCard, this);
final Card c1 = (Card) o; final Card c1 = (Card) o;
AllZone.getGameAction().moveToHand(c1); Singletons.getModel().getGameAction().moveToHand(c1);
} }
sourceCard.getController().shuffle(); sourceCard.getController().shuffle();
@@ -1278,7 +1278,7 @@ public class CardFactoryUtil {
@Override @Override
public void resolve() { public void resolve() {
final Card c = AllZone.getGameAction().exile(sourceCard); final Card c = Singletons.getModel().getGameAction().exile(sourceCard);
c.addCounter(Counters.TIME, suspendCounters); c.addCounter(Counters.TIME, suspendCounters);
} }
}; };
@@ -1670,7 +1670,7 @@ public class CardFactoryUtil {
if (o != null) { if (o != null) {
final Card c1 = (Card) o; final Card c1 = (Card) o;
AllZone.getGameAction().moveToHand(c1); Singletons.getModel().getGameAction().moveToHand(c1);
} }
} }
} else { } else {
@@ -1680,7 +1680,7 @@ public class CardFactoryUtil {
choice = sameCost.getCard(0); choice = sameCost.getCard(0);
if (!(choice == null)) { if (!(choice == null)) {
AllZone.getGameAction().moveToHand(choice); Singletons.getModel().getGameAction().moveToHand(choice);
} }
} }
} // resolve() } // resolve()
@@ -1814,7 +1814,7 @@ public class CardFactoryUtil {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(crd); Singletons.getModel().getGameAction().sacrifice(crd);
this.stop(); this.stop();
} }
@@ -1822,11 +1822,11 @@ public class CardFactoryUtil {
public void selectCard(final Card card, final PlayerZone zone) { public void selectCard(final Card card, final PlayerZone zone) {
if (choices.contains(card)) { if (choices.contains(card)) {
if (card == spell.getSourceCard()) { if (card == spell.getSourceCard()) {
AllZone.getGameAction().sacrifice(spell.getSourceCard()); Singletons.getModel().getGameAction().sacrifice(spell.getSourceCard());
this.stop(); this.stop();
} else { } else {
spell.getSourceCard().setChampionedCard(card); spell.getSourceCard().setChampionedCard(card);
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
this.stop(); this.stop();
@@ -1911,7 +1911,7 @@ public class CardFactoryUtil {
void done() { void done() {
Singletons.getControl().getMatchControl().showMessage("Returning cards to hand."); Singletons.getControl().getMatchControl().showMessage("Returning cards to hand.");
AllZone.getGameAction().exile(recall); Singletons.getModel().getGameAction().exile(recall);
final CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); final CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard);
for (int i = 1; i <= this.n; i++) { for (int i = 1; i <= this.n; i++) {
final String title = "Return card from grave to hand"; final String title = "Return card from grave to hand";
@@ -1921,7 +1921,7 @@ public class CardFactoryUtil {
} }
final Card toHand = (Card) o; final Card toHand = (Card) o;
grave.remove(toHand); grave.remove(toHand);
AllZone.getGameAction().moveToHand(toHand); Singletons.getModel().getGameAction().moveToHand(toHand);
} }
this.stop(); this.stop();
} }
@@ -3808,7 +3808,7 @@ public class CardFactoryUtil {
temp.setToken(true); temp.setToken(true);
CardFactoryUtil.parseKeywords(temp, temp.getName()); CardFactoryUtil.parseKeywords(temp, temp.getName());
temp = CardFactoryUtil.postFactoryKeywords(temp); temp = CardFactoryUtil.postFactoryKeywords(temp);
AllZone.getGameAction().moveToPlay(temp); Singletons.getModel().getGameAction().moveToPlay(temp);
list.add(temp); list.add(temp);
} }
return list; return list;
@@ -4092,7 +4092,7 @@ public class CardFactoryUtil {
* "When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand." * "When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand."
* ) ) { // || (c.isCreature() && AllZoneUtil.isCardInPlay("Cowardice")) * ) ) { // || (c.isCreature() && AllZoneUtil.isCardInPlay("Cowardice"))
* SpellAbility ability = new Ability(c, "0") { public void resolve() { * SpellAbility ability = new Ability(c, "0") { public void resolve() {
* AllZone.getGameAction().moveToHand(c); } }; StringBuilder sb = new * Singletons.getModel().getGameAction().moveToHand(c); } }; StringBuilder sb = new
* StringBuilder(); * StringBuilder();
* sb.append(c).append(" - return CARDNAME to its owner's hand."); * sb.append(c).append(" - return CARDNAME to its owner's hand.");
* ability.setStackDescription(sb.toString()); * ability.setStackDescription(sb.toString());
@@ -4102,14 +4102,14 @@ public class CardFactoryUtil {
* ) || AllZoneUtil.isCardInPlay("Horobi, Death's Wail")) { * ) || AllZoneUtil.isCardInPlay("Horobi, Death's Wail")) {
* *
* SpellAbility ability = new Ability(c, "0") { public void resolve() { * SpellAbility ability = new Ability(c, "0") { public void resolve() {
* AllZone.getGameAction().destroy(c); } }; StringBuilder sb = new * Singletons.getModel().getGameAction().destroy(c); } }; StringBuilder sb = new
* StringBuilder(); sb.append(c).append(" - destroy CARDNAME."); * StringBuilder(); sb.append(c).append(" - destroy CARDNAME.");
* ability.setStackDescription(sb.toString()); * ability.setStackDescription(sb.toString());
* *
* AllZone.getStack().add(ability); } if (c.hasKeyword( * AllZone.getStack().add(ability); } if (c.hasKeyword(
* "When CARDNAME becomes the target of a spell or ability, sacrifice it.")) * "When CARDNAME becomes the target of a spell or ability, sacrifice it."))
* { SpellAbility ability = new Ability(c, "0") { public void resolve() { * { SpellAbility ability = new Ability(c, "0") { public void resolve() {
* AllZone.getGameAction().sacrifice(c); } }; StringBuilder sb = new * Singletons.getModel().getGameAction().sacrifice(c); } }; StringBuilder sb = new
* StringBuilder(); sb.append(c).append(" - sacrifice CARDNAME."); * StringBuilder(); sb.append(c).append(" - sacrifice CARDNAME.");
* ability.setStackDescription(sb.toString()); * ability.setStackDescription(sb.toString());
* *
@@ -4142,12 +4142,12 @@ public class CardFactoryUtil {
* "for card \"" + c.getName() + "\""); } * "for card \"" + c.getName() + "\""); }
* *
* if(action[0].startsWith("exile")) { * if(action[0].startsWith("exile")) {
* AllZone.getGameAction().exile(target); } else * Singletons.getModel().getGameAction().exile(target); } else
* if(action[0].startsWith("destroy")) { if(noRegen) { * if(action[0].startsWith("destroy")) { if(noRegen) {
* AllZone.getGameAction().destroyNoRegeneration(target); } else { * Singletons.getModel().getGameAction().destroyNoRegeneration(target); } else {
* AllZone.getGameAction().destroy(target); } } else * Singletons.getModel().getGameAction().destroy(target); } } else
* if(action[0].startsWith("sacrifice")) { * if(action[0].startsWith("sacrifice")) {
* AllZone.getGameAction().sacrifice(target); } else { throw new * Singletons.getModel().getGameAction().sacrifice(target); } else { throw new
* IllegalArgumentException("There is a problem in the keyword " + keyword + * IllegalArgumentException("There is a problem in the keyword " + keyword +
* "for card \"" + c.getName() + "\""); } } }; * "for card \"" + c.getName() + "\""); } } };
* *
@@ -4289,7 +4289,7 @@ public class CardFactoryUtil {
@Override @Override
public void resolve() { public void resolve() {
card.setKicked(true); card.setKicked(true);
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
} }
}; };
final String parse = card.getKeyword().get(kicker).toString(); final String parse = card.getKeyword().get(kicker).toString();
@@ -4350,7 +4350,7 @@ public class CardFactoryUtil {
@Override @Override
public void resolve() { public void resolve() {
card.setEvoked(true); card.setEvoked(true);
AllZone.getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);
} }
@Override @Override
@@ -4719,7 +4719,7 @@ public class CardFactoryUtil {
@Override @Override
public void resolve() { public void resolve() {
this.getTargetCard().addHauntedBy(card); this.getTargetCard().addHauntedBy(card);
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
} }
}; };
haunterDiesWork.setDescription(hauntDescription); haunterDiesWork.setDescription(hauntDescription);
@@ -4887,11 +4887,11 @@ public class CardFactoryUtil {
eff.addTrigger(copyTrigger); eff.addTrigger(copyTrigger);
AllZone.getTriggerHandler().suppressMode("ChangesZone"); AllZone.getTriggerHandler().suppressMode("ChangesZone");
AllZone.getGameAction().moveToPlay(eff); Singletons.getModel().getGameAction().moveToPlay(eff);
AllZone.getTriggerHandler().clearSuppression("ChangesZone"); AllZone.getTriggerHandler().clearSuppression("ChangesZone");
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
AllZone.getGameAction().playSpellAbilityNoStack(origSA, false); Singletons.getModel().getGameAction().playSpellAbilityNoStack(origSA, false);
} else { } else {
ComputerUtil.playNoStack(origSA); ComputerUtil.playNoStack(origSA);
} }
@@ -5064,7 +5064,7 @@ public class CardFactoryUtil {
final CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("World"); final CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("World");
cardsInPlay.remove(card); cardsInPlay.remove(card);
for (int i = 0; i < cardsInPlay.size(); i++) { for (int i = 0; i < cardsInPlay.size(); i++) {
AllZone.getGameAction().sacrificeDestroy(cardsInPlay.get(i)); Singletons.getModel().getGameAction().sacrificeDestroy(cardsInPlay.get(i));
} }
} // execute() } // execute()
}; // Command }; // Command
@@ -5158,7 +5158,7 @@ public class CardFactoryUtil {
numCreatures[0] = selection.size(); numCreatures[0] = selection.size();
for (int m = 0; m < selection.size(); m++) { for (int m = 0; m < selection.size(); m++) {
card.addDevoured(selection.get(m)); card.addDevoured(selection.get(m));
AllZone.getGameAction().sacrifice(selection.get(m)); Singletons.getModel().getGameAction().sacrifice(selection.get(m));
} }
} }
@@ -5169,7 +5169,7 @@ public class CardFactoryUtil {
final Card c = creats.get(i); final Card c = creats.get(i);
if ((c.getNetAttack() <= 1) && ((c.getNetAttack() + c.getNetDefense()) <= 3)) { if ((c.getNetAttack() <= 1) && ((c.getNetAttack() + c.getNetDefense()) <= 3)) {
card.addDevoured(c); card.addDevoured(c);
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
count++; count++;
} }
// is this needed? // is this needed?

View File

@@ -20,10 +20,10 @@ package forge.card.cost;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import forge.AllZone;
import forge.Card; import forge.Card;
import forge.Constant; import forge.Constant;
import forge.Counters; import forge.Counters;
import forge.Singletons;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -400,7 +400,7 @@ public class Cost {
final String mana = this.getTotalMana(); final String mana = this.getTotalMana();
final ManaCost changedCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(mana)); final ManaCost changedCost = Singletons.getModel().getGameAction().getSpellCostChange(sa, new ManaCost(mana));
costMana.setAdjustedMana(changedCost.toString(false)); costMana.setAdjustedMana(changedCost.toString(false));
} }

View File

@@ -166,7 +166,7 @@ public class CostExile extends CostPartWithList {
@Override @Override
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) { public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
for (final Card c : this.getList()) { for (final Card c : this.getList()) {
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
} }
@@ -282,7 +282,7 @@ public class CostExile extends CostPartWithList {
while (itr.hasNext()) { while (itr.hasNext()) {
final Card c = itr.next(); final Card c = itr.next();
part.addToList(c); part.addToList(c);
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
part.addListToHash(sa, "Exiled"); part.addListToHash(sa, "Exiled");
payment.paidCost(part); payment.paidCost(part);
@@ -334,7 +334,7 @@ public class CostExile extends CostPartWithList {
final Card c = (Card) o; final Card c = (Card) o;
this.typeList.remove(c); this.typeList.remove(c);
part.addToList(c); part.addToList(c);
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
if (i == (nNeeded - 1)) { if (i == (nNeeded - 1)) {
this.done(); this.done();
} }
@@ -423,7 +423,7 @@ public class CostExile extends CostPartWithList {
if (this.typeList.contains(card)) { if (this.typeList.contains(card)) {
this.nExiles++; this.nExiles++;
part.addToList(card); part.addToList(card);
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
this.typeList.remove(card); this.typeList.remove(card);
// in case nothing else to exile // in case nothing else to exile
if (this.nExiles == nNeeded) { if (this.nExiles == nNeeded) {
@@ -483,7 +483,7 @@ public class CostExile extends CostPartWithList {
possibleValues[0]); possibleValues[0]);
if (choice.equals(0)) { if (choice.equals(0)) {
payment.getAbility().addCostToHashList(card, "Exiled"); payment.getAbility().addCostToHashList(card, "Exiled");
AllZone.getGameAction().exile(card); Singletons.getModel().getGameAction().exile(card);
part.addToList(card); part.addToList(card);
this.stop(); this.stop();
part.addListToHash(sa, "Exiled"); part.addListToHash(sa, "Exiled");

View File

@@ -27,6 +27,7 @@ import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -112,7 +113,7 @@ public class CostMill extends CostPartWithList {
@Override @Override
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) { public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
for (final Card c : this.getList()) { for (final Card c : this.getList()) {
AllZone.getGameAction().moveToGraveyard(c); Singletons.getModel().getGameAction().moveToGraveyard(c);
} }
} }
@@ -156,7 +157,7 @@ public class CostMill extends CostPartWithList {
while (itr.hasNext()) { while (itr.hasNext()) {
final Card card = itr.next(); final Card card = itr.next();
this.addToList(card); this.addToList(card);
AllZone.getGameAction().moveToGraveyard(card); Singletons.getModel().getGameAction().moveToGraveyard(card);
} }
this.addListToHash(ability, "Milled"); this.addListToHash(ability, "Milled");
payment.paidCost(this); payment.paidCost(this);

View File

@@ -19,7 +19,6 @@ package forge.card.cost;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import forge.AllZone;
import forge.AllZoneUtil; import forge.AllZoneUtil;
import forge.ButtonUtil; import forge.ButtonUtil;
import forge.Card; import forge.Card;
@@ -129,7 +128,7 @@ public class CostReturn extends CostPartWithList {
@Override @Override
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) { public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
for (final Card c : this.getList()) { for (final Card c : this.getList()) {
AllZone.getGameAction().moveToHand(c); Singletons.getModel().getGameAction().moveToHand(c);
} }
} }
@@ -246,7 +245,7 @@ public class CostReturn extends CostPartWithList {
if (this.typeList.contains(card)) { if (this.typeList.contains(card)) {
this.nReturns++; this.nReturns++;
part.addToList(card); part.addToList(card);
AllZone.getGameAction().moveToHand(card); Singletons.getModel().getGameAction().moveToHand(card);
this.typeList.remove(card); this.typeList.remove(card);
// in case nothing else to return // in case nothing else to return
if (this.nReturns == nNeeded) { if (this.nReturns == nNeeded) {
@@ -305,7 +304,7 @@ public class CostReturn extends CostPartWithList {
possibleValues[0]); possibleValues[0]);
if (choice.equals(0)) { if (choice.equals(0)) {
part.addToList(card); part.addToList(card);
AllZone.getGameAction().moveToHand(card); Singletons.getModel().getGameAction().moveToHand(card);
this.stop(); this.stop();
part.addListToHash(sa, "Returned"); part.addListToHash(sa, "Returned");
payment.paidCost(part); payment.paidCost(part);

View File

@@ -19,7 +19,6 @@ package forge.card.cost;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import forge.AllZone;
import forge.AllZoneUtil; import forge.AllZoneUtil;
import forge.ButtonUtil; import forge.ButtonUtil;
import forge.Card; import forge.Card;
@@ -128,7 +127,7 @@ public class CostSacrifice extends CostPartWithList {
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) { public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
this.addListToHash(ability, "Sacrificed"); this.addListToHash(ability, "Sacrificed");
for (final Card c : this.getList()) { for (final Card c : this.getList()) {
AllZone.getGameAction().sacrifice(c); Singletons.getModel().getGameAction().sacrifice(c);
} }
} }
@@ -231,7 +230,7 @@ public class CostSacrifice extends CostPartWithList {
// TODO Ask First // TODO Ask First
for (final Card card : typeList) { for (final Card card : typeList) {
payment.getAbility().addCostToHashList(card, "Sacrificed"); payment.getAbility().addCostToHashList(card, "Sacrificed");
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
} }
payment.setPaidManaPart(part, true); payment.setPaidManaPart(part, true);
@@ -288,7 +287,7 @@ public class CostSacrifice extends CostPartWithList {
if (typeList.contains(card)) { if (typeList.contains(card)) {
this.nSacrifices++; this.nSacrifices++;
part.addToList(card); part.addToList(card);
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
typeList.remove(card); typeList.remove(card);
// in case nothing else to sacrifice // in case nothing else to sacrifice
if (this.nSacrifices == nNeeded) { if (this.nSacrifices == nNeeded) {
@@ -349,7 +348,7 @@ public class CostSacrifice extends CostPartWithList {
if (choice.equals(0)) { if (choice.equals(0)) {
part.addToList(card); part.addToList(card);
part.addListToHash(sa, "Sacrificed"); part.addListToHash(sa, "Sacrificed");
AllZone.getGameAction().sacrifice(card); Singletons.getModel().getGameAction().sacrifice(card);
this.stop(); this.stop();
payment.paidCost(part); payment.paidCost(part);
} else { } else {

View File

@@ -21,12 +21,12 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import forge.AllZone;
import forge.AllZoneUtil; import forge.AllZoneUtil;
import forge.Card; import forge.Card;
import forge.CardUtil; import forge.CardUtil;
import forge.Constant; import forge.Constant;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.spellability.AbilityMana; import forge.card.spellability.AbilityMana;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.control.input.InputPayManaCostUtil; import forge.control.input.InputPayManaCostUtil;
@@ -260,7 +260,7 @@ public class ManaPool {
for (final Mana m : manaList) { for (final Mana m : manaList) {
this.addManaToPool(this.floatingMana, m); this.addManaToPool(this.floatingMana, m);
} }
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
owner.updateObservers(); owner.updateObservers();
} }

View File

@@ -27,6 +27,7 @@ import forge.ComputerUtil;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
@@ -174,7 +175,7 @@ public class ReplacementHandler {
} }
if (replacementEffect.getHostCard().getController().isHuman()) { if (replacementEffect.getHostCard().getController().isHuman()) {
AllZone.getGameAction().playSpellAbilityNoStack(effectSA, false); Singletons.getModel().getGameAction().playSpellAbilityNoStack(effectSA, false);
} else { } else {
ComputerUtil.playNoStack(effectSA); ComputerUtil.playNoStack(effectSA);
} }

View File

@@ -22,6 +22,7 @@ import java.util.ArrayList;
import forge.AllZone; import forge.AllZone;
import forge.Card; import forge.Card;
import forge.PlayerZone; import forge.PlayerZone;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.cost.CostPayment; import forge.card.cost.CostPayment;
@@ -110,7 +111,7 @@ public class SpellAbilityRequirements {
final Card c = this.ability.getSourceCard(); final Card c = this.ability.getSourceCard();
this.fromZone = AllZone.getZoneOf(c); this.fromZone = AllZone.getZoneOf(c);
this.ability.setSourceCard(AllZone.getGameAction().moveToStack(c)); this.ability.setSourceCard(Singletons.getModel().getGameAction().moveToStack(c));
} }
} }
@@ -141,7 +142,7 @@ public class SpellAbilityRequirements {
final Card c = this.ability.getSourceCard(); final Card c = this.ability.getSourceCard();
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
// add back to where it came from // add back to where it came from
AllZone.getGameAction().moveTo(this.fromZone, c); Singletons.getModel().getGameAction().moveTo(this.fromZone, c);
} }
this.select.resetTargets(); this.select.resetTargets();
@@ -189,12 +190,12 @@ public class SpellAbilityRequirements {
} }
this.select.resetTargets(); this.select.resetTargets();
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
} else if (this.payment.isCanceled()) { } else if (this.payment.isCanceled()) {
final Card c = this.ability.getSourceCard(); final Card c = this.ability.getSourceCard();
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
// add back to Previous Zone // add back to Previous Zone
AllZone.getGameAction().moveTo(this.fromZone, c); Singletons.getModel().getGameAction().moveTo(this.fromZone, c);
} }
if (this.select != null) { if (this.select != null) {

View File

@@ -31,6 +31,7 @@ import forge.ComputerUtil;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil; import forge.card.cardfactory.CardFactoryUtil;
import forge.card.cost.Cost; import forge.card.cost.Cost;
@@ -88,7 +89,7 @@ public class SpellPermanent extends Spell {
final CardList creature = (CardList) SpellPermanent.this.championGetCreature.execute(); final CardList creature = (CardList) SpellPermanent.this.championGetCreature.execute();
if (creature.size() == 0) { if (creature.size() == 0) {
AllZone.getGameAction().sacrifice(source); Singletons.getModel().getGameAction().sacrifice(source);
return; return;
} else if (controller.isHuman()) { } else if (controller.isHuman()) {
AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes); AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes);
@@ -102,7 +103,7 @@ public class SpellPermanent extends Spell {
final Card c = computer.get(0); final Card c = computer.get(0);
source.setChampionedCard(c); source.setChampionedCard(c);
if (AllZoneUtil.isCardInPlay(c)) { if (AllZoneUtil.isCardInPlay(c)) {
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
// Run triggers // Run triggers
@@ -111,7 +112,7 @@ public class SpellPermanent extends Spell {
runParams.put("Championed", source.getChampionedCard()); runParams.put("Championed", source.getChampionedCard());
AllZone.getTriggerHandler().runTrigger("Championed", runParams); AllZone.getTriggerHandler().runTrigger("Championed", runParams);
} else { } else {
AllZone.getGameAction().sacrifice(this.getSourceCard()); Singletons.getModel().getGameAction().sacrifice(this.getSourceCard());
} }
} // computer } // computer
} // resolve() } // resolve()
@@ -145,7 +146,7 @@ public class SpellPermanent extends Spell {
public void resolve() { public void resolve() {
final Card c = this.getSourceCard().getChampionedCard(); final Card c = this.getSourceCard().getChampionedCard();
if ((c != null) && !c.isToken() && AllZoneUtil.isCardExiled(c)) { if ((c != null) && !c.isToken() && AllZoneUtil.isCardExiled(c)) {
AllZone.getGameAction().moveToPlay(c); Singletons.getModel().getGameAction().moveToPlay(c);
} }
} // resolve() } // resolve()
}; // SpellAbility }; // SpellAbility
@@ -413,6 +414,6 @@ public class SpellPermanent extends Spell {
public void resolve() { public void resolve() {
final Card c = this.getSourceCard(); final Card c = this.getSourceCard();
c.addController(this.getActivatingPlayer()); c.addController(this.getActivatingPlayer());
AllZone.getGameAction().moveTo(this.getActivatingPlayer().getZone(Constant.Zone.Battlefield), c); Singletons.getModel().getGameAction().moveTo(this.getActivatingPlayer().getZone(Constant.Zone.Battlefield), c);
} }
} }

View File

@@ -32,6 +32,7 @@ import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.Player; import forge.Player;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.AbilityFactoryCharm; import forge.card.abilityfactory.AbilityFactoryCharm;
import forge.card.cost.Cost; import forge.card.cost.Cost;
@@ -358,12 +359,12 @@ public class TriggerHandler {
* they //aren't yet. And even if it (correctly?) sent unattached * they //aren't yet. And even if it (correctly?) sent unattached
* //auras to the graveyard,that would result in all auras //going * //auras to the graveyard,that would result in all auras //going
* straight to the grave no matter what. this.suppressMode("Always"); * straight to the grave no matter what. this.suppressMode("Always");
* AllZone.getGameAction().checkStateEffects(true); * Singletons.getModel().getGameAction().checkStateEffects(true);
* this.clearSuppression("Always"); * this.clearSuppression("Always");
*/ */
if (checkStatics) { if (checkStatics) {
this.suppressMode("Always"); this.suppressMode("Always");
AllZone.getGameAction().checkStaticAbilities(); Singletons.getModel().getGameAction().checkStaticAbilities();
this.clearSuppression("Always"); this.clearSuppression("Always");
} }
@@ -1052,7 +1053,7 @@ public class TriggerHandler {
// Card src = // Card src =
// (Card)(sa[0].getSourceCard().getTriggeringObject("Card")); // (Card)(sa[0].getSourceCard().getTriggeringObject("Card"));
// System.out.println("Trigger resolving for "+mode+". Card = "+src); // System.out.println("Trigger resolving for "+mode+". Card = "+src);
AllZone.getGameAction().playSpellAbilityNoStack(sa[0], true); Singletons.getModel().getGameAction().playSpellAbilityNoStack(sa[0], true);
} else { } else {
// commented out because i don't think this should be called // commented out because i don't think this should be called
// again here // again here
@@ -1075,7 +1076,7 @@ public class TriggerHandler {
wrapperAbility.setDescription(wrapperAbility.getStackDescription()); wrapperAbility.setDescription(wrapperAbility.getStackDescription());
/* /*
* if(host.getController().isHuman()) { * if(host.getController().isHuman()) {
* AllZone.getGameAction().playSpellAbility(wrapperAbility); } else { * Singletons.getModel().getGameAction().playSpellAbility(wrapperAbility); } else {
* wrapperAbility.doTrigger(isMandatory); * wrapperAbility.doTrigger(isMandatory);
* ComputerUtil.playStack(wrapperAbility); } * ComputerUtil.playStack(wrapperAbility); }
*/ */
@@ -1084,7 +1085,7 @@ public class TriggerHandler {
// System.out.println("Trigger going on stack for "+mode+". Card = "+src); // System.out.println("Trigger going on stack for "+mode+". Card = "+src);
if (params.containsKey("Static") && params.get("Static").equals("True")) { if (params.containsKey("Static") && params.get("Static").equals("True")) {
AllZone.getGameAction().playSpellAbilityNoStack(wrapperAbility, false); Singletons.getModel().getGameAction().playSpellAbilityNoStack(wrapperAbility, false);
} else { } else {
AllZone.getStack().addSimultaneousStackEntry(wrapperAbility); AllZone.getStack().addSimultaneousStackEntry(wrapperAbility);
} }

View File

@@ -31,7 +31,6 @@ import forge.CardList;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GuiMultipleBlockers; import forge.GuiMultipleBlockers;
import forge.ImageCache;
import forge.Player; import forge.Player;
import forge.Singletons; import forge.Singletons;
import forge.control.match.ControlDetail; import forge.control.match.ControlDetail;
@@ -86,22 +85,8 @@ public class ControlMatchUI implements CardContainer {
* *
*/ */
public void initMatch() { public void initMatch() {
// All child components have been assembled; observers and listeners can ControlMatchUI.this.showCombat("");
// be added safely. ControlMatchUI.this.showStack();
ControlMatchUI.this.getTabberControl().addObservers();
ControlMatchUI.this.getTabberControl().addListeners();
ControlMatchUI.this.getMessageControl().addListeners();
ControlMatchUI.this.getHandControl().addObservers();
ControlMatchUI.this.getHandControl().addListeners();
// Update all observers with values for start of match.
for (final ControlField f : ControlMatchUI.this.getFieldControls()) {
f.addObservers();
f.addListeners();
f.getPlayer().updateObservers();
}
// Update avatars // Update avatars
final String[] indices = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(","); final String[] indices = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
@@ -131,34 +116,20 @@ public class ControlMatchUI implements CardContainer {
((FLabel) ((ViewField) views[i]).getLblAvatar()).getResizeTimer().start(); ((FLabel) ((ViewField) views[i]).getLblAvatar()).getResizeTimer().start();
} }
// Update observers
AllZone.getHumanPlayer().updateObservers();
AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers(); AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers();
AllZone.getComputerPlayer().getZone(Zone.Hand).updateObservers();
AllZone.getStack().updateObservers();
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();
AllZone.getComputerPlayer().updateObservers();
AllZone.getComputerPlayer().getZone(Zone.Hand).updateObservers();
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();
AllZone.getStack().updateObservers();
AllZone.getInputControl().updateObservers(); AllZone.getInputControl().updateObservers();
ControlMatchUI.this.getTabberControl().updateObservers(); ControlMatchUI.this.getTabberControl().updateObservers();
} }
/**
* Deletes all observers for Match UI elements and clears the ImageCache.
*/
public void deinitMatch() {
ImageCache.clear();
// Delete player observers
for (Player p : AllZone.getPlayersInGame()) {
p.deleteObservers();
p.getZone(Zone.Battlefield).deleteObservers();
p.getZone(Zone.Hand).deleteObservers();
}
AllZone.getStack().deleteObservers();
AllZone.getGameLog().deleteObservers();
AllZone.getInputControl().deleteObservers();
AllZone.getPhaseHandler().deleteObservers();
}
/** /**
* Resets all phase buttons in all fields to "inactive", so highlight won't * Resets all phase buttons in all fields to "inactive", so highlight won't
* be drawn on them. "Enabled" state remains the same. * be drawn on them. "Enabled" state remains the same.

View File

@@ -96,6 +96,7 @@ public enum FControl {
/** After view and model have been initialized, control can start. */ /** After view and model have been initialized, control can start. */
public void initialize() { public void initialize() {
Singletons.getModel().getQuestEventManager().assembleAllEvents();
this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts(); this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
this.display = Singletons.getView().getLayeredContentPane(); this.display = Singletons.getView().getLayeredContentPane();

View File

@@ -18,12 +18,12 @@ import forge.CardList;
import forge.Constant; import forge.Constant;
import forge.PlayerType; import forge.PlayerType;
import forge.Singletons; import forge.Singletons;
import forge.control.FControl;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.generate.Generate2ColorDeck; import forge.deck.generate.Generate2ColorDeck;
import forge.deck.generate.Generate3ColorDeck; import forge.deck.generate.Generate3ColorDeck;
import forge.deck.generate.Generate5ColorDeck; import forge.deck.generate.Generate5ColorDeck;
import forge.deck.generate.GenerateThemeDeck; import forge.deck.generate.GenerateThemeDeck;
import forge.game.GameNew;
import forge.game.GameType; import forge.game.GameType;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.util.IFolderMap; import forge.util.IFolderMap;
@@ -224,7 +224,9 @@ public class ControlConstructed {
deck = new Deck(); deck = new Deck();
deck.getMain().add(cards); deck.getMain().add(cards);
} }
else if (lst0.getName().equals("lstQuest")) {
deck = Singletons.getModel().getQuestEventManager().getEvent(selection[0]).getEventDeck();
}
// Custom deck // Custom deck
else { else {
deck = AllZone.getDecks().getConstructed().get(selection[0]); deck = AllZone.getDecks().getConstructed().get(selection[0]);
@@ -281,10 +283,8 @@ public class ControlConstructed {
view.getBtnStart().setVisible(true); view.getBtnStart().setVisible(true);
view.getBarProgress().setVisible(false); view.getBarProgress().setVisible(false);
Singletons.getControl().changeState(FControl.MATCH_SCREEN); GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
Singletons.getControl().getControlMatch().initMatch(); new CardList(), new CardList(), 20, 20);
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
} }
}); });
} }
@@ -332,13 +332,13 @@ public class ControlConstructed {
final List<String> eventNames = new ArrayList<String>(); final List<String> eventNames = new ArrayList<String>();
eventNames.clear(); eventNames.clear();
/*for (QuestEvent e : AllZone.getQuestEventManager().getAllChallenges()) { /*for (QuestEvent e : Singletons.getModel().getQuestEventManager().getAllChallenges()) {
eventNames.add(e.getEventDeck().getName()); eventNames.add(e.getEventDeck().getName());
} }
for (QuestEvent e : AllZone.getQuestEventManager().getAllDuels()) { for (QuestEvent e : Singletons.getModel().getQuestEventManager().getAllDuels()) {
eventNames.add(e.getEventDeck().getName()); eventNames.add(e.getEventDeck().getName());
}*/ } */
return oa2sa(eventNames.toArray()); return oa2sa(eventNames.toArray());
} }

View File

@@ -11,10 +11,9 @@ import javax.swing.SwingUtilities;
import forge.AllZone; import forge.AllZone;
import forge.Constant; import forge.Constant;
import forge.Singletons;
import forge.control.FControl;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckGroup; import forge.deck.DeckGroup;
import forge.game.GameNew;
import forge.game.GameType; import forge.game.GameType;
import forge.game.limited.BoosterDraft; import forge.game.limited.BoosterDraft;
import forge.game.limited.CardPoolLimitation; import forge.game.limited.CardPoolLimitation;
@@ -146,10 +145,7 @@ public class ControlDraft {
public void run() { public void run() {
view.getBtnStart().setVisible(true); view.getBtnStart().setVisible(true);
view.getBarProgress().setVisible(false); view.getBarProgress().setVisible(false);
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
Singletons.getControl().getControlMatch().initMatch();
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
} }
}); });
} }

View File

@@ -22,6 +22,7 @@ import forge.Constant;
import forge.Singletons; import forge.Singletons;
import forge.control.FControl; import forge.control.FControl;
import forge.deck.Deck; import forge.deck.Deck;
import forge.game.GameNew;
import forge.game.GameType; import forge.game.GameType;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import forge.gui.deckeditor.DeckEditorQuest; import forge.gui.deckeditor.DeckEditorQuest;
@@ -70,7 +71,7 @@ public class ControlQuest {
public ControlQuest(ViewQuest v0) { public ControlQuest(ViewQuest v0) {
// Inits // Inits
this.view = v0; this.view = v0;
this.qem = new QuestEventManager(); this.qem = Singletons.getModel().getQuestEventManager();
this.qPrefs = Singletons.getModel().getQuestPreferences(); this.qPrefs = Singletons.getModel().getQuestPreferences();
AllZone.setQuestEventManager(this.qem); AllZone.setQuestEventManager(this.qem);
@@ -324,6 +325,7 @@ public class ControlQuest {
Singletons.getView().getViewHome().resetQuest(); Singletons.getView().getViewHome().resetQuest();
} // New Quest } // New Quest
/** Changes between quest data files. */
private void changeQuest() { private void changeQuest() {
AllZone.setQuestData(view.getLstQuests().getSelectedQuest()); AllZone.setQuestData(view.getLstQuests().getSelectedQuest());
this.qData = AllZone.getQuestData(); this.qData = AllZone.getQuestData();
@@ -567,10 +569,6 @@ public class ControlQuest {
view.getBtnStart().setVisible(true); view.getBtnStart().setVisible(true);
view.getBarProgress().setVisible(false); view.getBarProgress().setVisible(false);
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
Singletons.getControl().getControlMatch().initMatch();
AllZone.getMatchState().reset();
if (event.getEventType().equals("challenge")) { if (event.getEventType().equals("challenge")) {
setupChallenge(currentDeck); setupChallenge(currentDeck);
} else { } else {
@@ -593,7 +591,7 @@ public class ControlQuest {
final Deck computer = event.getEventDeck(); final Deck computer = event.getEventDeck();
Constant.Runtime.COMPUTER_DECK[0] = computer; Constant.Runtime.COMPUTER_DECK[0] = computer;
AllZone.getGameAction().newGame( GameNew.newGame(
Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0], Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
QuestUtil.getHumanStartingCards(qData), QuestUtil.getHumanStartingCards(qData),
QuestUtil.getComputerStartingCards(qData), QuestUtil.getComputerStartingCards(qData),
@@ -615,7 +613,7 @@ public class ControlQuest {
extraLife = 3; extraLife = 3;
} }
AllZone.getGameAction().newGame( GameNew.newGame(
Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0], Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
QuestUtil.getHumanStartingCards(qData, event), QuestUtil.getHumanStartingCards(qData, event),
QuestUtil.getComputerStartingCards(qData, event), QuestUtil.getComputerStartingCards(qData, event),

View File

@@ -19,9 +19,9 @@ import forge.AllZone;
import forge.Command; import forge.Command;
import forge.Constant; import forge.Constant;
import forge.Singletons; import forge.Singletons;
import forge.control.FControl;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckGroup; import forge.deck.DeckGroup;
import forge.game.GameNew;
import forge.game.GameType; import forge.game.GameType;
import forge.game.limited.SealedDeck; import forge.game.limited.SealedDeck;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
@@ -124,10 +124,7 @@ public class ControlSealed {
view.getBtnStart().setVisible(true); view.getBtnStart().setVisible(true);
view.getBarProgress().setVisible(false); view.getBarProgress().setVisible(false);
Singletons.getControl().changeState(FControl.MATCH_SCREEN); GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
Singletons.getControl().getControlMatch().initMatch();
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
} }
}); });
} }

View File

@@ -27,6 +27,7 @@ import forge.CardList;
import forge.ComputerUtil; import forge.ComputerUtil;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.GameAction;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.PhaseHandler; import forge.PhaseHandler;
import forge.PhaseUtil; import forge.PhaseUtil;
@@ -80,7 +81,7 @@ public class InputMulligan extends Input {
public final int doMulligan(final Player player, final GamePlayerRating playerRating) { public final int doMulligan(final Player player, final GamePlayerRating playerRating) {
final CardList hand = player.getCardsIn(Zone.Hand); final CardList hand = player.getCardsIn(Zone.Hand);
for (final Card c : hand) { for (final Card c : hand) {
AllZone.getGameAction().moveToLibrary(c); Singletons.getModel().getGameAction().moveToLibrary(c);
} }
for (int i = 0; i < InputMulligan.MAGIC_NUMBER_OF_SHUFFLES; i++) { for (int i = 0; i < InputMulligan.MAGIC_NUMBER_OF_SHUFFLES; i++) {
player.shuffle(); player.shuffle();
@@ -120,6 +121,7 @@ public class InputMulligan extends Input {
*/ */
final void end() { final void end() {
// Computer mulligan // Computer mulligan
final GameAction ga = Singletons.getModel().getGameAction();
final Player aiPlayer = AllZone.getComputerPlayer(); final Player aiPlayer = AllZone.getComputerPlayer();
final GamePlayerRating aiRating = Singletons.getModel().getGameSummary().getPlayerRating(aiPlayer.getName()); final GamePlayerRating aiRating = Singletons.getModel().getGameSummary().getPlayerRating(aiPlayer.getName());
boolean aiTakesMulligan = true; boolean aiTakesMulligan = true;
@@ -154,13 +156,13 @@ public class InputMulligan extends Input {
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) { if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
// If we ever let the AI memorize cards in the players // If we ever let the AI memorize cards in the players
// hand, this would be a place to do so. // hand, this would be a place to do so.
AllZone.getGameAction().playSpellAbilityNoStack(effect, false); ga.playSpellAbilityNoStack(effect, false);
} }
} }
} }
if (c.getName().startsWith("Leyline")) { if (c.getName().startsWith("Leyline")) {
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) { if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
AllZone.getGameAction().moveToPlay(c); ga.moveToPlay(c);
} }
} }
} }
@@ -190,24 +192,23 @@ public class InputMulligan extends Input {
if (c.getName().startsWith("Leyline") if (c.getName().startsWith("Leyline")
&& !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(Zone.Battlefield, && !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(Zone.Battlefield,
"Leyline of Singularity").size() > 0))) { "Leyline of Singularity").size() > 0))) {
AllZone.getGameAction().moveToPlay(c); ga.moveToPlay(c);
AllZone.getGameAction().checkStateEffects(); ga.checkStateEffects();
} }
} }
AllZone.getGameAction().checkStateEffects(); ga.checkStateEffects();
if (AllZone.getGameAction().isStartCut() if (ga.isStartCut() && !(humanOpeningHand.contains(ga.getHumanCut())
&& !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) || aiOpeningHand.contains(AllZone || aiOpeningHand.contains(ga.getComputerCut()))) {
.getGameAction().getComputerCut()))) { ga.moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), ga.getHumanCut());
AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), ga.moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), ga.getComputerCut());
AllZone.getGameAction().getHumanCut());
AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library),
AllZone.getGameAction().getComputerCut());
} }
AllZone.getGameAction().checkStateEffects();
ga.checkStateEffects();
PhaseHandler.setGameBegins(1); PhaseHandler.setGameBegins(1);
AllZone.getPhaseHandler().setNeedToNextPhase(false); AllZone.getPhaseHandler().setNeedToNextPhase(false);
PhaseUtil.visuallyActivatePhase(AllZone.getPhaseHandler().getPhase()); PhaseUtil.visuallyActivatePhase(AllZone.getPhaseHandler().getPhase());
this.stop(); this.stop();
} }
@@ -218,7 +219,7 @@ public class InputMulligan extends Input {
if (GameActionUtil.showYesNoDialog(c0, "Use " + c0.getName() + "'s ability?")) { if (GameActionUtil.showYesNoDialog(c0, "Use " + c0.getName() + "'s ability?")) {
CardList hand = c0.getController().getCardsIn(Zone.Hand); CardList hand = c0.getController().getCardsIn(Zone.Hand);
for (Card c : hand) { for (Card c : hand) {
AllZone.getGameAction().exile(c); Singletons.getModel().getGameAction().exile(c);
} }
c0.getController().drawCards(hand.size()); c0.getController().drawCards(hand.size());
} }

View File

@@ -81,7 +81,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectCard(final Card card, final PlayerZone zone) { public final void selectCard(final Card card, final PlayerZone zone) {
if (AllZone.getGameAction().playCard(card)) { if (Singletons.getModel().getGameAction().playCard(card)) {
AllZone.getPhaseHandler().setPriority(AllZone.getHumanPlayer()); AllZone.getPhaseHandler().setPriority(AllZone.getHumanPlayer());
} }
else { else {

View File

@@ -83,7 +83,7 @@ public class InputPayManaCost extends InputMana {
AllZone.getStack().add(this.spell); AllZone.getStack().add(this.spell);
} }
} else { } else {
this.manaCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost)); this.manaCost = Singletons.getModel().getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost));
} }
} else { } else {
this.manaCost = new ManaCost(sa.getManaCost()); this.manaCost = new ManaCost(sa.getManaCost());
@@ -128,7 +128,7 @@ public class InputPayManaCost extends InputMana {
AllZone.getStack().add(this.spell); AllZone.getStack().add(this.spell);
} }
} else { } else {
this.manaCost = manaCostToPay; // AllZone.getGameAction().getSpellCostChange(sa, this.manaCost = manaCostToPay; // Singletons.getModel().getGameAction().getSpellCostChange(sa,
// new // new
// ManaCost(this.originalManaCost)); // ManaCost(this.originalManaCost));
} }
@@ -218,7 +218,7 @@ public class InputPayManaCost extends InputMana {
// if this is a spell, move it to the Stack ZOne // if this is a spell, move it to the Stack ZOne
if (this.spell.isSpell()) { if (this.spell.isSpell()) {
this.spell.setSourceCard(AllZone.getGameAction().moveToStack(this.originalCard)); this.spell.setSourceCard(Singletons.getModel().getGameAction().moveToStack(this.originalCard));
} }
if (this.spell.getAfterPayMana() != null) { if (this.spell.getAfterPayMana() != null) {

View File

@@ -27,6 +27,7 @@ import forge.Card;
import forge.CardUtil; import forge.CardUtil;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Singletons;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.AbilityFactoryMana; import forge.card.abilityfactory.AbilityFactoryMana;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
@@ -188,7 +189,7 @@ public class InputPayManaCostUtil {
// save off color needed for use by any mana and reflected mana // save off color needed for use by any mana and reflected mana
chosen.setExpressChoice(colorsNeeded); chosen.setExpressChoice(colorsNeeded);
AllZone.getGameAction().playSpellAbility(chosen); Singletons.getModel().getGameAction().playSpellAbility(chosen);
manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen); manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen);

View File

@@ -29,6 +29,7 @@ import javax.swing.JOptionPane;
import forge.AllZone; import forge.AllZone;
import forge.Constant; import forge.Constant;
import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
import forge.gui.ForgeAction; import forge.gui.ForgeAction;
import forge.item.CardPrinted; import forge.item.CardPrinted;
@@ -55,7 +56,7 @@ public class ControlDock {
/** Concede game, bring up WinLose UI. */ /** Concede game, bring up WinLose UI. */
public void concede() { public void concede() {
AllZone.getHumanPlayer().concede(); AllZone.getHumanPlayer().concede();
AllZone.getGameAction().checkStateEffects(); Singletons.getModel().getGameAction().checkStateEffects();
} }
/** /**

View File

@@ -70,10 +70,10 @@ public class ControlField {
private final Player player; private final Player player;
private final ViewField view; private final ViewField view;
private MouseMotionListener maCardOver; private MouseMotionListener mmlCardOver;
private MouseListener maAvatar, maLibrary, maHand, maExiled, maGraveyard, maFlashback, maCardClick; private MouseListener madAvatar, madLibrary, madHand, madExiled,
madGraveyard, madFlashback, madCardClick, madBlack,
private MouseAdapter maBlack, maBlue, maGreen, maRed, maWhite, maColorless; madBlue, madGreen, madRed, madWhite, madColorless;
private Observer observerZones, observerDetails, observerPlay; private Observer observerZones, observerDetails, observerPlay;
@@ -93,6 +93,9 @@ public class ControlField {
initMouseAdapters(); initMouseAdapters();
initObservers(); initObservers();
addObservers();
addListeners();
} }
/** /**
@@ -128,45 +131,31 @@ public class ControlField {
* *
*/ */
public void addListeners() { public void addListeners() {
// When/if zone action properties become less specific, the conditional
// tests for computer/human players can be removed. If that's not ever
// going to happen, this comment can be removed. :) Doublestrike
// 29-10-11.
this.addZoneListeners();
this.addPoolListeners();
// Battlefield card clicks // Battlefield card clicks
this.view.getTabletop().removeMouseListener(maCardClick); this.view.getTabletop().removeMouseListener(madCardClick);
this.view.getTabletop().addMouseListener(maCardClick); this.view.getTabletop().addMouseListener(madCardClick);
// Battlefield card mouseover // Battlefield card mouseover
this.view.getTabletop().removeMouseMotionListener(maCardOver); this.view.getTabletop().removeMouseMotionListener(mmlCardOver);
this.view.getTabletop().addMouseMotionListener(maCardOver); this.view.getTabletop().addMouseMotionListener(mmlCardOver);
// Player select // Player select
this.view.getAvatarArea().removeMouseListener(maAvatar); this.view.getAvatarArea().removeMouseListener(madAvatar);
this.view.getAvatarArea().addMouseListener(maAvatar); this.view.getAvatarArea().addMouseListener(madAvatar);
} // End addListeners()
/**
* Adds listeners to "zone" labels: flashback, graveyard, etc. This method
* only exists to avoid the 150-line limit in the checkstyle rules.
*/
private void addZoneListeners() {
// Graveyard card list button // Graveyard card list button
((FLabel) this.view.getLblGraveyard()).setHoverable(true); ((FLabel) this.view.getLblGraveyard()).setHoverable(true);
this.view.getLblGraveyard().removeMouseListener(maGraveyard); this.view.getLblGraveyard().removeMouseListener(madGraveyard);
this.view.getLblGraveyard().addMouseListener(maGraveyard); this.view.getLblGraveyard().addMouseListener(madGraveyard);
// Exile card list button // Exile card list button
((FLabel) this.view.getLblExile()).setHoverable(true); ((FLabel) this.view.getLblExile()).setHoverable(true);
this.view.getLblExile().removeMouseListener(maExiled); this.view.getLblExile().removeMouseListener(madExiled);
this.view.getLblExile().addMouseListener(maExiled); this.view.getLblExile().addMouseListener(madExiled);
// Library card list button // Library card list button
if (Constant.Runtime.DEV_MODE[0]) { if (Constant.Runtime.DEV_MODE[0]) {
this.view.getLblLibrary().removeMouseListener(maLibrary); this.view.getLblLibrary().removeMouseListener(madLibrary);
this.view.getLblLibrary().addMouseListener(maLibrary); this.view.getLblLibrary().addMouseListener(madLibrary);
// Hand button // Hand button
((FLabel) this.view.getLblHand()).setHoverable(true); ((FLabel) this.view.getLblHand()).setHoverable(true);
@@ -175,37 +164,37 @@ public class ControlField {
((FLabel) this.view.getLblLibrary()).setHoverable(false); ((FLabel) this.view.getLblLibrary()).setHoverable(false);
} }
this.view.getLblHand().removeMouseListener(maHand); this.view.getLblHand().removeMouseListener(madHand);
this.view.getLblHand().addMouseListener(maHand); this.view.getLblHand().addMouseListener(madHand);
// Flashback card list button // Flashback card list button
((FLabel) this.view.getLblFlashback()).setHoverable(true); ((FLabel) this.view.getLblFlashback()).setHoverable(true);
this.view.getLblFlashback().removeMouseListener(maFlashback); this.view.getLblFlashback().removeMouseListener(madFlashback);
this.view.getLblFlashback().addMouseListener(maFlashback); this.view.getLblFlashback().addMouseListener(madFlashback);
}
/**
* Adds listeners to mana "pool" labels, for paying mana.
*/
private void addPoolListeners() {
((FLabel) this.view.getLblBlack()).setHoverable(true); ((FLabel) this.view.getLblBlack()).setHoverable(true);
this.view.getLblBlack().removeMouseListener(maBlack); this.view.getLblBlack().removeMouseListener(madBlack);
this.view.getLblBlack().addMouseListener(maBlack); this.view.getLblBlack().addMouseListener(madBlack);
((FLabel) this.view.getLblBlue()).setHoverable(true); ((FLabel) this.view.getLblBlue()).setHoverable(true);
this.view.getLblBlue().removeMouseListener(maBlue); this.view.getLblBlue().removeMouseListener(madBlue);
this.view.getLblBlue().addMouseListener(maBlue); this.view.getLblBlue().addMouseListener(madBlue);
((FLabel) this.view.getLblGreen()).setHoverable(true); ((FLabel) this.view.getLblGreen()).setHoverable(true);
this.view.getLblGreen().removeMouseListener(maGreen); this.view.getLblGreen().removeMouseListener(madGreen);
this.view.getLblGreen().addMouseListener(maGreen); this.view.getLblGreen().addMouseListener(madGreen);
((FLabel) this.view.getLblRed()).setHoverable(true); ((FLabel) this.view.getLblRed()).setHoverable(true);
this.view.getLblRed().removeMouseListener(maRed); this.view.getLblRed().removeMouseListener(madRed);
this.view.getLblRed().addMouseListener(maRed); this.view.getLblRed().addMouseListener(madRed);
((FLabel) this.view.getLblWhite()).setHoverable(true); ((FLabel) this.view.getLblWhite()).setHoverable(true);
this.view.getLblWhite().removeMouseListener(maWhite); this.view.getLblWhite().removeMouseListener(madWhite);
this.view.getLblWhite().addMouseListener(maWhite); this.view.getLblWhite().addMouseListener(madWhite);
((FLabel) this.view.getLblColorless()).setHoverable(true); ((FLabel) this.view.getLblColorless()).setHoverable(true);
this.view.getLblColorless().removeMouseListener(maColorless); this.view.getLblColorless().removeMouseListener(madColorless);
this.view.getLblColorless().addMouseListener(maColorless); this.view.getLblColorless().addMouseListener(madColorless);
} }
/** /**
@@ -340,7 +329,7 @@ public class ControlField {
*/ */
private void initMouseAdapters() { private void initMouseAdapters() {
// Hand listener // Hand listener
maHand = new MouseAdapter() { madHand = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (!ControlField.this.player.isComputer()) { if (!ControlField.this.player.isComputer()) {
@@ -355,7 +344,7 @@ public class ControlField {
}; };
// Flashback listener // Flashback listener
maFlashback = new MouseAdapter() { madFlashback = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (!ControlField.this.player.isComputer()) { if (!ControlField.this.player.isComputer()) {
@@ -372,7 +361,7 @@ public class ControlField {
@Override @Override
protected void doAction(final Card c) { protected void doAction(final Card c) {
AllZone.getGameAction().playCard(c); Singletons.getModel().getGameAction().playCard(c);
} }
} .actionPerformed(null); } .actionPerformed(null);
} else { } else {
@@ -389,7 +378,7 @@ public class ControlField {
@Override @Override
protected void doAction(final Card c) { protected void doAction(final Card c) {
AllZone.getGameAction().playCard(c); Singletons.getModel().getGameAction().playCard(c);
} }
} .actionPerformed(null); } .actionPerformed(null);
} }
@@ -397,7 +386,7 @@ public class ControlField {
}; };
// Library listener // Library listener
maLibrary = new MouseAdapter() { madLibrary = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (!ControlField.this.player.isComputer()) { if (!ControlField.this.player.isComputer()) {
@@ -411,7 +400,7 @@ public class ControlField {
}; };
// Exiled adapter // Exiled adapter
maExiled = new MouseAdapter() { madExiled = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -425,7 +414,7 @@ public class ControlField {
}; };
// Graveyard adapter // Graveyard adapter
maGraveyard = new MouseAdapter() { madGraveyard = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -439,7 +428,7 @@ public class ControlField {
}; };
// Avatar // Avatar
maAvatar = new MouseAdapter() { madAvatar = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -453,7 +442,7 @@ public class ControlField {
}; };
// Battlefield card mouse over // Battlefield card mouse over
maCardOver = new MouseMotionAdapter() { mmlCardOver = new MouseMotionAdapter() {
@Override @Override
public void mouseMoved(final MouseEvent me) { public void mouseMoved(final MouseEvent me) {
final Card c = ControlField.this.view.getTabletop().getCardFromMouseOverPanel(); final Card c = ControlField.this.view.getTabletop().getCardFromMouseOverPanel();
@@ -464,7 +453,7 @@ public class ControlField {
}; };
// Battlefield card // Battlefield card
maCardClick = new MouseAdapter() { madCardClick = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
@@ -519,7 +508,7 @@ public class ControlField {
} }
}; };
maBlack = new MouseAdapter() { madBlack = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -535,7 +524,7 @@ public class ControlField {
} }
}; };
maBlue = new MouseAdapter() { madBlue = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -551,7 +540,7 @@ public class ControlField {
} }
}; };
maGreen = new MouseAdapter() { madGreen = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -567,7 +556,7 @@ public class ControlField {
} }
}; };
maRed = new MouseAdapter() { madRed = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -583,7 +572,7 @@ public class ControlField {
} }
}; };
maWhite = new MouseAdapter() { madWhite = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -599,7 +588,7 @@ public class ControlField {
} }
}; };
maColorless = new MouseAdapter() { madColorless = new MouseAdapter() {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (ControlField.this.player.isComputer()) { if (ControlField.this.player.isComputer()) {
@@ -615,5 +604,4 @@ public class ControlField {
} }
}; };
} // End initMouseAdapters() } // End initMouseAdapters()
} // End class ControlField } // End class ControlField

View File

@@ -52,8 +52,8 @@ public class ControlHand {
private final List<Card> cardsInPanel; private final List<Card> cardsInPanel;
private final ViewHand view; private final ViewHand view;
private MouseListener maCardClick; private final MouseListener madCardClick;
private MouseMotionListener maCardMove; private final MouseMotionListener madCardMove;
/** The o1. */ /** The o1. */
private Observer o1; private Observer o1;
@@ -69,7 +69,7 @@ public class ControlHand {
this.view = v; this.view = v;
this.cardsInPanel = new ArrayList<Card>(); this.cardsInPanel = new ArrayList<Card>();
maCardClick = new MouseAdapter() { madCardClick = new MouseAdapter() {
// Card click // Card click
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
@@ -84,7 +84,7 @@ public class ControlHand {
} }
}; };
maCardMove = new MouseMotionAdapter() { madCardMove = new MouseMotionAdapter() {
// Card mouseover // Card mouseover
@Override @Override
public void mouseMoved(final MouseEvent me) { public void mouseMoved(final MouseEvent me) {
@@ -162,6 +162,9 @@ public class ControlHand {
} }
} }
}; };
addObservers();
addListeners();
} }
/** Adds observers to hand panel. */ /** Adds observers to hand panel. */
@@ -171,11 +174,11 @@ public class ControlHand {
/** Adds listeners to hand panel: clicks, mouseover, etc. */ /** Adds listeners to hand panel: clicks, mouseover, etc. */
public void addListeners() { public void addListeners() {
view.getHandArea().removeMouseListener(maCardClick); view.getHandArea().removeMouseListener(madCardClick);
view.getHandArea().addMouseListener(maCardClick); view.getHandArea().addMouseListener(madCardClick);
view.getHandArea().removeMouseMotionListener(maCardMove); view.getHandArea().removeMouseMotionListener(madCardMove);
view.getHandArea().addMouseMotionListener(maCardMove); view.getHandArea().addMouseMotionListener(madCardMove);
} }
/** /**

View File

@@ -23,6 +23,7 @@ import java.awt.event.ActionListener;
import forge.AllZone; import forge.AllZone;
import forge.Constant; import forge.Constant;
import forge.GuiInput; import forge.GuiInput;
import forge.Singletons;
import forge.view.match.ViewMessage; import forge.view.match.ViewMessage;
/** /**
@@ -34,7 +35,7 @@ public class ControlMessage {
private final GuiInput inputControl; private final GuiInput inputControl;
private ActionListener alCancel = null, alOK = null; private final ActionListener actCancel, actOK;
/** /**
* Child controller - handles operations related to input panel. * Child controller - handles operations related to input panel.
@@ -46,7 +47,7 @@ public class ControlMessage {
this.view = v; this.view = v;
this.inputControl = new GuiInput(); this.inputControl = new GuiInput();
this.alOK = new ActionListener() { this.actOK = new ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent evt) { public void actionPerformed(final ActionEvent evt) {
ControlMessage.this.btnOKActionPerformed(evt); ControlMessage.this.btnOKActionPerformed(evt);
@@ -60,22 +61,24 @@ public class ControlMessage {
} }
}; };
this.alCancel = new ActionListener() { this.actCancel = new ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent evt) { public void actionPerformed(final ActionEvent evt) {
ControlMessage.this.btnCancelActionPerformed(evt); ControlMessage.this.btnCancelActionPerformed(evt);
ControlMessage.this.view.getBtnOK().requestFocusInWindow(); ControlMessage.this.view.getBtnOK().requestFocusInWindow();
} }
}; };
addListeners();
} }
/** Adds listeners to input area. */ /** Adds listeners to input area. */
public void addListeners() { public void addListeners() {
this.view.getBtnCancel().removeActionListener(alCancel); this.view.getBtnCancel().removeActionListener(actCancel);
this.view.getBtnCancel().addActionListener(alCancel); this.view.getBtnCancel().addActionListener(actCancel);
this.view.getBtnOK().removeActionListener(alOK); this.view.getBtnOK().removeActionListener(actOK);
this.view.getBtnOK().addActionListener(alOK); this.view.getBtnOK().addActionListener(actOK);
} }
/** /**
@@ -122,8 +125,8 @@ public class ControlMessage {
/** Updates count label in input area. */ /** Updates count label in input area. */
public void updateGameCount() { public void updateGameCount() {
view.getLblGames().setText("<html>Game #" view.getLblGames().setText("<html>Game #"
+ (AllZone.getMatchState().getGamesPlayedCount() + 1) + (Singletons.getModel().getMatchState().getGamesPlayedCount() + 1)
+ " of " + AllZone.getMatchState().getGamesPerMatch() + " of " + Singletons.getModel().getMatchState().getGamesPerMatch()
+ "<br>" + Constant.Runtime.getGameType().toString() + " mode</html>"); + "<br>" + Constant.Runtime.getGameType().toString() + " mode</html>");
} }

View File

@@ -37,10 +37,10 @@ import forge.view.match.ViewTabber;
*/ */
public class ControlTabber extends MyObservable { public class ControlTabber extends MyObservable {
private final ViewTabber view; private final ViewTabber view;
private MouseListener maMilling, maUnlimited, private final MouseListener madMilling, madUnlimited,
maMana, maSetup, maTutor, maCounter, maTap, maUntap, maLife; madMana, madSetup, madTutor, madCounter, madTap, madUntap, madLife;
private Observer stackObserver, logObserver; private Observer obsStack, obsLog;
/** */ /** */
public static final int STACK_PANEL = 0; public static final int STACK_PANEL = 0;
@@ -75,73 +75,98 @@ public class ControlTabber extends MyObservable {
this.view.getLblUnlimitedLands().setEnabled(false); this.view.getLblUnlimitedLands().setEnabled(false);
} }
// Various mouse adapters for dev buttons // Observers and listeners
initMouseAdapters(); obsStack = new Observer() { @Override
initObservers();
}
private void initObservers() {
// Stack
stackObserver = new Observer() {
@Override
public void update(final Observable a, final Object b) { public void update(final Observable a, final Object b) {
ControlTabber.this.view.updateStack(); ControlTabber.this.view.updateStack(); } };
}
};
//Game Log obsLog = new Observer() { @Override
logObserver = new Observer() {
@Override
public void update(final Observable a, final Object b) { public void update(final Observable a, final Object b) {
ControlTabber.this.view.updateConsole(); ControlTabber.this.view.updateConsole(); } };
}
}; madMilling = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
ControlTabber.this.view.getLblMilling().toggleEnabled(); } };
madUnlimited = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
ControlTabber.this.view.getLblUnlimitedLands().toggleEnabled(); } };
madMana = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeGenerateMana(); } };
madSetup = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devSetupGameState(); } };
madTutor = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTutor(); } };
madCounter = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeAddCounter(); } };
madTap = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTapPerm(); } };
madUntap = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeUntapPerm(); } };
madLife = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeSetLife(); } };
addListeners();
addObservers();
} }
/** Adds observers to tabber. */ /** Adds observers to tabber. */
public void addObservers() { public void addObservers() {
AllZone.getStack().addObserver(stackObserver); AllZone.getStack().addObserver(obsStack);
AllZone.getGameLog().addObserver(logObserver); AllZone.getGameLog().addObserver(obsLog);
} }
/** Adds listeners to various components in tabber. */ /** Adds listeners to various components in tabber. */
public void addListeners() { public void addListeners() {
// Milling enable toggle // Milling enable toggle
this.view.getLblMilling().removeMouseListener(maMilling); this.view.getLblMilling().removeMouseListener(madMilling);
this.view.getLblMilling().addMouseListener(maMilling); this.view.getLblMilling().addMouseListener(madMilling);
// DevMode: Play unlimited land this turn toggle // DevMode: Play unlimited land this turn toggle
this.view.getLblUnlimitedLands().removeMouseListener(maUnlimited); this.view.getLblUnlimitedLands().removeMouseListener(madUnlimited);
this.view.getLblUnlimitedLands().addMouseListener(maUnlimited); this.view.getLblUnlimitedLands().addMouseListener(madUnlimited);
// DevMode: Generate mana // DevMode: Generate mana
this.view.getLblGenerateMana().removeMouseListener(maMana); this.view.getLblGenerateMana().removeMouseListener(madMana);
this.view.getLblGenerateMana().addMouseListener(maMana); this.view.getLblGenerateMana().addMouseListener(madMana);
// DevMode: Battlefield setup // DevMode: Battlefield setup
this.view.getLblSetupGame().removeMouseListener(maSetup); this.view.getLblSetupGame().removeMouseListener(madSetup);
this.view.getLblSetupGame().addMouseListener(maSetup); this.view.getLblSetupGame().addMouseListener(madSetup);
// DevMode: Tutor for card // DevMode: Tutor for card
this.view.getLblTutor().removeMouseListener(maTutor); this.view.getLblTutor().removeMouseListener(madTutor);
this.view.getLblTutor().addMouseListener(maTutor); this.view.getLblTutor().addMouseListener(madTutor);
// DevMode: Add counter to permanent // DevMode: Add counter to permanent
this.view.getLblCounterPermanent().removeMouseListener(maCounter); this.view.getLblCounterPermanent().removeMouseListener(madCounter);
this.view.getLblCounterPermanent().addMouseListener(maCounter); this.view.getLblCounterPermanent().addMouseListener(madCounter);
// DevMode: Tap permanent // DevMode: Tap permanent
this.view.getLblTapPermanent().removeMouseListener(maTap); this.view.getLblTapPermanent().removeMouseListener(madTap);
this.view.getLblTapPermanent().addMouseListener(maTap); this.view.getLblTapPermanent().addMouseListener(madTap);
// DevMode: Untap permanent // DevMode: Untap permanent
this.view.getLblUntapPermanent().removeMouseListener(maUntap); this.view.getLblUntapPermanent().removeMouseListener(madUntap);
this.view.getLblUntapPermanent().addMouseListener(maUntap); this.view.getLblUntapPermanent().addMouseListener(madUntap);
// DevMode: Set life // DevMode: Set life
this.view.getLblSetLife().removeMouseListener(maLife); this.view.getLblSetLife().removeMouseListener(madLife);
this.view.getLblSetLife().addMouseListener(maLife); this.view.getLblSetLife().addMouseListener(madLife);
} }
/** /**
@@ -191,72 +216,4 @@ public class ControlTabber extends MyObservable {
public void showPnlStack() { public void showPnlStack() {
this.view.getVtpTabber().showTab(STACK_PANEL); this.view.getVtpTabber().showTab(STACK_PANEL);
} }
/** Simple method that inits the mouse adapters for listeners,
* here to simplify life in the constructor.
*/
private void initMouseAdapters() {
maMilling = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
ControlTabber.this.view.getLblMilling().toggleEnabled();
}
};
maUnlimited = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
ControlTabber.this.view.getLblUnlimitedLands().toggleEnabled();
}
};
maMana = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeGenerateMana();
}
};
maSetup = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devSetupGameState();
}
};
maTutor = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTutor();
}
};
maCounter = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeAddCounter();
}
};
maTap = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeTapPerm();
}
};
maUntap = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeUntapPerm();
}
};
maLife = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeSetLife();
}
};
}
} }

View File

@@ -12,6 +12,7 @@ import forge.Constant.Zone;
import forge.Singletons; import forge.Singletons;
import forge.control.FControl; import forge.control.FControl;
import forge.deck.Deck; import forge.deck.Deck;
import forge.game.GameNew;
import forge.game.GameType; import forge.game.GameType;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import forge.item.CardDb; import forge.item.CardDb;
@@ -66,16 +67,15 @@ public class ControlWinLose {
/** Action performed when "restart" button is pressed in default win/lose UI. */ /** Action performed when "restart" button is pressed in default win/lose UI. */
public void actionOnRestart() { public void actionOnRestart() {
AllZone.getMatchState().reset(); Singletons.getModel().getMatchState().reset();
GuiUtils.closeOverlay(); GuiUtils.closeOverlay();
startNextRound(); startNextRound();
} }
/** Action performed when "quit" button is pressed in default win/lose UI. */ /** Action performed when "quit" button is pressed in default win/lose UI. */
public void actionOnQuit() { public void actionOnQuit() {
AllZone.getMatchState().reset(); Singletons.getModel().getMatchState().reset();
Singletons.getModel().savePrefs(); Singletons.getModel().savePrefs();
Singletons.getControl().getControlMatch().deinitMatch();
Singletons.getControl().changeState(FControl.HOME_SCREEN); Singletons.getControl().changeState(FControl.HOME_SCREEN);
GuiUtils.closeOverlay(); GuiUtils.closeOverlay();
} }
@@ -92,7 +92,7 @@ public class ControlWinLose {
if (isAnte && !gameType.equals(GameType.Quest)) { if (isAnte && !gameType.equals(GameType.Quest)) {
Deck hDeck = Constant.Runtime.HUMAN_DECK[0]; Deck hDeck = Constant.Runtime.HUMAN_DECK[0];
Deck cDeck = Constant.Runtime.COMPUTER_DECK[0]; Deck cDeck = Constant.Runtime.COMPUTER_DECK[0];
if (AllZone.getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) { if (Singletons.getModel().getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) {
CardList compAntes = AllZone.getComputerPlayer().getCardsIn(Zone.Ante); CardList compAntes = AllZone.getComputerPlayer().getCardsIn(Zone.Ante);
//remove compy's ante cards form his deck //remove compy's ante cards form his deck
@@ -122,7 +122,7 @@ public class ControlWinLose {
} }
} }
Singletons.getModel().savePrefs(); Singletons.getModel().savePrefs();
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]); GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
} }
/** /**

View File

@@ -0,0 +1,543 @@
package forge.game;
import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Random;
import javax.swing.JOptionPane;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.CardListFilter;
import forge.CardUtil;
import forge.Constant;
import forge.Constant.Zone;
import forge.GameAction;
import forge.PhaseHandler;
import forge.Player;
import forge.Singletons;
import forge.card.cardfactory.CardFactoryInterface;
import forge.control.FControl;
import forge.control.input.InputMulligan;
import forge.deck.Deck;
import forge.item.CardPrinted;
import forge.properties.ForgePreferences.FPref;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.Lang.GameAction.GameActionText;
import forge.util.MyRandom;
/**
* Methods for all things related to starting a new game.
* All of these methods can and should be static.
*/
public class GameNew {
/**
* Constructor for new game allowing card lists to be put into play
* immediately, and life totals to be adjusted, for computer and human.
*
* @param humanDeck
* &emsp; {@link forge.deck.Deck} object.
* @param computerDeck
* &emsp; {@link forge.deck.Deck} object.
* @param human
* &emsp; {@link forge.CardList} object.
* @param computer
* &emsp; {@link forge.CardList} object.
* @param humanLife
* &emsp; int.
* @param computerLife
* &emsp; int.
*/
public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
final CardList computer, final int humanLife, final int computerLife) {
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
Singletons.getControl().getControlMatch().initMatch();
Constant.Quest.FANTASY_QUEST[0] = true;
GameNew.newGameCleanup();
GameNew.newMatchCleanup();
AllZone.getComputerPlayer().setStartingLife(computerLife);
AllZone.getHumanPlayer().setStartingLife(humanLife);
AllZone.getHumanPlayer().updateObservers();
for (final Card c : human) {
AllZone.getHumanPlayer().getZone(Zone.Battlefield).add(c);
c.setSickness(true);
}
for (final Card c : computer) {
AllZone.getComputerPlayer().getZone(Zone.Battlefield).add(c);
c.setSickness(true);
}
GameNew.actuateGame(humanDeck, computerDeck);
}
/**
* The default constructor for a new game.
*
* @param humanDeck
* &emsp; {@link forge.deck.Deck} object.
* @param computerDeck
* &emsp; {@link forge.deck.Deck} object.
*/
public static void newGame(final Deck humanDeck, final Deck computerDeck) {
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
Singletons.getControl().getControlMatch().initMatch();
Constant.Quest.FANTASY_QUEST[0] = false;
GameNew.newGameCleanup();
GameNew.newMatchCleanup();
AllZone.getComputerPlayer().setStartingLife(20);
AllZone.getHumanPlayer().setStartingLife(20);
GameNew.actuateGame(humanDeck, computerDeck);
}
/**
* This must be separated from the newGame method since life totals and
* player details could be adjusted before the game is started.
*
* That process (also cleanup and observer updates) should be done in
* newGame, then when all is ready, call this function.
*/
private static void actuateGame(final Deck humanDeck, final Deck computerDeck) {
forge.card.trigger.Trigger.resetIDs();
AllZone.getTriggerHandler().clearTriggerSettings();
AllZone.getTriggerHandler().clearDelayedTrigger();
Singletons.getControl().getControlMatch().getMessageControl().updateGameCount();
// friendliness
final CardFactoryInterface c = AllZone.getCardFactory();
Card.resetUniqueNumber();
final boolean canRandomFoil = Constant.Runtime.RANDOM_FOIL[0]
&& Constant.Runtime.getGameType().equals(GameType.Constructed);
final Random generator = MyRandom.getRandom();
final ArrayList<String> hAnteRemoved = new ArrayList<String>();
final ArrayList<String> cAnteRemoved = new ArrayList<String>();
AllZone.getTriggerHandler().suppressMode("Transformed");
for (final Entry<CardPrinted, Integer> stackOfCards : humanDeck.getMain()) {
final CardPrinted cardPrinted = stackOfCards.getKey();
for (int i = 0; i < stackOfCards.getValue(); i++) {
final Card card = c.getCard(cardPrinted.getName(), AllZone.getHumanPlayer());
card.setCurSetCode(cardPrinted.getSet());
final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount();
if (cntVariants > 1) {
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
}
card.setImageFilename(CardUtil.buildFilename(card));
// Assign random foiling on approximately 1:20 cards
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
card.setFoil(iFoil);
}
if (card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
hAnteRemoved.add(card.getName());
} else {
AllZone.getHumanPlayer().getZone(Zone.Library).add(card);
}
if (card.hasAlternateState()) {
if (card.isDoubleFaced()) {
card.setState("Transformed");
}
if (card.isFlip()) {
card.setState("Flipped");
}
card.setImageFilename(CardUtil.buildFilename(card));
card.setState("Original");
}
}
}
final ArrayList<String> rAICards = new ArrayList<String>();
for (final Entry<CardPrinted, Integer> stackOfCards : computerDeck.getMain()) {
final CardPrinted cardPrinted = stackOfCards.getKey();
for (int i = 0; i < stackOfCards.getValue(); i++) {
final Card card = c.getCard(cardPrinted.getName(), AllZone.getComputerPlayer());
card.setCurSetCode(cardPrinted.getSet());
final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount();
if (cntVariants > 1) {
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
}
card.setImageFilename(CardUtil.buildFilename(card));
// Assign random foiling on approximately 1:20 cards
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
card.setFoil(iFoil);
}
if (card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
cAnteRemoved.add(card.getName());
} else {
AllZone.getComputerPlayer().getZone(Zone.Library).add(card);
}
if (card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
rAICards.add(card.getName());
// get card picture so that it is in the image cache
// ImageCache.getImage(card);
}
if (card.hasAlternateState()) {
if (card.isDoubleFaced()) {
card.setState("Transformed");
}
if (card.isFlip()) {
card.setState("Flipped");
}
card.setImageFilename(CardUtil.buildFilename(card));
card.setState("Original");
}
}
}
AllZone.getTriggerHandler().clearSuppression("Transformed");
if (rAICards.size() > 0) {
final StringBuilder sb = new StringBuilder(
"AI deck contains the following cards that it can't play or may be buggy:\n");
for (int i = 0; i < rAICards.size(); i++) {
sb.append(rAICards.get(i));
if (((i % 4) == 0) && (i > 0)) {
sb.append("\n");
} else if (i != (rAICards.size() - 1)) {
sb.append(", ");
}
}
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
if (hAnteRemoved.size() > 0) {
final StringBuilder sb = new StringBuilder("The following ante cards were removed from the human's deck:\n");
for (int i = 0; i < hAnteRemoved.size(); i++) {
sb.append(hAnteRemoved.get(i));
if (((i % 4) == 0) && (i > 0)) {
sb.append("\n");
} else if (i != (hAnteRemoved.size() - 1)) {
sb.append(", ");
}
}
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
if (cAnteRemoved.size() > 0) {
final StringBuilder sb = new StringBuilder(
"The following ante cards were removed from the computer's deck:\n");
for (int i = 0; i < cAnteRemoved.size(); i++) {
sb.append(cAnteRemoved.get(i));
if (((i % 4) == 0) && (i > 0)) {
sb.append("\n");
} else if (i != (cAnteRemoved.size() - 1)) {
sb.append(", ");
}
}
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
for (int i = 0; i < 100; i++) {
AllZone.getHumanPlayer().shuffle();
}
// do this instead of shuffling Computer's deck
final boolean smoothLand = Constant.Runtime.SMOOTH[0];
if (smoothLand) {
final Card[] c1 = GameNew.smoothComputerManaCurve(AllZone.getComputerPlayer().getCardsIn(Zone.Library)
.toArray());
AllZone.getComputerPlayer().getZone(Zone.Library).setCards(c1);
} else {
// WTF? (it was so before refactor)
AllZone.getComputerPlayer().getZone(Zone.Library)
.setCards(AllZone.getComputerPlayer().getCardsIn(Zone.Library).toArray());
AllZone.getComputerPlayer().shuffle();
}
// Only cut/coin toss if it's the first game of the match
if (Singletons.getModel().getMatchState().getGamesPlayedCount() == 0) {
// New code to determine who goes first. Delete this if it doesn't
// work properly
if (Singletons.getModel().getGameAction().isStartCut()) {
GameNew.seeWhoPlaysFirst();
} else {
GameNew.seeWhoPlaysFirstCoinToss();
}
} else if (Singletons.getModel().getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) {
// if player won last, AI starts
GameNew.computerStartsGame();
}
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
final String nl = System.getProperty("line.separator");
final StringBuilder msg = new StringBuilder();
for (final Player p : AllZone.getPlayersInGame()) {
final CardList lib = p.getCardsIn(Zone.Library);
Card ante;
if ((lib.size() > 0) && (lib.getNotType("Basic").size() > 1)) {
ante = CardUtil.getRandom(lib.toArray());
while (ante.isBasicLand()) {
ante = CardUtil.getRandom(lib.toArray());
}
} else if (lib.size() > 1) {
ante = lib.get(0);
} else {
throw new RuntimeException(p + " library is empty.");
}
AllZone.getGameLog().add("Ante", p + " anted " + ante, 0);
Singletons.getModel().getGameAction().moveTo(Zone.Ante, ante);
msg.append(p.getName()).append(" ante: ").append(ante).append(nl);
}
JOptionPane.showConfirmDialog(null, msg, "Ante", JOptionPane.OK_CANCEL_OPTION);
}
for (int i = 0; i < 7; i++) {
AllZone.getHumanPlayer().drawCard();
AllZone.getComputerPlayer().drawCard();
}
Singletons.getControl().getControlMatch().setCard(AllZone.getHumanPlayer().getCardsIn(Zone.Hand).get(0));
AllZone.getInputControl().setInput(new InputMulligan());
PhaseHandler.setGameBegins(1); // is this needed? It's already in InputMulligan...
AllZone.getGameLog().add("Turn",
"Turn " + AllZone.getPhaseHandler().getTurn() + " (" + AllZone.getPhaseHandler().getPlayerTurn() + ")",
0);
} // newGame()
private static void newGameCleanup() {
final GameState gs = Singletons.getModel().getGameState();
gs.setGameSummary(
new GameSummary(gs.getHumanPlayer().getName(), gs.getComputerPlayer().getName()));
gs.getHumanPlayer().reset();
gs.getComputerPlayer().reset();
gs.getPhaseHandler().reset();
gs.getStack().reset();
gs.getCombat().reset();
gs.getGameLog().reset();
for (final Player p : gs.getPlayers()) {
for (final Zone z : Player.ALL_ZONES) {
p.getZone(z).reset();
}
}
gs.getStaticEffects().reset();
AllZone.getInputControl().clearInput();
AllZone.getColorChanger().reset();
}
private static void newMatchCleanup() {
if (Singletons.getModel().getMatchState().getGamesPlayedCount() != 0) { return; }
AllZone.getInputControl().resetInput();
Singletons.getModel().getMatchState().reset();
Singletons.getModel().loadPrefs();
}
// this is where the computer cheats
// changes AllZone.getComputerPlayer().getZone(Zone.Library)
/**
* <p>
* smoothComputerManaCurve.
* </p>
*
* @param in
* an array of {@link forge.Card} objects.
* @return an array of {@link forge.Card} objects.
*/
private static Card[] smoothComputerManaCurve(final Card[] in) {
final CardList library = new CardList(in);
library.shuffle();
// remove all land, keep non-basicland in there, shuffled
CardList land = library.getType("Land");
for (int i = 0; i < land.size(); i++) {
if (land.get(i).isLand()) {
library.remove(land.get(i));
}
}
try {
// mana weave, total of 7 land
// The Following have all been reduced by 1, to account for the
// computer starting first.
library.add(5, land.get(0));
library.add(6, land.get(1));
library.add(8, land.get(2));
library.add(9, land.get(3));
library.add(10, land.get(4));
library.add(12, land.get(5));
library.add(15, land.get(6));
} catch (final IndexOutOfBoundsException e) {
System.err.println("Error: cannot smooth mana curve, not enough land");
return in;
}
// add the rest of land to the end of the deck
for (int i = 0; i < land.size(); i++) {
if (!library.contains(land.get(i))) {
library.add(land.get(i));
}
}
// check
for (int i = 0; i < library.size(); i++) {
System.out.println(library.get(i));
}
return library.toArray();
} // smoothComputerManaCurve()
// decides who goes first when starting another game, used by newGame()
/**
* <p>
* seeWhoPlaysFirstCoinToss.
* </p>
*/
private static void seeWhoPlaysFirstCoinToss() {
final Object[] possibleValues = { ForgeProps.getLocalized(GameActionText.HEADS),
ForgeProps.getLocalized(GameActionText.TAILS) };
final Object q = JOptionPane.showOptionDialog(null, ForgeProps.getLocalized(GameActionText.HEADS_OR_TAILS),
ForgeProps.getLocalized(GameActionText.COIN_TOSS), JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
final int flip = MyRandom.getRandom().nextInt(2);
String humanFlip = " ";
String computerFlip = " ";
// JOptionPane.showMessageDialog(null, q, "",
// JOptionPane.INFORMATION_MESSAGE);
if (q.equals(0)) {
humanFlip = ForgeProps.getLocalized(GameActionText.HEADS);
computerFlip = ForgeProps.getLocalized(GameActionText.TAILS);
} else {
humanFlip = ForgeProps.getLocalized(GameActionText.TAILS);
computerFlip = ForgeProps.getLocalized(GameActionText.HEADS);
}
if (((flip == 0) && q.equals(0)) || ((flip == 1) && q.equals(1))) {
JOptionPane.showMessageDialog(null, humanFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN),
"", JOptionPane.INFORMATION_MESSAGE);
} else {
GameNew.computerStartsGame();
JOptionPane.showMessageDialog(null,
computerFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.COMPUTER_WIN), "",
JOptionPane.INFORMATION_MESSAGE);
}
} // seeWhoPlaysFirst_CoinToss()
/**
* <p>
* seeWhoPlaysFirst.
* </p>
*/
private static void seeWhoPlaysFirst() {
final GameAction ga = Singletons.getModel().getGameAction();
CardList hLibrary = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
hLibrary = hLibrary.filter(CardListFilter.NON_LANDS);
CardList cLibrary = AllZone.getComputerPlayer().getCardsIn(Zone.Library);
cLibrary = cLibrary.filter(CardListFilter.NON_LANDS);
final boolean starterDetermined = false;
int cutCount = 0;
final int cutCountMax = 20;
for (int i = 0; i < cutCountMax; i++) {
if (starterDetermined) {
break;
}
if (hLibrary.size() > 0) {
ga.setHumanCut(hLibrary.get(MyRandom.getRandom().nextInt(hLibrary.size())));
} else {
GameNew.computerStartsGame();
JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.HUMAN_MANA_COST) + "\r\n"
+ ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (cLibrary.size() > 0) {
ga.setComputerCut(cLibrary.get(MyRandom.getRandom().nextInt(cLibrary.size())));
} else {
JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.COMPUTER_MANA_COST) + "\r\n"
+ ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "", JOptionPane.INFORMATION_MESSAGE);
return;
}
cutCount = cutCount + 1;
ga.moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library),
ga.getHumanCut());
ga.moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library),
ga.getComputerCut());
final StringBuilder sb = new StringBuilder();
sb.append(ForgeProps.getLocalized(GameActionText.HUMAN_CUT) + ga.getHumanCut().getName() + " ("
+ ga.getHumanCut().getManaCost() + ")" + "\r\n");
sb.append(ForgeProps.getLocalized(GameActionText.COMPUTER_CUT) + ga.getComputerCut().getName() + " ("
+ ga.getComputerCut().getManaCost() + ")" + "\r\n");
sb.append("\r\n" + "Number of times the deck has been cut: " + cutCount + "\r\n");
if (CardUtil.getConvertedManaCost(ga.getComputerCut().getManaCost()) > CardUtil.getConvertedManaCost(
ga.getHumanCut().getManaCost())) {
GameNew.computerStartsGame();
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "",
JOptionPane.INFORMATION_MESSAGE);
return;
} else if (CardUtil.getConvertedManaCost(ga.getComputerCut().getManaCost()) < CardUtil
.getConvertedManaCost(ga.getHumanCut().getManaCost())) {
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "",
JOptionPane.INFORMATION_MESSAGE);
return;
} else {
sb.append(ForgeProps.getLocalized(GameActionText.EQUAL_CONVERTED_MANA) + "\r\n");
if (i == (cutCountMax - 1)) {
sb.append(ForgeProps.getLocalized(GameActionText.RESOLVE_STARTER));
if (MyRandom.getRandom().nextInt(2) == 1) {
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), "",
JOptionPane.INFORMATION_MESSAGE);
} else {
GameNew.computerStartsGame();
JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.COMPUTER_WIN),
"", JOptionPane.INFORMATION_MESSAGE);
}
return;
} else {
sb.append(ForgeProps.getLocalized(GameActionText.CUTTING_AGAIN));
}
JOptionPane.showMessageDialog(null, sb, "", JOptionPane.INFORMATION_MESSAGE);
}
} // for-loop for multiple card cutting
} // seeWhoPlaysFirst()
private static void computerStartsGame() {
final Player computer = AllZone.getComputerPlayer();
AllZone.getPhaseHandler().setPlayerTurn(computer);
// AllZone.getGameInfo().setPlayerWhoGotFirstTurn(computer.getName());
}
}

View File

@@ -15,16 +15,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package forge.model; package forge.game;
import forge.AIPlayer; import forge.AIPlayer;
import forge.Combat; import forge.Combat;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone;
import forge.DefaultPlayerZone; import forge.DefaultPlayerZone;
import forge.EndOfCombat; import forge.EndOfCombat;
import forge.EndOfTurn; import forge.EndOfTurn;
import forge.GameAction;
import forge.GameLog; import forge.GameLog;
import forge.HumanPlayer; import forge.HumanPlayer;
import forge.MagicStack; import forge.MagicStack;
@@ -32,17 +30,16 @@ import forge.PhaseHandler;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.StaticEffects; import forge.StaticEffects;
import forge.Upkeep;
import forge.Untap; import forge.Untap;
import forge.Upkeep;
import forge.card.replacement.ReplacementHandler; import forge.card.replacement.ReplacementHandler;
import forge.card.trigger.TriggerHandler; import forge.card.trigger.TriggerHandler;
import forge.game.GameSummary;
/** /**
* Represents the state of a <i>single game</i> and is * Represents the state of a <i>single game</i> and is
* "cleaned up" at each new game. * "cleaned up" at each new game.
*/ */
public class FGameState { public class GameState {
/** The Constant HUMAN_PLAYER_NAME. */ /** The Constant HUMAN_PLAYER_NAME. */
public static final String HUMAN_PLAYER_NAME = "Human"; public static final String HUMAN_PLAYER_NAME = "Human";
@@ -50,18 +47,17 @@ public class FGameState {
/** The Constant AI_PLAYER_NAME. */ /** The Constant AI_PLAYER_NAME. */
public static final String AI_PLAYER_NAME = "Computer"; public static final String AI_PLAYER_NAME = "Computer";
private Player humanPlayer = new HumanPlayer(FGameState.HUMAN_PLAYER_NAME); private Player humanPlayer = new HumanPlayer(GameState.HUMAN_PLAYER_NAME);
private Player computerPlayer = new AIPlayer(FGameState.AI_PLAYER_NAME); private Player computerPlayer = new AIPlayer(GameState.AI_PLAYER_NAME);
private EndOfTurn endOfTurn = new EndOfTurn(); private EndOfTurn endOfTurn = new EndOfTurn();
private EndOfCombat endOfCombat = new EndOfCombat(); private EndOfCombat endOfCombat = new EndOfCombat();
private Untap untap = new Untap(); private Untap untap = new Untap();
private Upkeep upkeep = new Upkeep(); private Upkeep upkeep = new Upkeep();
private PhaseHandler phaseHandler = new PhaseHandler(); private PhaseHandler phaseHandler = new PhaseHandler();
private MagicStack stack = new MagicStack(); private MagicStack stack = new MagicStack();
private GameAction gameAction = new GameAction();
private StaticEffects staticEffects = new StaticEffects(); private StaticEffects staticEffects = new StaticEffects();
private TriggerHandler triggerHandler = new TriggerHandler(); private TriggerHandler triggerHandler = new TriggerHandler();
private ReplacementHandler replacementHandler = new ReplacementHandler(); private final ReplacementHandler replacementHandler = new ReplacementHandler();
private Combat combat = new Combat(); private Combat combat = new Combat();
private GameLog gameLog = new GameLog(); private GameLog gameLog = new GameLog();
@@ -73,7 +69,7 @@ public class FGameState {
/** /**
* Constructor. * Constructor.
*/ */
public FGameState() { /* no more zones to map here */ public GameState() { /* no more zones to map here */
} }
/** /**
@@ -208,16 +204,6 @@ public class FGameState {
return this.phaseHandler; return this.phaseHandler;
} }
/**
* Sets the phase.
*
* @param phaseHandlerIn
* the phaseHandler to set
*/
protected final void setPhaseHandler(final PhaseHandler phaseHandlerIn) {
this.phaseHandler = phaseHandlerIn;
}
/** /**
* Gets the stack. * Gets the stack.
* *
@@ -237,25 +223,6 @@ public class FGameState {
this.stack = stack0; this.stack = stack0;
} }
/**
* Gets the game action.
*
* @return the gameAction
*/
public final GameAction getGameAction() {
return this.gameAction;
}
/**
* Sets the game action.
*
* @param gameAction0
* the gameAction to set
*/
protected final void setGameAction(final GameAction gameAction0) {
this.gameAction = gameAction0;
}
/** /**
* Gets the static effects. * Gets the static effects.
* *
@@ -389,27 +356,12 @@ public class FGameState {
} }
/** /**
* Call this each time you start a new game, ok?. * Sets the game info.
*
* @param summary0 {@link forge.game.GameSummary}
*/ */
public final void newGameCleanup() { public final void setGameSummary(final GameSummary summary0) {
this.gameSummary = new GameSummary(this.humanPlayer.getName(), this.computerPlayer.getName()); this.gameSummary = summary0;
this.getHumanPlayer().reset();
this.getComputerPlayer().reset();
this.getPhaseHandler().reset();
this.getStack().reset();
this.getCombat().reset();
this.getGameLog().reset();
for (final Player p : this.getPlayers()) {
for (final Zone z : Player.ALL_ZONES) {
p.getZone(z).reset();
}
}
this.getStaticEffects().reset();
} }
/** /**

View File

@@ -32,13 +32,16 @@ import forge.ComputerAIGeneral;
import forge.ComputerAIInput; import forge.ComputerAIInput;
import forge.Constant; import forge.Constant;
import forge.ConstantStringArrayList; import forge.ConstantStringArrayList;
import forge.GameAction;
import forge.Singletons; import forge.Singletons;
import forge.control.input.InputControl; import forge.control.input.InputControl;
import forge.game.GameState;
import forge.game.GameSummary; import forge.game.GameSummary;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.data.QuestEventManager;
import forge.quest.data.QuestPreferences; import forge.quest.data.QuestPreferences;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.HttpUtil; import forge.util.HttpUtil;
@@ -55,18 +58,22 @@ import forge.view.toolbox.FSkin;
* In case we need to convert it into an interface in the future, all fields of * In case we need to convert it into an interface in the future, all fields of
* this class must be either private or public static final. * this class must be either private or public static final.
*/ */
public class FModel { public enum FModel {
/** */
SINGLETON_INSTANCE;
// private static final int NUM_INIT_PHASES = 1; // private static final int NUM_INIT_PHASES = 1;
private final transient OutputStream logFileStream; private final PrintStream oldSystemOut;
private final transient PrintStream oldSystemOut; private final PrintStream oldSystemErr;
private final transient PrintStream oldSystemErr;
private BuildInfo buildInfo; private BuildInfo buildInfo;
private OutputStream logFileStream;
/** The preferences. */ private final GameAction gameAction;
private final QuestPreferences questPreferences; private final QuestPreferences questPreferences;
private final ForgePreferences preferences; private final ForgePreferences preferences;
private FGameState gameState; private final QuestEventManager questEventManager;
private final GameState gameState;
private final FMatchState matchState;
/** /**
* Constructor. * Constructor.
@@ -74,7 +81,7 @@ public class FModel {
* @throws FileNotFoundException * @throws FileNotFoundException
* if we could not find or write to the log file. * if we could not find or write to the log file.
*/ */
public FModel() throws FileNotFoundException { private FModel() {
// Fire up log file // Fire up log file
final File logFile = new File("forge.log"); final File logFile = new File("forge.log");
final boolean deleteSucceeded = logFile.delete(); final boolean deleteSucceeded = logFile.delete();
@@ -83,22 +90,29 @@ public class FModel {
throw new IllegalStateException("Could not delete existing logFile:" + logFile.getAbsolutePath()); throw new IllegalStateException("Could not delete existing logFile:" + logFile.getAbsolutePath());
} }
this.logFileStream = new FileOutputStream(logFile); try {
this.logFileStream = new FileOutputStream(logFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
this.oldSystemOut = System.out; this.oldSystemOut = System.out;
System.setOut(new PrintStream(new MultiplexOutputStream(System.out, this.logFileStream), true)); System.setOut(new PrintStream(new MultiplexOutputStream(System.out, this.logFileStream), true));
this.oldSystemErr = System.err; this.oldSystemErr = System.err;
System.setErr(new PrintStream(new MultiplexOutputStream(System.err, this.logFileStream), true)); System.setErr(new PrintStream(new MultiplexOutputStream(System.err, this.logFileStream), true));
// Instantiate preferences // Instantiate preferences: quest and regular
try { try {
this.preferences = new ForgePreferences(); this.preferences = new ForgePreferences();
} catch (final Exception exn) { } catch (final Exception exn) {
throw new RuntimeException(exn); throw new RuntimeException(exn);
} }
// Instantiate quest preferences this.gameAction = new GameAction();
this.gameState = new GameState();
this.matchState = new FMatchState();
this.questPreferences = new QuestPreferences(); this.questPreferences = new QuestPreferences();
this.questEventManager = new QuestEventManager();
// TODO this single setting from preferences should not be here, or, // TODO this single setting from preferences should not be here, or,
// it should be here with all the other settings at the same time. // it should be here with all the other settings at the same time.
@@ -246,32 +260,6 @@ public class FModel {
*/ */
} }
/**
* Destructor for FModel.
*
* @throws Throwable
* indirectly
*/
@Override
protected final void finalize() throws Throwable {
this.close();
super.finalize();
}
/**
* Opposite of constructor; resets all system resources and closes the log
* file.
*/
public final void close() {
System.setOut(this.oldSystemOut);
System.setErr(this.oldSystemErr);
try {
this.logFileStream.close();
} catch (final IOException e) {
// ignored
}
}
/** /**
* Gets the builds the info. * Gets the builds the info.
* *
@@ -309,14 +297,41 @@ public class FModel {
} }
/** /**
* Gets the game state. * Gets the quest preferences.
* *
* @return {@link forge.model.FGameState} * @return {@link forge.quest.data.QuestEventManager}
*/ */
public final FGameState getGameState() { public final QuestEventManager getQuestEventManager() {
return this.questEventManager;
}
/**
* Gets the game action model.
*
* @return {@link forge.GameAction}
*/
public final GameAction getGameAction() {
return this.gameAction;
}
/**
* Gets the game state model - that is, the data stored for a single game.
*
* @return {@link forge.game.GameState}
*/
public final GameState getGameState() {
return this.gameState; return this.gameState;
} }
/**
* Gets the match state model - that is, the data stored over multiple games.
*
* @return {@link forge.model.FMatchState}
*/
public final FMatchState getMatchState() {
return this.matchState;
}
/** /**
* Gets the game summary. * Gets the game summary.
* *
@@ -326,16 +341,6 @@ public class FModel {
return this.gameState.getGameSummary(); return this.gameState.getGameSummary();
} }
/**
* Create and return a new game state.
*
* @return a fresh {@link forge.model.FGameState}
*/
public final FGameState resetGameState() {
this.gameState = new FGameState();
return this.gameState;
}
/** /**
* TODO: Needs to be reworked for efficiency with rest of prefs saves in * TODO: Needs to be reworked for efficiency with rest of prefs saves in
* codebase. * codebase.
@@ -437,4 +442,19 @@ public class FModel {
Singletons.getView().getViewMatch().setLayoutParams(fp.getPref(FPref.UI_LAYOUT_PARAMS)); Singletons.getView().getViewMatch().setLayoutParams(fp.getPref(FPref.UI_LAYOUT_PARAMS));
return true; return true;
} }
/**
* Finalizer, generally should be avoided, but here
* closes the log file stream and
* resets the system output streams.
*/
public final void close() {
System.setOut(this.oldSystemOut);
System.setErr(this.oldSystemErr);
try {
this.logFileStream.close();
} catch (final IOException e) {
// ignored
}
}
} }

View File

@@ -61,12 +61,6 @@ public class QuestEventManager {
/** The all challenges. */ /** The all challenges. */
private List<QuestChallenge> allChallenges = null; private List<QuestChallenge> allChallenges = null;
private final QuestPreferences qpref;
/** */
public QuestEventManager() {
this.qpref = Singletons.getModel().getQuestPreferences();
}
/** /**
* <p> * <p>
* assembleAllEvents. * assembleAllEvents.
@@ -106,6 +100,22 @@ public class QuestEventManager {
} // End assembleAllEvents() } // End assembleAllEvents()
/**
* Retrieve single event, using its name.
*
* @param s0 &emsp; {@link java.lang.String}
* @return {@link forge.data.QuestEvent}
*/
public QuestEvent getEvent(final String s0) {
for (QuestEvent q : allDuels) {
if (q.getName().equals(s0)) { return q; } }
for (QuestChallenge q : allChallenges) {
if (q.getName().equals(s0)) { return q; } }
return null;
}
/** /**
* <p> * <p>
* assembleDuelUniqueData. * assembleDuelUniqueData.
@@ -363,6 +373,7 @@ public class QuestEventManager {
* @return an array of {@link java.lang.String} objects. * @return an array of {@link java.lang.String} objects.
*/ */
public final List<QuestDuel> generateDuels() { public final List<QuestDuel> generateDuels() {
final QuestPreferences qpref = Singletons.getModel().getQuestPreferences();
if (AllZone.getQuestData() == null) { return null; } if (AllZone.getQuestData() == null) { return null; }
final int index = AllZone.getQuestData().getDifficultyIndex(); final int index = AllZone.getQuestData().getDifficultyIndex();

View File

@@ -48,22 +48,15 @@ public final class Main {
public static void main(final String[] args) { public static void main(final String[] args) {
ExceptionHandler.registerErrorHandling(); ExceptionHandler.registerErrorHandling();
try { try {
final FModel model = new FModel(); Singletons.setModel(FModel.SINGLETON_INSTANCE);
final FView view = new FView(); Singletons.setView(new FView());
final FControl control = FControl.SINGLETON_INSTANCE; Singletons.setControl(FControl.SINGLETON_INSTANCE);
Singletons.setModel(model);
Singletons.setView(view);
Singletons.setControl(control);
// Instantiate FGameState for TriggerHandler on card objects created in preloader.
model.resetGameState();
// Start splash frame. // Start splash frame.
view.initialize(); Singletons.getView().initialize();
// Start control on FView. // Start control on FView.
control.initialize(); Singletons.getControl().initialize();
// Open previous menu on first run, or constructed. // Open previous menu on first run, or constructed.
// Focus is reset when the frame becomes visible, // Focus is reset when the frame becomes visible,
@@ -105,4 +98,18 @@ public final class Main {
ErrorViewer.showError(exn); ErrorViewer.showError(exn);
} }
} }
/**
* Destructor for FModel.
*
* @throws Throwable
* indirectly
*/
@Override
protected void finalize() throws Throwable {
// NOT WORKING
// this should call close in model,
// should probably be attached to frame close method
super.finalize();
}
} }

View File

@@ -23,6 +23,7 @@ import javax.swing.border.LineBorder;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import forge.AllZone; import forge.AllZone;
import forge.Command; import forge.Command;
import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.view.toolbox.FLabel; import forge.view.toolbox.FLabel;
@@ -147,11 +148,15 @@ public class ConstructedDeckSelectPanel extends JPanel {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
listSelectManager((JList) e.getSource()); listSelectManager((JList) e.getSource());
if (e.getClickCount() == 2 if (e.getClickCount() == 2 && ((JList) e.getSource()).getName().equals("lstCustom")) {
&& (((JList) e.getSource()).getName().equals("lstQuest") || ((JList) e.getSource()).getName().equals("lstCustom"))) {
final String deckName = ((JList) e.getSource()).getSelectedValue().toString(); final String deckName = ((JList) e.getSource()).getSelectedValue().toString();
showDecklist(AllZone.getDecks().getConstructed().get(deckName)); showDecklist(AllZone.getDecks().getConstructed().get(deckName));
} }
else if (e.getClickCount() == 2 && ((JList) e.getSource()).getName().equals("lstQuest")) {
final String deckName = ((JList) e.getSource()).getSelectedValue().toString();
Singletons.getModel().getQuestEventManager().getEvent(deckName);
showDecklist(Singletons.getModel().getQuestEventManager().getEvent(deckName).getEventDeck());
}
} }
}; };

View File

@@ -39,6 +39,7 @@ import forge.control.match.ControlWinLose;
import forge.game.GameEndReason; import forge.game.GameEndReason;
import forge.game.GameFormat; import forge.game.GameFormat;
import forge.game.GameLossReason; import forge.game.GameLossReason;
import forge.game.GameNew;
import forge.game.GamePlayerRating; import forge.game.GamePlayerRating;
import forge.game.GameSummary; import forge.game.GameSummary;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
@@ -88,7 +89,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
public QuestWinLoseHandler(final ViewWinLose view0) { public QuestWinLoseHandler(final ViewWinLose view0) {
super(view0); super(view0);
this.view = view0; this.view = view0;
matchState = AllZone.getMatchState(); matchState = Singletons.getModel().getMatchState();
qData = AllZone.getQuestData(); qData = AllZone.getQuestData();
qEvent = AllZone.getQuestEvent(); qEvent = AllZone.getQuestEvent();
this.wonMatch = matchState.isMatchWonBy(AllZone.getHumanPlayer().getName()); this.wonMatch = matchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
@@ -126,7 +127,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
computerLife = ((QuestChallenge) qEvent).getAILife(); computerLife = ((QuestChallenge) qEvent).getAILife();
} }
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0], GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
humanList, computerList, humanLife, computerLife); humanList, computerList, humanLife, computerLife);
} else { } else {
super.startNextRound(); super.startNextRound();
@@ -151,14 +152,14 @@ public class QuestWinLoseHandler extends ControlWinLose {
if (matchState.hasWonLastGame(AllZone.getHumanPlayer().getName())) { if (matchState.hasWonLastGame(AllZone.getHumanPlayer().getName())) {
if (isAnte) { if (isAnte) {
final CardList antes = AllZone.getComputerPlayer().getCardsIn(Zone.Ante); final CardList antes = AllZone.getComputerPlayer().getCardsIn(Zone.Ante);
final List<CardPrinted> antesPrinted = AllZone.getMatchState().addAnteWon(antes); final List<CardPrinted> antesPrinted = Singletons.getModel().getMatchState().addAnteWon(antes);
this.anteWon(antesPrinted); this.anteWon(antesPrinted);
} }
} else { } else {
if (isAnte) { if (isAnte) {
final CardList antes = AllZone.getHumanPlayer().getCardsIn(Zone.Ante); final CardList antes = AllZone.getHumanPlayer().getCardsIn(Zone.Ante);
final List<CardPrinted> antesPrinted = AllZone.getMatchState().addAnteLost(antes); final List<CardPrinted> antesPrinted = Singletons.getModel().getMatchState().addAnteLost(antes);
for (final CardPrinted ante : antesPrinted) { for (final CardPrinted ante : antesPrinted) {
//the last param here (should) determine if this is added to the Card Shop //the last param here (should) determine if this is added to the Card Shop
AllZone.getQuestData().getCards().sellCard(ante, 0, false); AllZone.getQuestData().getCards().sellCard(ante, 0, false);
@@ -219,7 +220,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
// Add any antes won this match (regardless of Match Win/Lose to Card Pool // Add any antes won this match (regardless of Match Win/Lose to Card Pool
// Note: Antes lost have already been remove from decks. // Note: Antes lost have already been remove from decks.
AllZone.getMatchState().addAnteWonToCardPool(); Singletons.getModel().getMatchState().addAnteWonToCardPool();
return true; return true;
} }
@@ -291,7 +292,6 @@ public class QuestWinLoseHandler extends ControlWinLose {
Singletons.getModel().getQuestPreferences().save(); Singletons.getModel().getQuestPreferences().save();
Singletons.getModel().savePrefs(); Singletons.getModel().savePrefs();
Singletons.getControl().getControlMatch().deinitMatch();
Singletons.getControl().changeState(FControl.HOME_SCREEN); Singletons.getControl().changeState(FControl.HOME_SCREEN);
Singletons.getView().getViewHome().showQuestMenu(); Singletons.getView().getViewHome().showQuestMenu();
GuiUtils.closeOverlay(); GuiUtils.closeOverlay();

View File

@@ -39,7 +39,7 @@ public class ViewWinLose {
/** */ /** */
public ViewWinLose() { public ViewWinLose() {
final FOverlay overlay = Singletons.getView().getOverlay(); final FOverlay overlay = Singletons.getView().getOverlay();
final FMatchState matchState = AllZone.getMatchState(); final FMatchState matchState = Singletons.getModel().getMatchState();
final JPanel pnlLeft = new JPanel(); final JPanel pnlLeft = new JPanel();
final JPanel pnlRight = new JPanel(); final JPanel pnlRight = new JPanel();

View File

@@ -1,43 +0,0 @@
package forge;
import org.testng.annotations.Test;
import forge.deck.generate.GenerateConstructedDeck;
/**
* The Class GameActionTest.
*/
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
public class GameActionTest {
/**
* <p>
* main.
* </p>
*
* @throws Exception
* the exception
*/
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000, enabled = false)
public void gameActionTest1() throws Exception {
System.out.println("GameActionTest");
final GameAction gameAction = new GameAction();
final GenerateConstructedDeck gen = new GenerateConstructedDeck();
for (int i = 0; i < 2000; i++) {
final CardList list = gen.generateDeck();
final Card[] card = gameAction.smoothComputerManaCurve(list.toArray());
final CardList check = new CardList();
for (int a = 0; a < 30; a++) {
check.add(card[a]);
}
if (check.getType("Land").size() != 7) {
System.out.println("error - " + check);
break;
}
} // for
}
}

View File

@@ -25,7 +25,7 @@ public class FModelTest {
*/ */
@BeforeTest @BeforeTest
public final void setUp() throws FileNotFoundException { public final void setUp() throws FileNotFoundException {
this.model = new FModel(); // this.model = new FModel();
} }
/** /**
@@ -63,7 +63,7 @@ public class FModelTest {
System.err.println("log test"); System.err.println("log test");
this.model = new FModel(); // this.model = new FModel();
Assert.assertNotNull(this.model, "model is not null"); Assert.assertNotNull(this.model, "model is not null");
} }
@@ -118,12 +118,12 @@ public class FModelTest {
Singletons.setModel(this.model); Singletons.setModel(this.model);
Assert.assertNull(this.model.getGameState(), "game state has not yet been initialized"); Assert.assertNull(this.model.getGameState(), "game state has not yet been initialized");
final FGameState state1 = this.model.resetGameState(); /*final GameState state1 = this.model.resetGameState();
Assert.assertNotNull(state1, "first state is OK"); Assert.assertNotNull(state1, "first state is OK");
final FGameState state2 = this.model.resetGameState(); final GameState state2 = this.model.resetGameState();
Assert.assertNotNull(state1, "first state is OK"); Assert.assertNotNull(state1, "first state is OK");
Assert.assertNotEquals(state1, state2, "first and second states are different"); Assert.assertNotEquals(state1, state2, "first and second states are different");*/
} }