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.CardRules;
|
||||||
import forge.card.CardSplitType;
|
import forge.card.CardSplitType;
|
||||||
|
import forge.control.FControl;
|
||||||
import forge.game.player.IHasIcon;
|
import forge.game.player.IHasIcon;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.item.BoosterPack;
|
import forge.item.BoosterPack;
|
||||||
@@ -104,7 +105,7 @@ public class ImageCache {
|
|||||||
*/
|
*/
|
||||||
public static BufferedImage getImage(Card card, int width, int height) {
|
public static BufferedImage getImage(Card card, int width, int height) {
|
||||||
final String key;
|
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;
|
key = TOKEN_PREFIX + NewConstants.CACHE_MORPH_IMAGE_FILE;
|
||||||
} else {
|
} else {
|
||||||
key = card.getImageKey();
|
key = card.getImageKey();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
|
import forge.Card;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.control.KeyboardShortcuts.Shortcut;
|
import forge.control.KeyboardShortcuts.Shortcut;
|
||||||
import forge.game.MatchController;
|
import forge.game.MatchController;
|
||||||
@@ -284,12 +285,6 @@ public enum FControl {
|
|||||||
if (children.length != 0) { children[0].setSize(display.getSize()); }
|
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.
|
* TODO: Write javadoc for this method.
|
||||||
* @return
|
* @return
|
||||||
@@ -302,12 +297,9 @@ public enum FControl {
|
|||||||
return lobby;
|
return lobby;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean mayShowCard(Card c) {
|
||||||
* TODO: Write javadoc for this method.
|
Player p = match.getCurrentGame().getPhaseHandler().getPriorityPlayer();
|
||||||
* @param localHuman
|
return c.canBeShownTo(p);
|
||||||
*/
|
|
||||||
public void setPlayer(Player localHuman) {
|
|
||||||
localPlayer = localHuman;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -181,16 +181,6 @@ public class MatchController {
|
|||||||
GameState game = match.getCurrentGame();
|
GameState game = match.getCurrentGame();
|
||||||
game.getEvents().register(Singletons.getControl().getSoundSystem());
|
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
|
// The UI controls should use these game data as models
|
||||||
CMatchUI.SINGLETON_INSTANCE.initMatch(game.getRegisteredPlayers(), humanLobbyPlayer);
|
CMatchUI.SINGLETON_INSTANCE.initMatch(game.getRegisteredPlayers(), humanLobbyPlayer);
|
||||||
CDock.SINGLETON_INSTANCE.setModel(game, humanLobbyPlayer);
|
CDock.SINGLETON_INSTANCE.setModel(game, humanLobbyPlayer);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import forge.CounterType;
|
|||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
|
import forge.control.FControl;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
@@ -211,7 +212,7 @@ public class CardDetailPanel extends FPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer());
|
final boolean canShowThis = FControl.SINGLETON_INSTANCE.mayShowCard(card);
|
||||||
if (canShowThis) {
|
if (canShowThis) {
|
||||||
if (card.getManaCost().isNoCost()) {
|
if (card.getManaCost().isNoCost()) {
|
||||||
this.nameCostLabel.setText(card.getName());
|
this.nameCostLabel.setText(card.getName());
|
||||||
@@ -488,7 +489,7 @@ public class CardDetailPanel extends FPanel {
|
|||||||
|
|
||||||
if (entity instanceof Card) {
|
if (entity instanceof Card) {
|
||||||
final Card c = (Card) entity;
|
final Card c = (Card) entity;
|
||||||
if (!c.canBeShownTo(Singletons.getControl().getPlayer())) {
|
if (!FControl.SINGLETON_INSTANCE.mayShowCard(c)) {
|
||||||
area.append("Morph (");
|
area.append("Morph (");
|
||||||
area.append(card.getUniqueNumber());
|
area.append(card.getUniqueNumber());
|
||||||
area.append(")");
|
area.append(")");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import javax.swing.event.ListSelectionListener;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.Singletons;
|
import forge.control.FControl;
|
||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public class GuiChoose {
|
|||||||
public void valueChanged(final ListSelectionEvent ev) {
|
public void valueChanged(final ListSelectionEvent ev) {
|
||||||
if (list.getSelectedValue() instanceof Card) {
|
if (list.getSelectedValue() instanceof Card) {
|
||||||
Card card = (Card) list.getSelectedValue();
|
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);
|
CMatchUI.SINGLETON_INSTANCE.setCard(card, true);
|
||||||
} else {
|
} else {
|
||||||
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public final class GuiDisplayUtil {
|
|||||||
|
|
||||||
public static void devModeGenerateMana() {
|
public static void devModeGenerateMana() {
|
||||||
final Card dummy = new Card();
|
final Card dummy = new Card();
|
||||||
dummy.setOwner(getPlayer());
|
dummy.setOwner(getGame().getPhaseHandler().getPriorityPlayer());
|
||||||
Map<String, String> produced = new HashMap<String, String>();
|
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");
|
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);
|
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
||||||
@@ -286,8 +286,8 @@ public final class GuiDisplayUtil {
|
|||||||
List<Card> humanDevExileSetup = new ArrayList<Card>();
|
List<Card> humanDevExileSetup = new ArrayList<Card>();
|
||||||
List<Card> computerDevExileSetup = new ArrayList<Card>();
|
List<Card> computerDevExileSetup = new ArrayList<Card>();
|
||||||
|
|
||||||
final Player human = getPlayer();
|
final Player human = getGame().getPlayers().get(0);
|
||||||
final Player ai = human.getOpponents().get(0);
|
final Player ai = getGame().getPlayers().get(1);
|
||||||
|
|
||||||
if (!tChangePlayer.trim().toLowerCase().equals("none")) {
|
if (!tChangePlayer.trim().toLowerCase().equals("none")) {
|
||||||
if (tChangePlayer.trim().toLowerCase().equals("human")) {
|
if (tChangePlayer.trim().toLowerCase().equals("human")) {
|
||||||
@@ -454,7 +454,7 @@ public final class GuiDisplayUtil {
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public static void devModeTutor() {
|
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);
|
final Object o = GuiChoose.oneOrNone("Choose a card", lib);
|
||||||
if (null == o) {
|
if (null == o) {
|
||||||
return;
|
return;
|
||||||
@@ -531,16 +531,6 @@ public final class GuiDisplayUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* devModeUnlimitedLand.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 1.0.16
|
|
||||||
*/
|
|
||||||
public static void devModeUnlimitedLand() {
|
|
||||||
getPlayer().addMaxLandsToPlay(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -636,7 +626,7 @@ public final class GuiDisplayUtil {
|
|||||||
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
||||||
// Human player is choosing targets for an ability controlled by chosen player.
|
// Human player is choosing targets for an ability controlled by chosen player.
|
||||||
sa.setActivatingPlayer(p);
|
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();
|
return Singletons.getControl().getMatch().getCurrentGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Player getPlayer() {
|
|
||||||
return Singletons.getControl().getPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end class GuiDisplayUtil
|
} // end class GuiDisplayUtil
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class LimitedWinLose extends ControlWinLose {
|
|||||||
super(view0, match);
|
super(view0, match);
|
||||||
this.view = view0;
|
this.view = view0;
|
||||||
gauntlet = Singletons.getModel().getGauntletMini();
|
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;
|
nextRound = false;
|
||||||
|
|
||||||
|
|
||||||
|
if (match.getLastGameOutcome().isWinner(Singletons.getControl().getLobby().getGuiPlayer())) {
|
||||||
if (match.getLastGameOutcome().isWinner(Singletons.getControl().getPlayer().getLobbyPlayer())) {
|
|
||||||
gauntlet.addWin();
|
gauntlet.addWin();
|
||||||
} else {
|
} else {
|
||||||
gauntlet.addLoss();
|
gauntlet.addLoss();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.awt.event.MouseEvent;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.control.FControl;
|
||||||
import forge.gui.framework.ICDoc;
|
import forge.gui.framework.ICDoc;
|
||||||
import forge.gui.match.views.VDetail;
|
import forge.gui.match.views.VDetail;
|
||||||
import forge.item.IPaperCard;
|
import forge.item.IPaperCard;
|
||||||
@@ -45,7 +45,7 @@ public enum CDetail implements ICDoc {
|
|||||||
* @param c   Card object
|
* @param c   Card object
|
||||||
*/
|
*/
|
||||||
public void showCard(final Card c) {
|
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.getPnlDetail().setCard(c);
|
||||||
view.getParentCell().repaintSelf();
|
view.getParentCell().repaintSelf();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.awt.event.MouseEvent;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardCharacteristicName;
|
import forge.CardCharacteristicName;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.control.FControl;
|
||||||
import forge.gui.framework.ICDoc;
|
import forge.gui.framework.ICDoc;
|
||||||
import forge.gui.match.views.VPicture;
|
import forge.gui.match.views.VPicture;
|
||||||
import forge.item.IPaperCard;
|
import forge.item.IPaperCard;
|
||||||
@@ -48,7 +48,7 @@ public enum CPicture implements ICDoc {
|
|||||||
*   Card object
|
*   Card object
|
||||||
*/
|
*/
|
||||||
public void showCard(final Card c, boolean showFlipped) {
|
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;
|
canFlip = c.isDoubleFaced() || c.isFlipCard() || cameFaceDown;
|
||||||
currentCard = c;
|
currentCard = c;
|
||||||
flipped = canFlip && (c.getCurState() == CardCharacteristicName.Transformed ||
|
flipped = canFlip && (c.getCurState() == CardCharacteristicName.Transformed ||
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardCharacteristicName;
|
import forge.CardCharacteristicName;
|
||||||
import forge.Singletons;
|
|
||||||
import forge.card.cardfactory.CardFactory;
|
import forge.card.cardfactory.CardFactory;
|
||||||
|
import forge.control.FControl;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.gui.ForgeAction;
|
import forge.gui.ForgeAction;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
@@ -54,7 +54,7 @@ class ZoneAction extends ForgeAction {
|
|||||||
for (Card crd : choices) {
|
for (Card crd : choices) {
|
||||||
Card toAdd = crd;
|
Card toAdd = crd;
|
||||||
if (crd.isFaceDown()) {
|
if (crd.isFaceDown()) {
|
||||||
if (crd.canBeShownTo(Singletons.getControl().getPlayer())) {
|
if (FControl.SINGLETON_INSTANCE.mayShowCard(crd)) {
|
||||||
toAdd = CardFactory.copyCard(crd);
|
toAdd = CardFactory.copyCard(crd);
|
||||||
toAdd.setState(CardCharacteristicName.Original);
|
toAdd.setState(CardCharacteristicName.Original);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user