mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
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:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -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/GameFormat.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/GameState.java -text
|
||||
src/main/java/forge/game/GameSummary.java svneol=native#text/plain
|
||||
src/main/java/forge/game/GameType.java -text
|
||||
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/package-info.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/FModel.java svneol=native#text/plain
|
||||
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/CardColorTest.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/GuiDownloadSetPicturesLQTest.java svneol=native#text/plain
|
||||
src/test/java/forge/GuiMigrateLocalMWSSetPicturesHQTest.java svneol=native#text/plain
|
||||
|
||||
@@ -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
|
||||
if (this.getDredgeNumber(c) <= this.getCardsIn(Zone.Library).size()) {
|
||||
// dredge library, put card in hand
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
// put dredge number in graveyard
|
||||
for (int i = 0; i < this.getDredgeNumber(c); i++) {
|
||||
final Card c2 = this.getCardsIn(Zone.Library).get(0);
|
||||
AllZone.getGameAction().moveToGraveyard(c2);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(c2);
|
||||
}
|
||||
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) {
|
||||
final Card card = blIH.get(CardUtil.getRandomIndex(blIH));
|
||||
|
||||
AllZone.getGameAction().moveToLibrary(card, position);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(card, position);
|
||||
} else {
|
||||
CardListUtil.sortAttackLowFirst(hand);
|
||||
CardListUtil.sortNonFlyingFirst(hand);
|
||||
|
||||
AllZone.getGameAction().moveToLibrary(hand.get(0), position);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(hand.get(0), position);
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
final Card c = topN.get(i);
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
|
||||
// topN.remove(c);
|
||||
}
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public class AIPlayer extends Player {
|
||||
final Random rndm = MyRandom.getRandom();
|
||||
final int r = rndm.nextInt(topN.size());
|
||||
final Card c = topN.get(r);
|
||||
AllZone.getGameAction().moveToLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c);
|
||||
topN.remove(r);
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ public class AIPlayer extends Player {
|
||||
if (choices.size() > 0) {
|
||||
// TODO - this could probably use better AI
|
||||
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) {
|
||||
// computer just puts the card back until such time it can make a
|
||||
// smarter decision
|
||||
AllZone.getGameAction().moveToLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,11 +26,10 @@ import forge.card.cardfactory.CardFactoryInterface;
|
||||
import forge.card.cardfactory.PreloadingCardFactory;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.deck.CardCollections;
|
||||
import forge.control.input.InputControl;
|
||||
import forge.deck.CardCollections;
|
||||
import forge.game.GameState;
|
||||
import forge.game.limited.CardRatings;
|
||||
import forge.model.FGameState;
|
||||
import forge.model.FMatchState;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.data.QuestData;
|
||||
@@ -78,9 +77,6 @@ public final class AllZone {
|
||||
/** Constant <code>inputControl</code>. */
|
||||
private static InputControl inputControl = null;
|
||||
|
||||
/** */
|
||||
private static FMatchState matchState = new FMatchState();
|
||||
|
||||
// initialized at Runtime since it has to be the last object constructed
|
||||
|
||||
// shared between Input_Attack, Input_Block, Input_CombatDamage ,
|
||||
@@ -110,10 +106,8 @@ public final class AllZone {
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static Player getHumanPlayer() {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
|
||||
if (gameState != null) {
|
||||
return gameState.getHumanPlayer();
|
||||
if (Singletons.getModel() != null) {
|
||||
return Singletons.getModel().getGameState().getHumanPlayer();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -294,10 +288,8 @@ public final class AllZone {
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static PhaseHandler getPhaseHandler() {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
|
||||
if (gameState != null) {
|
||||
return gameState.getPhaseHandler();
|
||||
if (Singletons.getModel() != null) {
|
||||
return Singletons.getModel().getGameState().getPhaseHandler();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -312,7 +304,7 @@ public final class AllZone {
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public static GameLog getGameLog() {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
final GameState gameState = Singletons.getModel().getGameState();
|
||||
|
||||
if (gameState != null) {
|
||||
return gameState.getGameLog();
|
||||
@@ -360,10 +352,8 @@ public final class AllZone {
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static MagicStack getStack() {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
|
||||
if (gameState != null) {
|
||||
return gameState.getStack();
|
||||
if (Singletons.getModel() != null) {
|
||||
return Singletons.getModel().getGameState().getStack();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -386,26 +376,6 @@ public final class AllZone {
|
||||
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>
|
||||
* getStaticEffects.
|
||||
@@ -417,7 +387,7 @@ public final class AllZone {
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static StaticEffects getStaticEffects() {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
final GameState gameState = Singletons.getModel().getGameState();
|
||||
|
||||
if (gameState != null) {
|
||||
return gameState.getStaticEffects();
|
||||
@@ -502,7 +472,7 @@ public final class AllZone {
|
||||
* @return a {@link forge.PlayerZone} object.
|
||||
*/
|
||||
public static PlayerZone getZoneOf(final Card c) {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
final GameState gameState = Singletons.getModel().getGameState();
|
||||
if (gameState == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -534,7 +504,7 @@ public final class AllZone {
|
||||
* @return boolean
|
||||
*/
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
@@ -560,7 +530,7 @@ public final class AllZone {
|
||||
* </p>
|
||||
*/
|
||||
public static void resetZoneMoveTracking() {
|
||||
final FGameState gameState = Singletons.getModel().getGameState();
|
||||
final GameState gameState = Singletons.getModel().getGameState();
|
||||
if (gameState == null) {
|
||||
return;
|
||||
}
|
||||
@@ -582,30 +552,6 @@ public final class AllZone {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -1557,7 +1557,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1;
|
||||
|
||||
if (hasVanish && AllZoneUtil.isCardInPlay(this)) {
|
||||
AllZone.getGameAction().sacrifice(this);
|
||||
Singletons.getModel().getGameAction().sacrifice(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
|
||||
AllZone.getPhaseHandler().setSkipPhase(false);
|
||||
if (c.getOwner().isHuman()) {
|
||||
AllZone.getGameAction().playCardNoCost(c);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(c);
|
||||
} else {
|
||||
final ArrayList<SpellAbility> choices = this.getBasicSpells();
|
||||
|
||||
@@ -3852,8 +3852,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
this.controllerObjects.add(controllerObject);
|
||||
if ((AllZone.getGameAction() != null) && (prevController != null)) {
|
||||
AllZone.getGameAction().controllerChangeZoneCorrection(this);
|
||||
if ((Singletons.getModel().getGameAction() != null) && (prevController != null)) {
|
||||
Singletons.getModel().getGameAction().controllerChangeZoneCorrection(this);
|
||||
}
|
||||
|
||||
if (prevController != null) {
|
||||
@@ -3878,7 +3878,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
this.controllerObjects.remove(controllerObject);
|
||||
|
||||
if (!currentController.equals(this.getController())) {
|
||||
AllZone.getGameAction().controllerChangeZoneCorrection(this);
|
||||
Singletons.getModel().getGameAction().controllerChangeZoneCorrection(this);
|
||||
|
||||
for (final Command c : this.changeControllerCommandList) {
|
||||
c.execute();
|
||||
@@ -6276,7 +6276,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// Suppressed Exiling is as close as we can get to
|
||||
// "ceasing to exist"
|
||||
AllZone.getTriggerHandler().suppressMode("ChangesZone");
|
||||
AllZone.getGameAction().exile(this);
|
||||
Singletons.getModel().getGameAction().exile(this);
|
||||
AllZone.getTriggerHandler().clearSuppression("ChangesZone");
|
||||
}
|
||||
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
|
||||
// AllZone.getGameAction()...
|
||||
// Singletons.getModel().getGameAction()...
|
||||
/**
|
||||
* <p>
|
||||
* addReceivedDamageFromThisTurn.
|
||||
@@ -8203,7 +8203,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
this.addCounter(Counters.M1M1, damageToAdd);
|
||||
}
|
||||
if (source.hasKeyword("Deathtouch") && this.isCreature()) {
|
||||
AllZone.getGameAction().destroy(this);
|
||||
Singletons.getModel().getGameAction().destroy(this);
|
||||
} else if (AllZoneUtil.isCardInPlay(this) && !wither) {
|
||||
this.damage += damageToAdd;
|
||||
}
|
||||
|
||||
@@ -2495,7 +2495,7 @@ public class CombatUtil {
|
||||
enchantments.toArray());
|
||||
if (o != null) {
|
||||
final Card crd = (Card) o;
|
||||
AllZone.getGameAction().moveToPlay(crd);
|
||||
Singletons.getModel().getGameAction().moveToPlay(crd);
|
||||
|
||||
if (crd.isAura()) {
|
||||
Object obj = null;
|
||||
@@ -2535,7 +2535,7 @@ public class CombatUtil {
|
||||
});
|
||||
if (enchantments.size() > 0) {
|
||||
final Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, null, false);
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
c.getController().shuffle();
|
||||
}
|
||||
}
|
||||
@@ -2609,7 +2609,7 @@ public class CombatUtil {
|
||||
player.gainLife(top.getBaseDefense(), c);
|
||||
player.loseLife(top.getBaseAttack(), c);
|
||||
|
||||
AllZone.getGameAction().moveToHand(top);
|
||||
Singletons.getModel().getGameAction().moveToHand(top);
|
||||
}
|
||||
}
|
||||
} // Sapling of Colfenor
|
||||
|
||||
@@ -170,7 +170,7 @@ public class ComputerUtil {
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(AllZone.getGameAction().moveToStack(source));
|
||||
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
|
||||
}
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
@@ -333,7 +333,7 @@ public class ComputerUtil {
|
||||
final Card source = bestSA.getSourceCard();
|
||||
|
||||
if (bestSA.isSpell() && !source.isCopiedSpell()) {
|
||||
bestSA.setSourceCard(AllZone.getGameAction().moveToStack(source));
|
||||
bestSA.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
|
||||
}
|
||||
|
||||
final Cost cost = bestSA.getPayCosts();
|
||||
@@ -367,7 +367,7 @@ public class ComputerUtil {
|
||||
if (ComputerUtil.canPayCost(sa)) {
|
||||
final Card source = sa.getSourceCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(AllZone.getGameAction().moveToStack(source));
|
||||
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
|
||||
}
|
||||
|
||||
sa.setActivatingPlayer(AllZone.getComputerPlayer());
|
||||
@@ -391,7 +391,7 @@ public class ComputerUtil {
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(AllZone.getGameAction().moveToStack(source));
|
||||
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
|
||||
}
|
||||
|
||||
AllZone.getStack().add(sa);
|
||||
@@ -426,7 +426,7 @@ public class ComputerUtil {
|
||||
|
||||
final Card source = newSA.getSourceCard();
|
||||
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);
|
||||
@@ -449,7 +449,7 @@ public class ComputerUtil {
|
||||
if (ComputerUtil.canPayCost(sa)) {
|
||||
final Card source = sa.getSourceCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(AllZone.getGameAction().moveToStack(source));
|
||||
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
|
||||
}
|
||||
|
||||
sa.setActivatingPlayer(AllZone.getComputerPlayer());
|
||||
@@ -465,7 +465,7 @@ public class ComputerUtil {
|
||||
AbilityFactory.resolve(sa, false);
|
||||
|
||||
// destroys creatures if they have lethal damage, etc..
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
}
|
||||
} // play()
|
||||
|
||||
@@ -625,7 +625,7 @@ public class ComputerUtil {
|
||||
ManaCost cost = new ManaCost(mana);
|
||||
|
||||
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();
|
||||
@@ -1821,11 +1821,11 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
if (destroy) {
|
||||
if (!AllZone.getGameAction().destroy(c)) {
|
||||
if (!Singletons.getModel().getGameAction().destroy(c)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!AllZone.getGameAction().sacrifice(c)) {
|
||||
if (!Singletons.getModel().getGameAction().sacrifice(c)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
|
||||
@Override
|
||||
public void resolve() {
|
||||
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
|
||||
public void resolve() {
|
||||
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
|
||||
public void resolve() {
|
||||
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
|
||||
public void resolve() {
|
||||
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() {
|
||||
if (AllZoneUtil.isCardInPlay(vale)) {
|
||||
vale.addController(vale.getController().getOpponent());
|
||||
// AllZone.getGameAction().changeController(
|
||||
// Singletons.getModel().getGameAction().changeController(
|
||||
// new CardList(vale), vale.getController(),
|
||||
// vale.getController().getOpponent());
|
||||
|
||||
@@ -180,7 +180,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
|
||||
@Override
|
||||
public void resolve() {
|
||||
if (AllZoneUtil.isCardInPlay(source)) {
|
||||
AllZone.getGameAction().moveToHand(source);
|
||||
Singletons.getModel().getGameAction().moveToHand(source);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,17 +20,13 @@ package forge;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.abilityfactory.AbilityFactoryAttach;
|
||||
import forge.card.abilityfactory.AbilityFactoryCharm;
|
||||
import forge.card.cardfactory.CardFactoryInterface;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostMana;
|
||||
@@ -46,38 +42,21 @@ import forge.card.spellability.Target;
|
||||
import forge.card.spellability.TargetSelection;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.control.input.InputMulligan;
|
||||
import forge.control.input.InputPayManaCost;
|
||||
import forge.control.input.InputPayManaCostAbility;
|
||||
import forge.control.input.InputPayManaCostUtil;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameEndReason;
|
||||
import forge.game.GameSummary;
|
||||
import forge.game.GameType;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* GameAction class.
|
||||
* </p>
|
||||
* Methods for common actions performed during a game.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
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>
|
||||
* resetActivationsPerTurn.
|
||||
@@ -135,7 +114,7 @@ public class GameAction {
|
||||
|
||||
if (AllZone.getReplacementHandler().run(repParams)) {
|
||||
if (AllZone.getStack().isResolving(c) && !zone.is(Constant.Zone.Graveyard)) {
|
||||
return AllZone.getGameAction().moveToGraveyard(c);
|
||||
return Singletons.getModel().getGameAction().moveToGraveyard(c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -449,7 +428,7 @@ public class GameAction {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
AllZone.getGameAction().moveToHand(recoverable);
|
||||
Singletons.getModel().getGameAction().moveToHand(recoverable);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -458,14 +437,14 @@ public class GameAction {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
AllZone.getGameAction().exile(recoverable);
|
||||
Singletons.getModel().getGameAction().exile(recoverable);
|
||||
}
|
||||
};
|
||||
|
||||
final SpellAbility abRecover = new Ability(recoverable, recoverCost) {
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.getGameAction().moveToHand(recoverable);
|
||||
Singletons.getModel().getGameAction().moveToHand(recoverable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -490,7 +469,7 @@ public class GameAction {
|
||||
if (ComputerUtil.canPayCost(abRecover)) {
|
||||
ComputerUtil.playNoStack(abRecover);
|
||||
} 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);
|
||||
|
||||
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(),
|
||||
computer.getLossConditionSource());
|
||||
game.getPlayerRating(human.getName()).setLossReason(human.getLossState(), human.getLossConditionSource());
|
||||
AllZone.getMatchState().addGamePlayed(game);
|
||||
Singletons.getModel().getMatchState().addGamePlayed(game);
|
||||
}
|
||||
|
||||
return isGameDone;
|
||||
@@ -900,10 +879,8 @@ public class GameAction {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.canShowWinLose && this.checkEndGameState()) {
|
||||
if (this.checkEndGameState()) {
|
||||
new ViewWinLose();
|
||||
this.canShowWinLose = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// do this twice, sometimes creatures/permanents will survive when they
|
||||
@@ -1057,7 +1034,7 @@ public class GameAction {
|
||||
c = list.get(i);
|
||||
|
||||
if (c.getCounters(Counters.LOYALTY) <= 0) {
|
||||
AllZone.getGameAction().moveToGraveyard(c);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(c);
|
||||
}
|
||||
|
||||
final ArrayList<String> types = c.getType();
|
||||
@@ -1070,7 +1047,7 @@ public class GameAction {
|
||||
|
||||
if (cl.size() > 1) {
|
||||
for (final Card crd : cl) {
|
||||
AllZone.getGameAction().moveToGraveyard(crd);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(crd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1097,7 +1074,7 @@ public class GameAction {
|
||||
a.remove(0);
|
||||
if (1 < b.size()) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*   {@link forge.deck.Deck} object.
|
||||
* @param computerDeck
|
||||
*   {@link forge.deck.Deck} object.
|
||||
* @param human
|
||||
*   {@link forge.CardList} object.
|
||||
* @param computer
|
||||
*   {@link forge.CardList} object.
|
||||
* @param humanLife
|
||||
*   int.
|
||||
* @param computerLife
|
||||
*   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;
|
||||
|
||||
/**
|
||||
* The default constructor for a new game.
|
||||
*
|
||||
* @param humanDeck
|
||||
*   {@link forge.deck.Deck} object.
|
||||
* @param computerDeck
|
||||
*   {@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
|
||||
// local enchantments are always attached to something
|
||||
@@ -1992,7 +1494,7 @@ public class GameAction {
|
||||
if (sa.isSpell()) {
|
||||
final Card c = sa.getSourceCard();
|
||||
if (!c.isCopiedSpell()) {
|
||||
sa.setSourceCard(AllZone.getGameAction().moveToStack(c));
|
||||
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(c));
|
||||
}
|
||||
}
|
||||
boolean x = false;
|
||||
@@ -2739,7 +2241,7 @@ public class GameAction {
|
||||
if (sa.getAfterPayMana() == null) {
|
||||
final Card source = sa.getSourceCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(AllZone.getGameAction().moveToStack(source));
|
||||
sa.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source));
|
||||
}
|
||||
|
||||
AllZone.getStack().add(sa);
|
||||
@@ -2885,6 +2387,9 @@ public class GameAction {
|
||||
return this.startCut;
|
||||
}
|
||||
|
||||
private Card humanCut = null;
|
||||
private Card computerCut = null;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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
|
||||
* the costCuttingGetMultiMickerManaCostPaidColored to set
|
||||
|
||||
@@ -152,7 +152,7 @@ public final class GameActionUtil {
|
||||
title.toString(), JOptionPane.YES_NO_OPTION);
|
||||
|
||||
if (answer == JOptionPane.YES_OPTION) {
|
||||
AllZone.getGameAction().playCardNoCost(cascadedCard);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(cascadedCard);
|
||||
revealed.remove(cascadedCard);
|
||||
}
|
||||
} else {
|
||||
@@ -178,7 +178,7 @@ public final class GameActionUtil {
|
||||
}
|
||||
revealed.shuffle();
|
||||
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,
|
||||
possibleValues, possibleValues[0]);
|
||||
if (q.equals(0)) {
|
||||
AllZone.getGameAction().playCardNoCost(rippledCards[i]);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(rippledCards[i]);
|
||||
revealed.remove(rippledCards[i]);
|
||||
}
|
||||
} else {
|
||||
@@ -306,7 +306,7 @@ public final class GameActionUtil {
|
||||
}
|
||||
revealed.shuffle();
|
||||
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") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.getGameAction().destroy(affected);
|
||||
Singletons.getModel().getGameAction().destroy(affected);
|
||||
}
|
||||
};
|
||||
|
||||
final Ability ability2 = new Ability(source, "0") {
|
||||
@Override
|
||||
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) {
|
||||
final SpellAbility[] sa = c.getSpellAbility();
|
||||
if (c.getController().isHuman()) {
|
||||
AllZone.getGameAction().playSpellAbility(sa[1]);
|
||||
Singletons.getModel().getGameAction().playSpellAbility(sa[1]);
|
||||
} else {
|
||||
ComputerUtil.playNoStack(sa[1]);
|
||||
}
|
||||
@@ -1001,7 +1001,7 @@ public final class GameActionUtil {
|
||||
|
||||
for (int j = 0; j < max; j++) {
|
||||
final Card c = libList.get(j);
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
}
|
||||
}; // ability
|
||||
|
||||
@@ -1353,13 +1353,13 @@ public final class GuiDisplayUtil {
|
||||
AllZone.getCombat().reset();
|
||||
for (final Card c : humanDevSetup) {
|
||||
AllZone.getHumanPlayer().getZone(Zone.Hand).add(c);
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
c.setSickness(false);
|
||||
}
|
||||
|
||||
for (final Card c : computerDevSetup) {
|
||||
AllZone.getComputerPlayer().getZone(Zone.Hand).add(c);
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
c.setSickness(false);
|
||||
}
|
||||
|
||||
@@ -1400,7 +1400,7 @@ public final class GuiDisplayUtil {
|
||||
AllZone.getHumanPlayer().setLife(setHumanLife, null);
|
||||
}
|
||||
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
AllZone.getPhaseHandler().updateObservers();
|
||||
AllZone.getHumanPlayer().getZone(Zone.Exile).updateObservers();
|
||||
AllZone.getComputerPlayer().getZone(Zone.Exile).updateObservers();
|
||||
@@ -1475,7 +1475,7 @@ public final class GuiDisplayUtil {
|
||||
return;
|
||||
} else {
|
||||
final Card c = (Card) o;
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,11 +143,11 @@ public class HumanPlayer extends Player {
|
||||
|
||||
// might have to make this more sophisticated
|
||||
// dredge library, put card in hand
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
|
||||
for (int i = 0; i < this.getDredgeNumber(c); i++) {
|
||||
final Card c2 = AllZone.getHumanPlayer().getZone(Zone.Library).get(0);
|
||||
AllZone.getGameAction().moveToGraveyard(c2);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(c2);
|
||||
}
|
||||
dredged = true;
|
||||
} else {
|
||||
@@ -214,7 +214,7 @@ public class HumanPlayer extends Player {
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
topN.remove(c);
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
|
||||
} else {
|
||||
// no card chosen for the bottom
|
||||
break;
|
||||
@@ -227,7 +227,7 @@ public class HumanPlayer extends Player {
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
topN.remove(c);
|
||||
AllZone.getGameAction().moveToLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c);
|
||||
}
|
||||
// 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);
|
||||
|
||||
if (choice.equals("bottom")) {
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
|
||||
} else {
|
||||
AllZone.getGameAction().moveToLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class MagicStack extends MyObservable {
|
||||
if (ability.isSpell()) {
|
||||
final Card source = ability.getSourceCard();
|
||||
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);
|
||||
}
|
||||
if (checkState) {
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public class MagicStack extends MyObservable {
|
||||
ManaCost manaCost = new ManaCost(sa.getManaCost());
|
||||
String mana = manaCost.toString();
|
||||
|
||||
int multiKickerPaid = AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaid();
|
||||
int multiKickerPaid = Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid();
|
||||
|
||||
String numberManaCost = " ";
|
||||
|
||||
@@ -313,12 +313,12 @@ public class MagicStack extends MyObservable {
|
||||
|
||||
if ((check - multiKickerPaid) < 0) {
|
||||
multiKickerPaid = multiKickerPaid - check;
|
||||
AllZone.getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid);
|
||||
Singletons.getModel().getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid);
|
||||
mana = mana.replaceFirst(String.valueOf(check), "0");
|
||||
} else {
|
||||
mana = mana.replaceFirst(String.valueOf(check), String.valueOf(check - multiKickerPaid));
|
||||
multiKickerPaid = 0;
|
||||
AllZone.getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid);
|
||||
Singletons.getModel().getGameAction().setCostCuttingGetMultiMickerManaCostPaid(multiKickerPaid);
|
||||
}
|
||||
}
|
||||
mana = mana.trim();
|
||||
@@ -327,15 +327,15 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
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++) {
|
||||
if ("WUGRB".contains(colorCut.substring(colorCutIx, colorCutIx + 1))
|
||||
&& !mana.equals(mana.replaceFirst((colorCut.substring(colorCutIx, colorCutIx + 1)), ""))) {
|
||||
mana = mana.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), "");
|
||||
|
||||
AllZone.getGameAction().setCostCuttingGetMultiMickerManaCostPaidColored(
|
||||
AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored()
|
||||
Singletons.getModel().getGameAction().setCostCuttingGetMultiMickerManaCostPaidColored(
|
||||
Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored()
|
||||
.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""));
|
||||
|
||||
mana = mana.trim();
|
||||
@@ -537,8 +537,8 @@ public class MagicStack extends MyObservable {
|
||||
if (manaCost.isPaid()) {
|
||||
this.execute();
|
||||
} else {
|
||||
if ((AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0)
|
||||
&& AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored()
|
||||
if ((Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0)
|
||||
&& Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored()
|
||||
.equals("")) {
|
||||
|
||||
AllZone.getInputControl().setInput(
|
||||
@@ -553,13 +553,12 @@ public class MagicStack extends MyObservable {
|
||||
+ sa.getSourceCard()
|
||||
+ "\r\n"
|
||||
+ "Mana in Reserve: "
|
||||
+ ((AllZone.getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaid() != 0) ? AllZone
|
||||
.getGameAction()
|
||||
+ ((Singletons.getModel().getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaid() != 0) ?
|
||||
Singletons.getModel().getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaid()
|
||||
: "")
|
||||
+ AllZone
|
||||
.getGameAction()
|
||||
+ Singletons.getModel().getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaidColored()
|
||||
+ "\r\n" + "Times Kicked: "
|
||||
+ sa.getSourceCard().getMultiKickerMagnitude() + "\r\n",
|
||||
@@ -575,8 +574,8 @@ public class MagicStack extends MyObservable {
|
||||
if (manaCost.isPaid()) {
|
||||
paidCommand.execute();
|
||||
} else {
|
||||
if ((AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0)
|
||||
&& AllZone.getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored().equals("")) {
|
||||
if ((Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid() == 0)
|
||||
&& Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaidColored().equals("")) {
|
||||
AllZone.getInputControl().setInput(
|
||||
new InputPayManaCostAbility("Multikicker for " + sa.getSourceCard() + "\r\n"
|
||||
+ "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n",
|
||||
@@ -588,11 +587,11 @@ public class MagicStack extends MyObservable {
|
||||
+ sa.getSourceCard()
|
||||
+ "\r\n"
|
||||
+ "Mana in Reserve: "
|
||||
+ ((AllZone.getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaid() != 0) ? AllZone
|
||||
.getGameAction().getCostCuttingGetMultiMickerManaCostPaid()
|
||||
+ ((Singletons.getModel().getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaid() != 0) ?
|
||||
Singletons.getModel().getGameAction().getCostCuttingGetMultiMickerManaCostPaid()
|
||||
: "")
|
||||
+ AllZone.getGameAction()
|
||||
+ Singletons.getModel().getGameAction()
|
||||
.getCostCuttingGetMultiMickerManaCostPaidColored() + "\r\n"
|
||||
+ "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude()
|
||||
+ "\r\n", manaCost.toString(), paidCommand, unpaidCommand));
|
||||
@@ -753,14 +752,14 @@ public class MagicStack extends MyObservable {
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getStack().pop();
|
||||
AllZone.getGameAction().moveToGraveyard(sp.getSourceCard());
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(sp.getSourceCard());
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() && c.isLand()) {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
@@ -775,7 +774,7 @@ public class MagicStack extends MyObservable {
|
||||
AllZone.getComputerPlayer().sacrificePermanent("prompt", lands);
|
||||
} else {
|
||||
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") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.getGameAction().exile(source);
|
||||
Singletons.getModel().getGameAction().exile(source);
|
||||
this.getTargetCard().addHauntedBy(source);
|
||||
}
|
||||
};
|
||||
@@ -992,9 +991,9 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
// Handle cards that need to be moved differently
|
||||
else if (sa.isBuyBackAbility() && !fizzle) {
|
||||
AllZone.getGameAction().moveToHand(source);
|
||||
Singletons.getModel().getGameAction().moveToHand(source);
|
||||
} else if (sa.isFlashBackAbility()) {
|
||||
AllZone.getGameAction().exile(source);
|
||||
Singletons.getModel().getGameAction().exile(source);
|
||||
sa.setFlashBackAbility(false);
|
||||
} else if (source.hasKeyword("Rebound")
|
||||
&& source.getCastFrom() == Zone.Hand
|
||||
@@ -1003,7 +1002,7 @@ public class MagicStack extends MyObservable {
|
||||
{
|
||||
|
||||
//Move rebounding card to exile
|
||||
AllZone.getGameAction().exile(source);
|
||||
Singletons.getModel().getGameAction().exile(source);
|
||||
System.out.println("rebound1: " + source);
|
||||
|
||||
//Setup a Rebound-trigger
|
||||
@@ -1041,7 +1040,7 @@ public class MagicStack extends MyObservable {
|
||||
return;
|
||||
}
|
||||
if (source.getOwner().isHuman()) {
|
||||
AllZone.getGameAction().playCardNoCost(source);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(source);
|
||||
} else {
|
||||
System.out.println("rebound: " + source);
|
||||
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
|
||||
else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle)
|
||||
&& 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();
|
||||
sa.resetOnceResolved();
|
||||
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
|
||||
AllZone.getPhaseHandler().setNeedToNextPhase(false);
|
||||
|
||||
@@ -1391,18 +1390,18 @@ public class MagicStack extends MyObservable {
|
||||
activePlayerSAs.remove(next);
|
||||
|
||||
if (next.isTrigger()) {
|
||||
AllZone.getGameAction().playSpellAbility(next);
|
||||
Singletons.getModel().getGameAction().playSpellAbility(next);
|
||||
} else {
|
||||
this.add(next);
|
||||
}
|
||||
}
|
||||
|
||||
if (activePlayerSAs.get(0).isTrigger()) {
|
||||
AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0));
|
||||
Singletons.getModel().getGameAction().playSpellAbility(activePlayerSAs.get(0));
|
||||
} else {
|
||||
this.add(activePlayerSAs.get(0));
|
||||
}
|
||||
// AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0));
|
||||
// Singletons.getModel().getGameAction().playSpellAbility(activePlayerSAs.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
final String phase = AllZone.getPhaseHandler().getPhase();
|
||||
final Player turn = AllZone.getPhaseHandler().getPlayerTurn();
|
||||
AllZone.getPhaseHandler().setSkipPhase(true);
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
|
||||
// UNTAP
|
||||
if (phase.equals(Constant.Phase.UNTAP)) {
|
||||
@@ -383,7 +383,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
Combat.dealAssignedDamage();
|
||||
}
|
||||
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
CombatUtil.showCombat();
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
Combat.dealAssignedDamage();
|
||||
}
|
||||
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
CombatUtil.showCombat();
|
||||
}
|
||||
}
|
||||
@@ -579,6 +579,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
// When consecutively skipping phases (like in combat) this section
|
||||
// pushes through that block
|
||||
this.updateObservers();
|
||||
|
||||
if ((AllZone.getPhaseHandler() != null) && AllZone.getPhaseHandler().isNeedToNextPhase()) {
|
||||
AllZone.getPhaseHandler().setNeedToNextPhase(false);
|
||||
AllZone.getPhaseHandler().nextPhase();
|
||||
|
||||
@@ -86,7 +86,7 @@ public class PhaseUtil {
|
||||
}
|
||||
turn.incrementTurn();
|
||||
|
||||
AllZone.getGameAction().resetActivationsPerTurn();
|
||||
Singletons.getModel().getGameAction().resetActivationsPerTurn();
|
||||
|
||||
final CardList lands = AllZoneUtil.getPlayerLandsInPlay(turn).filter(CardListFilter.UNTAPPED);
|
||||
turn.setNumPowerSurgeLands(lands.size());
|
||||
|
||||
@@ -760,7 +760,7 @@ public abstract class Player extends GameEntity {
|
||||
for (int i = 0; i < damage; i++) {
|
||||
final CardList lib = this.getCardsIn(Zone.Library);
|
||||
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
|
||||
@@ -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) {
|
||||
|
||||
Card c = library.get(0);
|
||||
c = AllZone.getGameAction().moveToHand(c);
|
||||
c = Singletons.getModel().getGameAction().moveToHand(c);
|
||||
drawn.add(c);
|
||||
|
||||
if ((this.numDrawnThisTurn == 0) && this.isComputer()) {
|
||||
@@ -1291,7 +1291,7 @@ public abstract class Player extends GameEntity {
|
||||
// Condition
|
||||
if (!this.cantLose()) {
|
||||
this.loseConditionMet(GameLossReason.Milled, null);
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
AllZone.getGameAction().discardMadness(c);
|
||||
Singletons.getModel().getGameAction().discardMadness(c);
|
||||
|
||||
if ((c.hasKeyword("If a spell or ability an opponent controls causes "
|
||||
+ "you to discard CARDNAME, put it onto the battlefield instead of putting it into your graveyard.") || c
|
||||
@@ -1535,9 +1535,9 @@ public abstract class Player extends GameEntity {
|
||||
+ "you to discard CARDNAME, put it onto the battlefield with two +1/+1 "
|
||||
+ "counters on it instead of putting it into your graveyard."))
|
||||
&& (null != sa) && !c.getController().equals(sa.getSourceCard().getController())) {
|
||||
AllZone.getGameAction().discardPutIntoPlayInstead(c);
|
||||
Singletons.getModel().getGameAction().discardPutIntoPlayInstead(c);
|
||||
} else {
|
||||
AllZone.getGameAction().moveToGraveyard(c);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(c);
|
||||
}
|
||||
|
||||
// Run triggers
|
||||
@@ -1673,9 +1673,9 @@ public abstract class Player extends GameEntity {
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
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 {
|
||||
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) {
|
||||
if (this.canPlayLand()) {
|
||||
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);
|
||||
this.numLandsPlayed++;
|
||||
|
||||
// check state effects for static animate (Living Lands, Conversion,
|
||||
// etc...)
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
|
||||
// add to log
|
||||
AllZone.getGameLog().add("Land", this + " played " + land, 2);
|
||||
|
||||
@@ -288,7 +288,7 @@ public final class PlayerUtil {
|
||||
@Override
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (zone.equals(AllZone.getHumanPlayer().getZone(Zone.Battlefield)) && list.contains(card)) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.n++;
|
||||
list.remove(card);
|
||||
|
||||
@@ -345,7 +345,7 @@ public final class PlayerUtil {
|
||||
position = -1;
|
||||
}
|
||||
|
||||
AllZone.getGameAction().moveToLibrary(card, position);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(card, position);
|
||||
|
||||
this.n++;
|
||||
if (this.n == num) {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Untap extends Phase implements java.io.Serializable {
|
||||
|
||||
for (final Card c : list) {
|
||||
if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) {
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
} else if (GameActionUtil.showYesNoDialog(c, sb.toString())) {
|
||||
abMana.produceMana();
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
@Override
|
||||
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)) {
|
||||
ComputerUtil.playNoStack(aiPaid);
|
||||
} 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")) {
|
||||
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")) {
|
||||
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
|
||||
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)) {
|
||||
ComputerUtil.playNoStack(aiPaid);
|
||||
} 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
|
||||
// also
|
||||
if (targets.contains(selected)) {
|
||||
AllZone.getGameAction().destroyNoRegeneration(selected);
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(selected);
|
||||
this.stop();
|
||||
}
|
||||
} // selectCard()
|
||||
@@ -509,13 +509,13 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
final CardList indestruct = targets.getKeyword("Indestructible");
|
||||
if (indestruct.size() > 0) {
|
||||
AllZone.getGameAction().destroyNoRegeneration(indestruct.get(0));
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(indestruct.get(0));
|
||||
} else if (targets.size() > 0) {
|
||||
final Card target = CardFactoryUtil.getWorstCreatureAI(targets);
|
||||
if (null == target) {
|
||||
// must be nothing valid to destroy
|
||||
} 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
|
||||
if (artifact.isArtifact() && zone.is(Constant.Zone.Battlefield)
|
||||
&& zone.getPlayer().isHuman()) {
|
||||
AllZone.getGameAction().sacrifice(artifact);
|
||||
Singletons.getModel().getGameAction().sacrifice(artifact);
|
||||
this.stop();
|
||||
}
|
||||
} // selectCard()
|
||||
@@ -586,7 +586,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
if (null == target) {
|
||||
this.tapAndDamage(player);
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(target);
|
||||
Singletons.getModel().getGameAction().sacrifice(target);
|
||||
}
|
||||
}
|
||||
} // resolve
|
||||
@@ -635,7 +635,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
* PlayerUtil.inputSacrificePermanent(creatures, c.getName() +
|
||||
* " - Select a creature to sacrifice.")); } else { // computer final Card
|
||||
* target = CardFactoryUtil.getWorstCreatureAI(creatures);
|
||||
* AllZone.getGameAction().sacrifice(target); } } // resolve };
|
||||
* Singletons.getModel().getGameAction().sacrifice(target); } } // resolve };
|
||||
*
|
||||
* 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."));
|
||||
} else { // computer
|
||||
final Card compyTarget = this.getCompyCardToDestroy(creatures);
|
||||
AllZone.getGameAction().destroyNoRegeneration(compyTarget);
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(compyTarget);
|
||||
}
|
||||
}
|
||||
} // resolve
|
||||
@@ -770,7 +770,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
} else {
|
||||
final Card target = CardFactoryUtil.getBestLandAI(playerLand);
|
||||
|
||||
AllZone.getGameAction().sacrifice(target);
|
||||
Singletons.getModel().getGameAction().sacrifice(target);
|
||||
}
|
||||
} // end resolve()
|
||||
}; // end noPay ability
|
||||
@@ -1083,7 +1083,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
if (wantToPlayCard) {
|
||||
if (player.isHuman()) {
|
||||
final Card c = library.get(0);
|
||||
AllZone.getGameAction().playCardNoCost(c);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(c);
|
||||
}
|
||||
// player isComputer()
|
||||
else {
|
||||
@@ -2029,7 +2029,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
public void resolve() {
|
||||
final int fadeCounters = card.getCounters(Counters.FADE);
|
||||
if (fadeCounters <= 0) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
} else {
|
||||
card.subtractCounter(Counters.FADE, 1);
|
||||
}
|
||||
@@ -2100,10 +2100,10 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
final Card c = libraryList.get(i);
|
||||
cardsToReveal.add(c);
|
||||
if (c.isCreature()) {
|
||||
AllZone.getGameAction().moveTo(battlefield, c);
|
||||
Singletons.getModel().getGameAction().moveTo(battlefield, c);
|
||||
break;
|
||||
} else {
|
||||
AllZone.getGameAction().moveToGraveyard(c);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(c);
|
||||
}
|
||||
} // for loop
|
||||
if (cardsToReveal.size() > 0) {
|
||||
@@ -2155,12 +2155,12 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
if (o != null) {
|
||||
final Card card = (Card) o;
|
||||
|
||||
AllZone.getGameAction().moveToHand(card);
|
||||
Singletons.getModel().getGameAction().moveToHand(card);
|
||||
}
|
||||
} else if (player.isComputer()) {
|
||||
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
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(crd);
|
||||
Singletons.getModel().getGameAction().sacrifice(crd);
|
||||
this.stop();
|
||||
}
|
||||
}; // Input
|
||||
@@ -2466,7 +2466,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
public void resolve() {
|
||||
if (crd.getController().isHuman()) {
|
||||
if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) {
|
||||
AllZone.getGameAction().sacrifice(crd);
|
||||
Singletons.getModel().getGameAction().sacrifice(crd);
|
||||
} else {
|
||||
AllZone.getInputControl().setInput(discard);
|
||||
}
|
||||
@@ -2476,7 +2476,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
if (list.size() != 0) {
|
||||
list.get(0).getController().discard(list.get(0), this);
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(crd);
|
||||
Singletons.getModel().getGameAction().sacrifice(crd);
|
||||
}
|
||||
} // else
|
||||
} // resolve()
|
||||
@@ -2511,7 +2511,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
final CardList creats = AllZoneUtil.getCreaturesInPlay(player);
|
||||
|
||||
if (creats.size() < 1) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2522,10 +2522,10 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
creats.shuffle();
|
||||
sac = creats.get(0);
|
||||
}
|
||||
AllZone.getGameAction().sacrifice(sac);
|
||||
Singletons.getModel().getGameAction().sacrifice(sac);
|
||||
} else { // computer
|
||||
CardListUtil.sortAttackLowFirst(creats);
|
||||
AllZone.getGameAction().sacrifice(creats.get(0));
|
||||
Singletons.getModel().getGameAction().sacrifice(creats.get(0));
|
||||
}
|
||||
}
|
||||
}; // ability
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameEntity;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -91,7 +92,7 @@ public class AbilityFactoryAttach {
|
||||
public void resolve() {
|
||||
// The Spell_Permanent (Auras) version of this AF needs to
|
||||
// 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);
|
||||
AbilityFactoryAttach.attachResolve(this.af, this);
|
||||
}
|
||||
|
||||
@@ -32,11 +32,12 @@ import forge.CardUtil;
|
||||
import forge.CombatUtil;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.GameEntity;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.GameEntity;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostUtil;
|
||||
@@ -887,7 +888,7 @@ public final class AbilityFactoryChangeZone {
|
||||
if (origin.contains(Zone.Library) && (i < 1)) {
|
||||
player.shuffle();
|
||||
}
|
||||
movedCard = AllZone.getGameAction().moveToLibrary(c, libraryPos);
|
||||
movedCard = Singletons.getModel().getGameAction().moveToLibrary(c, libraryPos);
|
||||
} else if (destination.equals(Zone.Battlefield)) {
|
||||
if (params.containsKey("Tapped")) {
|
||||
c.setTapped(true);
|
||||
@@ -916,14 +917,14 @@ public final class AbilityFactoryChangeZone {
|
||||
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)) {
|
||||
movedCard = AllZone.getGameAction().exile(c);
|
||||
movedCard = Singletons.getModel().getGameAction().exile(c);
|
||||
if (params.containsKey("ExileFaceDown")) {
|
||||
movedCard.setState("FaceDown");
|
||||
}
|
||||
} else {
|
||||
movedCard = AllZone.getGameAction().moveTo(destZone, c);
|
||||
movedCard = Singletons.getModel().getGameAction().moveTo(destZone, c);
|
||||
}
|
||||
|
||||
if (remember != null) {
|
||||
@@ -1071,7 +1072,7 @@ public final class AbilityFactoryChangeZone {
|
||||
if (Zone.Library.equals(destination)) {
|
||||
final int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params
|
||||
.get("LibraryPosition")) : 0;
|
||||
AllZone.getGameAction().moveToLibrary(c, libraryPos);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c, libraryPos);
|
||||
} else if (Zone.Battlefield.equals(destination)) {
|
||||
if (params.containsKey("Tapped")) {
|
||||
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)) {
|
||||
newCard = AllZone.getGameAction().exile(c);
|
||||
newCard = Singletons.getModel().getGameAction().exile(c);
|
||||
if (params.containsKey("ExileFaceDown")) {
|
||||
newCard.setState("FaceDown");
|
||||
}
|
||||
} else {
|
||||
newCard = AllZone.getGameAction().moveTo(destZone, c);
|
||||
newCard = Singletons.getModel().getGameAction().moveTo(destZone, c);
|
||||
}
|
||||
|
||||
if (remember != null) {
|
||||
@@ -1885,7 +1886,7 @@ public final class AbilityFactoryChangeZone {
|
||||
final int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params
|
||||
.get("LibraryPosition")) : 0;
|
||||
|
||||
movedCard = AllZone.getGameAction().moveToLibrary(tgtC, libraryPosition);
|
||||
movedCard = Singletons.getModel().getGameAction().moveToLibrary(tgtC, libraryPosition);
|
||||
|
||||
// for things like Gaea's Blessing
|
||||
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")) {
|
||||
AllZone.getCombat().addAttacker(tgtC);
|
||||
AllZone.getCombat().addUnblockedAttacker(tgtC);
|
||||
}
|
||||
} else {
|
||||
movedCard = AllZone.getGameAction().moveTo(pl.getZone(destination), tgtC);
|
||||
movedCard = Singletons.getModel().getGameAction().moveTo(pl.getZone(destination), tgtC);
|
||||
if (params.containsKey("ExileFaceDown")) {
|
||||
movedCard.setState("FaceDown");
|
||||
}
|
||||
@@ -2349,9 +2350,9 @@ public final class AbilityFactoryChangeZone {
|
||||
|
||||
if (params.containsKey("GainControl")) {
|
||||
c.addController(af.getHostCard());
|
||||
AllZone.getGameAction().moveToPlay(c, sa.getActivatingPlayer());
|
||||
Singletons.getModel().getGameAction().moveToPlay(c, sa.getActivatingPlayer());
|
||||
} else {
|
||||
final Card movedCard = AllZone.getGameAction().moveTo(destination, c, libraryPos);
|
||||
final Card movedCard = Singletons.getModel().getGameAction().moveTo(destination, c, libraryPos);
|
||||
if (params.containsKey("ExileFaceDown")) {
|
||||
movedCard.setState("FaceDown");
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -431,7 +432,7 @@ public final class AbilityFactoryCopy {
|
||||
if (c.isFaceDown()) {
|
||||
c.setState("FaceDown");
|
||||
}
|
||||
copy = AllZone.getGameAction().moveToPlay(copy);
|
||||
copy = Singletons.getModel().getGameAction().moveToPlay(copy);
|
||||
|
||||
copy.setCloneOrigin(hostCard);
|
||||
sa.getSourceCard().addClone(copy);
|
||||
@@ -456,9 +457,9 @@ public final class AbilityFactoryCopy {
|
||||
if (params.get("AtEOT").equals("Sacrifice")) {
|
||||
// maybe do a setSacrificeAtEOT, but
|
||||
// probably not.
|
||||
AllZone.getGameAction().sacrifice(target[index]);
|
||||
Singletons.getModel().getGameAction().sacrifice(target[index]);
|
||||
} else if (params.get("AtEOT").equals("Exile")) {
|
||||
AllZone.getGameAction().exile(target[index]);
|
||||
Singletons.getModel().getGameAction().exile(target[index]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostUtil;
|
||||
@@ -418,7 +419,7 @@ public class AbilityFactoryCounterMagic {
|
||||
|
||||
// Destroy Permanent may be able to be turned into a SubAbility
|
||||
if (tgtSA.isAbility() && this.params.containsKey("DestroyPermanent")) {
|
||||
AllZone.getGameAction().destroy(tgtSACard);
|
||||
Singletons.getModel().getGameAction().destroy(tgtSACard);
|
||||
}
|
||||
|
||||
if (this.params.containsKey("RememberTargets")) {
|
||||
@@ -505,17 +506,17 @@ public class AbilityFactoryCounterMagic {
|
||||
// For Ability-targeted counterspells - do not move it anywhere,
|
||||
// even if Destination$ is specified.
|
||||
} else if (this.destination.equals("Graveyard")) {
|
||||
AllZone.getGameAction().moveToGraveyard(tgtSA.getSourceCard());
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(tgtSA.getSourceCard());
|
||||
} else if (this.destination.equals("Exile")) {
|
||||
AllZone.getGameAction().exile(tgtSA.getSourceCard());
|
||||
Singletons.getModel().getGameAction().exile(tgtSA.getSourceCard());
|
||||
} else if (this.destination.equals("TopOfLibrary")) {
|
||||
AllZone.getGameAction().moveToLibrary(tgtSA.getSourceCard());
|
||||
Singletons.getModel().getGameAction().moveToLibrary(tgtSA.getSourceCard());
|
||||
} else if (this.destination.equals("Hand")) {
|
||||
AllZone.getGameAction().moveToHand(tgtSA.getSourceCard());
|
||||
Singletons.getModel().getGameAction().moveToHand(tgtSA.getSourceCard());
|
||||
} else if (this.destination.equals("BottomOfLibrary")) {
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
} else if (this.destination.equals("ShuffleIntoLibrary")) {
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(tgtSA.getSourceCard());
|
||||
tgtSA.getSourceCard().getController().shuffle();
|
||||
} else {
|
||||
throw new IllegalArgumentException("AbilityFactory_CounterMagic: Invalid Destination argument for card "
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.CardUtil;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostUtil;
|
||||
@@ -542,11 +543,11 @@ public class AbilityFactoryDestroy {
|
||||
for (final Card tgtC : tgtCards) {
|
||||
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
|
||||
if (sac) {
|
||||
AllZone.getGameAction().sacrifice(tgtC);
|
||||
Singletons.getModel().getGameAction().sacrifice(tgtC);
|
||||
} else if (noRegen) {
|
||||
AllZone.getGameAction().destroyNoRegeneration(tgtC);
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(tgtC);
|
||||
} else {
|
||||
AllZone.getGameAction().destroy(tgtC);
|
||||
Singletons.getModel().getGameAction().destroy(tgtC);
|
||||
} if (remDestroyed) {
|
||||
card.addRemembered(tgtC);
|
||||
}
|
||||
@@ -556,11 +557,11 @@ public class AbilityFactoryDestroy {
|
||||
for (final Card unTgtC : untargetedCards) {
|
||||
if (AllZoneUtil.isCardInPlay(unTgtC)) {
|
||||
if (sac) {
|
||||
AllZone.getGameAction().sacrifice(unTgtC);
|
||||
Singletons.getModel().getGameAction().sacrifice(unTgtC);
|
||||
} else if (noRegen) {
|
||||
AllZone.getGameAction().destroyNoRegeneration(unTgtC);
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(unTgtC);
|
||||
} else {
|
||||
AllZone.getGameAction().destroy(unTgtC);
|
||||
Singletons.getModel().getGameAction().destroy(unTgtC);
|
||||
} if (remDestroyed) {
|
||||
card.addRemembered(unTgtC);
|
||||
}
|
||||
@@ -896,13 +897,13 @@ public class AbilityFactoryDestroy {
|
||||
|
||||
if (noRegen) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PhaseHandler;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.Spell;
|
||||
@@ -470,7 +471,7 @@ public class AbilityFactoryEffect {
|
||||
|
||||
@Override
|
||||
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
|
||||
AllZone.getTriggerHandler().suppressMode("ChangesZone");
|
||||
AllZone.getGameAction().moveToPlay(eff);
|
||||
Singletons.getModel().getGameAction().moveToPlay(eff);
|
||||
AllZone.getTriggerHandler().clearSuppression("ChangesZone");
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameEntity;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -429,7 +430,7 @@ public class AbilityFactoryGainControl {
|
||||
if (AllZoneUtil.isCardInPlay(tgtC) && tgtC.canBeTargetedBy(sa)) {
|
||||
|
||||
tgtC.addController(newController);
|
||||
// AllZone.getGameAction().changeController(new CardList(tgtC),
|
||||
// Singletons.getModel().getGameAction().changeController(new CardList(tgtC),
|
||||
// tgtC.getController(), newController.get(0));
|
||||
|
||||
if (this.bUntap) {
|
||||
@@ -547,9 +548,9 @@ public class AbilityFactoryGainControl {
|
||||
public void resolve() {
|
||||
|
||||
if (AbilityFactoryGainControl.this.bNoRegen) {
|
||||
AllZone.getGameAction().destroyNoRegeneration(c);
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(c);
|
||||
} else {
|
||||
AllZone.getGameAction().destroy(c);
|
||||
Singletons.getModel().getGameAction().destroy(c);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -601,7 +602,7 @@ public class AbilityFactoryGainControl {
|
||||
}
|
||||
if (AllZoneUtil.isCardInPlay(c)) {
|
||||
c.removeController(host);
|
||||
// AllZone.getGameAction().changeController(new CardList(c),
|
||||
// Singletons.getModel().getGameAction().changeController(new CardList(c),
|
||||
// c.getController(), originalController);
|
||||
|
||||
if (tapOnLose) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Counters;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -368,7 +369,7 @@ public class AbilityFactoryMana {
|
||||
final int num = card.getCounters(Counters.getType(deplete));
|
||||
if (num == 0) {
|
||||
abMana.setUndoable(false);
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@ import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostMana;
|
||||
@@ -432,7 +433,7 @@ public final class AbilityFactoryPlay {
|
||||
newSA.setPayCosts(cost);
|
||||
newSA.setManaCost("");
|
||||
newSA.setDescription(sa.getDescription() + " (without paying its mana cost)");
|
||||
AllZone.getGameAction().playSpellAbility(newSA);
|
||||
Singletons.getModel().getGameAction().playSpellAbility(newSA);
|
||||
} else {
|
||||
if (tgtSA instanceof Spell) {
|
||||
Spell spell = (Spell) tgtSA;
|
||||
@@ -444,7 +445,7 @@ public final class AbilityFactoryPlay {
|
||||
}
|
||||
} else {
|
||||
if (controller.isHuman()) {
|
||||
AllZone.getGameAction().playSpellAbility(tgtSA);
|
||||
Singletons.getModel().getGameAction().playSpellAbility(tgtSA);
|
||||
} else if (tgtSA.canPlayAI()) {
|
||||
ComputerUtil.playStack(tgtSA);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostUtil;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -398,7 +399,7 @@ public final class AbilityFactoryReveal {
|
||||
if (params.containsKey("Reveal")) {
|
||||
GuiUtils.getChoice("Revealing cards from library", top.toArray());
|
||||
cardsRevealed = true;
|
||||
// AllZone.getGameAction().revealToCopmuter(top.toArray());
|
||||
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
|
||||
// - for when it exists
|
||||
} else if (params.containsKey("RevealOptional")) {
|
||||
String question = "Reveal: ";
|
||||
@@ -407,7 +408,7 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) {
|
||||
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray());
|
||||
// AllZone.getGameAction().revealToCopmuter(top.toArray());
|
||||
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
|
||||
cardsRevealed = true;
|
||||
} else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) {
|
||||
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
|
||||
} else if (choser.isHuman()) {
|
||||
// show the user the revealed cards
|
||||
@@ -470,9 +471,9 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
final PlayerZone zone = c.getOwner().getZone(destZone1);
|
||||
if (zone.is(Zone.Library)) {
|
||||
AllZone.getGameAction().moveToLibrary(c, libraryPosition);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c, libraryPosition);
|
||||
} else {
|
||||
AllZone.getGameAction().moveTo(zone, c);
|
||||
Singletons.getModel().getGameAction().moveTo(zone, c);
|
||||
if (destZone1.equals(Zone.Battlefield) && params.containsKey("Tapped")) {
|
||||
c.setTapped(true);
|
||||
}
|
||||
@@ -509,9 +510,9 @@ public final class AbilityFactoryReveal {
|
||||
final PlayerZone zone = chosen.getOwner().getZone(destZone1);
|
||||
if (zone.is(Zone.Library)) {
|
||||
// System.out.println("Moving to lib position: "+libraryPosition);
|
||||
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition);
|
||||
} 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()) {
|
||||
for (final String kw : keywords) {
|
||||
c.addExtrinsicKeyword(kw);
|
||||
@@ -521,7 +522,7 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
}
|
||||
}
|
||||
// AllZone.getGameAction().revealToComputer()
|
||||
// Singletons.getModel().getGameAction().revealToComputer()
|
||||
// - for when this exists
|
||||
j++;
|
||||
}
|
||||
@@ -538,9 +539,9 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
final PlayerZone zone = chosen.getOwner().getZone(destZone1);
|
||||
if (zone.is(Zone.Library)) {
|
||||
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition);
|
||||
} 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()) {
|
||||
for (final String kw : keywords) {
|
||||
chosen.addExtrinsicKeyword(kw);
|
||||
@@ -582,12 +583,12 @@ public final class AbilityFactoryReveal {
|
||||
} else {
|
||||
chosen = rest.get(0);
|
||||
}
|
||||
AllZone.getGameAction().moveToLibrary(chosen, libraryPosition2);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition2);
|
||||
rest.remove(chosen);
|
||||
}
|
||||
} else { // Computer
|
||||
for (int i = 0; i < rest.size(); i++) {
|
||||
AllZone.getGameAction().moveToLibrary(rest.get(i), libraryPosition2);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(rest.get(i), libraryPosition2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -595,7 +596,7 @@ public final class AbilityFactoryReveal {
|
||||
for (int i = 0; i < rest.size(); i++) {
|
||||
Card c = rest.get(i);
|
||||
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()) {
|
||||
for (final String kw : keywords) {
|
||||
c.addExtrinsicKeyword(kw);
|
||||
@@ -984,9 +985,9 @@ public final class AbilityFactoryReveal {
|
||||
final Card c = itr.next();
|
||||
if (params.containsKey("GainControl") && foundDest.equals(Zone.Battlefield)) {
|
||||
c.addController(af.getHostCard());
|
||||
AllZone.getGameAction().moveTo(c.getController().getZone(foundDest), c);
|
||||
Singletons.getModel().getGameAction().moveTo(c.getController().getZone(foundDest), c);
|
||||
} else {
|
||||
AllZone.getGameAction().moveTo(foundDest, c, foundLibPos);
|
||||
Singletons.getModel().getGameAction().moveTo(foundDest, c, foundLibPos);
|
||||
}
|
||||
revealed.remove(c);
|
||||
}
|
||||
@@ -1001,7 +1002,7 @@ public final class AbilityFactoryReveal {
|
||||
final Iterator<Card> itr = revealed.iterator();
|
||||
while (itr.hasNext()) {
|
||||
final Card c = itr.next();
|
||||
AllZone.getGameAction().moveTo(revealedDest, c, revealedLibPos);
|
||||
Singletons.getModel().getGameAction().moveTo(revealedDest, c, revealedLibPos);
|
||||
}
|
||||
|
||||
if (params.containsKey("Shuffle")) {
|
||||
@@ -1921,7 +1922,7 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
final Card c1 = (Card) o;
|
||||
topCards.remove(c1);
|
||||
AllZone.getGameAction().moveToLibrary(c1, i - 1);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c1, i - 1);
|
||||
}
|
||||
if (mayshuffle) {
|
||||
if (GameActionUtil.showYesNoDialog(src, "Do you want to shuffle the library?")) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostUtil;
|
||||
@@ -455,7 +456,7 @@ public class AbilityFactorySacrifice {
|
||||
|
||||
if (valid.equals("Self")) {
|
||||
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
if (remSacrificed) {
|
||||
card.addRemembered(card);
|
||||
@@ -465,7 +466,7 @@ public class AbilityFactorySacrifice {
|
||||
else if (valid.equals("Card.AttachedBy")) {
|
||||
final Card toSac = card.getEnchantingCard();
|
||||
if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && AllZoneUtil.isCardInPlay(toSac)) {
|
||||
AllZone.getGameAction().sacrifice(toSac);
|
||||
Singletons.getModel().getGameAction().sacrifice(toSac);
|
||||
if (remSacrificed) {
|
||||
card.addRemembered(toSac);
|
||||
}
|
||||
@@ -473,7 +474,7 @@ public class AbilityFactorySacrifice {
|
||||
} else if (valid.equals("TriggeredCard")) {
|
||||
final Card equipee = (Card) sa.getTriggeringObject("Card");
|
||||
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
|
||||
AllZone.getGameAction().sacrifice(equipee);
|
||||
Singletons.getModel().getGameAction().sacrifice(equipee);
|
||||
if (remSacrificed) {
|
||||
card.addRemembered(equipee);
|
||||
}
|
||||
@@ -561,11 +562,11 @@ public class AbilityFactorySacrifice {
|
||||
final Card c = (Card) o;
|
||||
|
||||
if (destroy) {
|
||||
if (AllZone.getGameAction().destroy(c)) {
|
||||
if (Singletons.getModel().getGameAction().destroy(c)) {
|
||||
saccedList.add(c);
|
||||
}
|
||||
} else {
|
||||
if (AllZone.getGameAction().sacrifice(c)) {
|
||||
if (Singletons.getModel().getGameAction().sacrifice(c)) {
|
||||
saccedList.add(c);
|
||||
}
|
||||
}
|
||||
@@ -857,7 +858,7 @@ public class AbilityFactorySacrifice {
|
||||
list = AbilityFactory.filterListByType(list, valid, sa);
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.Constant;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.Spell;
|
||||
@@ -409,7 +410,7 @@ public class AbilityFactoryTurns {
|
||||
// Time Stop, though it will continue to resolve. It also includes
|
||||
// spells and abilities that can't be countered.
|
||||
for (final Card c : AllZone.getStackZone().getCards()) {
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
AllZone.getStack().getStack().clear();
|
||||
|
||||
@@ -419,7 +420,7 @@ public class AbilityFactoryTurns {
|
||||
|
||||
// 3) State-based actions are checked. No player gets priority, and no
|
||||
// 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
|
||||
// cleanup step. The cleanup step happens in its entirety.
|
||||
|
||||
@@ -294,7 +294,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
}
|
||||
|
||||
if (controller.isHuman()) {
|
||||
AllZone.getGameAction().playSpellAbilityForFree(copySA);
|
||||
Singletons.getModel().getGameAction().playSpellAbilityForFree(copySA);
|
||||
} else if (copySA.canPlayAI()) {
|
||||
ComputerUtil.playStackFree(copySA);
|
||||
}
|
||||
@@ -386,7 +386,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
}
|
||||
|
||||
if (source.getController().isHuman()) {
|
||||
AllZone.getGameAction().playSpellAbilityForFree(copySA);
|
||||
Singletons.getModel().getGameAction().playSpellAbilityForFree(copySA);
|
||||
} else if (copySA.canPlayAI()) {
|
||||
ComputerUtil.playStackFree(copySA);
|
||||
}
|
||||
@@ -701,8 +701,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
if (o2 != null) {
|
||||
final Card c2 = (Card) o2;
|
||||
newGrave.remove(c2);
|
||||
AllZone.getGameAction().exile(c);
|
||||
AllZone.getGameAction().exile(c2);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c2);
|
||||
this.once = true;
|
||||
|
||||
AllZone.getStack().addSimultaneousStackEntry(nightSoil);
|
||||
@@ -798,7 +798,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
* targetHand.toArray());
|
||||
*
|
||||
* final Card card = (Card) discard;
|
||||
* AllZone.getGameAction().moveToLibrary(card); } else if
|
||||
* Singletons.getModel().getGameAction().moveToLibrary(card); } else if
|
||||
* (target.isComputer()) { AllZone.getComputerPlayer().handToLibrary(1,
|
||||
* "Top"); } }
|
||||
*
|
||||
@@ -814,7 +814,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
* private static final long serialVersionUID = -8990402917139817175L;
|
||||
*
|
||||
* @Override public void resolve() {
|
||||
* AllZone.getGameAction().destroy(card); }
|
||||
* Singletons.getModel().getGameAction().destroy(card); }
|
||||
*
|
||||
* @Override public boolean canPlay() { return super.canPlay(); }
|
||||
*
|
||||
@@ -862,7 +862,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
AllZone.getHumanPlayer().discard(c, null);
|
||||
this.stop();
|
||||
} else if (c.equals(card)) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
@@ -873,7 +873,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
public void resolve() {
|
||||
if (card.getController().isHuman()) {
|
||||
if (AllZone.getHumanPlayer().getZone(Zone.Hand).isEmpty()) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
} else {
|
||||
AllZone.getInputControl().setInput(discard);
|
||||
}
|
||||
@@ -991,7 +991,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
} // while
|
||||
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray());
|
||||
for (final Card revealedCard : revealed) {
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(revealedCard);
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(revealedCard);
|
||||
}
|
||||
|
||||
if (this.getTargetCard() != null) {
|
||||
@@ -1072,7 +1072,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
}
|
||||
final Card c1 = (Card) o;
|
||||
lands.remove(c1); // remove from the display list
|
||||
AllZone.getGameAction().moveToLibrary(c1, i - 1);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c1, i - 1);
|
||||
}
|
||||
} else { // Computer
|
||||
// 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++) {
|
||||
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() {
|
||||
// exile those cards
|
||||
for (final Card c : this.exiled) {
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
|
||||
// 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);
|
||||
int numCards = 0;
|
||||
while ((lib.size() > 0) && (numCards < this.exiled.size())) {
|
||||
AllZone.getGameAction().moveToHand(lib.get(0));
|
||||
Singletons.getModel().getGameAction().moveToHand(lib.get(0));
|
||||
numCards++;
|
||||
}
|
||||
|
||||
@@ -1267,7 +1267,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
final Object o = GuiUtils.getChoice("Put a card on top of your library.",
|
||||
this.exiled.toArray());
|
||||
final Card c1 = (Card) o;
|
||||
AllZone.getGameAction().moveToLibrary(c1);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c1);
|
||||
this.exiled.remove(c1);
|
||||
}
|
||||
|
||||
@@ -1327,7 +1327,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
AllZone.getGameAction().playCardNoCost(freeCard);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(freeCard);
|
||||
}
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Error in " + cardName + ". freeCard is null", "",
|
||||
@@ -1567,7 +1567,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
AllZone.getTriggerHandler().clearSuppression("Transformed");
|
||||
}
|
||||
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
}
|
||||
|
||||
private void grantExtras() {
|
||||
@@ -1649,7 +1649,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
player.payLife(4, card);
|
||||
// card stays in hand
|
||||
} else {
|
||||
AllZone.getGameAction().moveToLibrary(card);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(card);
|
||||
}
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.Spell;
|
||||
@@ -127,7 +128,7 @@ class CardFactoryAuras {
|
||||
newType[0] = GuiUtils.getChoice("Select land type.", "Plains", "Island", "Swamp", "Mountain",
|
||||
"Forest");
|
||||
}
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
|
||||
final Card c = this.getTargetCard();
|
||||
|
||||
@@ -291,7 +292,7 @@ class CardFactoryAuras {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
|
||||
final Card c = this.getTargetCard();
|
||||
|
||||
@@ -398,7 +399,7 @@ class CardFactoryAuras {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
final Card aura = AllZone.getGameAction().moveToPlay(card);
|
||||
final Card aura = Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
|
||||
final Card c = this.getTargetCard();
|
||||
|
||||
@@ -480,14 +481,14 @@ class CardFactoryAuras {
|
||||
|
||||
if (!grave.is(Constant.Zone.Graveyard)) {
|
||||
// Animated Creature got removed before ability resolved
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
return;
|
||||
}
|
||||
|
||||
// Bring creature onto the battlefield under your control
|
||||
// (should trigger etb Abilities)
|
||||
animated.addController(card.getController());
|
||||
AllZone.getGameAction().moveToPlay(animated, card.getController());
|
||||
Singletons.getModel().getGameAction().moveToPlay(animated, card.getController());
|
||||
if (cardName.equals("Dance of the Dead")) {
|
||||
animated.tap();
|
||||
}
|
||||
@@ -496,7 +497,7 @@ class CardFactoryAuras {
|
||||
|
||||
if (CardFactoryUtil.hasProtectionFrom(card, animated)) {
|
||||
// Animated a creature with protection
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -515,7 +516,7 @@ class CardFactoryAuras {
|
||||
// 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
|
||||
// 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);
|
||||
|
||||
if (play.contains(c)) {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
}
|
||||
}
|
||||
}; // Detach
|
||||
|
||||
@@ -335,7 +335,7 @@ public class CardFactoryCreatures {
|
||||
public void resolve() {
|
||||
final CardList hand = card.getController().getCardsIn(Zone.Hand);
|
||||
if (hand.size() == 0) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
} else {
|
||||
card.getController().discardRandom(this);
|
||||
}
|
||||
@@ -509,7 +509,7 @@ public class CardFactoryCreatures {
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Hand) && !c.isLand()) {
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
chosen.push(c);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(card.toString()).append(" - Suspending ").append(c.toString());
|
||||
@@ -692,7 +692,7 @@ public class CardFactoryCreatures {
|
||||
@Override
|
||||
public void execute() {
|
||||
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");
|
||||
|
||||
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)) {
|
||||
final PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield);
|
||||
AllZone.getGameAction().moveTo(play, c);
|
||||
Singletons.getModel().getGameAction().moveTo(play, c);
|
||||
}
|
||||
} // resolve()
|
||||
|
||||
@@ -977,7 +977,7 @@ public class CardFactoryCreatures {
|
||||
@Override
|
||||
public void execute() {
|
||||
getTargetCard().addDamage(1, target);
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@ public class CardFactoryCreatures {
|
||||
@Override
|
||||
public void resolve() {
|
||||
int xCounters = card.getXManaCostPaid();
|
||||
final Card c = AllZone.getGameAction().moveToPlay(this.getSourceCard());
|
||||
final Card c = Singletons.getModel().getGameAction().moveToPlay(this.getSourceCard());
|
||||
|
||||
if (xCounters >= 5) {
|
||||
xCounters = 2 * xCounters;
|
||||
@@ -1172,7 +1172,7 @@ public class CardFactoryCreatures {
|
||||
|
||||
if (GameActionUtil.showYesNoDialog(card, question.toString())) {
|
||||
if (card.getName().equals("Academy Rector")) {
|
||||
AllZone.getGameAction().exile(card);
|
||||
Singletons.getModel().getGameAction().exile(card);
|
||||
}
|
||||
CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
|
||||
list = list.getType("Enchantment");
|
||||
@@ -1184,7 +1184,7 @@ public class CardFactoryCreatures {
|
||||
if (objectSelected != null) {
|
||||
|
||||
final Card c = (Card) objectSelected;
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
|
||||
if (c.isAura()) {
|
||||
|
||||
@@ -1295,9 +1295,9 @@ public class CardFactoryCreatures {
|
||||
if (list.size() > 0) {
|
||||
final Card c = CardFactoryUtil.getBestEnchantmentAI(list, this, false);
|
||||
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
if (card.getName().equals("Academy Rector")) {
|
||||
AllZone.getGameAction().exile(card);
|
||||
Singletons.getModel().getGameAction().exile(card);
|
||||
}
|
||||
card.getController().shuffle();
|
||||
}
|
||||
@@ -1527,7 +1527,7 @@ public class CardFactoryCreatures {
|
||||
for (int m = 0; m < selection.size(); m++) {
|
||||
intermSumPower += selection.get(m).getBaseAttack();
|
||||
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)) {
|
||||
intermSumPower += c.getBaseAttack();
|
||||
intermSumToughness += c.getBaseDefense();
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
count++;
|
||||
}
|
||||
// is this needed?
|
||||
@@ -1730,7 +1730,7 @@ public class CardFactoryCreatures {
|
||||
@Override
|
||||
public void resolve() {
|
||||
card.setKicked(true);
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
card.addCounterFromNonEffect(Counters.P1P1, 2);
|
||||
}
|
||||
|
||||
@@ -1890,7 +1890,7 @@ public class CardFactoryCreatures {
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
toSac.clear();
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@@ -1906,10 +1906,10 @@ public class CardFactoryCreatures {
|
||||
private void done() {
|
||||
if (getTotalPower() >= 12) {
|
||||
for (final Card sac : toSac) {
|
||||
AllZone.getGameAction().sacrifice(sac);
|
||||
Singletons.getModel().getGameAction().sacrifice(sac);
|
||||
}
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
toSac.clear();
|
||||
this.stop();
|
||||
@@ -2037,7 +2037,7 @@ public class CardFactoryCreatures {
|
||||
|
||||
//keep the Clone card image for the cloned card
|
||||
card.setImageFilename(imageFileName);
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
}
|
||||
|
||||
private void grantExtras() {
|
||||
@@ -2342,14 +2342,14 @@ public class CardFactoryCreatures {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Battlefield) && arts.contains(c)) {
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
this.stop();
|
||||
}
|
||||
} // selectCard()
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.Constant.Zone;
|
||||
import forge.PhaseUtil;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
@@ -139,10 +140,10 @@ public class CardFactoryInstants {
|
||||
JOptionPane
|
||||
.showMessageDialog(null, sbMsgP1.toString(), "", JOptionPane.INFORMATION_MESSAGE);
|
||||
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++) {
|
||||
AllZone.getGameAction().moveToGraveyard(pile2.get(i));
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(pile2.get(i));
|
||||
}
|
||||
} else {
|
||||
final StringBuilder sbMsgP2 = new StringBuilder();
|
||||
@@ -151,10 +152,10 @@ public class CardFactoryInstants {
|
||||
JOptionPane
|
||||
.showMessageDialog(null, sbMsgP2.toString(), "", JOptionPane.INFORMATION_MESSAGE);
|
||||
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++) {
|
||||
AllZone.getGameAction().moveToGraveyard(pile1.get(i));
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(pile1.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,17 +199,17 @@ public class CardFactoryInstants {
|
||||
possibleValues[0]);
|
||||
if (q.equals(0)) {
|
||||
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++) {
|
||||
AllZone.getGameAction().moveToGraveyard(pile2.get(i));
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(pile2.get(i));
|
||||
}
|
||||
} else {
|
||||
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++) {
|
||||
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);
|
||||
if (thisArtifact.getOwner().equals(player)) {
|
||||
//moveToHand handles tokens
|
||||
AllZone.getGameAction().moveToHand(thisArtifact);
|
||||
Singletons.getModel().getGameAction().moveToHand(thisArtifact);
|
||||
}
|
||||
}
|
||||
} //resolve()
|
||||
@@ -318,10 +319,10 @@ public class CardFactoryInstants {
|
||||
final Card choice = selectedCards.get(MyRandom.getRandom().nextInt(2));
|
||||
|
||||
selectedCards.remove(choice);
|
||||
AllZone.getGameAction().moveToHand(choice);
|
||||
Singletons.getModel().getGameAction().moveToHand(choice);
|
||||
|
||||
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;
|
||||
|
||||
selectedCards.remove(choice);
|
||||
AllZone.getGameAction().moveToHand(choice);
|
||||
Singletons.getModel().getGameAction().moveToHand(choice);
|
||||
|
||||
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;
|
||||
graveList.remove(c1); // remove from the display
|
||||
// list
|
||||
AllZone.getGameAction().exile(c1);
|
||||
Singletons.getModel().getGameAction().exile(c1);
|
||||
}
|
||||
} else { // Computer
|
||||
// Random random = MyRandom.random;
|
||||
for (int j = 0; j < 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)) {
|
||||
// System.out.println("Siren's Call - destroying "+creature.getName());
|
||||
// this should probably go on the stack
|
||||
AllZone.getGameAction().destroy(creature);
|
||||
Singletons.getModel().getGameAction().destroy(creature);
|
||||
}
|
||||
}
|
||||
creature.setSirenAttackOrDestroy(false);
|
||||
@@ -555,11 +556,11 @@ public class CardFactoryInstants {
|
||||
final Object o = GuiUtils.getChoice(this.prompt[i], choices.toArray());
|
||||
final Card c1 = (Card) o;
|
||||
if (i == 0) {
|
||||
AllZone.getGameAction().moveToHand(c1);
|
||||
Singletons.getModel().getGameAction().moveToHand(c1);
|
||||
} else if (i == 1) {
|
||||
AllZone.getGameAction().moveToLibrary(c1);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c1);
|
||||
} else if (i == 2) {
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(c1);
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c1);
|
||||
}
|
||||
|
||||
choices.remove(c1);
|
||||
@@ -600,12 +601,12 @@ public class CardFactoryInstants {
|
||||
}
|
||||
});
|
||||
for (final Card c : toReturn) {
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
}
|
||||
|
||||
for (final Card c : ens) {
|
||||
if (!toReturn.contains(c)) {
|
||||
AllZone.getGameAction().destroy(c);
|
||||
Singletons.getModel().getGameAction().destroy(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,14 +215,14 @@ class CardFactoryLands {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
if (paid[0] < 1) {
|
||||
paid[0]++;
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -236,7 +236,7 @@ class CardFactoryLands {
|
||||
}; // Input
|
||||
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED)
|
||||
.size() < 2)) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
return;
|
||||
} else {
|
||||
AllZone.getInputControl().setInput(target);
|
||||
@@ -285,12 +285,12 @@ class CardFactoryLands {
|
||||
// if any are tapped, sacrifice it
|
||||
// else sacrifice random
|
||||
if (tappedLand.size() > 0) {
|
||||
AllZone.getGameAction().sacrifice(tappedLand.get(0));
|
||||
Singletons.getModel().getGameAction().sacrifice(tappedLand.get(0));
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(land.get(0));
|
||||
Singletons.getModel().getGameAction().sacrifice(land.get(0));
|
||||
}
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
} else { // this is the human resolution
|
||||
final Input target = new Input() {
|
||||
@@ -305,14 +305,14 @@ class CardFactoryLands {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
this.stop();
|
||||
}
|
||||
} // selectCard()
|
||||
@@ -344,7 +344,7 @@ class CardFactoryLands {
|
||||
|
||||
if (land.size() > 0) {
|
||||
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());
|
||||
tappedPlains = tappedPlains.getType("Basic");
|
||||
for (final Card c : tappedPlains) {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
}
|
||||
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
|
||||
// else sacrifice random
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
} else { // this is the human resolution
|
||||
final int[] paid = { 0 };
|
||||
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.UNTAPPED)
|
||||
.size() < 2)) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
return;
|
||||
}
|
||||
final Input target = new Input() {
|
||||
@@ -398,14 +398,14 @@ class CardFactoryLands {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
if (paid[0] < 1) {
|
||||
paid[0]++;
|
||||
Singletons.getControl().getControlMatch().showMessage(
|
||||
@@ -656,12 +656,12 @@ class CardFactoryLands {
|
||||
CardList tappedLand = new CardList(land.toArray());
|
||||
tappedLand = tappedLand.filter(CardListFilter.TAPPED);
|
||||
if (tappedLand.size() > 0) {
|
||||
AllZone.getGameAction().moveToHand(CardFactoryUtil.getWorstLand(tappedLand));
|
||||
Singletons.getModel().getGameAction().moveToHand(CardFactoryUtil.getWorstLand(tappedLand));
|
||||
} else {
|
||||
AllZone.getGameAction().moveToHand(CardFactoryUtil.getWorstLand(land));
|
||||
Singletons.getModel().getGameAction().moveToHand(CardFactoryUtil.getWorstLand(land));
|
||||
}
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
} else { // this is the human resolution
|
||||
final Input target = new Input() {
|
||||
@@ -678,7 +678,7 @@ class CardFactoryLands {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ class CardFactoryLands {
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer())
|
||||
&& !c.isType("Lair")) {
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
this.stop();
|
||||
}
|
||||
} // selectCard()
|
||||
@@ -728,9 +728,9 @@ class CardFactoryLands {
|
||||
if (player.isComputer()) {
|
||||
if (land.size() > 0) {
|
||||
final Card c = CardFactoryUtil.getWorstLand(land);
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
} else { // this is the human resolution
|
||||
final Input target = new Input() {
|
||||
@@ -747,14 +747,14 @@ class CardFactoryLands {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card c, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) {
|
||||
AllZone.getGameAction().moveToHand(c);
|
||||
Singletons.getModel().getGameAction().moveToHand(c);
|
||||
this.stop();
|
||||
}
|
||||
} // selectCard()
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.Counters;
|
||||
import forge.PhaseHandler;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
@@ -95,7 +96,7 @@ public class CardFactoryPlaneswalkers {
|
||||
GuiUtils.getChoiceOptional("Revealed top card: ", showTop.toArray());
|
||||
|
||||
// now, move it to player's hand
|
||||
AllZone.getGameAction().moveToHand(topCard);
|
||||
Singletons.getModel().getGameAction().moveToHand(topCard);
|
||||
|
||||
// now, do X damage to Sarkhan
|
||||
card.addDamage(convertedManaTopCard, card);
|
||||
@@ -145,7 +146,7 @@ public class CardFactoryPlaneswalkers {
|
||||
turn[0] = AllZone.getPhaseHandler().getTurn();
|
||||
|
||||
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
|
||||
// correct Zone
|
||||
CardFactoryUtil.makeToken("Dragon", "R 5 5 Dragon", target.getController(), "R", new String[] {
|
||||
|
||||
@@ -101,9 +101,9 @@ public class CardFactorySorceries {
|
||||
final Player p1 = crd1.getController();
|
||||
crd0.addController(p1);
|
||||
crd1.addController(p0);
|
||||
// AllZone.getGameAction().changeController(new
|
||||
// Singletons.getModel().getGameAction().changeController(new
|
||||
// CardList(crd0), p0, p1);
|
||||
// AllZone.getGameAction().changeController(new
|
||||
// Singletons.getModel().getGameAction().changeController(new
|
||||
// CardList(crd1), p1, p0);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class CardFactorySorceries {
|
||||
}
|
||||
|
||||
target.removeController(card);
|
||||
// AllZone.getGameAction().changeController(new
|
||||
// Singletons.getModel().getGameAction().changeController(new
|
||||
// CardList(target), card.getController(),
|
||||
// controllerEOT.get(i));
|
||||
|
||||
@@ -225,7 +225,7 @@ public class CardFactorySorceries {
|
||||
targets.add(i, target);
|
||||
|
||||
target.addController(card);
|
||||
// AllZone.getGameAction().changeController(new
|
||||
// Singletons.getModel().getGameAction().changeController(new
|
||||
// CardList(target), target.getController(),
|
||||
// card.getController());
|
||||
|
||||
@@ -275,7 +275,7 @@ public class CardFactorySorceries {
|
||||
}
|
||||
for (int i = 0; i < count; 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 pile2 = new CardList();
|
||||
@@ -415,7 +415,7 @@ public class CardFactorySorceries {
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
AllZone.getGameAction().playCardNoCost(playing);
|
||||
Singletons.getModel().getGameAction().playCardNoCost(playing);
|
||||
}
|
||||
chosen.remove(playing);
|
||||
}
|
||||
@@ -454,7 +454,7 @@ public class CardFactorySorceries {
|
||||
for (int i = 0; i < all.size(); i++) {
|
||||
final Card c = all.get(i);
|
||||
if (c.isCreature()) {
|
||||
AllZone.getGameAction().destroy(c);
|
||||
Singletons.getModel().getGameAction().destroy(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,7 +579,7 @@ public class CardFactorySorceries {
|
||||
// selected are sacrificed.
|
||||
for (int i = 0; i < target.size(); 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()
|
||||
@@ -738,10 +738,10 @@ public class CardFactorySorceries {
|
||||
for (final Card c : grave) {
|
||||
final CardList remLib = lib.getName(c.getName());
|
||||
for (final Card rem : remLib) {
|
||||
AllZone.getGameAction().exile(rem);
|
||||
Singletons.getModel().getGameAction().exile(rem);
|
||||
lib.remove(rem);
|
||||
}
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
}
|
||||
}; // SpellAbility
|
||||
@@ -811,7 +811,7 @@ public class CardFactorySorceries {
|
||||
if (compLand.size() > humLand.size()) {
|
||||
compLand.shuffle();
|
||||
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()) {
|
||||
final int diff = humLand.size() - compLand.size();
|
||||
@@ -838,7 +838,7 @@ public class CardFactorySorceries {
|
||||
CardListUtil.sortCMC(compCreats);
|
||||
compCreats.reverse();
|
||||
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()) {
|
||||
final int diff = humCreats.size() - compCreats.size();
|
||||
@@ -1168,12 +1168,12 @@ public class CardFactorySorceries {
|
||||
/*
|
||||
* else { //computer
|
||||
* card.getControler().discardRandom(numCards);
|
||||
* AllZone.getGameAction().exile(card); CardList grave =
|
||||
* Singletons.getModel().getGameAction().exile(card); CardList grave =
|
||||
* AllZoneUtil.getPlayerGraveyard(card.getController());
|
||||
* for(int i = 1; i <= numCards; i ++) { Card t1 =
|
||||
* CardFactoryUtil.AI_getBestCreature(grave); if(null != t1)
|
||||
* { t1 = grave.get(0); grave.remove(t1);
|
||||
* AllZone.getGameAction().moveToHand(t1); } } }
|
||||
* Singletons.getModel().getGameAction().moveToHand(t1); } } }
|
||||
*
|
||||
} // resolve()
|
||||
}; // SpellAbility
|
||||
@@ -1286,7 +1286,7 @@ public class CardFactorySorceries {
|
||||
bidded = bidded.getType("Creature");
|
||||
for (final Card c : bidded) {
|
||||
if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) {
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
}
|
||||
}
|
||||
} // resolve()
|
||||
@@ -1376,7 +1376,7 @@ public class CardFactorySorceries {
|
||||
|
||||
// then, move revealed cards to bottom of library
|
||||
for (final Card c : topCards) {
|
||||
AllZone.getGameAction().moveToBottomOfLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
|
||||
}
|
||||
} // resolve()
|
||||
|
||||
@@ -1408,7 +1408,7 @@ public class CardFactorySorceries {
|
||||
final CardList hand = player.getCardsIn(Zone.Hand);
|
||||
|
||||
for (final Card c : hand) {
|
||||
AllZone.getGameAction().moveToLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c);
|
||||
}
|
||||
|
||||
// Shuffle library
|
||||
@@ -1460,7 +1460,7 @@ public class CardFactorySorceries {
|
||||
|
||||
// move hand to library
|
||||
for (final Card c : hand) {
|
||||
AllZone.getGameAction().moveToLibrary(c);
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c);
|
||||
}
|
||||
|
||||
// Shuffle library
|
||||
@@ -1498,10 +1498,10 @@ public class CardFactorySorceries {
|
||||
public void resolve() {
|
||||
final Player player = card.getController();
|
||||
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());
|
||||
player.addHandSizeOperation(new HandSizeOp("=", -1, Integer.parseInt(card.getSVar("HSStamp"))));
|
||||
@@ -1557,7 +1557,7 @@ public class CardFactorySorceries {
|
||||
final Card c = ab1card[0];
|
||||
if (c != null) {
|
||||
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);
|
||||
final CardList equipment = new CardList(tgt.getEquippedBy());
|
||||
for (final Card eq : equipment) {
|
||||
AllZone.getGameAction().destroy(eq);
|
||||
Singletons.getModel().getGameAction().destroy(eq);
|
||||
}
|
||||
}
|
||||
} // resolve()
|
||||
@@ -2018,7 +2018,7 @@ public class CardFactorySorceries {
|
||||
if (toSac != null) {
|
||||
final Card c = (Card) toSac;
|
||||
baseCMC = CardUtil.getConvertedManaCost(c);
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -2038,7 +2038,7 @@ public class CardFactorySorceries {
|
||||
|
||||
// if <= baseCMC, put it onto the battlefield
|
||||
if (newCMC <= baseCMC) {
|
||||
AllZone.getGameAction().moveToPlay(newArtifact[0]);
|
||||
Singletons.getModel().getGameAction().moveToPlay(newArtifact[0]);
|
||||
} else {
|
||||
final String diffCost = String.valueOf(newCMC - baseCMC);
|
||||
AllZone.getInputControl().setInput(new InputPayManaCostAbility(diffCost, new Command() {
|
||||
@@ -2046,14 +2046,14 @@ public class CardFactorySorceries {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
AllZone.getGameAction().moveToPlay(newArtifact[0]);
|
||||
Singletons.getModel().getGameAction().moveToPlay(newArtifact[0]);
|
||||
}
|
||||
}, new Command() {
|
||||
private static final long serialVersionUID = -246036834856971935L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
AllZone.getGameAction().moveToGraveyard(newArtifact[0]);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(newArtifact[0]);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ public class CardFactoryUtil {
|
||||
@Override
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (choices.contains(card)) {
|
||||
AllZone.getGameAction().destroyNoRegeneration(card);
|
||||
Singletons.getModel().getGameAction().destroyNoRegeneration(card);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
@@ -890,7 +890,7 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
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("Haste");
|
||||
@@ -937,7 +937,7 @@ public class CardFactoryUtil {
|
||||
|
||||
sourceCard.comesIntoPlay();
|
||||
|
||||
AllZone.getGameAction().moveToPlay(sourceCard);
|
||||
Singletons.getModel().getGameAction().moveToPlay(sourceCard);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1138,7 +1138,7 @@ public class CardFactoryUtil {
|
||||
|
||||
sourceCard.getController().discard(sourceCard, this);
|
||||
final Card c1 = (Card) o;
|
||||
AllZone.getGameAction().moveToHand(c1);
|
||||
Singletons.getModel().getGameAction().moveToHand(c1);
|
||||
|
||||
}
|
||||
sourceCard.getController().shuffle();
|
||||
@@ -1218,7 +1218,7 @@ public class CardFactoryUtil {
|
||||
sourceCard.getController().discard(sourceCard, this);
|
||||
final Card c1 = (Card) o;
|
||||
|
||||
AllZone.getGameAction().moveToHand(c1);
|
||||
Singletons.getModel().getGameAction().moveToHand(c1);
|
||||
|
||||
}
|
||||
sourceCard.getController().shuffle();
|
||||
@@ -1278,7 +1278,7 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
final Card c = AllZone.getGameAction().exile(sourceCard);
|
||||
final Card c = Singletons.getModel().getGameAction().exile(sourceCard);
|
||||
c.addCounter(Counters.TIME, suspendCounters);
|
||||
}
|
||||
};
|
||||
@@ -1670,7 +1670,7 @@ public class CardFactoryUtil {
|
||||
if (o != null) {
|
||||
|
||||
final Card c1 = (Card) o;
|
||||
AllZone.getGameAction().moveToHand(c1);
|
||||
Singletons.getModel().getGameAction().moveToHand(c1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1680,7 +1680,7 @@ public class CardFactoryUtil {
|
||||
choice = sameCost.getCard(0);
|
||||
|
||||
if (!(choice == null)) {
|
||||
AllZone.getGameAction().moveToHand(choice);
|
||||
Singletons.getModel().getGameAction().moveToHand(choice);
|
||||
}
|
||||
}
|
||||
} // resolve()
|
||||
@@ -1814,7 +1814,7 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
AllZone.getGameAction().sacrifice(crd);
|
||||
Singletons.getModel().getGameAction().sacrifice(crd);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@@ -1822,11 +1822,11 @@ public class CardFactoryUtil {
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (choices.contains(card)) {
|
||||
if (card == spell.getSourceCard()) {
|
||||
AllZone.getGameAction().sacrifice(spell.getSourceCard());
|
||||
Singletons.getModel().getGameAction().sacrifice(spell.getSourceCard());
|
||||
this.stop();
|
||||
} else {
|
||||
spell.getSourceCard().setChampionedCard(card);
|
||||
AllZone.getGameAction().exile(card);
|
||||
Singletons.getModel().getGameAction().exile(card);
|
||||
|
||||
this.stop();
|
||||
|
||||
@@ -1911,7 +1911,7 @@ public class CardFactoryUtil {
|
||||
|
||||
void done() {
|
||||
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);
|
||||
for (int i = 1; i <= this.n; i++) {
|
||||
final String title = "Return card from grave to hand";
|
||||
@@ -1921,7 +1921,7 @@ public class CardFactoryUtil {
|
||||
}
|
||||
final Card toHand = (Card) o;
|
||||
grave.remove(toHand);
|
||||
AllZone.getGameAction().moveToHand(toHand);
|
||||
Singletons.getModel().getGameAction().moveToHand(toHand);
|
||||
}
|
||||
this.stop();
|
||||
}
|
||||
@@ -3808,7 +3808,7 @@ public class CardFactoryUtil {
|
||||
temp.setToken(true);
|
||||
CardFactoryUtil.parseKeywords(temp, temp.getName());
|
||||
temp = CardFactoryUtil.postFactoryKeywords(temp);
|
||||
AllZone.getGameAction().moveToPlay(temp);
|
||||
Singletons.getModel().getGameAction().moveToPlay(temp);
|
||||
list.add(temp);
|
||||
}
|
||||
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."
|
||||
* ) ) { // || (c.isCreature() && AllZoneUtil.isCardInPlay("Cowardice"))
|
||||
* 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();
|
||||
* sb.append(c).append(" - return CARDNAME to its owner's hand.");
|
||||
* ability.setStackDescription(sb.toString());
|
||||
@@ -4102,14 +4102,14 @@ public class CardFactoryUtil {
|
||||
* ) || AllZoneUtil.isCardInPlay("Horobi, Death's Wail")) {
|
||||
*
|
||||
* 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.");
|
||||
* ability.setStackDescription(sb.toString());
|
||||
*
|
||||
* AllZone.getStack().add(ability); } if (c.hasKeyword(
|
||||
* "When CARDNAME becomes the target of a spell or ability, sacrifice it."))
|
||||
* { 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.");
|
||||
* ability.setStackDescription(sb.toString());
|
||||
*
|
||||
@@ -4142,12 +4142,12 @@ public class CardFactoryUtil {
|
||||
* "for card \"" + c.getName() + "\""); }
|
||||
*
|
||||
* if(action[0].startsWith("exile")) {
|
||||
* AllZone.getGameAction().exile(target); } else
|
||||
* Singletons.getModel().getGameAction().exile(target); } else
|
||||
* if(action[0].startsWith("destroy")) { if(noRegen) {
|
||||
* AllZone.getGameAction().destroyNoRegeneration(target); } else {
|
||||
* AllZone.getGameAction().destroy(target); } } else
|
||||
* Singletons.getModel().getGameAction().destroyNoRegeneration(target); } else {
|
||||
* Singletons.getModel().getGameAction().destroy(target); } } else
|
||||
* 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 +
|
||||
* "for card \"" + c.getName() + "\""); } } };
|
||||
*
|
||||
@@ -4289,7 +4289,7 @@ public class CardFactoryUtil {
|
||||
@Override
|
||||
public void resolve() {
|
||||
card.setKicked(true);
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
}
|
||||
};
|
||||
final String parse = card.getKeyword().get(kicker).toString();
|
||||
@@ -4350,7 +4350,7 @@ public class CardFactoryUtil {
|
||||
@Override
|
||||
public void resolve() {
|
||||
card.setEvoked(true);
|
||||
AllZone.getGameAction().moveToPlay(card);
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4719,7 +4719,7 @@ public class CardFactoryUtil {
|
||||
@Override
|
||||
public void resolve() {
|
||||
this.getTargetCard().addHauntedBy(card);
|
||||
AllZone.getGameAction().exile(card);
|
||||
Singletons.getModel().getGameAction().exile(card);
|
||||
}
|
||||
};
|
||||
haunterDiesWork.setDescription(hauntDescription);
|
||||
@@ -4887,11 +4887,11 @@ public class CardFactoryUtil {
|
||||
eff.addTrigger(copyTrigger);
|
||||
|
||||
AllZone.getTriggerHandler().suppressMode("ChangesZone");
|
||||
AllZone.getGameAction().moveToPlay(eff);
|
||||
Singletons.getModel().getGameAction().moveToPlay(eff);
|
||||
AllZone.getTriggerHandler().clearSuppression("ChangesZone");
|
||||
|
||||
if (card.getController().isHuman()) {
|
||||
AllZone.getGameAction().playSpellAbilityNoStack(origSA, false);
|
||||
Singletons.getModel().getGameAction().playSpellAbilityNoStack(origSA, false);
|
||||
} else {
|
||||
ComputerUtil.playNoStack(origSA);
|
||||
}
|
||||
@@ -5064,7 +5064,7 @@ public class CardFactoryUtil {
|
||||
final CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("World");
|
||||
cardsInPlay.remove(card);
|
||||
for (int i = 0; i < cardsInPlay.size(); i++) {
|
||||
AllZone.getGameAction().sacrificeDestroy(cardsInPlay.get(i));
|
||||
Singletons.getModel().getGameAction().sacrificeDestroy(cardsInPlay.get(i));
|
||||
}
|
||||
} // execute()
|
||||
}; // Command
|
||||
@@ -5158,7 +5158,7 @@ public class CardFactoryUtil {
|
||||
numCreatures[0] = selection.size();
|
||||
for (int m = 0; m < selection.size(); 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);
|
||||
if ((c.getNetAttack() <= 1) && ((c.getNetAttack() + c.getNetDefense()) <= 3)) {
|
||||
card.addDevoured(c);
|
||||
AllZone.getGameAction().sacrifice(c);
|
||||
Singletons.getModel().getGameAction().sacrifice(c);
|
||||
count++;
|
||||
}
|
||||
// is this needed?
|
||||
|
||||
@@ -20,10 +20,10 @@ package forge.card.cost;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.Constant;
|
||||
import forge.Counters;
|
||||
import forge.Singletons;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
|
||||
@@ -400,7 +400,7 @@ public class Cost {
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class CostExile extends CostPartWithList {
|
||||
@Override
|
||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||
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()) {
|
||||
final Card c = itr.next();
|
||||
part.addToList(c);
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
part.addListToHash(sa, "Exiled");
|
||||
payment.paidCost(part);
|
||||
@@ -334,7 +334,7 @@ public class CostExile extends CostPartWithList {
|
||||
final Card c = (Card) o;
|
||||
this.typeList.remove(c);
|
||||
part.addToList(c);
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
if (i == (nNeeded - 1)) {
|
||||
this.done();
|
||||
}
|
||||
@@ -423,7 +423,7 @@ public class CostExile extends CostPartWithList {
|
||||
if (this.typeList.contains(card)) {
|
||||
this.nExiles++;
|
||||
part.addToList(card);
|
||||
AllZone.getGameAction().exile(card);
|
||||
Singletons.getModel().getGameAction().exile(card);
|
||||
this.typeList.remove(card);
|
||||
// in case nothing else to exile
|
||||
if (this.nExiles == nNeeded) {
|
||||
@@ -483,7 +483,7 @@ public class CostExile extends CostPartWithList {
|
||||
possibleValues[0]);
|
||||
if (choice.equals(0)) {
|
||||
payment.getAbility().addCostToHashList(card, "Exiled");
|
||||
AllZone.getGameAction().exile(card);
|
||||
Singletons.getModel().getGameAction().exile(card);
|
||||
part.addToList(card);
|
||||
this.stop();
|
||||
part.addListToHash(sa, "Exiled");
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
|
||||
@@ -112,7 +113,7 @@ public class CostMill extends CostPartWithList {
|
||||
@Override
|
||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||
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()) {
|
||||
final Card card = itr.next();
|
||||
this.addToList(card);
|
||||
AllZone.getGameAction().moveToGraveyard(card);
|
||||
Singletons.getModel().getGameAction().moveToGraveyard(card);
|
||||
}
|
||||
this.addListToHash(ability, "Milled");
|
||||
payment.paidCost(this);
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge.card.cost;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.ButtonUtil;
|
||||
import forge.Card;
|
||||
@@ -129,7 +128,7 @@ public class CostReturn extends CostPartWithList {
|
||||
@Override
|
||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||
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)) {
|
||||
this.nReturns++;
|
||||
part.addToList(card);
|
||||
AllZone.getGameAction().moveToHand(card);
|
||||
Singletons.getModel().getGameAction().moveToHand(card);
|
||||
this.typeList.remove(card);
|
||||
// in case nothing else to return
|
||||
if (this.nReturns == nNeeded) {
|
||||
@@ -305,7 +304,7 @@ public class CostReturn extends CostPartWithList {
|
||||
possibleValues[0]);
|
||||
if (choice.equals(0)) {
|
||||
part.addToList(card);
|
||||
AllZone.getGameAction().moveToHand(card);
|
||||
Singletons.getModel().getGameAction().moveToHand(card);
|
||||
this.stop();
|
||||
part.addListToHash(sa, "Returned");
|
||||
payment.paidCost(part);
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge.card.cost;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.ButtonUtil;
|
||||
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) {
|
||||
this.addListToHash(ability, "Sacrificed");
|
||||
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
|
||||
for (final Card card : typeList) {
|
||||
payment.getAbility().addCostToHashList(card, "Sacrificed");
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
}
|
||||
|
||||
payment.setPaidManaPart(part, true);
|
||||
@@ -288,7 +287,7 @@ public class CostSacrifice extends CostPartWithList {
|
||||
if (typeList.contains(card)) {
|
||||
this.nSacrifices++;
|
||||
part.addToList(card);
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
typeList.remove(card);
|
||||
// in case nothing else to sacrifice
|
||||
if (this.nSacrifices == nNeeded) {
|
||||
@@ -349,7 +348,7 @@ public class CostSacrifice extends CostPartWithList {
|
||||
if (choice.equals(0)) {
|
||||
part.addToList(card);
|
||||
part.addListToHash(sa, "Sacrificed");
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
Singletons.getModel().getGameAction().sacrifice(card);
|
||||
this.stop();
|
||||
payment.paidCost(part);
|
||||
} else {
|
||||
|
||||
@@ -21,12 +21,12 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.spellability.AbilityMana;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.control.input.InputPayManaCostUtil;
|
||||
@@ -260,7 +260,7 @@ public class ManaPool {
|
||||
for (final Mana m : manaList) {
|
||||
this.addManaToPool(this.floatingMana, m);
|
||||
}
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
owner.updateObservers();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.gui.GuiUtils;
|
||||
@@ -174,7 +175,7 @@ public class ReplacementHandler {
|
||||
}
|
||||
|
||||
if (replacementEffect.getHostCard().getController().isHuman()) {
|
||||
AllZone.getGameAction().playSpellAbilityNoStack(effectSA, false);
|
||||
Singletons.getModel().getGameAction().playSpellAbilityNoStack(effectSA, false);
|
||||
} else {
|
||||
ComputerUtil.playNoStack(effectSA);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.PlayerZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.cost.CostPayment;
|
||||
|
||||
@@ -110,7 +111,7 @@ public class SpellAbilityRequirements {
|
||||
final Card c = this.ability.getSourceCard();
|
||||
|
||||
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();
|
||||
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
// add back to where it came from
|
||||
AllZone.getGameAction().moveTo(this.fromZone, c);
|
||||
Singletons.getModel().getGameAction().moveTo(this.fromZone, c);
|
||||
}
|
||||
|
||||
this.select.resetTargets();
|
||||
@@ -189,12 +190,12 @@ public class SpellAbilityRequirements {
|
||||
}
|
||||
|
||||
this.select.resetTargets();
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
} else if (this.payment.isCanceled()) {
|
||||
final Card c = this.ability.getSourceCard();
|
||||
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
// add back to Previous Zone
|
||||
AllZone.getGameAction().moveTo(this.fromZone, c);
|
||||
Singletons.getModel().getGameAction().moveTo(this.fromZone, c);
|
||||
}
|
||||
|
||||
if (this.select != null) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -88,7 +89,7 @@ public class SpellPermanent extends Spell {
|
||||
|
||||
final CardList creature = (CardList) SpellPermanent.this.championGetCreature.execute();
|
||||
if (creature.size() == 0) {
|
||||
AllZone.getGameAction().sacrifice(source);
|
||||
Singletons.getModel().getGameAction().sacrifice(source);
|
||||
return;
|
||||
} else if (controller.isHuman()) {
|
||||
AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes);
|
||||
@@ -102,7 +103,7 @@ public class SpellPermanent extends Spell {
|
||||
final Card c = computer.get(0);
|
||||
source.setChampionedCard(c);
|
||||
if (AllZoneUtil.isCardInPlay(c)) {
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
|
||||
// Run triggers
|
||||
@@ -111,7 +112,7 @@ public class SpellPermanent extends Spell {
|
||||
runParams.put("Championed", source.getChampionedCard());
|
||||
AllZone.getTriggerHandler().runTrigger("Championed", runParams);
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(this.getSourceCard());
|
||||
Singletons.getModel().getGameAction().sacrifice(this.getSourceCard());
|
||||
}
|
||||
} // computer
|
||||
} // resolve()
|
||||
@@ -145,7 +146,7 @@ public class SpellPermanent extends Spell {
|
||||
public void resolve() {
|
||||
final Card c = this.getSourceCard().getChampionedCard();
|
||||
if ((c != null) && !c.isToken() && AllZoneUtil.isCardExiled(c)) {
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||
}
|
||||
} // resolve()
|
||||
}; // SpellAbility
|
||||
@@ -413,6 +414,6 @@ public class SpellPermanent extends Spell {
|
||||
public void resolve() {
|
||||
final Card c = this.getSourceCard();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameActionUtil;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.abilityfactory.AbilityFactoryCharm;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -358,12 +359,12 @@ public class TriggerHandler {
|
||||
* they //aren't yet. And even if it (correctly?) sent unattached
|
||||
* //auras to the graveyard,that would result in all auras //going
|
||||
* straight to the grave no matter what. this.suppressMode("Always");
|
||||
* AllZone.getGameAction().checkStateEffects(true);
|
||||
* Singletons.getModel().getGameAction().checkStateEffects(true);
|
||||
* this.clearSuppression("Always");
|
||||
*/
|
||||
if (checkStatics) {
|
||||
this.suppressMode("Always");
|
||||
AllZone.getGameAction().checkStaticAbilities();
|
||||
Singletons.getModel().getGameAction().checkStaticAbilities();
|
||||
this.clearSuppression("Always");
|
||||
}
|
||||
|
||||
@@ -1052,7 +1053,7 @@ public class TriggerHandler {
|
||||
// Card src =
|
||||
// (Card)(sa[0].getSourceCard().getTriggeringObject("Card"));
|
||||
// System.out.println("Trigger resolving for "+mode+". Card = "+src);
|
||||
AllZone.getGameAction().playSpellAbilityNoStack(sa[0], true);
|
||||
Singletons.getModel().getGameAction().playSpellAbilityNoStack(sa[0], true);
|
||||
} else {
|
||||
// commented out because i don't think this should be called
|
||||
// again here
|
||||
@@ -1075,7 +1076,7 @@ public class TriggerHandler {
|
||||
wrapperAbility.setDescription(wrapperAbility.getStackDescription());
|
||||
/*
|
||||
* if(host.getController().isHuman()) {
|
||||
* AllZone.getGameAction().playSpellAbility(wrapperAbility); } else {
|
||||
* Singletons.getModel().getGameAction().playSpellAbility(wrapperAbility); } else {
|
||||
* wrapperAbility.doTrigger(isMandatory);
|
||||
* ComputerUtil.playStack(wrapperAbility); }
|
||||
*/
|
||||
@@ -1084,7 +1085,7 @@ public class TriggerHandler {
|
||||
// System.out.println("Trigger going on stack for "+mode+". Card = "+src);
|
||||
|
||||
if (params.containsKey("Static") && params.get("Static").equals("True")) {
|
||||
AllZone.getGameAction().playSpellAbilityNoStack(wrapperAbility, false);
|
||||
Singletons.getModel().getGameAction().playSpellAbilityNoStack(wrapperAbility, false);
|
||||
} else {
|
||||
AllZone.getStack().addSimultaneousStackEntry(wrapperAbility);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GuiMultipleBlockers;
|
||||
import forge.ImageCache;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
import forge.control.match.ControlDetail;
|
||||
@@ -86,22 +85,8 @@ public class ControlMatchUI implements CardContainer {
|
||||
*
|
||||
*/
|
||||
public void initMatch() {
|
||||
// All child components have been assembled; observers and listeners can
|
||||
// be added safely.
|
||||
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();
|
||||
}
|
||||
ControlMatchUI.this.showCombat("");
|
||||
ControlMatchUI.this.showStack();
|
||||
|
||||
// Update avatars
|
||||
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();
|
||||
}
|
||||
|
||||
// Update observers
|
||||
AllZone.getHumanPlayer().updateObservers();
|
||||
AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers();
|
||||
AllZone.getComputerPlayer().getZone(Zone.Hand).updateObservers();
|
||||
AllZone.getStack().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();
|
||||
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
|
||||
* be drawn on them. "Enabled" state remains the same.
|
||||
|
||||
@@ -96,6 +96,7 @@ public enum FControl {
|
||||
|
||||
/** After view and model have been initialized, control can start. */
|
||||
public void initialize() {
|
||||
Singletons.getModel().getQuestEventManager().assembleAllEvents();
|
||||
this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
|
||||
this.display = Singletons.getView().getLayeredContentPane();
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.PlayerType;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.generate.Generate2ColorDeck;
|
||||
import forge.deck.generate.Generate3ColorDeck;
|
||||
import forge.deck.generate.Generate5ColorDeck;
|
||||
import forge.deck.generate.GenerateThemeDeck;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.util.IFolderMap;
|
||||
@@ -224,7 +224,9 @@ public class ControlConstructed {
|
||||
deck = new Deck();
|
||||
deck.getMain().add(cards);
|
||||
}
|
||||
|
||||
else if (lst0.getName().equals("lstQuest")) {
|
||||
deck = Singletons.getModel().getQuestEventManager().getEvent(selection[0]).getEventDeck();
|
||||
}
|
||||
// Custom deck
|
||||
else {
|
||||
deck = AllZone.getDecks().getConstructed().get(selection[0]);
|
||||
@@ -281,10 +283,8 @@ public class ControlConstructed {
|
||||
view.getBtnStart().setVisible(true);
|
||||
view.getBarProgress().setVisible(false);
|
||||
|
||||
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
||||
Singletons.getControl().getControlMatch().initMatch();
|
||||
|
||||
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],
|
||||
new CardList(), new CardList(), 20, 20);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -332,13 +332,13 @@ public class ControlConstructed {
|
||||
final List<String> eventNames = new ArrayList<String>();
|
||||
eventNames.clear();
|
||||
|
||||
/*for (QuestEvent e : AllZone.getQuestEventManager().getAllChallenges()) {
|
||||
/*for (QuestEvent e : Singletons.getModel().getQuestEventManager().getAllChallenges()) {
|
||||
eventNames.add(e.getEventDeck().getName());
|
||||
}
|
||||
|
||||
for (QuestEvent e : AllZone.getQuestEventManager().getAllDuels()) {
|
||||
for (QuestEvent e : Singletons.getModel().getQuestEventManager().getAllDuels()) {
|
||||
eventNames.add(e.getEventDeck().getName());
|
||||
}*/
|
||||
} */
|
||||
|
||||
return oa2sa(eventNames.toArray());
|
||||
}
|
||||
|
||||
@@ -11,10 +11,9 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.game.limited.BoosterDraft;
|
||||
import forge.game.limited.CardPoolLimitation;
|
||||
@@ -146,10 +145,7 @@ public class ControlDraft {
|
||||
public void run() {
|
||||
view.getBtnStart().setVisible(true);
|
||||
view.getBarProgress().setVisible(false);
|
||||
|
||||
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
||||
Singletons.getControl().getControlMatch().initMatch();
|
||||
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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.deckeditor.DeckEditorQuest;
|
||||
@@ -70,7 +71,7 @@ public class ControlQuest {
|
||||
public ControlQuest(ViewQuest v0) {
|
||||
// Inits
|
||||
this.view = v0;
|
||||
this.qem = new QuestEventManager();
|
||||
this.qem = Singletons.getModel().getQuestEventManager();
|
||||
this.qPrefs = Singletons.getModel().getQuestPreferences();
|
||||
AllZone.setQuestEventManager(this.qem);
|
||||
|
||||
@@ -324,6 +325,7 @@ public class ControlQuest {
|
||||
Singletons.getView().getViewHome().resetQuest();
|
||||
} // New Quest
|
||||
|
||||
/** Changes between quest data files. */
|
||||
private void changeQuest() {
|
||||
AllZone.setQuestData(view.getLstQuests().getSelectedQuest());
|
||||
this.qData = AllZone.getQuestData();
|
||||
@@ -567,10 +569,6 @@ public class ControlQuest {
|
||||
view.getBtnStart().setVisible(true);
|
||||
view.getBarProgress().setVisible(false);
|
||||
|
||||
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
||||
Singletons.getControl().getControlMatch().initMatch();
|
||||
|
||||
AllZone.getMatchState().reset();
|
||||
if (event.getEventType().equals("challenge")) {
|
||||
setupChallenge(currentDeck);
|
||||
} else {
|
||||
@@ -593,7 +591,7 @@ public class ControlQuest {
|
||||
final Deck computer = event.getEventDeck();
|
||||
Constant.Runtime.COMPUTER_DECK[0] = computer;
|
||||
|
||||
AllZone.getGameAction().newGame(
|
||||
GameNew.newGame(
|
||||
Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
||||
QuestUtil.getHumanStartingCards(qData),
|
||||
QuestUtil.getComputerStartingCards(qData),
|
||||
@@ -615,7 +613,7 @@ public class ControlQuest {
|
||||
extraLife = 3;
|
||||
}
|
||||
|
||||
AllZone.getGameAction().newGame(
|
||||
GameNew.newGame(
|
||||
Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
||||
QuestUtil.getHumanStartingCards(qData, event),
|
||||
QuestUtil.getComputerStartingCards(qData, event),
|
||||
|
||||
@@ -19,9 +19,9 @@ import forge.AllZone;
|
||||
import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.game.limited.SealedDeck;
|
||||
import forge.gui.GuiUtils;
|
||||
@@ -124,10 +124,7 @@ public class ControlSealed {
|
||||
view.getBtnStart().setVisible(true);
|
||||
view.getBarProgress().setVisible(false);
|
||||
|
||||
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
||||
Singletons.getControl().getControlMatch().initMatch();
|
||||
|
||||
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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.CardList;
|
||||
import forge.ComputerUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.GameAction;
|
||||
import forge.GameActionUtil;
|
||||
import forge.PhaseHandler;
|
||||
import forge.PhaseUtil;
|
||||
@@ -80,7 +81,7 @@ public class InputMulligan extends Input {
|
||||
public final int doMulligan(final Player player, final GamePlayerRating playerRating) {
|
||||
final CardList hand = player.getCardsIn(Zone.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++) {
|
||||
player.shuffle();
|
||||
@@ -120,6 +121,7 @@ public class InputMulligan extends Input {
|
||||
*/
|
||||
final void end() {
|
||||
// Computer mulligan
|
||||
final GameAction ga = Singletons.getModel().getGameAction();
|
||||
final Player aiPlayer = AllZone.getComputerPlayer();
|
||||
final GamePlayerRating aiRating = Singletons.getModel().getGameSummary().getPlayerRating(aiPlayer.getName());
|
||||
boolean aiTakesMulligan = true;
|
||||
@@ -154,13 +156,13 @@ public class InputMulligan extends Input {
|
||||
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
||||
// If we ever let the AI memorize cards in the players
|
||||
// hand, this would be a place to do so.
|
||||
AllZone.getGameAction().playSpellAbilityNoStack(effect, false);
|
||||
ga.playSpellAbilityNoStack(effect, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c.getName().startsWith("Leyline")) {
|
||||
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")
|
||||
&& !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(Zone.Battlefield,
|
||||
"Leyline of Singularity").size() > 0))) {
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
ga.moveToPlay(c);
|
||||
ga.checkStateEffects();
|
||||
}
|
||||
}
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
ga.checkStateEffects();
|
||||
|
||||
if (AllZone.getGameAction().isStartCut()
|
||||
&& !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) || aiOpeningHand.contains(AllZone
|
||||
.getGameAction().getComputerCut()))) {
|
||||
AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library),
|
||||
AllZone.getGameAction().getHumanCut());
|
||||
AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library),
|
||||
AllZone.getGameAction().getComputerCut());
|
||||
if (ga.isStartCut() && !(humanOpeningHand.contains(ga.getHumanCut())
|
||||
|| aiOpeningHand.contains(ga.getComputerCut()))) {
|
||||
ga.moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), ga.getHumanCut());
|
||||
ga.moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), ga.getComputerCut());
|
||||
}
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
|
||||
ga.checkStateEffects();
|
||||
PhaseHandler.setGameBegins(1);
|
||||
AllZone.getPhaseHandler().setNeedToNextPhase(false);
|
||||
PhaseUtil.visuallyActivatePhase(AllZone.getPhaseHandler().getPhase());
|
||||
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@@ -218,7 +219,7 @@ public class InputMulligan extends Input {
|
||||
if (GameActionUtil.showYesNoDialog(c0, "Use " + c0.getName() + "'s ability?")) {
|
||||
CardList hand = c0.getController().getCardsIn(Zone.Hand);
|
||||
for (Card c : hand) {
|
||||
AllZone.getGameAction().exile(c);
|
||||
Singletons.getModel().getGameAction().exile(c);
|
||||
}
|
||||
c0.getController().drawCards(hand.size());
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class InputPassPriority extends Input implements java.io.Serializable {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class InputPayManaCost extends InputMana {
|
||||
AllZone.getStack().add(this.spell);
|
||||
}
|
||||
} else {
|
||||
this.manaCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost));
|
||||
this.manaCost = Singletons.getModel().getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost));
|
||||
}
|
||||
} else {
|
||||
this.manaCost = new ManaCost(sa.getManaCost());
|
||||
@@ -128,7 +128,7 @@ public class InputPayManaCost extends InputMana {
|
||||
AllZone.getStack().add(this.spell);
|
||||
}
|
||||
} else {
|
||||
this.manaCost = manaCostToPay; // AllZone.getGameAction().getSpellCostChange(sa,
|
||||
this.manaCost = manaCostToPay; // Singletons.getModel().getGameAction().getSpellCostChange(sa,
|
||||
// new
|
||||
// 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.spell.isSpell()) {
|
||||
this.spell.setSourceCard(AllZone.getGameAction().moveToStack(this.originalCard));
|
||||
this.spell.setSourceCard(Singletons.getModel().getGameAction().moveToStack(this.originalCard));
|
||||
}
|
||||
|
||||
if (this.spell.getAfterPayMana() != null) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.Card;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.abilityfactory.AbilityFactoryMana;
|
||||
import forge.card.mana.ManaCost;
|
||||
@@ -188,7 +189,7 @@ public class InputPayManaCostUtil {
|
||||
// save off color needed for use by any mana and reflected mana
|
||||
chosen.setExpressChoice(colorsNeeded);
|
||||
|
||||
AllZone.getGameAction().playSpellAbility(chosen);
|
||||
Singletons.getModel().getGameAction().playSpellAbility(chosen);
|
||||
|
||||
manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.swing.JOptionPane;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.item.CardPrinted;
|
||||
@@ -55,7 +56,7 @@ public class ControlDock {
|
||||
/** Concede game, bring up WinLose UI. */
|
||||
public void concede() {
|
||||
AllZone.getHumanPlayer().concede();
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
Singletons.getModel().getGameAction().checkStateEffects();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,10 +70,10 @@ public class ControlField {
|
||||
private final Player player;
|
||||
private final ViewField view;
|
||||
|
||||
private MouseMotionListener maCardOver;
|
||||
private MouseListener maAvatar, maLibrary, maHand, maExiled, maGraveyard, maFlashback, maCardClick;
|
||||
|
||||
private MouseAdapter maBlack, maBlue, maGreen, maRed, maWhite, maColorless;
|
||||
private MouseMotionListener mmlCardOver;
|
||||
private MouseListener madAvatar, madLibrary, madHand, madExiled,
|
||||
madGraveyard, madFlashback, madCardClick, madBlack,
|
||||
madBlue, madGreen, madRed, madWhite, madColorless;
|
||||
|
||||
private Observer observerZones, observerDetails, observerPlay;
|
||||
|
||||
@@ -93,6 +93,9 @@ public class ControlField {
|
||||
|
||||
initMouseAdapters();
|
||||
initObservers();
|
||||
|
||||
addObservers();
|
||||
addListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,45 +131,31 @@ public class ControlField {
|
||||
*
|
||||
*/
|
||||
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
|
||||
this.view.getTabletop().removeMouseListener(maCardClick);
|
||||
this.view.getTabletop().addMouseListener(maCardClick);
|
||||
this.view.getTabletop().removeMouseListener(madCardClick);
|
||||
this.view.getTabletop().addMouseListener(madCardClick);
|
||||
|
||||
// Battlefield card mouseover
|
||||
this.view.getTabletop().removeMouseMotionListener(maCardOver);
|
||||
this.view.getTabletop().addMouseMotionListener(maCardOver);
|
||||
this.view.getTabletop().removeMouseMotionListener(mmlCardOver);
|
||||
this.view.getTabletop().addMouseMotionListener(mmlCardOver);
|
||||
|
||||
// Player select
|
||||
this.view.getAvatarArea().removeMouseListener(maAvatar);
|
||||
this.view.getAvatarArea().addMouseListener(maAvatar);
|
||||
} // End addListeners()
|
||||
this.view.getAvatarArea().removeMouseListener(madAvatar);
|
||||
this.view.getAvatarArea().addMouseListener(madAvatar);
|
||||
|
||||
/**
|
||||
* 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
|
||||
((FLabel) this.view.getLblGraveyard()).setHoverable(true);
|
||||
this.view.getLblGraveyard().removeMouseListener(maGraveyard);
|
||||
this.view.getLblGraveyard().addMouseListener(maGraveyard);
|
||||
this.view.getLblGraveyard().removeMouseListener(madGraveyard);
|
||||
this.view.getLblGraveyard().addMouseListener(madGraveyard);
|
||||
// Exile card list button
|
||||
((FLabel) this.view.getLblExile()).setHoverable(true);
|
||||
this.view.getLblExile().removeMouseListener(maExiled);
|
||||
this.view.getLblExile().addMouseListener(maExiled);
|
||||
this.view.getLblExile().removeMouseListener(madExiled);
|
||||
this.view.getLblExile().addMouseListener(madExiled);
|
||||
|
||||
// Library card list button
|
||||
if (Constant.Runtime.DEV_MODE[0]) {
|
||||
this.view.getLblLibrary().removeMouseListener(maLibrary);
|
||||
this.view.getLblLibrary().addMouseListener(maLibrary);
|
||||
this.view.getLblLibrary().removeMouseListener(madLibrary);
|
||||
this.view.getLblLibrary().addMouseListener(madLibrary);
|
||||
|
||||
// Hand button
|
||||
((FLabel) this.view.getLblHand()).setHoverable(true);
|
||||
@@ -175,37 +164,37 @@ public class ControlField {
|
||||
((FLabel) this.view.getLblLibrary()).setHoverable(false);
|
||||
}
|
||||
|
||||
this.view.getLblHand().removeMouseListener(maHand);
|
||||
this.view.getLblHand().addMouseListener(maHand);
|
||||
this.view.getLblHand().removeMouseListener(madHand);
|
||||
this.view.getLblHand().addMouseListener(madHand);
|
||||
|
||||
// Flashback card list button
|
||||
((FLabel) this.view.getLblFlashback()).setHoverable(true);
|
||||
this.view.getLblFlashback().removeMouseListener(maFlashback);
|
||||
this.view.getLblFlashback().addMouseListener(maFlashback);
|
||||
}
|
||||
this.view.getLblFlashback().removeMouseListener(madFlashback);
|
||||
this.view.getLblFlashback().addMouseListener(madFlashback);
|
||||
|
||||
/**
|
||||
* Adds listeners to mana "pool" labels, for paying mana.
|
||||
*/
|
||||
private void addPoolListeners() {
|
||||
((FLabel) this.view.getLblBlack()).setHoverable(true);
|
||||
this.view.getLblBlack().removeMouseListener(maBlack);
|
||||
this.view.getLblBlack().addMouseListener(maBlack);
|
||||
this.view.getLblBlack().removeMouseListener(madBlack);
|
||||
this.view.getLblBlack().addMouseListener(madBlack);
|
||||
|
||||
((FLabel) this.view.getLblBlue()).setHoverable(true);
|
||||
this.view.getLblBlue().removeMouseListener(maBlue);
|
||||
this.view.getLblBlue().addMouseListener(maBlue);
|
||||
this.view.getLblBlue().removeMouseListener(madBlue);
|
||||
this.view.getLblBlue().addMouseListener(madBlue);
|
||||
|
||||
((FLabel) this.view.getLblGreen()).setHoverable(true);
|
||||
this.view.getLblGreen().removeMouseListener(maGreen);
|
||||
this.view.getLblGreen().addMouseListener(maGreen);
|
||||
this.view.getLblGreen().removeMouseListener(madGreen);
|
||||
this.view.getLblGreen().addMouseListener(madGreen);
|
||||
|
||||
((FLabel) this.view.getLblRed()).setHoverable(true);
|
||||
this.view.getLblRed().removeMouseListener(maRed);
|
||||
this.view.getLblRed().addMouseListener(maRed);
|
||||
this.view.getLblRed().removeMouseListener(madRed);
|
||||
this.view.getLblRed().addMouseListener(madRed);
|
||||
|
||||
((FLabel) this.view.getLblWhite()).setHoverable(true);
|
||||
this.view.getLblWhite().removeMouseListener(maWhite);
|
||||
this.view.getLblWhite().addMouseListener(maWhite);
|
||||
this.view.getLblWhite().removeMouseListener(madWhite);
|
||||
this.view.getLblWhite().addMouseListener(madWhite);
|
||||
|
||||
((FLabel) this.view.getLblColorless()).setHoverable(true);
|
||||
this.view.getLblColorless().removeMouseListener(maColorless);
|
||||
this.view.getLblColorless().addMouseListener(maColorless);
|
||||
this.view.getLblColorless().removeMouseListener(madColorless);
|
||||
this.view.getLblColorless().addMouseListener(madColorless);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +329,7 @@ public class ControlField {
|
||||
*/
|
||||
private void initMouseAdapters() {
|
||||
// Hand listener
|
||||
maHand = new MouseAdapter() {
|
||||
madHand = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (!ControlField.this.player.isComputer()) {
|
||||
@@ -355,7 +344,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Flashback listener
|
||||
maFlashback = new MouseAdapter() {
|
||||
madFlashback = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (!ControlField.this.player.isComputer()) {
|
||||
@@ -372,7 +361,7 @@ public class ControlField {
|
||||
|
||||
@Override
|
||||
protected void doAction(final Card c) {
|
||||
AllZone.getGameAction().playCard(c);
|
||||
Singletons.getModel().getGameAction().playCard(c);
|
||||
}
|
||||
} .actionPerformed(null);
|
||||
} else {
|
||||
@@ -389,7 +378,7 @@ public class ControlField {
|
||||
|
||||
@Override
|
||||
protected void doAction(final Card c) {
|
||||
AllZone.getGameAction().playCard(c);
|
||||
Singletons.getModel().getGameAction().playCard(c);
|
||||
}
|
||||
} .actionPerformed(null);
|
||||
}
|
||||
@@ -397,7 +386,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Library listener
|
||||
maLibrary = new MouseAdapter() {
|
||||
madLibrary = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (!ControlField.this.player.isComputer()) {
|
||||
@@ -411,7 +400,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Exiled adapter
|
||||
maExiled = new MouseAdapter() {
|
||||
madExiled = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -425,7 +414,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Graveyard adapter
|
||||
maGraveyard = new MouseAdapter() {
|
||||
madGraveyard = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -439,7 +428,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Avatar
|
||||
maAvatar = new MouseAdapter() {
|
||||
madAvatar = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -453,7 +442,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Battlefield card mouse over
|
||||
maCardOver = new MouseMotionAdapter() {
|
||||
mmlCardOver = new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent me) {
|
||||
final Card c = ControlField.this.view.getTabletop().getCardFromMouseOverPanel();
|
||||
@@ -464,7 +453,7 @@ public class ControlField {
|
||||
};
|
||||
|
||||
// Battlefield card
|
||||
maCardClick = new MouseAdapter() {
|
||||
madCardClick = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
|
||||
@@ -519,7 +508,7 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
|
||||
maBlack = new MouseAdapter() {
|
||||
madBlack = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -535,7 +524,7 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
|
||||
maBlue = new MouseAdapter() {
|
||||
madBlue = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -551,7 +540,7 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
|
||||
maGreen = new MouseAdapter() {
|
||||
madGreen = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -567,7 +556,7 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
|
||||
maRed = new MouseAdapter() {
|
||||
madRed = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -583,7 +572,7 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
|
||||
maWhite = new MouseAdapter() {
|
||||
madWhite = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -599,7 +588,7 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
|
||||
maColorless = new MouseAdapter() {
|
||||
madColorless = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (ControlField.this.player.isComputer()) {
|
||||
@@ -615,5 +604,4 @@ public class ControlField {
|
||||
}
|
||||
};
|
||||
} // End initMouseAdapters()
|
||||
|
||||
} // End class ControlField
|
||||
|
||||
@@ -52,8 +52,8 @@ public class ControlHand {
|
||||
private final List<Card> cardsInPanel;
|
||||
private final ViewHand view;
|
||||
|
||||
private MouseListener maCardClick;
|
||||
private MouseMotionListener maCardMove;
|
||||
private final MouseListener madCardClick;
|
||||
private final MouseMotionListener madCardMove;
|
||||
|
||||
/** The o1. */
|
||||
private Observer o1;
|
||||
@@ -69,7 +69,7 @@ public class ControlHand {
|
||||
this.view = v;
|
||||
this.cardsInPanel = new ArrayList<Card>();
|
||||
|
||||
maCardClick = new MouseAdapter() {
|
||||
madCardClick = new MouseAdapter() {
|
||||
// Card click
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
@@ -84,7 +84,7 @@ public class ControlHand {
|
||||
}
|
||||
};
|
||||
|
||||
maCardMove = new MouseMotionAdapter() {
|
||||
madCardMove = new MouseMotionAdapter() {
|
||||
// Card mouseover
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent me) {
|
||||
@@ -162,6 +162,9 @@ public class ControlHand {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addObservers();
|
||||
addListeners();
|
||||
}
|
||||
|
||||
/** Adds observers to hand panel. */
|
||||
@@ -171,11 +174,11 @@ public class ControlHand {
|
||||
|
||||
/** Adds listeners to hand panel: clicks, mouseover, etc. */
|
||||
public void addListeners() {
|
||||
view.getHandArea().removeMouseListener(maCardClick);
|
||||
view.getHandArea().addMouseListener(maCardClick);
|
||||
view.getHandArea().removeMouseListener(madCardClick);
|
||||
view.getHandArea().addMouseListener(madCardClick);
|
||||
|
||||
view.getHandArea().removeMouseMotionListener(maCardMove);
|
||||
view.getHandArea().addMouseMotionListener(maCardMove);
|
||||
view.getHandArea().removeMouseMotionListener(madCardMove);
|
||||
view.getHandArea().addMouseMotionListener(madCardMove);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.awt.event.ActionListener;
|
||||
import forge.AllZone;
|
||||
import forge.Constant;
|
||||
import forge.GuiInput;
|
||||
import forge.Singletons;
|
||||
import forge.view.match.ViewMessage;
|
||||
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ public class ControlMessage {
|
||||
|
||||
private final GuiInput inputControl;
|
||||
|
||||
private ActionListener alCancel = null, alOK = null;
|
||||
private final ActionListener actCancel, actOK;
|
||||
|
||||
/**
|
||||
* Child controller - handles operations related to input panel.
|
||||
@@ -46,7 +47,7 @@ public class ControlMessage {
|
||||
this.view = v;
|
||||
this.inputControl = new GuiInput();
|
||||
|
||||
this.alOK = new ActionListener() {
|
||||
this.actOK = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent evt) {
|
||||
ControlMessage.this.btnOKActionPerformed(evt);
|
||||
@@ -60,22 +61,24 @@ public class ControlMessage {
|
||||
}
|
||||
};
|
||||
|
||||
this.alCancel = new ActionListener() {
|
||||
this.actCancel = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent evt) {
|
||||
ControlMessage.this.btnCancelActionPerformed(evt);
|
||||
ControlMessage.this.view.getBtnOK().requestFocusInWindow();
|
||||
}
|
||||
};
|
||||
|
||||
addListeners();
|
||||
}
|
||||
|
||||
/** Adds listeners to input area. */
|
||||
public void addListeners() {
|
||||
this.view.getBtnCancel().removeActionListener(alCancel);
|
||||
this.view.getBtnCancel().addActionListener(alCancel);
|
||||
this.view.getBtnCancel().removeActionListener(actCancel);
|
||||
this.view.getBtnCancel().addActionListener(actCancel);
|
||||
|
||||
this.view.getBtnOK().removeActionListener(alOK);
|
||||
this.view.getBtnOK().addActionListener(alOK);
|
||||
this.view.getBtnOK().removeActionListener(actOK);
|
||||
this.view.getBtnOK().addActionListener(actOK);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,8 +125,8 @@ public class ControlMessage {
|
||||
/** Updates count label in input area. */
|
||||
public void updateGameCount() {
|
||||
view.getLblGames().setText("<html>Game #"
|
||||
+ (AllZone.getMatchState().getGamesPlayedCount() + 1)
|
||||
+ " of " + AllZone.getMatchState().getGamesPerMatch()
|
||||
+ (Singletons.getModel().getMatchState().getGamesPlayedCount() + 1)
|
||||
+ " of " + Singletons.getModel().getMatchState().getGamesPerMatch()
|
||||
+ "<br>" + Constant.Runtime.getGameType().toString() + " mode</html>");
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ import forge.view.match.ViewTabber;
|
||||
*/
|
||||
public class ControlTabber extends MyObservable {
|
||||
private final ViewTabber view;
|
||||
private MouseListener maMilling, maUnlimited,
|
||||
maMana, maSetup, maTutor, maCounter, maTap, maUntap, maLife;
|
||||
private final MouseListener madMilling, madUnlimited,
|
||||
madMana, madSetup, madTutor, madCounter, madTap, madUntap, madLife;
|
||||
|
||||
private Observer stackObserver, logObserver;
|
||||
private Observer obsStack, obsLog;
|
||||
|
||||
/** */
|
||||
public static final int STACK_PANEL = 0;
|
||||
@@ -75,73 +75,98 @@ public class ControlTabber extends MyObservable {
|
||||
this.view.getLblUnlimitedLands().setEnabled(false);
|
||||
}
|
||||
|
||||
// Various mouse adapters for dev buttons
|
||||
initMouseAdapters();
|
||||
|
||||
initObservers();
|
||||
}
|
||||
|
||||
private void initObservers() {
|
||||
// Stack
|
||||
stackObserver = new Observer() {
|
||||
@Override
|
||||
// Observers and listeners
|
||||
obsStack = new Observer() { @Override
|
||||
public void update(final Observable a, final Object b) {
|
||||
ControlTabber.this.view.updateStack();
|
||||
}
|
||||
};
|
||||
ControlTabber.this.view.updateStack(); } };
|
||||
|
||||
//Game Log
|
||||
logObserver = new Observer() {
|
||||
@Override
|
||||
obsLog = new Observer() { @Override
|
||||
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. */
|
||||
public void addObservers() {
|
||||
AllZone.getStack().addObserver(stackObserver);
|
||||
AllZone.getGameLog().addObserver(logObserver);
|
||||
AllZone.getStack().addObserver(obsStack);
|
||||
AllZone.getGameLog().addObserver(obsLog);
|
||||
}
|
||||
|
||||
/** Adds listeners to various components in tabber. */
|
||||
public void addListeners() {
|
||||
// Milling enable toggle
|
||||
this.view.getLblMilling().removeMouseListener(maMilling);
|
||||
this.view.getLblMilling().addMouseListener(maMilling);
|
||||
this.view.getLblMilling().removeMouseListener(madMilling);
|
||||
this.view.getLblMilling().addMouseListener(madMilling);
|
||||
|
||||
// DevMode: Play unlimited land this turn toggle
|
||||
this.view.getLblUnlimitedLands().removeMouseListener(maUnlimited);
|
||||
this.view.getLblUnlimitedLands().addMouseListener(maUnlimited);
|
||||
this.view.getLblUnlimitedLands().removeMouseListener(madUnlimited);
|
||||
this.view.getLblUnlimitedLands().addMouseListener(madUnlimited);
|
||||
|
||||
// DevMode: Generate mana
|
||||
this.view.getLblGenerateMana().removeMouseListener(maMana);
|
||||
this.view.getLblGenerateMana().addMouseListener(maMana);
|
||||
this.view.getLblGenerateMana().removeMouseListener(madMana);
|
||||
this.view.getLblGenerateMana().addMouseListener(madMana);
|
||||
|
||||
// DevMode: Battlefield setup
|
||||
this.view.getLblSetupGame().removeMouseListener(maSetup);
|
||||
this.view.getLblSetupGame().addMouseListener(maSetup);
|
||||
this.view.getLblSetupGame().removeMouseListener(madSetup);
|
||||
this.view.getLblSetupGame().addMouseListener(madSetup);
|
||||
|
||||
// DevMode: Tutor for card
|
||||
this.view.getLblTutor().removeMouseListener(maTutor);
|
||||
this.view.getLblTutor().addMouseListener(maTutor);
|
||||
this.view.getLblTutor().removeMouseListener(madTutor);
|
||||
this.view.getLblTutor().addMouseListener(madTutor);
|
||||
|
||||
// DevMode: Add counter to permanent
|
||||
this.view.getLblCounterPermanent().removeMouseListener(maCounter);
|
||||
this.view.getLblCounterPermanent().addMouseListener(maCounter);
|
||||
this.view.getLblCounterPermanent().removeMouseListener(madCounter);
|
||||
this.view.getLblCounterPermanent().addMouseListener(madCounter);
|
||||
|
||||
// DevMode: Tap permanent
|
||||
this.view.getLblTapPermanent().removeMouseListener(maTap);
|
||||
this.view.getLblTapPermanent().addMouseListener(maTap);
|
||||
this.view.getLblTapPermanent().removeMouseListener(madTap);
|
||||
this.view.getLblTapPermanent().addMouseListener(madTap);
|
||||
|
||||
// DevMode: Untap permanent
|
||||
this.view.getLblUntapPermanent().removeMouseListener(maUntap);
|
||||
this.view.getLblUntapPermanent().addMouseListener(maUntap);
|
||||
this.view.getLblUntapPermanent().removeMouseListener(madUntap);
|
||||
this.view.getLblUntapPermanent().addMouseListener(madUntap);
|
||||
|
||||
// DevMode: Set life
|
||||
this.view.getLblSetLife().removeMouseListener(maLife);
|
||||
this.view.getLblSetLife().addMouseListener(maLife);
|
||||
this.view.getLblSetLife().removeMouseListener(madLife);
|
||||
this.view.getLblSetLife().addMouseListener(madLife);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,72 +216,4 @@ public class ControlTabber extends MyObservable {
|
||||
public void showPnlStack() {
|
||||
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();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import forge.Constant.Zone;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.item.CardDb;
|
||||
@@ -66,16 +67,15 @@ public class ControlWinLose {
|
||||
|
||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||
public void actionOnRestart() {
|
||||
AllZone.getMatchState().reset();
|
||||
Singletons.getModel().getMatchState().reset();
|
||||
GuiUtils.closeOverlay();
|
||||
startNextRound();
|
||||
}
|
||||
|
||||
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
||||
public void actionOnQuit() {
|
||||
AllZone.getMatchState().reset();
|
||||
Singletons.getModel().getMatchState().reset();
|
||||
Singletons.getModel().savePrefs();
|
||||
Singletons.getControl().getControlMatch().deinitMatch();
|
||||
Singletons.getControl().changeState(FControl.HOME_SCREEN);
|
||||
GuiUtils.closeOverlay();
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class ControlWinLose {
|
||||
if (isAnte && !gameType.equals(GameType.Quest)) {
|
||||
Deck hDeck = Constant.Runtime.HUMAN_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);
|
||||
|
||||
//remove compy's ante cards form his deck
|
||||
@@ -122,7 +122,7 @@ public class ControlWinLose {
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
543
src/main/java/forge/game/GameNew.java
Normal file
543
src/main/java/forge/game/GameNew.java
Normal 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
|
||||
*   {@link forge.deck.Deck} object.
|
||||
* @param computerDeck
|
||||
*   {@link forge.deck.Deck} object.
|
||||
* @param human
|
||||
*   {@link forge.CardList} object.
|
||||
* @param computer
|
||||
*   {@link forge.CardList} object.
|
||||
* @param humanLife
|
||||
*   int.
|
||||
* @param computerLife
|
||||
*   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
|
||||
*   {@link forge.deck.Deck} object.
|
||||
* @param computerDeck
|
||||
*   {@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());
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.model;
|
||||
package forge.game;
|
||||
|
||||
import forge.AIPlayer;
|
||||
import forge.Combat;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.DefaultPlayerZone;
|
||||
import forge.EndOfCombat;
|
||||
import forge.EndOfTurn;
|
||||
import forge.GameAction;
|
||||
import forge.GameLog;
|
||||
import forge.HumanPlayer;
|
||||
import forge.MagicStack;
|
||||
@@ -32,17 +30,16 @@ import forge.PhaseHandler;
|
||||
import forge.Player;
|
||||
import forge.PlayerZone;
|
||||
import forge.StaticEffects;
|
||||
import forge.Upkeep;
|
||||
import forge.Untap;
|
||||
import forge.Upkeep;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.game.GameSummary;
|
||||
|
||||
/**
|
||||
* Represents the state of a <i>single game</i> and is
|
||||
* "cleaned up" at each new game.
|
||||
*/
|
||||
public class FGameState {
|
||||
public class GameState {
|
||||
|
||||
/** The Constant HUMAN_PLAYER_NAME. */
|
||||
public static final String HUMAN_PLAYER_NAME = "Human";
|
||||
@@ -50,18 +47,17 @@ public class FGameState {
|
||||
/** The Constant AI_PLAYER_NAME. */
|
||||
public static final String AI_PLAYER_NAME = "Computer";
|
||||
|
||||
private Player humanPlayer = new HumanPlayer(FGameState.HUMAN_PLAYER_NAME);
|
||||
private Player computerPlayer = new AIPlayer(FGameState.AI_PLAYER_NAME);
|
||||
private Player humanPlayer = new HumanPlayer(GameState.HUMAN_PLAYER_NAME);
|
||||
private Player computerPlayer = new AIPlayer(GameState.AI_PLAYER_NAME);
|
||||
private EndOfTurn endOfTurn = new EndOfTurn();
|
||||
private EndOfCombat endOfCombat = new EndOfCombat();
|
||||
private Untap untap = new Untap();
|
||||
private Upkeep upkeep = new Upkeep();
|
||||
private PhaseHandler phaseHandler = new PhaseHandler();
|
||||
private MagicStack stack = new MagicStack();
|
||||
private GameAction gameAction = new GameAction();
|
||||
private StaticEffects staticEffects = new StaticEffects();
|
||||
private TriggerHandler triggerHandler = new TriggerHandler();
|
||||
private ReplacementHandler replacementHandler = new ReplacementHandler();
|
||||
private final ReplacementHandler replacementHandler = new ReplacementHandler();
|
||||
private Combat combat = new Combat();
|
||||
private GameLog gameLog = new GameLog();
|
||||
|
||||
@@ -73,7 +69,7 @@ public class FGameState {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the phase.
|
||||
*
|
||||
* @param phaseHandlerIn
|
||||
* the phaseHandler to set
|
||||
*/
|
||||
protected final void setPhaseHandler(final PhaseHandler phaseHandlerIn) {
|
||||
this.phaseHandler = phaseHandlerIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stack.
|
||||
*
|
||||
@@ -237,25 +223,6 @@ public class FGameState {
|
||||
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.
|
||||
*
|
||||
@@ -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() {
|
||||
this.gameSummary = new GameSummary(this.humanPlayer.getName(), this.computerPlayer.getName());
|
||||
|
||||
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();
|
||||
public final void setGameSummary(final GameSummary summary0) {
|
||||
this.gameSummary = summary0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,13 +32,16 @@ import forge.ComputerAIGeneral;
|
||||
import forge.ComputerAIInput;
|
||||
import forge.Constant;
|
||||
import forge.ConstantStringArrayList;
|
||||
import forge.GameAction;
|
||||
import forge.Singletons;
|
||||
import forge.control.input.InputControl;
|
||||
import forge.game.GameState;
|
||||
import forge.game.GameSummary;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.data.QuestEventManager;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.util.FileUtil;
|
||||
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
|
||||
* 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 final transient OutputStream logFileStream;
|
||||
private final transient PrintStream oldSystemOut;
|
||||
private final transient PrintStream oldSystemErr;
|
||||
private final PrintStream oldSystemOut;
|
||||
private final PrintStream oldSystemErr;
|
||||
private BuildInfo buildInfo;
|
||||
private OutputStream logFileStream;
|
||||
|
||||
/** The preferences. */
|
||||
private final GameAction gameAction;
|
||||
private final QuestPreferences questPreferences;
|
||||
private final ForgePreferences preferences;
|
||||
private FGameState gameState;
|
||||
private final QuestEventManager questEventManager;
|
||||
private final GameState gameState;
|
||||
private final FMatchState matchState;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -74,7 +81,7 @@ public class FModel {
|
||||
* @throws FileNotFoundException
|
||||
* if we could not find or write to the log file.
|
||||
*/
|
||||
public FModel() throws FileNotFoundException {
|
||||
private FModel() {
|
||||
// Fire up log file
|
||||
final File logFile = new File("forge.log");
|
||||
final boolean deleteSucceeded = logFile.delete();
|
||||
@@ -83,22 +90,29 @@ public class FModel {
|
||||
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;
|
||||
System.setOut(new PrintStream(new MultiplexOutputStream(System.out, this.logFileStream), true));
|
||||
this.oldSystemErr = System.err;
|
||||
System.setErr(new PrintStream(new MultiplexOutputStream(System.err, this.logFileStream), true));
|
||||
|
||||
// Instantiate preferences
|
||||
// Instantiate preferences: quest and regular
|
||||
try {
|
||||
this.preferences = new ForgePreferences();
|
||||
} catch (final Exception 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.questEventManager = new QuestEventManager();
|
||||
|
||||
// TODO this single setting from preferences should not be here, or,
|
||||
// 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.
|
||||
*
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -326,16 +341,6 @@ public class FModel {
|
||||
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
|
||||
* codebase.
|
||||
@@ -437,4 +442,19 @@ public class FModel {
|
||||
Singletons.getView().getViewMatch().setLayoutParams(fp.getPref(FPref.UI_LAYOUT_PARAMS));
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,6 @@ public class QuestEventManager {
|
||||
/** The all challenges. */
|
||||
private List<QuestChallenge> allChallenges = null;
|
||||
|
||||
private final QuestPreferences qpref;
|
||||
|
||||
/** */
|
||||
public QuestEventManager() {
|
||||
this.qpref = Singletons.getModel().getQuestPreferences();
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* assembleAllEvents.
|
||||
@@ -106,6 +100,22 @@ public class QuestEventManager {
|
||||
|
||||
} // End assembleAllEvents()
|
||||
|
||||
/**
|
||||
* Retrieve single event, using its name.
|
||||
*
|
||||
* @param s0   {@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>
|
||||
* assembleDuelUniqueData.
|
||||
@@ -363,6 +373,7 @@ public class QuestEventManager {
|
||||
* @return an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
public final List<QuestDuel> generateDuels() {
|
||||
final QuestPreferences qpref = Singletons.getModel().getQuestPreferences();
|
||||
if (AllZone.getQuestData() == null) { return null; }
|
||||
|
||||
final int index = AllZone.getQuestData().getDifficultyIndex();
|
||||
|
||||
@@ -48,22 +48,15 @@ public final class Main {
|
||||
public static void main(final String[] args) {
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
try {
|
||||
final FModel model = new FModel();
|
||||
final FView view = new FView();
|
||||
final FControl control = FControl.SINGLETON_INSTANCE;
|
||||
|
||||
Singletons.setModel(model);
|
||||
Singletons.setView(view);
|
||||
Singletons.setControl(control);
|
||||
|
||||
// Instantiate FGameState for TriggerHandler on card objects created in preloader.
|
||||
model.resetGameState();
|
||||
Singletons.setModel(FModel.SINGLETON_INSTANCE);
|
||||
Singletons.setView(new FView());
|
||||
Singletons.setControl(FControl.SINGLETON_INSTANCE);
|
||||
|
||||
// Start splash frame.
|
||||
view.initialize();
|
||||
Singletons.getView().initialize();
|
||||
|
||||
// Start control on FView.
|
||||
control.initialize();
|
||||
Singletons.getControl().initialize();
|
||||
|
||||
// Open previous menu on first run, or constructed.
|
||||
// Focus is reset when the frame becomes visible,
|
||||
@@ -105,4 +98,18 @@ public final class Main {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.swing.border.LineBorder;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.AllZone;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.view.toolbox.FLabel;
|
||||
@@ -147,11 +148,15 @@ public class ConstructedDeckSelectPanel extends JPanel {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
listSelectManager((JList) e.getSource());
|
||||
|
||||
if (e.getClickCount() == 2
|
||||
&& (((JList) e.getSource()).getName().equals("lstQuest") || ((JList) e.getSource()).getName().equals("lstCustom"))) {
|
||||
if (e.getClickCount() == 2 && ((JList) e.getSource()).getName().equals("lstCustom")) {
|
||||
final String deckName = ((JList) e.getSource()).getSelectedValue().toString();
|
||||
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());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import forge.control.match.ControlWinLose;
|
||||
import forge.game.GameEndReason;
|
||||
import forge.game.GameFormat;
|
||||
import forge.game.GameLossReason;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GamePlayerRating;
|
||||
import forge.game.GameSummary;
|
||||
import forge.gui.GuiUtils;
|
||||
@@ -88,7 +89,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
public QuestWinLoseHandler(final ViewWinLose view0) {
|
||||
super(view0);
|
||||
this.view = view0;
|
||||
matchState = AllZone.getMatchState();
|
||||
matchState = Singletons.getModel().getMatchState();
|
||||
qData = AllZone.getQuestData();
|
||||
qEvent = AllZone.getQuestEvent();
|
||||
this.wonMatch = matchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
|
||||
@@ -126,7 +127,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
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);
|
||||
} else {
|
||||
super.startNextRound();
|
||||
@@ -151,14 +152,14 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
if (matchState.hasWonLastGame(AllZone.getHumanPlayer().getName())) {
|
||||
if (isAnte) {
|
||||
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);
|
||||
|
||||
}
|
||||
} else {
|
||||
if (isAnte) {
|
||||
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) {
|
||||
//the last param here (should) determine if this is added to the Card Shop
|
||||
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
|
||||
// Note: Antes lost have already been remove from decks.
|
||||
AllZone.getMatchState().addAnteWonToCardPool();
|
||||
Singletons.getModel().getMatchState().addAnteWonToCardPool();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -291,7 +292,6 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
Singletons.getModel().getQuestPreferences().save();
|
||||
Singletons.getModel().savePrefs();
|
||||
|
||||
Singletons.getControl().getControlMatch().deinitMatch();
|
||||
Singletons.getControl().changeState(FControl.HOME_SCREEN);
|
||||
Singletons.getView().getViewHome().showQuestMenu();
|
||||
GuiUtils.closeOverlay();
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ViewWinLose {
|
||||
/** */
|
||||
public ViewWinLose() {
|
||||
final FOverlay overlay = Singletons.getView().getOverlay();
|
||||
final FMatchState matchState = AllZone.getMatchState();
|
||||
final FMatchState matchState = Singletons.getModel().getMatchState();
|
||||
|
||||
final JPanel pnlLeft = new JPanel();
|
||||
final JPanel pnlRight = new JPanel();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class FModelTest {
|
||||
*/
|
||||
@BeforeTest
|
||||
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");
|
||||
|
||||
this.model = new FModel();
|
||||
// this.model = new FModel();
|
||||
Assert.assertNotNull(this.model, "model is not null");
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ public class FModelTest {
|
||||
Singletons.setModel(this.model);
|
||||
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");
|
||||
|
||||
final FGameState state2 = this.model.resetGameState();
|
||||
final GameState state2 = this.model.resetGameState();
|
||||
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");*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user