diff --git a/src/main/java/forge/ImageCache.java b/src/main/java/forge/ImageCache.java index b73cbef1ef4..c47d61bde5b 100644 --- a/src/main/java/forge/ImageCache.java +++ b/src/main/java/forge/ImageCache.java @@ -36,6 +36,7 @@ import com.mortennobel.imagescaling.ResampleOp; import forge.card.CardRules; import forge.card.CardSplitType; +import forge.control.FControl; import forge.game.player.IHasIcon; import forge.gui.toolbox.FSkin; import forge.item.BoosterPack; @@ -104,7 +105,7 @@ public class ImageCache { */ public static BufferedImage getImage(Card card, int width, int height) { final String key; - if (!card.canBeShownTo(Singletons.getControl().getPlayer()) || card.isFaceDown()) { + if (!FControl.SINGLETON_INSTANCE.mayShowCard(card) || card.isFaceDown()) { key = TOKEN_PREFIX + NewConstants.CACHE_MORPH_IMAGE_FILE; } else { key = card.getImageKey(); diff --git a/src/main/java/forge/control/FControl.java b/src/main/java/forge/control/FControl.java index d7151ca5e0c..d4a7a4a7719 100644 --- a/src/main/java/forge/control/FControl.java +++ b/src/main/java/forge/control/FControl.java @@ -31,6 +31,7 @@ import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; +import forge.Card; import forge.Singletons; import forge.control.KeyboardShortcuts.Shortcut; import forge.game.MatchController; @@ -284,12 +285,6 @@ public enum FControl { if (children.length != 0) { children[0].setSize(display.getSize()); } } - /** @return {@link forge.game.player.Player} */ - private Player localPlayer; - public Player getPlayer() { - return localPlayer; - } - /** * TODO: Write javadoc for this method. * @return @@ -301,13 +296,10 @@ public enum FControl { } return lobby; } - - /** - * TODO: Write javadoc for this method. - * @param localHuman - */ - public void setPlayer(Player localHuman) { - localPlayer = localHuman; + + public boolean mayShowCard(Card c) { + Player p = match.getCurrentGame().getPhaseHandler().getPriorityPlayer(); + return c.canBeShownTo(p); } /** diff --git a/src/main/java/forge/game/MatchController.java b/src/main/java/forge/game/MatchController.java index 1f7aa793e80..5863d9d929e 100644 --- a/src/main/java/forge/game/MatchController.java +++ b/src/main/java/forge/game/MatchController.java @@ -181,16 +181,6 @@ public class MatchController { GameState game = match.getCurrentGame(); game.getEvents().register(Singletons.getControl().getSoundSystem()); - Player localHuman = null; - for(Player p : game.getPlayers()) { - if ( p.getLobbyPlayer() != humanLobbyPlayer) - continue; - localHuman = p; - break; - } - - FControl.SINGLETON_INSTANCE.setPlayer(localHuman); - // The UI controls should use these game data as models CMatchUI.SINGLETON_INSTANCE.initMatch(game.getRegisteredPlayers(), humanLobbyPlayer); CDock.SINGLETON_INSTANCE.setModel(game, humanLobbyPlayer); diff --git a/src/main/java/forge/gui/CardDetailPanel.java b/src/main/java/forge/gui/CardDetailPanel.java index 22c8a3eb1e6..d9c5219900e 100644 --- a/src/main/java/forge/gui/CardDetailPanel.java +++ b/src/main/java/forge/gui/CardDetailPanel.java @@ -41,6 +41,7 @@ import forge.CounterType; import forge.GameEntity; import forge.Singletons; import forge.card.CardEdition; +import forge.control.FControl; import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.gui.toolbox.FLabel; @@ -211,7 +212,7 @@ public class CardDetailPanel extends FPanel { return; } - final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer()); + final boolean canShowThis = FControl.SINGLETON_INSTANCE.mayShowCard(card); if (canShowThis) { if (card.getManaCost().isNoCost()) { this.nameCostLabel.setText(card.getName()); @@ -488,7 +489,7 @@ public class CardDetailPanel extends FPanel { if (entity instanceof Card) { final Card c = (Card) entity; - if (!c.canBeShownTo(Singletons.getControl().getPlayer())) { + if (!FControl.SINGLETON_INSTANCE.mayShowCard(c)) { area.append("Morph ("); area.append(card.getUniqueNumber()); area.append(")"); diff --git a/src/main/java/forge/gui/GuiChoose.java b/src/main/java/forge/gui/GuiChoose.java index 418e8eda1ed..f2fb1e5e45a 100644 --- a/src/main/java/forge/gui/GuiChoose.java +++ b/src/main/java/forge/gui/GuiChoose.java @@ -19,7 +19,7 @@ import javax.swing.event.ListSelectionListener; import forge.Card; import forge.FThreads; -import forge.Singletons; +import forge.control.FControl; import forge.gui.match.CMatchUI; import forge.item.InventoryItem; @@ -120,7 +120,7 @@ public class GuiChoose { public void valueChanged(final ListSelectionEvent ev) { if (list.getSelectedValue() instanceof Card) { Card card = (Card) list.getSelectedValue(); - if (card.isFaceDown() && card.canBeShownTo(Singletons.getControl().getPlayer())) { + if (card.isFaceDown() && FControl.SINGLETON_INSTANCE.mayShowCard(card)) { CMatchUI.SINGLETON_INSTANCE.setCard(card, true); } else { CMatchUI.SINGLETON_INSTANCE.setCard(card); diff --git a/src/main/java/forge/gui/GuiDisplayUtil.java b/src/main/java/forge/gui/GuiDisplayUtil.java index e7c8651b40e..2721e981144 100644 --- a/src/main/java/forge/gui/GuiDisplayUtil.java +++ b/src/main/java/forge/gui/GuiDisplayUtil.java @@ -120,7 +120,7 @@ public final class GuiDisplayUtil { public static void devModeGenerateMana() { final Card dummy = new Card(); - dummy.setOwner(getPlayer()); + dummy.setOwner(getGame().getPhaseHandler().getPriorityPlayer()); Map produced = new HashMap(); produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7"); final AbilityManaPart abMana = new AbilityManaPart(dummy, produced); @@ -286,8 +286,8 @@ public final class GuiDisplayUtil { List humanDevExileSetup = new ArrayList(); List computerDevExileSetup = new ArrayList(); - final Player human = getPlayer(); - final Player ai = human.getOpponents().get(0); + final Player human = getGame().getPlayers().get(0); + final Player ai = getGame().getPlayers().get(1); if (!tChangePlayer.trim().toLowerCase().equals("none")) { if (tChangePlayer.trim().toLowerCase().equals("human")) { @@ -454,7 +454,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeTutor() { - final List lib = getPlayer().getCardsIn(ZoneType.Library); + final List lib = getGame().getPhaseHandler().getPriorityPlayer().getCardsIn(ZoneType.Library); final Object o = GuiChoose.oneOrNone("Choose a card", lib); if (null == o) { return; @@ -531,16 +531,6 @@ public final class GuiDisplayUtil { } } - /** - *

- * devModeUnlimitedLand. - *

- * - * @since 1.0.16 - */ - public static void devModeUnlimitedLand() { - getPlayer().addMaxLandsToPlay(100); - } /** *

@@ -636,7 +626,7 @@ public final class GuiDisplayUtil { game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least) // Human player is choosing targets for an ability controlled by chosen player. sa.setActivatingPlayer(p); - HumanPlay.playSaWithoutPayingManaCost(getPlayer(), sa); + HumanPlay.playSaWithoutPayingManaCost(game.getPhaseHandler().getPriorityPlayer(), sa); } }); } @@ -704,9 +694,6 @@ public final class GuiDisplayUtil { private static GameState getGame() { return Singletons.getControl().getMatch().getCurrentGame(); } - - private static Player getPlayer() { - return Singletons.getControl().getPlayer(); - } + } // end class GuiDisplayUtil diff --git a/src/main/java/forge/gui/match/LimitedWinLose.java b/src/main/java/forge/gui/match/LimitedWinLose.java index 27219ade084..2d3bde71583 100644 --- a/src/main/java/forge/gui/match/LimitedWinLose.java +++ b/src/main/java/forge/gui/match/LimitedWinLose.java @@ -58,7 +58,7 @@ public class LimitedWinLose extends ControlWinLose { super(view0, match); this.view = view0; gauntlet = Singletons.getModel().getGauntletMini(); - this.wonMatch = match.isWonBy(Singletons.getControl().getPlayer().getLobbyPlayer()); + this.wonMatch = match.isWonBy(Singletons.getControl().getLobby().getGuiPlayer()); } @@ -80,8 +80,7 @@ public class LimitedWinLose extends ControlWinLose { nextRound = false; - - if (match.getLastGameOutcome().isWinner(Singletons.getControl().getPlayer().getLobbyPlayer())) { + if (match.getLastGameOutcome().isWinner(Singletons.getControl().getLobby().getGuiPlayer())) { gauntlet.addWin(); } else { gauntlet.addLoss(); diff --git a/src/main/java/forge/gui/match/controllers/CDetail.java b/src/main/java/forge/gui/match/controllers/CDetail.java index d27cbcc0d04..ac57b3884ba 100644 --- a/src/main/java/forge/gui/match/controllers/CDetail.java +++ b/src/main/java/forge/gui/match/controllers/CDetail.java @@ -22,7 +22,7 @@ import java.awt.event.MouseEvent; import forge.Card; import forge.Command; -import forge.Singletons; +import forge.control.FControl; import forge.gui.framework.ICDoc; import forge.gui.match.views.VDetail; import forge.item.IPaperCard; @@ -45,7 +45,7 @@ public enum CDetail implements ICDoc { * @param c   Card object */ public void showCard(final Card c) { - view.getLblFlipcard().setVisible(c != null && (c.isDoubleFaced() || c.isFlipCard() || c.isFaceDown() && c.canBeShownTo(Singletons.getControl().getPlayer()))); + view.getLblFlipcard().setVisible(c != null && (c.isDoubleFaced() || c.isFlipCard() || c.isFaceDown() && FControl.SINGLETON_INSTANCE.mayShowCard(c))); view.getPnlDetail().setCard(c); view.getParentCell().repaintSelf(); } diff --git a/src/main/java/forge/gui/match/controllers/CPicture.java b/src/main/java/forge/gui/match/controllers/CPicture.java index 9f54d53aa64..e1206aa99c7 100644 --- a/src/main/java/forge/gui/match/controllers/CPicture.java +++ b/src/main/java/forge/gui/match/controllers/CPicture.java @@ -22,7 +22,7 @@ import java.awt.event.MouseEvent; import forge.Card; import forge.CardCharacteristicName; import forge.Command; -import forge.Singletons; +import forge.control.FControl; import forge.gui.framework.ICDoc; import forge.gui.match.views.VPicture; import forge.item.IPaperCard; @@ -48,7 +48,7 @@ public enum CPicture implements ICDoc { *   Card object */ public void showCard(final Card c, boolean showFlipped) { - cameFaceDown = c.isFaceDown() && c.canBeShownTo(Singletons.getControl().getPlayer()); + cameFaceDown = c.isFaceDown() && FControl.SINGLETON_INSTANCE.mayShowCard(c); canFlip = c.isDoubleFaced() || c.isFlipCard() || cameFaceDown; currentCard = c; flipped = canFlip && (c.getCurState() == CardCharacteristicName.Transformed || diff --git a/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java b/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java index 8bf7c2520b5..04ca9bb5d5a 100644 --- a/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java +++ b/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java @@ -6,8 +6,8 @@ import java.util.List; import forge.Card; import forge.CardCharacteristicName; -import forge.Singletons; import forge.card.cardfactory.CardFactory; +import forge.control.FControl; import forge.game.zone.PlayerZone; import forge.gui.ForgeAction; import forge.gui.GuiChoose; @@ -54,7 +54,7 @@ class ZoneAction extends ForgeAction { for (Card crd : choices) { Card toAdd = crd; if (crd.isFaceDown()) { - if (crd.canBeShownTo(Singletons.getControl().getPlayer())) { + if (FControl.SINGLETON_INSTANCE.mayShowCard(crd)) { toAdd = CardFactory.copyCard(crd); toAdd.setState(CardCharacteristicName.Original); } else {