mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Fix many more problems with the GUI refactoring (plus some preparations for mobile GUI support).
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -509,6 +509,7 @@ forge-game/src/main/java/forge/game/event/GameEventPlayerDamaged.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerLivesChanged.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerPoisoned.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerPriority.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventShuffle.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventSpellAbilityCast.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventSpellRemovedFromStack.java -text
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package forge.game.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.game.player.Player;
|
||||
import forge.util.Lang;
|
||||
|
||||
/**
|
||||
* This means card's characteristics have changed on server, clients must re-request them
|
||||
*/
|
||||
public class GameEventPlayerStatsChanged extends GameEvent {
|
||||
|
||||
public final Collection<Player> players;
|
||||
public GameEventPlayerStatsChanged(Player affected) {
|
||||
players = Arrays.asList(affected);
|
||||
}
|
||||
|
||||
public GameEventPlayerStatsChanged(Collection<Player> affected) {
|
||||
players = affected;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.event.GameEvent#visit(forge.game.event.IGameEventVisitor)
|
||||
*/
|
||||
@Override
|
||||
public <T> T visit(IGameEventVisitor<T> visitor) {
|
||||
// TODO Auto-generated method stub
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (null == players || Iterables.isEmpty(players)) {
|
||||
return "Player state changes: (empty list)";
|
||||
}
|
||||
return String.format("Player state changes: %s", Lang.joinHomogenous(players));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public interface IGameEventVisitor<T> {
|
||||
T visit(GameEventPlayerDamaged gameEventPlayerDamaged);
|
||||
T visit(GameEventPlayerPoisoned event);
|
||||
T visit(GameEventPlayerPriority event);
|
||||
T visit(GameEventPlayerStatsChanged event);
|
||||
T visit(GameEventShuffle event);
|
||||
T visit(GameEventSpellAbilityCast gameEventSpellAbilityCast);
|
||||
T visit(GameEventSpellResolved event);
|
||||
@@ -72,6 +73,7 @@ public interface IGameEventVisitor<T> {
|
||||
public T visit(GameEventPlayerControl event) { return null; }
|
||||
public T visit(GameEventPlayerPoisoned event) { return null; }
|
||||
public T visit(GameEventPlayerPriority event) { return null; }
|
||||
public T visit(GameEventPlayerStatsChanged event) { return null; }
|
||||
public T visit(GameEventShuffle event) { return null; }
|
||||
public T visit(GameEventSpellResolved event) { return null; }
|
||||
public T visit(GameEventSpellAbilityCast event) { return null; }
|
||||
|
||||
@@ -1159,9 +1159,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
this.changedKeywords.put(timestamp, new KeywordsChange(addKeywords, removeKeywords, false));
|
||||
game.fireEvent(new GameEventPlayerStatsChanged(this));
|
||||
}
|
||||
|
||||
public final KeywordsChange removeChangedKeywords(final Long timestamp) {
|
||||
game.fireEvent(new GameEventPlayerStatsChanged(this));
|
||||
return changedKeywords.remove(Long.valueOf(timestamp));
|
||||
}
|
||||
|
||||
@@ -1205,6 +1207,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
this.changedKeywords.remove(ck.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
game.fireEvent(new GameEventPlayerStatsChanged(this));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -223,9 +223,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
//PhaseHandler pH = Singletons.getControl().getObservedGame().getPhaseHandler();
|
||||
//PhaseType ph = pH.getPhase();
|
||||
|
||||
final PlayerView p = Singletons.getControl().getGameView().getPlayerTurn();
|
||||
final PhaseType ph = Singletons.getControl().getGameView().getPhase();
|
||||
final CMatchUI matchUi = CMatchUI.SINGLETON_INSTANCE;
|
||||
@@ -411,9 +408,9 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZones(final List<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
public boolean openZones(final Collection<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
switch (zones.get(0)) {
|
||||
switch (zones.iterator().next()) {
|
||||
case Battlefield:
|
||||
case Hand:
|
||||
return true; //don't actually need to open anything, but indicate that zone can be opened
|
||||
|
||||
@@ -130,7 +130,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
cdArea.setText(CardDetailUtil.getItemDescription(item));
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getOriginal() : null, false);
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getOriginal() : null);
|
||||
|
||||
String set = item.getEdition();
|
||||
setInfoLabel.setText(set);
|
||||
@@ -175,25 +175,21 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel.setBorder(null);
|
||||
this.cdArea.setText("");
|
||||
if (card == null) {
|
||||
this.updateBorder((CardStateView)null, false);
|
||||
this.updateBorder(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final CardStateView state = card.getState(isInAltState);
|
||||
//this.setCard(card.card);
|
||||
|
||||
boolean canShowThis = false;
|
||||
|
||||
//if (Singletons.getControl().mayShowCard(card) || FDialog.isModalOpen()) { //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
canShowThis = true;
|
||||
|
||||
if (state.getManaCost().isNoCost()) {
|
||||
this.nameCostLabel.setText(state.getName());
|
||||
} else {
|
||||
String manaCost = state.getManaCost().toString();
|
||||
//if (state.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
|
||||
// manaCost = card.getRules().getMainPart().getManaCost().toString() + " // " + card.getRules().getOtherPart().getManaCost().toString();
|
||||
//}
|
||||
final String manaCost;
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
manaCost = card.getOriginal().getManaCost() + " // " + card.getAlternate().getManaCost();
|
||||
} else {
|
||||
manaCost = state.getManaCost().toString();
|
||||
}
|
||||
this.nameCostLabel.setText(FSkin.encodeSymbols(state.getName() + " - " + manaCost, true));
|
||||
}
|
||||
this.typeLabel.setText(CardDetailUtil.formatCardType(state));
|
||||
@@ -240,14 +236,14 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor));
|
||||
}
|
||||
|
||||
this.updateBorder(state, canShowThis);
|
||||
this.updateBorder(state);
|
||||
|
||||
this.powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state));
|
||||
|
||||
this.idLabel.setText(CardDetailUtil.formatCardId(state));
|
||||
|
||||
// fill the card text
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, canShowThis), true));
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state), true));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -282,7 +278,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return this.cdArea;
|
||||
}
|
||||
|
||||
private void updateBorder(final CardStateView card, final boolean canShow) {
|
||||
private void updateBorder(final CardStateView card) {
|
||||
// color info
|
||||
if (card == null) {
|
||||
this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
@@ -290,7 +286,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card, canShow));
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card));
|
||||
this.setBorder(BorderFactory.createLineBorder(color, 2));
|
||||
scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color));
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.util.Set;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.testng.collections.Maps;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
@@ -34,8 +34,7 @@ import javax.swing.border.Border;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.testng.collections.Lists;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.control.FControl;
|
||||
|
||||
@@ -3,14 +3,15 @@ package forge.screens.match;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Receives click and programmatic requests for viewing data stacks in the
|
||||
@@ -19,7 +20,8 @@ import forge.view.CardView.CardStateView;
|
||||
*/
|
||||
public class ZoneAction extends ForgeAction {
|
||||
private static final long serialVersionUID = -5822976087772388839L;
|
||||
private final Iterable<CardView> cards;
|
||||
private final PlayerView player;
|
||||
private final ZoneType zone;
|
||||
private final String title;
|
||||
|
||||
/**
|
||||
@@ -32,10 +34,11 @@ public class ZoneAction extends ForgeAction {
|
||||
* @param property
|
||||
*   String obj
|
||||
*/
|
||||
public ZoneAction(final Iterable<CardView> cards, final MatchConstants property) {
|
||||
public ZoneAction(final PlayerView player, final ZoneType zone, final MatchConstants property) {
|
||||
super(property);
|
||||
this.title = property.title;
|
||||
this.cards = Iterables.unmodifiableIterable(cards);
|
||||
this.player = player;
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ public class ZoneAction extends ForgeAction {
|
||||
}
|
||||
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return cards;
|
||||
return player.getCards(zone);
|
||||
}
|
||||
|
||||
protected void doAction(final CardView c) {
|
||||
|
||||
@@ -98,8 +98,8 @@ public enum CCombat implements ICDoc {
|
||||
}
|
||||
|
||||
final Iterable<CardView> blockers = localCombat.getBlockers(band);
|
||||
boolean blocked = (blockers == null);
|
||||
boolean isBand = bandSize > 1;
|
||||
final boolean blocked = (blockers != null);
|
||||
final boolean isBand = bandSize > 1;
|
||||
if (isBand) {
|
||||
// Only print Band data if it's actually a band
|
||||
display.append(" > BAND");
|
||||
|
||||
@@ -26,10 +26,9 @@ import com.google.common.base.Function;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.match.input.Input;
|
||||
import forge.match.input.InputPayMana;
|
||||
import forge.screens.match.ZoneAction;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
@@ -57,21 +56,21 @@ public class CField implements ICDoc {
|
||||
/**
|
||||
* Controls Swing components of a player's field instance.
|
||||
*
|
||||
* @param player2   {@link forge.game.player.Player}
|
||||
* @param player0   {@link forge.game.player.Player}
|
||||
* @param v0   {@link forge.screens.match.views.VField}
|
||||
* @param playerViewer
|
||||
*/
|
||||
public CField(final PlayerView player2, final VField v0, LobbyPlayer playerViewer) {
|
||||
this.player = player2;
|
||||
public CField(final PlayerView player0, final VField v0, LobbyPlayer playerViewer) {
|
||||
this.player = player0;
|
||||
this.viewer = playerViewer;
|
||||
this.view = v0;
|
||||
|
||||
final ZoneAction handAction = new ZoneAction(player.getHandCards(), MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(player.getLibraryCards(), MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(player.getExileCards(), MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(player.getGraveCards(), MatchConstants.HUMANGRAVEYARD);
|
||||
final ZoneAction handAction = new ZoneAction(player, ZoneType.Hand, MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(player, ZoneType.Library, MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(player, ZoneType.Exile, MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD);
|
||||
@SuppressWarnings("serial")
|
||||
final ZoneAction flashBackAction = new ZoneAction(player.getFlashbackCards(), MatchConstants.HUMANFLASHBACK) {
|
||||
final ZoneAction flashBackAction = new ZoneAction(player, null, MatchConstants.HUMANFLASHBACK) {
|
||||
@Override
|
||||
protected void doAction(final CardView c) {
|
||||
// activate cards only via your own flashback button
|
||||
@@ -81,16 +80,16 @@ public class CField implements ICDoc {
|
||||
|
||||
CPrompt.SINGLETON_INSTANCE.selectCard(c, null);
|
||||
}
|
||||
@Override
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return player.getFlashbackCards();
|
||||
}
|
||||
};
|
||||
|
||||
Function<Byte, Void> manaAction = new Function<Byte, Void>() {
|
||||
public Void apply(Byte colorCode) {
|
||||
if (CField.this.player.getLobbyPlayer() == CField.this.viewer) {
|
||||
final Input in = Singletons.getControl().getInputQueue().getInput();
|
||||
if (in instanceof InputPayMana) {
|
||||
// Do something
|
||||
((InputPayMana) in).useManaFromPool(colorCode);
|
||||
}
|
||||
Singletons.getControl().getGameView().useMana(colorCode.byteValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,12 @@ import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.ImageCache;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.match.input.InputConfirm;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.controllers.CStack;
|
||||
@@ -219,7 +217,7 @@ public enum VStack implements IVDoc<CStack> {
|
||||
});
|
||||
}
|
||||
|
||||
DetailColors color = CardDetailUtil.getBorderColor(item.getSource().getOriginal(), !txt.startsWith("Morph "));
|
||||
final DetailColors color = CardDetailUtil.getBorderColor(item.getSource().getOriginal());
|
||||
setBackground(new Color(color.r, color.g, color.b));
|
||||
setForeground(FSkin.getHighContrastColor(getBackground()));
|
||||
}
|
||||
@@ -275,10 +273,9 @@ public enum VStack implements IVDoc<CStack> {
|
||||
}
|
||||
else {
|
||||
game.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (game.peekStack() == item &&
|
||||
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
if (game.peekStack() == item) {
|
||||
//auto-yes if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.selectButtonOk();
|
||||
game.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,10 +291,9 @@ public enum VStack implements IVDoc<CStack> {
|
||||
}
|
||||
else {
|
||||
game.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (game.peekStack() == item &&
|
||||
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
if (game.peekStack() == item) {
|
||||
//auto-no if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.selectButtonOk();
|
||||
game.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
final CardView c2 = toDelete.get(i);
|
||||
if (c.getId() == c2.getId()) {
|
||||
if (c.getTimestamp() == c2.getTimestamp()) {
|
||||
toDelete.remove(i);
|
||||
toDelete.remove(c2);
|
||||
} else {
|
||||
toReplace.add(c);
|
||||
}
|
||||
|
||||
@@ -47,16 +47,25 @@ public class CardDetailUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static DetailColors getBorderColor(final CardStateView card, final boolean canShow) {
|
||||
return getBorderColors(card.getColors(), card.isLand(), canShow, false).iterator().next();
|
||||
public static DetailColors getBorderColor(final CardStateView card) {
|
||||
if (card == null) {
|
||||
return getBorderColors(null, false, false, false).iterator().next();
|
||||
}
|
||||
return getBorderColors(card.getColors(), card.isLand(), card.getCard().isUiDisplayable(), false).iterator().next();
|
||||
}
|
||||
public static DetailColors getBorderColor(final ColorSet cardColors, final boolean isLand, boolean canShow) {
|
||||
return getBorderColors(cardColors, isLand, canShow, false).get(0);
|
||||
}
|
||||
public static List<DetailColors> getBorderColors(final ColorSet cardColors, final boolean isLand, boolean canShow, boolean supportMultiple) {
|
||||
public static List<DetailColors> getBorderColors(final CardStateView card) {
|
||||
if (card == null) {
|
||||
return getBorderColors(null, false, false, true);
|
||||
}
|
||||
return getBorderColors(card.getColors(), card.isLand(), card.getCard().isUiDisplayable(), true);
|
||||
}
|
||||
private static List<DetailColors> getBorderColors(final ColorSet cardColors, final boolean isLand, boolean canShow, boolean supportMultiple) {
|
||||
List<DetailColors> borderColors = new ArrayList<DetailColors>();
|
||||
|
||||
if (!canShow) {
|
||||
if (cardColors == null || !canShow) {
|
||||
borderColors.add(DetailColors.FACE_DOWN);
|
||||
}
|
||||
else if (cardColors.isColorless()) {
|
||||
@@ -218,7 +227,7 @@ public class CardDetailUtil {
|
||||
return id > 0 ? "[" + id + "]" : "";
|
||||
}
|
||||
|
||||
public static String composeCardText(final CardStateView state, final boolean canShow) {
|
||||
public static String composeCardText(final CardStateView state) {
|
||||
final CardView card = state.getCard();
|
||||
final StringBuilder area = new StringBuilder();
|
||||
|
||||
@@ -227,7 +236,6 @@ public class CardDetailUtil {
|
||||
area.append("Token");
|
||||
}
|
||||
|
||||
if (canShow) {
|
||||
// card text
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
@@ -247,7 +255,6 @@ public class CardDetailUtil {
|
||||
text = text.replaceAll(regex, ".\r\n");
|
||||
|
||||
area.append(text);
|
||||
}
|
||||
|
||||
if (card.isPhasedOut()) {
|
||||
if (area.length() != 0) {
|
||||
|
||||
@@ -35,6 +35,8 @@ import forge.game.event.GameEventPlayerControl;
|
||||
import forge.game.event.GameEventPlayerLivesChanged;
|
||||
import forge.game.event.GameEventPlayerPoisoned;
|
||||
import forge.game.event.GameEventPlayerPriority;
|
||||
import forge.game.event.GameEventPlayerStatsChanged;
|
||||
import forge.game.event.GameEventShuffle;
|
||||
import forge.game.event.GameEventSpellAbilityCast;
|
||||
import forge.game.event.GameEventSpellRemovedFromStack;
|
||||
import forge.game.event.GameEventSpellResolved;
|
||||
@@ -125,9 +127,9 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
@Override
|
||||
public Void visit(GameEventAnteCardsSelected ev) {
|
||||
List<Card> options = new ArrayList<Card>();
|
||||
for (final Entry<Player, Card> kv : ((GameEventAnteCardsSelected) ev).cards.entries()) {
|
||||
Card fakeCard = new Card(-1); //use fake card so real cards appear with proper formatting
|
||||
final List<Card> options = new ArrayList<Card>();
|
||||
for (final Entry<Player, Card> kv : ev.cards.entries()) {
|
||||
final Card fakeCard = new Card(-1); //use fake card so real cards appear with proper formatting
|
||||
fakeCard.setName(" -- From " + Lang.getPossesive(kv.getKey().getName()) + " deck --");
|
||||
options.add(fakeCard);
|
||||
options.add(kv.getValue());
|
||||
@@ -359,6 +361,20 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
return updateManyCards(cardViews);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(GameEventPlayerStatsChanged event) {
|
||||
for (final Player p : event.players) {
|
||||
gui.refreshCardDetails(controller.getCardViews(p.getAllCards()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(GameEventShuffle event) {
|
||||
updateZone(event.player.getZone(ZoneType.Library));
|
||||
return null;
|
||||
}
|
||||
|
||||
// Update manapool
|
||||
private final List<Player> manaPoolUpdate = new Vector<Player>();
|
||||
private final Runnable updManaPool = new Runnable() {
|
||||
|
||||
@@ -73,7 +73,7 @@ public interface IGuiBase {
|
||||
void finishGame();
|
||||
Object showManaPool(PlayerView player);
|
||||
void hideManaPool(PlayerView player, Object zoneToRestore);
|
||||
boolean openZones(List<ZoneType> zones, Map<PlayerView, Object> players);
|
||||
boolean openZones(Collection<ZoneType> zones, Map<PlayerView, Object> players);
|
||||
void restoreOldZones(Map<PlayerView, Object> playersToRestoreZonesFor);
|
||||
void updateStack();
|
||||
void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate);
|
||||
|
||||
@@ -96,6 +96,10 @@ public abstract class PlayerControllerHuman extends PlayerController {
|
||||
return Lists.transform(players, FN_GET_PLAYER_VIEW);
|
||||
}
|
||||
|
||||
public final Iterable<PlayerView> getPlayerViews(final Iterable<Player> players) {
|
||||
return Iterables.transform(players, FN_GET_PLAYER_VIEW);
|
||||
}
|
||||
|
||||
public abstract Player getPlayer(PlayerView p);
|
||||
|
||||
public abstract SpellAbilityView getSpellAbilityView(SpellAbility sa);
|
||||
|
||||
@@ -77,6 +77,7 @@ import forge.match.input.InputBlock;
|
||||
import forge.match.input.InputConfirm;
|
||||
import forge.match.input.InputConfirmMulligan;
|
||||
import forge.match.input.InputPassPriority;
|
||||
import forge.match.input.InputPayMana;
|
||||
import forge.match.input.InputProliferate;
|
||||
import forge.match.input.InputSelectCardsForConvoke;
|
||||
import forge.match.input.InputSelectCardsFromList;
|
||||
@@ -1416,6 +1417,13 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
getInputProxy().selectButtonCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirm() {
|
||||
if (getGui().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
selectButtonOk();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passPriority() {
|
||||
return getInputProxy().passPriority();
|
||||
@@ -1426,14 +1434,22 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
return getInputProxy().passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useMana(final byte mana) {
|
||||
final Input input = getGui().getInputQueue().getInput();
|
||||
if (input instanceof InputPayMana) {
|
||||
((InputPayMana) input).useManaFromPool(mana);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPlayer(final PlayerView player, final ITriggerEvent triggerEvent) {
|
||||
getInputProxy().selectPlayer(player, triggerEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final CardView card, final ITriggerEvent triggerEvent) {
|
||||
getInputProxy().selectCard(card, triggerEvent);
|
||||
public boolean selectCard(final CardView card, final ITriggerEvent triggerEvent) {
|
||||
return getInputProxy().selectCard(card, triggerEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1517,8 +1533,8 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
si.getSpellAbility().toUnsuppressedString(),
|
||||
si.getSpellAbility().getSourceTrigger(),
|
||||
si.getStackDescription(), getCardView(si.getSourceCard()),
|
||||
getPlayerView(si.getActivator()), si.isAbility(),
|
||||
si.isOptionalTrigger());
|
||||
getPlayerView(si.getActivator()), getCardViews(si.getTargetChoices().getTargetCards()),
|
||||
getPlayerViews(si.getTargetChoices().getTargetPlayers()), si.isAbility(), si.isOptionalTrigger());
|
||||
stackItems.put(si, newItem);
|
||||
return newItem;
|
||||
}
|
||||
@@ -1542,6 +1558,7 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
view = new PlayerView(p.getLobbyPlayer(), p.getController());
|
||||
players.put(p, view);
|
||||
getPlayerView(p, view);
|
||||
view.setOpponents(getPlayerViews(p.getOpponents()));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@@ -1601,6 +1618,10 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
}
|
||||
|
||||
private CardView getCardViewFast(final Card c) {
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final CardView view = cards.get(c);
|
||||
if (!mayShowCard(view)) {
|
||||
view.reset();
|
||||
@@ -1651,7 +1672,6 @@ public class PlayerControllerLocal extends PlayerControllerHuman implements IGam
|
||||
public boolean mayShowCard(final CardView c) {
|
||||
final Card card = getCard(c);
|
||||
return card == null || card.canBeShownTo(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ import forge.view.PlayerView;
|
||||
|
||||
public abstract class QuestWinLoseController {
|
||||
private final IGameView lastGame;
|
||||
private final IGuiBase gui;
|
||||
protected final IGuiBase gui;
|
||||
private final transient boolean wonMatch;
|
||||
private final transient boolean isAnte;
|
||||
private final transient QuestController qData;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -14,6 +15,7 @@ import com.google.common.collect.Iterables;
|
||||
import forge.ImageKeys;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.CounterType;
|
||||
@@ -1009,6 +1011,9 @@ public class CardView extends GameEntityView {
|
||||
this.hasTrample = hasTrample;
|
||||
}
|
||||
|
||||
public boolean isBasicLand() {
|
||||
return this.isLand() && Iterables.any(type, Predicates.in(CardType.getBasicTypes()));
|
||||
}
|
||||
public boolean isCreature() {
|
||||
return this.type.contains("Creature");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.view;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@@ -20,6 +21,10 @@ public class CombatView {
|
||||
return attackersWithDefenders.size();
|
||||
}
|
||||
|
||||
public boolean isAttacking(final CardView card) {
|
||||
return attackersWithDefenders.containsKey(card);
|
||||
}
|
||||
|
||||
public Iterable<CardView> getAttackers() {
|
||||
return attackersWithDefenders.keySet();
|
||||
}
|
||||
@@ -32,6 +37,14 @@ public class CombatView {
|
||||
return attackersWithDefenders.get(attacker);
|
||||
}
|
||||
|
||||
public boolean isBlocking(final CardView card) {
|
||||
for (final Iterable<CardView> blockers : attackersWithBlockers.values()) {
|
||||
if (Iterables.contains(blockers, card)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Iterable<CardView> getBlockers(final CardView attacker) {
|
||||
return attackersWithBlockers.get(attacker);
|
||||
}
|
||||
|
||||
@@ -54,10 +54,12 @@ public interface IGameView {
|
||||
|
||||
public abstract void selectButtonOk();
|
||||
public abstract void selectButtonCancel();
|
||||
public abstract void confirm();
|
||||
public abstract boolean passPriority();
|
||||
public abstract boolean passPriorityUntilEndOfTurn();
|
||||
public abstract void useMana(byte mana);
|
||||
public abstract void selectPlayer(PlayerView player, ITriggerEvent triggerEvent);
|
||||
public abstract void selectCard(CardView card, ITriggerEvent triggerEvent);
|
||||
public abstract boolean selectCard(CardView card, ITriggerEvent triggerEvent);
|
||||
public abstract void selectAbility(SpellAbilityView sa);
|
||||
|
||||
// the following method should eventually be replaced by methods returning
|
||||
|
||||
@@ -2,20 +2,24 @@ package forge.view;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.player.PlayerController;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class PlayerView extends GameEntityView {
|
||||
|
||||
private final LobbyPlayer lobbyPlayer;
|
||||
private final PlayerController controller;
|
||||
|
||||
private Set<PlayerView> opponents;
|
||||
private int life, poisonCounters, maxHandSize, numDrawnThisTurn, preventNextDamage;
|
||||
private List<String> keywords;
|
||||
private String commanderInfo;
|
||||
@@ -42,6 +46,14 @@ public class PlayerView extends GameEntityView {
|
||||
return lobbyPlayer;
|
||||
}
|
||||
|
||||
public void setOpponents(final Iterable<PlayerView> opponents) {
|
||||
this.opponents = Sets.newHashSet(opponents);
|
||||
}
|
||||
|
||||
public boolean isOpponentOf(final PlayerView other) {
|
||||
return opponents.contains(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the controller
|
||||
*/
|
||||
@@ -168,8 +180,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param anteCards the anteCards to set
|
||||
*/
|
||||
public void setAnteCards(final List<CardView> anteCards) {
|
||||
this.anteCards.clear();
|
||||
this.anteCards.addAll(anteCards);
|
||||
this.anteCards = ImmutableList.copyOf(anteCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,8 +194,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param bfCards the bfCards to set
|
||||
*/
|
||||
public void setBfCards(final List<CardView> bfCards) {
|
||||
this.bfCards.clear();
|
||||
this.bfCards.addAll(bfCards);
|
||||
this.bfCards = ImmutableList.copyOf(bfCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,8 +208,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param commandCards the commandCards to set
|
||||
*/
|
||||
public void setCommandCards(List<CardView> commandCards) {
|
||||
this.commandCards.clear();
|
||||
this.commandCards.addAll(commandCards);
|
||||
this.commandCards = ImmutableList.copyOf(commandCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,8 +222,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param exileCards the exileCards to set
|
||||
*/
|
||||
public void setExileCards(final List<CardView> exileCards) {
|
||||
this.exileCards.clear();
|
||||
this.exileCards.addAll(exileCards);
|
||||
this.exileCards = ImmutableList.copyOf(exileCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,8 +236,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param flashbackCards the flashbackCards to set
|
||||
*/
|
||||
public void setFlashbackCards(final List<CardView> flashbackCards) {
|
||||
this.flashbackCards.clear();
|
||||
this.flashbackCards.addAll(flashbackCards);
|
||||
this.flashbackCards = ImmutableList.copyOf(flashbackCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,8 +250,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param graveCards the graveCards to set
|
||||
*/
|
||||
public void setGraveCards(final List<CardView> graveCards) {
|
||||
this.graveCards.clear();
|
||||
this.graveCards.addAll(graveCards);
|
||||
this.graveCards = ImmutableList.copyOf(graveCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,8 +264,7 @@ public class PlayerView extends GameEntityView {
|
||||
* @param handCards the handCards to set
|
||||
*/
|
||||
public void setHandCards(final List<CardView> handCards) {
|
||||
this.handCards.clear();
|
||||
this.handCards.addAll(handCards);
|
||||
this.handCards = ImmutableList.copyOf(handCards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,8 +278,28 @@ public class PlayerView extends GameEntityView {
|
||||
* @param libraryCards the libraryCards to set
|
||||
*/
|
||||
public void setLibraryCards(final List<CardView> libraryCards) {
|
||||
this.libraryCards.clear();
|
||||
this.libraryCards.addAll(libraryCards);
|
||||
this.libraryCards = ImmutableList.copyOf(libraryCards);
|
||||
}
|
||||
|
||||
public List<CardView> getCards(final ZoneType zone) {
|
||||
switch (zone) {
|
||||
case Ante:
|
||||
return getAnteCards();
|
||||
case Battlefield:
|
||||
return getBfCards();
|
||||
case Command:
|
||||
return getCommandCards();
|
||||
case Exile:
|
||||
return getExileCards();
|
||||
case Graveyard:
|
||||
return getGraveCards();
|
||||
case Hand:
|
||||
return getHandCards();
|
||||
case Library:
|
||||
return getLibraryCards();
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,22 +323,5 @@ public class PlayerView extends GameEntityView {
|
||||
public void setMana(final byte color, final int mana) {
|
||||
this.mana.put(Byte.valueOf(color), Integer.valueOf(mana));
|
||||
}
|
||||
public void setWhiteMana(final int mana) {
|
||||
this.setMana(MagicColor.WHITE, mana);
|
||||
}
|
||||
public void setBlueMana(final int mana) {
|
||||
this.setMana(MagicColor.BLUE, mana);
|
||||
}
|
||||
public void setBlackMana(final int mana) {
|
||||
this.setMana(MagicColor.BLACK, mana);
|
||||
}
|
||||
public void setRedMana(final int mana) {
|
||||
this.setMana(MagicColor.RED, mana);
|
||||
}
|
||||
public void setGreenMana(final int mana) {
|
||||
this.setMana(MagicColor.GREEN, mana);
|
||||
}
|
||||
public void setColorlessMana(final int mana) {
|
||||
this.setMana(MagicColor.COLORLESS, mana);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,19 +2,28 @@ package forge.view;
|
||||
|
||||
public class StackItemView {
|
||||
|
||||
final String key;
|
||||
final int sourceTrigger;
|
||||
final String text;
|
||||
final CardView source;
|
||||
final PlayerView activatingPlayer;
|
||||
final boolean ability, optionalTrigger;
|
||||
private final String key;
|
||||
private final int sourceTrigger;
|
||||
private final String text;
|
||||
private final CardView source;
|
||||
private final PlayerView activatingPlayer;
|
||||
private final Iterable<CardView> targetCards;
|
||||
private final Iterable<PlayerView> targetPlayers;
|
||||
private final boolean ability, optionalTrigger;
|
||||
|
||||
public StackItemView(final String key, final int sourceTrigger, final String text, final CardView source, final PlayerView activatingPlayer, final boolean isAbility, final boolean isOptionalTrigger) {
|
||||
public StackItemView(final String key, final int sourceTrigger,
|
||||
final String text, final CardView source,
|
||||
final PlayerView activatingPlayer,
|
||||
final Iterable<CardView> targetCards,
|
||||
final Iterable<PlayerView> targetPlayers, final boolean isAbility,
|
||||
final boolean isOptionalTrigger) {
|
||||
this.key = key;
|
||||
this.sourceTrigger = sourceTrigger;
|
||||
this.text = text;
|
||||
this.source = source;
|
||||
this.activatingPlayer = activatingPlayer;
|
||||
this.targetCards = targetCards;
|
||||
this.targetPlayers = targetPlayers;
|
||||
this.ability = isAbility;
|
||||
this.optionalTrigger = isOptionalTrigger;
|
||||
}
|
||||
@@ -39,6 +48,14 @@ public class StackItemView {
|
||||
return activatingPlayer;
|
||||
}
|
||||
|
||||
public Iterable<CardView> getTargetCards() {
|
||||
return targetCards;
|
||||
}
|
||||
|
||||
public Iterable<PlayerView> getTargetPlayers() {
|
||||
return targetPlayers;
|
||||
}
|
||||
|
||||
public boolean isAbility() {
|
||||
return ability;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user