mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
FControl no longer keeps reference to single player.
canShowCard is located at FControl where the current player is determined (quite roughly at the moment)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
@@ -302,12 +297,9 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(")");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<String, String> produced = new HashMap<String, String>();
|
||||
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<Card> humanDevExileSetup = new ArrayList<Card>();
|
||||
List<Card> computerDevExileSetup = new ArrayList<Card>();
|
||||
|
||||
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<Card> lib = getPlayer().getCardsIn(ZoneType.Library);
|
||||
final List<Card> 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 {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeUnlimitedLand.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.0.16
|
||||
*/
|
||||
public static void devModeUnlimitedLand() {
|
||||
getPlayer().addMaxLandsToPlay(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -705,8 +695,5 @@ public final class GuiDisplayUtil {
|
||||
return Singletons.getControl().getMatch().getCurrentGame();
|
||||
}
|
||||
|
||||
private static Player getPlayer() {
|
||||
return Singletons.getControl().getPlayer();
|
||||
}
|
||||
|
||||
} // end class GuiDisplayUtil
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user