mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Add views to GUI refactoring, and update some more code.
This commit is contained in:
8
.gitattributes
vendored
8
.gitattributes
vendored
@@ -16842,6 +16842,14 @@ forge-gui/src/main/java/forge/util/gui/SGuiChoose.java -text
|
|||||||
forge-gui/src/main/java/forge/util/gui/SGuiDialog.java -text
|
forge-gui/src/main/java/forge/util/gui/SGuiDialog.java -text
|
||||||
forge-gui/src/main/java/forge/util/gui/SOptionPane.java -text
|
forge-gui/src/main/java/forge/util/gui/SOptionPane.java -text
|
||||||
forge-gui/src/main/java/forge/util/package-info.java -text
|
forge-gui/src/main/java/forge/util/package-info.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/CardView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/CombatView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/GameEntityView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/IGameView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/PlayerView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/SpellAbilityView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/StackItemView.java -text
|
||||||
|
forge-gui/src/main/java/forge/view/ViewUtil.java -text
|
||||||
forge-gui/src/main/resources/proxy-template.ftl -text
|
forge-gui/src/main/resources/proxy-template.ftl -text
|
||||||
forge-gui/src/site/apt/index.apt -text
|
forge-gui/src/site/apt/index.apt -text
|
||||||
forge-gui/tools/PerSetTracking.py svneol=native#text/x-python
|
forge-gui/tools/PerSetTracking.py svneol=native#text/x-python
|
||||||
|
|||||||
@@ -17,20 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package forge.screens.match;
|
package forge.screens.match;
|
||||||
|
|
||||||
import forge.Singletons;
|
import java.awt.Color;
|
||||||
import forge.game.card.Card;
|
import java.awt.Graphics;
|
||||||
import forge.game.combat.Combat;
|
import java.awt.Graphics2D;
|
||||||
import forge.gui.framework.FScreen;
|
import java.awt.Point;
|
||||||
import forge.screens.match.controllers.CDock;
|
import java.awt.RenderingHints;
|
||||||
import forge.screens.match.views.VField;
|
|
||||||
import forge.toolbox.FSkin;
|
|
||||||
import forge.toolbox.FSkin.SkinnedPanel;
|
|
||||||
import forge.view.FView;
|
|
||||||
import forge.view.arcane.CardPanel;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.GeneralPath;
|
import java.awt.geom.GeneralPath;
|
||||||
@@ -39,6 +30,22 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import org.testng.collections.Lists;
|
||||||
|
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.gui.framework.FScreen;
|
||||||
|
import forge.screens.match.controllers.CDock;
|
||||||
|
import forge.screens.match.views.VField;
|
||||||
|
import forge.toolbox.FSkin;
|
||||||
|
import forge.toolbox.FSkin.SkinnedPanel;
|
||||||
|
import forge.view.CardView;
|
||||||
|
import forge.view.CombatView;
|
||||||
|
import forge.view.FView;
|
||||||
|
import forge.view.GameEntityView;
|
||||||
|
import forge.view.arcane.CardPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semi-transparent overlay panel. Should be used with layered panes.
|
* Semi-transparent overlay panel. Should be used with layered panes.
|
||||||
*
|
*
|
||||||
@@ -74,7 +81,7 @@ public enum TargetingOverlay {
|
|||||||
// TODO - this is called every repaint, regardless if card
|
// TODO - this is called every repaint, regardless if card
|
||||||
// positions have changed or not. Could perform better if
|
// positions have changed or not. Could perform better if
|
||||||
// it checked for a state change. Doublestrike 28-09-12
|
// it checked for a state change. Doublestrike 28-09-12
|
||||||
private void assembleArcs(Combat combat) {
|
private void assembleArcs(final CombatView combat) {
|
||||||
//List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
//List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||||
arcsCombat.clear();
|
arcsCombat.clear();
|
||||||
arcsOther.clear();
|
arcsOther.clear();
|
||||||
@@ -115,7 +122,7 @@ public enum TargetingOverlay {
|
|||||||
for (CardPanel c : cardPanels) {
|
for (CardPanel c : cardPanels) {
|
||||||
if (c.isShowing()) {
|
if (c.isShowing()) {
|
||||||
cardLocOnScreen = c.getCardLocationOnScreen();
|
cardLocOnScreen = c.getCardLocationOnScreen();
|
||||||
endpoints.put(c.getCard().getUniqueNumber(), new Point(
|
endpoints.put(c.getCard().getId(), new Point(
|
||||||
(int) (cardLocOnScreen.getX() - locOnScreen.getX() + c.getWidth() / 4),
|
(int) (cardLocOnScreen.getX() - locOnScreen.getX() + c.getWidth() / 4),
|
||||||
(int) (cardLocOnScreen.getY() - locOnScreen.getY() + c.getHeight() / 2)
|
(int) (cardLocOnScreen.getY() - locOnScreen.getY() + c.getHeight() / 2)
|
||||||
));
|
));
|
||||||
@@ -124,16 +131,16 @@ public enum TargetingOverlay {
|
|||||||
|
|
||||||
if (CDock.SINGLETON_INSTANCE.getArcState() == 1) {
|
if (CDock.SINGLETON_INSTANCE.getArcState() == 1) {
|
||||||
// Only work with the active panel
|
// Only work with the active panel
|
||||||
Card c = activePanel.getCard();
|
final CardView c = activePanel.getCard();
|
||||||
addArcsForCard(c, endpoints, combat);
|
addArcsForCard(c, endpoints, combat);
|
||||||
} else {
|
} else {
|
||||||
// Work with all card panels currently visible
|
// Work with all card panels currently visible
|
||||||
List<Card> visualized = new ArrayList<Card>();
|
final List<CardView> visualized = Lists.newArrayList();
|
||||||
for (CardPanel c : cardPanels) {
|
for (final CardPanel c : cardPanels) {
|
||||||
if (!c.isShowing()) {
|
if (!c.isShowing()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Card card = c.getCard();
|
final CardView card = c.getCard();
|
||||||
if (visualized.contains(card)) { continue; }
|
if (visualized.contains(card)) { continue; }
|
||||||
|
|
||||||
visualized.addAll(addArcsForCard(card, endpoints, combat));
|
visualized.addAll(addArcsForCard(card, endpoints, combat));
|
||||||
@@ -141,23 +148,22 @@ public enum TargetingOverlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Card> addArcsForCard(final Card c, final Map<Integer, Point> endpoints, final Combat combat) {
|
private List<CardView> addArcsForCard(final CardView c, final Map<Integer, Point> endpoints, final CombatView combat) {
|
||||||
List<Card> cardsVisualized = new ArrayList<Card>();
|
final List<CardView> cardsVisualized = Lists.newArrayList(c);
|
||||||
cardsVisualized.add(c);
|
|
||||||
|
|
||||||
Card enchanting = c.getEnchantingCard();
|
final CardView enchanting = c.getEnchantingCard();
|
||||||
Card equipping = c.getEquippingCard();
|
final CardView equipping = c.getEquipping();
|
||||||
Card fortifying = c.getFortifyingCard();
|
final CardView fortifying = c.getFortifying();
|
||||||
List<Card> enchantedBy = c.getEnchantedBy();
|
final Iterable<CardView> enchantedBy = c.getEnchantedBy();
|
||||||
List<Card> equippedBy = c.getEquippedBy();
|
final Iterable<CardView> equippedBy = c.getEquippedBy();
|
||||||
List<Card> fortifiedBy = c.getFortifiedBy();
|
final Iterable<CardView> fortifiedBy = c.getFortifiedBy();
|
||||||
Card paired = c.getPairedWith();
|
final CardView paired = c.getPairedWith();
|
||||||
|
|
||||||
if (null != enchanting) {
|
if (null != enchanting) {
|
||||||
if (!enchanting.getController().equals(c.getController())) {
|
if (!enchanting.getController().equals(c.getController())) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(enchanting.getUniqueNumber()),
|
endpoints.get(enchanting.getId()),
|
||||||
endpoints.get(c.getUniqueNumber())
|
endpoints.get(c.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(enchanting);
|
cardsVisualized.add(enchanting);
|
||||||
}
|
}
|
||||||
@@ -165,8 +171,8 @@ public enum TargetingOverlay {
|
|||||||
if (null != equipping) {
|
if (null != equipping) {
|
||||||
if (!equipping.getController().equals(c.getController())) {
|
if (!equipping.getController().equals(c.getController())) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(equipping.getUniqueNumber()),
|
endpoints.get(equipping.getId()),
|
||||||
endpoints.get(c.getUniqueNumber())
|
endpoints.get(c.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(equipping);
|
cardsVisualized.add(equipping);
|
||||||
}
|
}
|
||||||
@@ -174,40 +180,40 @@ public enum TargetingOverlay {
|
|||||||
if (null != fortifying) {
|
if (null != fortifying) {
|
||||||
if (!fortifying.getController().equals(c.getController())) {
|
if (!fortifying.getController().equals(c.getController())) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(fortifying.getUniqueNumber()),
|
endpoints.get(fortifying.getId()),
|
||||||
endpoints.get(c.getUniqueNumber())
|
endpoints.get(c.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(fortifying);
|
cardsVisualized.add(fortifying);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != enchantedBy) {
|
if (null != enchantedBy) {
|
||||||
for (Card enc : enchantedBy) {
|
for (final CardView enc : enchantedBy) {
|
||||||
if (!enc.getController().equals(c.getController())) {
|
if (!enc.getController().equals(c.getController())) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(c.getUniqueNumber()),
|
endpoints.get(c.getId()),
|
||||||
endpoints.get(enc.getUniqueNumber())
|
endpoints.get(enc.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(enc);
|
cardsVisualized.add(enc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != equippedBy) {
|
if (null != equippedBy) {
|
||||||
for (Card eq : equippedBy) {
|
for (final CardView eq : equippedBy) {
|
||||||
if (!eq.getController().equals(c.getController())) {
|
if (!eq.getController().equals(c.getController())) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(c.getUniqueNumber()),
|
endpoints.get(c.getId()),
|
||||||
endpoints.get(eq.getUniqueNumber())
|
endpoints.get(eq.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(eq);
|
cardsVisualized.add(eq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != fortifiedBy) {
|
if (null != fortifiedBy) {
|
||||||
for (Card eq : fortifiedBy) {
|
for (final CardView eq : fortifiedBy) {
|
||||||
if (!eq.getController().equals(c.getController())) {
|
if (!eq.getController().equals(c.getController())) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(c.getUniqueNumber()),
|
endpoints.get(c.getId()),
|
||||||
endpoints.get(eq.getUniqueNumber())
|
endpoints.get(eq.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(eq);
|
cardsVisualized.add(eq);
|
||||||
}
|
}
|
||||||
@@ -215,29 +221,35 @@ public enum TargetingOverlay {
|
|||||||
}
|
}
|
||||||
if (null != paired) {
|
if (null != paired) {
|
||||||
arcsOther.add(new Point[] {
|
arcsOther.add(new Point[] {
|
||||||
endpoints.get(paired.getUniqueNumber()),
|
endpoints.get(paired.getId()),
|
||||||
endpoints.get(c.getUniqueNumber())
|
endpoints.get(c.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(paired);
|
cardsVisualized.add(paired);
|
||||||
}
|
}
|
||||||
if ( null != combat ) {
|
if (null != combat) {
|
||||||
for (Card planeswalker : combat.getDefendingPlaneswalkers()) {
|
final GameEntityView defender = combat.getDefender(c);
|
||||||
List<Card> cards = combat.getAttackersOf(planeswalker);
|
// if c is attacking a planeswalker
|
||||||
for (Card pwAttacker : cards) {
|
if (defender instanceof CardView) {
|
||||||
if (!planeswalker.equals(c) && !pwAttacker.equals(c)) { continue; }
|
arcsCombat.add(new Point[] {
|
||||||
arcsCombat.add(new Point[] {
|
endpoints.get(((CardView)defender).getId()),
|
||||||
endpoints.get(planeswalker.getUniqueNumber()),
|
endpoints.get(c.getId())
|
||||||
endpoints.get(pwAttacker.getUniqueNumber())
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (Card attackingCard : combat.getAttackers()) {
|
// if c is a planeswalker that's being attacked
|
||||||
List<Card> cards = combat.getBlockers(attackingCard);
|
final Iterable<CardView> attackers = combat.getAttackersOf(c);
|
||||||
for (Card blockingCard : cards) {
|
for (final CardView pwAttacker : attackers) {
|
||||||
|
arcsCombat.add(new Point[] {
|
||||||
|
endpoints.get(c.getId()),
|
||||||
|
endpoints.get(pwAttacker.getId())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (final CardView attackingCard : combat.getAttackers()) {
|
||||||
|
final Iterable<CardView> cards = combat.getBlockers(attackingCard);
|
||||||
|
for (final CardView blockingCard : cards) {
|
||||||
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
|
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
|
||||||
arcsCombat.add(new Point[] {
|
arcsCombat.add(new Point[] {
|
||||||
endpoints.get(attackingCard.getUniqueNumber()),
|
endpoints.get(attackingCard.getId()),
|
||||||
endpoints.get(blockingCard.getUniqueNumber())
|
endpoints.get(blockingCard.getId())
|
||||||
});
|
});
|
||||||
cardsVisualized.add(blockingCard);
|
cardsVisualized.add(blockingCard);
|
||||||
}
|
}
|
||||||
@@ -340,7 +352,6 @@ public enum TargetingOverlay {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(final Graphics g) {
|
public void paintComponent(final Graphics g) {
|
||||||
final Combat combat = Singletons.getControl().getObservedGame().getCombat(); // this will get deprecated too
|
|
||||||
// No need for this except in match view
|
// No need for this except in match view
|
||||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||||
|
|
||||||
@@ -351,7 +362,7 @@ public enum TargetingOverlay {
|
|||||||
if (overlaystate == 0) { return; }
|
if (overlaystate == 0) { return; }
|
||||||
|
|
||||||
// Arc drawing
|
// Arc drawing
|
||||||
assembleArcs(combat);
|
assembleArcs(Singletons.getControl().getGameView().getCombat());
|
||||||
|
|
||||||
if (arcsCombat.isEmpty() && arcsOther.isEmpty()) { return; }
|
if (arcsCombat.isEmpty() && arcsOther.isEmpty()) { return; }
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,28 @@
|
|||||||
*/
|
*/
|
||||||
package forge.screens.match;
|
package forge.screens.match;
|
||||||
|
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
import org.testng.collections.Lists;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.control.FControl;
|
import forge.control.FControl;
|
||||||
import forge.game.GameEntity;
|
|
||||||
import forge.game.card.Card;
|
|
||||||
import forge.game.card.CounterType;
|
|
||||||
import forge.game.player.Player;
|
|
||||||
import forge.gui.SOverlayUtils;
|
import forge.gui.SOverlayUtils;
|
||||||
import forge.toolbox.FButton;
|
import forge.toolbox.FButton;
|
||||||
import forge.toolbox.FLabel;
|
import forge.toolbox.FLabel;
|
||||||
@@ -33,25 +50,6 @@ import forge.view.FDialog;
|
|||||||
import forge.view.GameEntityView;
|
import forge.view.GameEntityView;
|
||||||
import forge.view.PlayerView;
|
import forge.view.PlayerView;
|
||||||
import forge.view.arcane.CardPanel;
|
import forge.view.arcane.CardPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
|
|
||||||
import org.testng.collections.Lists;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import java.awt.Dialog.ModalityType;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembles Swing components of assign damage dialog.
|
* Assembles Swing components of assign damage dialog.
|
||||||
@@ -200,13 +198,13 @@ public class VAssignDamage {
|
|||||||
if (defender instanceof CardView)
|
if (defender instanceof CardView)
|
||||||
fakeCard = (CardView)defender;
|
fakeCard = (CardView)defender;
|
||||||
else if (defender instanceof PlayerView) {
|
else if (defender instanceof PlayerView) {
|
||||||
fakeCard = new CardView(null, -1);
|
fakeCard = new CardView(null, -1, true);
|
||||||
fakeCard.getState().setName(this.defender.toString());
|
fakeCard.getState().setName(this.defender.toString());
|
||||||
final PlayerView p = (PlayerView)defender;
|
final PlayerView p = (PlayerView)defender;
|
||||||
fakeCard.getState().setOwner(p);
|
fakeCard.setOwner(p);
|
||||||
fakeCard.getState().setImageKey(CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
fakeCard.getState().setImageKey(CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
||||||
} else {
|
} else {
|
||||||
fakeCard = new CardView(null, -2);
|
fakeCard = new CardView(null, -2, true);
|
||||||
fakeCard.getState().setName(this.defender.toString());
|
fakeCard.getState().setName(this.defender.toString());
|
||||||
}
|
}
|
||||||
addPanelForDefender(pnlDefenders, fakeCard);
|
addPanelForDefender(pnlDefenders, fakeCard);
|
||||||
|
|||||||
@@ -623,13 +623,13 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CardView> toAdd = new ArrayList<CardView>(model);
|
final List<CardView> toAdd = new ArrayList<CardView>(model);
|
||||||
toAdd.removeAll(oldCards);
|
toAdd.removeAll(oldCards);
|
||||||
toAdd.addAll(toReplace);
|
toAdd.addAll(toReplace);
|
||||||
|
|
||||||
List<CardPanel> newPanels = new ArrayList<CardPanel>();
|
final List<CardPanel> newPanels = new ArrayList<CardPanel>();
|
||||||
for (final CardView card : toAdd) {
|
for (final CardView card : toAdd) {
|
||||||
if (card.getCardForUi() == card) { //only include cards that are meant for display
|
if (card.isUiDisplayable()) { //only include cards that are meant for display
|
||||||
final CardPanel placeholder = new CardPanel(card);
|
final CardPanel placeholder = new CardPanel(card);
|
||||||
placeholder.setDisplayEnabled(false);
|
placeholder.setDisplayEnabled(false);
|
||||||
this.getCardPanels().add(placeholder);
|
this.getCardPanels().add(placeholder);
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ import forge.util.gui.SGuiChoose;
|
|||||||
import forge.util.gui.SGuiDialog;
|
import forge.util.gui.SGuiDialog;
|
||||||
import forge.util.gui.SOptionPane;
|
import forge.util.gui.SOptionPane;
|
||||||
import forge.view.CardView;
|
import forge.view.CardView;
|
||||||
|
import forge.view.CombatView;
|
||||||
import forge.view.GameEntityView;
|
import forge.view.GameEntityView;
|
||||||
import forge.view.IGameView;
|
import forge.view.IGameView;
|
||||||
import forge.view.PlayerView;
|
import forge.view.PlayerView;
|
||||||
@@ -226,7 +227,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
private final boolean assignDamageAsIfNotBlocked(final Card attacker) {
|
private final boolean assignDamageAsIfNotBlocked(final Card attacker) {
|
||||||
return attacker.hasKeyword("CARDNAME assigns its combat damage as though it weren't blocked.")
|
return attacker.hasKeyword("CARDNAME assigns its combat damage as though it weren't blocked.")
|
||||||
|| (attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")
|
|| (attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.")
|
||||||
&& SGuiDialog.confirm(attacker, "Do you want to assign its combat damage as though it weren't blocked?"));
|
&& SGuiDialog.confirm(getCardView(attacker), "Do you want to assign its combat damage as though it weren't blocked?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -359,18 +360,18 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||||
return SGuiDialog.confirm(sa.getHostCard(), message);
|
return SGuiDialog.confirm(getCardView(sa.getHostCard()), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife,
|
public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife,
|
||||||
String string, int bid, Player winner) {
|
String string, int bid, Player winner) {
|
||||||
return SGuiDialog.confirm(sa.getHostCard(), string + " Highest Bidder " + winner);
|
return SGuiDialog.confirm(getCardView(sa.getHostCard()), string + " Highest Bidder " + winner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
||||||
return SGuiDialog.confirm(hostCard, message);
|
return SGuiDialog.confirm(getCardView(hostCard), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -500,10 +501,11 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean willPutCardOnTop(Card c) {
|
public boolean willPutCardOnTop(final Card c) {
|
||||||
PaperCard pc = FModel.getMagicDb().getCommonCards().getCard(c.getName());
|
final PaperCard pc = FModel.getMagicDb().getCommonCards().getCard(c.getName());
|
||||||
Card c1 = (pc != null ? Card.fromPaperCard(pc, null) : c);
|
final Card c1 = (pc != null ? Card.fromPaperCard(pc, null) : c);
|
||||||
return SGuiDialog.confirm(c1, "Put " + c1.getName() + " on the top or bottom of your library?", new String[]{"Top", "Bottom"});
|
final CardView view = getCardView(c1);
|
||||||
|
return SGuiDialog.confirm(view, "Put " + view + " on the top or bottom of your library?", new String[]{"Top", "Bottom"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -542,8 +544,9 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playMiracle(SpellAbility miracle, Card card) {
|
public void playMiracle(final SpellAbility miracle, final Card card) {
|
||||||
if (SGuiDialog.confirm(card, card + " - Drawn. Play for Miracle Cost?")) {
|
final CardView view = getCardView(card);
|
||||||
|
if (SGuiDialog.confirm(view, view + " - Drawn. Play for Miracle Cost?")) {
|
||||||
HumanPlay.playSpellAbility(player, miracle);
|
HumanPlay.playSpellAbility(player, miracle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,7 +662,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question) {
|
public boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question) {
|
||||||
return SGuiDialog.confirm(replacementEffect.getHostCard(), question);
|
return SGuiDialog.confirm(getCardView(replacementEffect.getHostCard()), question);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -870,7 +873,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
default: labels = kindOfChoice.toString().split("Or");
|
default: labels = kindOfChoice.toString().split("Or");
|
||||||
|
|
||||||
}
|
}
|
||||||
return SGuiDialog.confirm(sa.getHostCard(), question, defaultVal == null || defaultVal.booleanValue(), labels);
|
return SGuiDialog.confirm(getCardView(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1040,7 +1043,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
if (colorNames.length > 2) {
|
if (colorNames.length > 2) {
|
||||||
return MagicColor.fromName(SGuiChoose.one(message, colorNames));
|
return MagicColor.fromName(SGuiChoose.one(message, colorNames));
|
||||||
}
|
}
|
||||||
int idxChosen = SGuiDialog.confirm(c, message, colorNames) ? 0 : 1;
|
int idxChosen = SGuiDialog.confirm(getCardView(c), message, colorNames) ? 0 : 1;
|
||||||
return MagicColor.fromName(colorNames[idxChosen]);
|
return MagicColor.fromName(colorNames[idxChosen]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,7 +1139,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
final String p1Str = String.format("Pile 1 (%s cards)", pile1.size());
|
final String p1Str = String.format("Pile 1 (%s cards)", pile1.size());
|
||||||
final String p2Str = String.format("Pile 2 (%s cards)", pile2.size());
|
final String p2Str = String.format("Pile 2 (%s cards)", pile2.size());
|
||||||
final String[] possibleValues = { p1Str , p2Str };
|
final String[] possibleValues = { p1Str , p2Str };
|
||||||
return SGuiDialog.confirm(sa.getHostCard(), "Choose a Pile", possibleValues);
|
return SGuiDialog.confirm(getCardView(sa.getHostCard()), "Choose a Pile", possibleValues);
|
||||||
} else {
|
} else {
|
||||||
final Card[] disp = new Card[pile1.size() + pile2.size() + 2];
|
final Card[] disp = new Card[pile1.size() + pile2.size() + 2];
|
||||||
disp[0] = new Card(-1);
|
disp[0] = new Card(-1);
|
||||||
@@ -1230,6 +1233,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
/** Cache of stack items. */
|
/** Cache of stack items. */
|
||||||
private final BiMap<SpellAbilityStackInstance, StackItemView> stackItems
|
private final BiMap<SpellAbilityStackInstance, StackItemView> stackItems
|
||||||
= HashBiMap.create();
|
= HashBiMap.create();
|
||||||
|
/** Combat view. */
|
||||||
|
private final CombatView combatView = new CombatView();
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.view.IGameView#isCommander()
|
* @see forge.view.IGameView#isCommander()
|
||||||
@@ -1324,15 +1329,23 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
game.subscribeToEvents(subscriber);
|
game.subscribeToEvents(subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the following methods should eventually be replaced by methods returning
|
|
||||||
// View classes
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.view.IGameView#getCombat()
|
* @see forge.view.IGameView#getCombat()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Combat getCombat() {
|
public CombatView getCombat() {
|
||||||
return game.getCombat();
|
updateCombatView(game.getCombat());
|
||||||
|
return combatView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final void updateCombatView(final Combat combat) {
|
||||||
|
for (final Card c : combat.getAttackers()) {
|
||||||
|
final GameEntity defender = combat.getDefenderByAttacker(c);
|
||||||
|
final List<Card> blockers = combat.getBlockers(c);
|
||||||
|
combatView.addAttacker(getCardView(c), getGameEntityView(defender), getCardViews(blockers));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.view.IGameView#getGameLog()
|
* @see forge.view.IGameView#getGameLog()
|
||||||
*/
|
*/
|
||||||
@@ -1474,14 +1487,15 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Card cUi = c.getCardForUi();
|
||||||
final CardView view;
|
final CardView view;
|
||||||
if (cards.containsKey(c)) {
|
if (cards.containsKey(cUi)) {
|
||||||
view = cards.get(c);
|
view = cards.get(cUi);
|
||||||
writeCardToView(c, view);
|
writeCardToView(cUi, view);
|
||||||
} else {
|
} else {
|
||||||
view = new CardView(c, c.getUniqueNumber());
|
view = new CardView(cUi, cUi.getUniqueNumber(), cUi == c);
|
||||||
writeCardToView(c, view);
|
writeCardToView(cUi, view);
|
||||||
cards.put(c, view);
|
cards.put(cUi, view);
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -1539,6 +1553,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameView
|
|||||||
view.setHauntedBy(getCardViews(c.getHauntedBy()));
|
view.setHauntedBy(getCardViews(c.getHauntedBy()));
|
||||||
view.setHaunting(getCardView(c.getHaunting()));
|
view.setHaunting(getCardView(c.getHaunting()));
|
||||||
view.setMustBlock(c.getMustBlockCards() == null ? Collections.<CardView>emptySet() : Iterables.transform(c.getMustBlockCards(), FN_GET_CARD_VIEW));
|
view.setMustBlock(c.getMustBlockCards() == null ? Collections.<CardView>emptySet() : Iterables.transform(c.getMustBlockCards(), FN_GET_CARD_VIEW));
|
||||||
|
view.setPairedWith(getCardView(c.getPairedWith()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package forge.util.gui;
|
package forge.util.gui;
|
||||||
|
|
||||||
import forge.game.card.Card;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import forge.view.CardView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds player interactions using standard windows
|
* Holds player interactions using standard windows
|
||||||
*
|
*
|
||||||
@@ -11,19 +11,18 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
public class SGuiDialog {
|
public class SGuiDialog {
|
||||||
private static final String[] defaultConfirmOptions = { "Yes", "No" };
|
private static final String[] defaultConfirmOptions = { "Yes", "No" };
|
||||||
|
|
||||||
public static boolean confirm(final Card c, final String question) {
|
public static boolean confirm(final CardView c, final String question) {
|
||||||
return SGuiDialog.confirm(c, question, true, null);
|
return SGuiDialog.confirm(c, question, true, null);
|
||||||
}
|
}
|
||||||
public static boolean confirm(final Card c, final String question, final boolean defaultChoice) {
|
public static boolean confirm(final CardView c, final String question, final boolean defaultChoice) {
|
||||||
return SGuiDialog.confirm(c, question, defaultChoice, null);
|
return SGuiDialog.confirm(c, question, defaultChoice, null);
|
||||||
}
|
}
|
||||||
public static boolean confirm(final Card c, final String question, String[] options) {
|
public static boolean confirm(final CardView c, final String question, String[] options) {
|
||||||
return SGuiDialog.confirm(c, question, true, options);
|
return SGuiDialog.confirm(c, question, true, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean confirm(Card c, final String question, final boolean defaultIsYes, final String[] options) {
|
public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||||
c = Card.getCardForUi(c);
|
final String title = c == null ? "Question" : c + " - Ability";
|
||||||
final String title = c == null ? "Question" : c.getName() + " - Ability";
|
|
||||||
String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
||||||
String[] opts = options == null ? defaultConfirmOptions : options;
|
String[] opts = options == null ? defaultConfirmOptions : options;
|
||||||
int answer = SOptionPane.showCardOptionDialog(c, questionToUse, title, SOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
|
int answer = SOptionPane.showCardOptionDialog(c, questionToUse, title, SOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
|
||||||
|
|||||||
1027
forge-gui/src/main/java/forge/view/CardView.java
Normal file
1027
forge-gui/src/main/java/forge/view/CardView.java
Normal file
File diff suppressed because it is too large
Load Diff
37
forge-gui/src/main/java/forge/view/CombatView.java
Normal file
37
forge-gui/src/main/java/forge/view/CombatView.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package forge.view;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
public class CombatView {
|
||||||
|
|
||||||
|
private Map<CardView, GameEntityView> attackersWithDefenders;
|
||||||
|
private Map<CardView, Iterable<CardView>> attackersWithBlockers;
|
||||||
|
|
||||||
|
public CombatView() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<CardView> getAttackers() {
|
||||||
|
return attackersWithDefenders.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameEntityView getDefender(final CardView attacker) {
|
||||||
|
return attackersWithDefenders.get(attacker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<CardView> getBlockers(final CardView attacker) {
|
||||||
|
return attackersWithBlockers.get(attacker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<CardView> getAttackersOf(final GameEntityView defender) {
|
||||||
|
return Maps.filterValues(attackersWithDefenders, Predicates.equalTo(defender)).keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAttacker(final CardView attacker, final GameEntityView defender, final Iterable<CardView> blockers) {
|
||||||
|
this.attackersWithDefenders.put(attacker, defender);
|
||||||
|
this.attackersWithBlockers.put(attacker, blockers);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
5
forge-gui/src/main/java/forge/view/GameEntityView.java
Normal file
5
forge-gui/src/main/java/forge/view/GameEntityView.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package forge.view;
|
||||||
|
|
||||||
|
public abstract class GameEntityView {
|
||||||
|
|
||||||
|
}
|
||||||
61
forge-gui/src/main/java/forge/view/IGameView.java
Normal file
61
forge-gui/src/main/java/forge/view/IGameView.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package forge.view;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.LobbyPlayer;
|
||||||
|
import forge.game.GameLog;
|
||||||
|
import forge.game.GameOutcome;
|
||||||
|
import forge.game.GameType;
|
||||||
|
import forge.game.phase.PhaseType;
|
||||||
|
import forge.game.player.Player;
|
||||||
|
import forge.game.player.RegisteredPlayer;
|
||||||
|
|
||||||
|
public interface IGameView {
|
||||||
|
|
||||||
|
public abstract boolean isCommander();
|
||||||
|
|
||||||
|
public abstract GameType getGameType();
|
||||||
|
|
||||||
|
public abstract boolean isWinner(LobbyPlayer p);
|
||||||
|
public abstract LobbyPlayer getWinningPlayer();
|
||||||
|
public abstract int getWinningTeam();
|
||||||
|
|
||||||
|
public abstract boolean isFirstGameInMatch();
|
||||||
|
public abstract boolean isMatchOver();
|
||||||
|
public abstract int getNumPlayedGamesInMatch();
|
||||||
|
public abstract boolean isMatchWonBy(LobbyPlayer p);
|
||||||
|
public abstract int getGamesWonBy(LobbyPlayer p);
|
||||||
|
public abstract GameOutcome.AnteResult getAnteResult();
|
||||||
|
|
||||||
|
public abstract boolean isCombatDeclareAttackers();
|
||||||
|
|
||||||
|
public abstract boolean isGameOver();
|
||||||
|
|
||||||
|
public abstract int getPoisonCountersToLose();
|
||||||
|
|
||||||
|
public abstract void subscribeToEvents(Object subscriber);
|
||||||
|
|
||||||
|
public abstract CombatView getCombat();
|
||||||
|
|
||||||
|
// the following methods should eventually be replaced by methods returning
|
||||||
|
// View classes
|
||||||
|
@Deprecated
|
||||||
|
public abstract GameLog getGameLog();
|
||||||
|
@Deprecated
|
||||||
|
public abstract RegisteredPlayer getGuiRegisteredPlayer(LobbyPlayer p);
|
||||||
|
|
||||||
|
public abstract List<PlayerView> getPlayers();
|
||||||
|
|
||||||
|
public abstract PlayerView getPlayerTurn();
|
||||||
|
|
||||||
|
public abstract PhaseType getPhase();
|
||||||
|
|
||||||
|
public abstract List<StackItemView> getStack();
|
||||||
|
public abstract StackItemView peekStack();
|
||||||
|
|
||||||
|
public abstract boolean mayShowCard(CardView c, Player viewer);
|
||||||
|
|
||||||
|
public abstract boolean getDisableAutoYields();
|
||||||
|
public abstract void setDisableAutoYields(boolean b);
|
||||||
|
|
||||||
|
}
|
||||||
303
forge-gui/src/main/java/forge/view/PlayerView.java
Normal file
303
forge-gui/src/main/java/forge/view/PlayerView.java
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
package forge.view;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import forge.LobbyPlayer;
|
||||||
|
import forge.card.MagicColor;
|
||||||
|
import forge.game.player.PlayerController;
|
||||||
|
|
||||||
|
public class PlayerView extends GameEntityView {
|
||||||
|
|
||||||
|
private final LobbyPlayer lobbyPlayer;
|
||||||
|
private final PlayerController controller;
|
||||||
|
|
||||||
|
private int life, poisonCounters, maxHandSize, numDrawnThisTurn, preventNextDamage;
|
||||||
|
private List<String> keywords;
|
||||||
|
private String commanderInfo;
|
||||||
|
private List<CardView> anteCards, bfCards, commandCards, exileCards, flashbackCards, graveCards, handCards, libraryCards;
|
||||||
|
private boolean hasUnlimitedHandSize;
|
||||||
|
private Map<Byte, Integer> mana = Maps.newHashMapWithExpectedSize(MagicColor.NUMBER_OR_COLORS + 1);
|
||||||
|
|
||||||
|
public PlayerView(final LobbyPlayer lobbyPlayer, final PlayerController controller) {
|
||||||
|
this.lobbyPlayer = lobbyPlayer;
|
||||||
|
this.controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lobbyPlayer
|
||||||
|
*/
|
||||||
|
public LobbyPlayer getLobbyPlayer() {
|
||||||
|
return lobbyPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the controller
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PlayerController getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.getLobbyPlayer().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the life
|
||||||
|
*/
|
||||||
|
public int getLife() {
|
||||||
|
return life;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param life the life to set
|
||||||
|
*/
|
||||||
|
public void setLife(final int life) {
|
||||||
|
this.life = life;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the poisonCounters
|
||||||
|
*/
|
||||||
|
public int getPoisonCounters() {
|
||||||
|
return poisonCounters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param poisonCounters the poisonCounters to set
|
||||||
|
*/
|
||||||
|
public void setPoisonCounters(final int poisonCounters) {
|
||||||
|
this.poisonCounters = poisonCounters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the maxHandSize
|
||||||
|
*/
|
||||||
|
public int getMaxHandSize() {
|
||||||
|
return maxHandSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param maxHandSize the maxHandSize to set
|
||||||
|
*/
|
||||||
|
public void setMaxHandSize(final int maxHandSize) {
|
||||||
|
this.maxHandSize = maxHandSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the numDrawnThisTurn
|
||||||
|
*/
|
||||||
|
public int getNumDrawnThisTurn() {
|
||||||
|
return numDrawnThisTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param numDrawnThisTurn the numDrawnThisTurn to set
|
||||||
|
*/
|
||||||
|
public void setNumDrawnThisTurn(final int numDrawnThisTurn) {
|
||||||
|
this.numDrawnThisTurn = numDrawnThisTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the preventNextDamage
|
||||||
|
*/
|
||||||
|
public int getPreventNextDamage() {
|
||||||
|
return preventNextDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param preventNextDamage the preventNextDamage to set
|
||||||
|
*/
|
||||||
|
public void setPreventNextDamage(final int preventNextDamage) {
|
||||||
|
this.preventNextDamage = preventNextDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the keywords
|
||||||
|
*/
|
||||||
|
public List<String> getKeywords() {
|
||||||
|
return keywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keywords the keywords to set
|
||||||
|
*/
|
||||||
|
public void setKeywords(final List<String> keywords) {
|
||||||
|
this.keywords = ImmutableList.copyOf(keywords);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the commanderInfo
|
||||||
|
*/
|
||||||
|
public String getCommanderInfo() {
|
||||||
|
return commanderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param commanderInfo the commanderInfo to set
|
||||||
|
*/
|
||||||
|
public void setCommanderInfo(final String commanderInfo) {
|
||||||
|
this.commanderInfo = commanderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the anteCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getAnteCards() {
|
||||||
|
return anteCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param anteCards the anteCards to set
|
||||||
|
*/
|
||||||
|
public void setAnteCards(final List<CardView> anteCards) {
|
||||||
|
this.anteCards = ImmutableList.copyOf(anteCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the bfCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getBfCards() {
|
||||||
|
return bfCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bfCards the bfCards to set
|
||||||
|
*/
|
||||||
|
public void setBfCards(final List<CardView> bfCards) {
|
||||||
|
this.bfCards = ImmutableList.copyOf(bfCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the commandCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getCommandCards() {
|
||||||
|
return commandCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param commandCards the commandCards to set
|
||||||
|
*/
|
||||||
|
public void setCommandCards(List<CardView> commandCards) {
|
||||||
|
this.commandCards = commandCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the exileCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getExileCards() {
|
||||||
|
return exileCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param exileCards the exileCards to set
|
||||||
|
*/
|
||||||
|
public void setExileCards(final List<CardView> exileCards) {
|
||||||
|
this.exileCards = ImmutableList.copyOf(exileCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the flashbackCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getFlashbackCards() {
|
||||||
|
return flashbackCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param flashbackCards the flashbackCards to set
|
||||||
|
*/
|
||||||
|
public void setFlashbackCards(final List<CardView> flashbackCards) {
|
||||||
|
this.flashbackCards = ImmutableList.copyOf(flashbackCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the graveCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getGraveCards() {
|
||||||
|
return graveCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param graveCards the graveCards to set
|
||||||
|
*/
|
||||||
|
public void setGraveCards(final List<CardView> graveCards) {
|
||||||
|
this.graveCards = ImmutableList.copyOf(graveCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the handCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getHandCards() {
|
||||||
|
return handCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param handCards the handCards to set
|
||||||
|
*/
|
||||||
|
public void setHandCards(final List<CardView> handCards) {
|
||||||
|
this.handCards = ImmutableList.copyOf(handCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the libraryCards
|
||||||
|
*/
|
||||||
|
public List<CardView> getLibraryCards() {
|
||||||
|
return libraryCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libraryCards the libraryCards to set
|
||||||
|
*/
|
||||||
|
public void setLibraryCards(final List<CardView> libraryCards) {
|
||||||
|
this.libraryCards = ImmutableList.copyOf(libraryCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the hasUnlimitedHandSize
|
||||||
|
*/
|
||||||
|
public boolean hasUnlimitedHandSize() {
|
||||||
|
return hasUnlimitedHandSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param hasUnlimitedHandSize the hasUnlimitedHandSize to set
|
||||||
|
*/
|
||||||
|
public void setHasUnlimitedHandSize(final boolean hasUnlimitedHandSize) {
|
||||||
|
this.hasUnlimitedHandSize = hasUnlimitedHandSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMana(final Byte color) {
|
||||||
|
return this.mana.get(color).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
forge-gui/src/main/java/forge/view/SpellAbilityView.java
Normal file
21
forge-gui/src/main/java/forge/view/SpellAbilityView.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package forge.view;
|
||||||
|
|
||||||
|
public class SpellAbilityView {
|
||||||
|
|
||||||
|
private CardView hostCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the hostCard
|
||||||
|
*/
|
||||||
|
public CardView getHostCard() {
|
||||||
|
return hostCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param hostCard the hostCard to set
|
||||||
|
*/
|
||||||
|
public void setHostCard(CardView hostCard) {
|
||||||
|
this.hostCard = hostCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
50
forge-gui/src/main/java/forge/view/StackItemView.java
Normal file
50
forge-gui/src/main/java/forge/view/StackItemView.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public StackItemView(final String key, final int sourceTrigger, final String text, final CardView source, final PlayerView activatingPlayer, final boolean isAbility, final boolean isOptionalTrigger) {
|
||||||
|
this.key = key;
|
||||||
|
this.sourceTrigger = sourceTrigger;
|
||||||
|
this.text = text;
|
||||||
|
this.source = source;
|
||||||
|
this.activatingPlayer = activatingPlayer;
|
||||||
|
this.ability = isAbility;
|
||||||
|
this.optionalTrigger = isOptionalTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSourceTrigger() {
|
||||||
|
return sourceTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardView getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerView getActivatingPlayer() {
|
||||||
|
return activatingPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAbility() {
|
||||||
|
return ability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOptionalTrigger() {
|
||||||
|
return optionalTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
90
forge-gui/src/main/java/forge/view/ViewUtil.java
Normal file
90
forge-gui/src/main/java/forge/view/ViewUtil.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package forge.view;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import forge.card.CardCharacteristicName;
|
||||||
|
import forge.game.card.Card;
|
||||||
|
import forge.game.card.CardCharacteristics;
|
||||||
|
import forge.view.CardView.CardStateView;
|
||||||
|
|
||||||
|
public final class ViewUtil {
|
||||||
|
|
||||||
|
private ViewUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write those properties of a {@link Card} to a {@link CardView} that do
|
||||||
|
* <i>not</i> depend on other cards.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the {@link Card} to read from.
|
||||||
|
* @param view
|
||||||
|
* the {@link CardView} to write to.
|
||||||
|
*/
|
||||||
|
public static void writeNonDependentCardViewProperties(final Card c, final CardView view) {
|
||||||
|
final boolean hasAltState = c.isDoubleFaced() || c.isFlipCard() || c.isFaceDown();
|
||||||
|
view.setZone(c.getZone().getZoneType());
|
||||||
|
view.setHasAltState(hasAltState);
|
||||||
|
view.setFaceDown(c.isFaceDown());
|
||||||
|
view.setFoilIndex(c.getFoil());
|
||||||
|
view.setCloned(c.isCloned());
|
||||||
|
view.setFlipCard(c.isFlipCard());
|
||||||
|
view.setFlipped(c.getCurState().equals(CardCharacteristicName.Flipped));
|
||||||
|
view.setSplitCard(c.isSplitCard());
|
||||||
|
view.setTransformed(c.getCurState().equals(CardCharacteristicName.Transformed));
|
||||||
|
view.setSetCode(c.getCurSetCode());
|
||||||
|
view.setRarity(c.getRarity());
|
||||||
|
view.setTimestamp(c.getTimestamp());
|
||||||
|
view.setPhasedOut(c.isPhasedOut());
|
||||||
|
view.setSick(c.isInPlay() && c.isSick());
|
||||||
|
view.setTapped(c.isTapped());
|
||||||
|
view.setToken(c.isToken());
|
||||||
|
view.setCounters(c.getCounters());
|
||||||
|
view.setDamage(c.getDamage());
|
||||||
|
view.setAssignedDamage(c.getTotalAssignedDamage());
|
||||||
|
view.setRegenerationShields(c.getShield().size());
|
||||||
|
view.setPreventNextDamage(c.getPreventNextDamageTotalShields());
|
||||||
|
view.setChosenType(c.getChosenType());
|
||||||
|
view.setChosenColors(c.getChosenColor());
|
||||||
|
view.setNamedCard(c.getNamedCard());
|
||||||
|
|
||||||
|
final CardStateView origView = view.getOriginal();
|
||||||
|
origView.setName(c.getName());
|
||||||
|
origView.setColors(c.determineColor());
|
||||||
|
origView.setImageKey(c.getImageKey());
|
||||||
|
origView.setType(Collections.unmodifiableList(c.getType()));
|
||||||
|
origView.setManaCost(c.getManaCost());
|
||||||
|
origView.setPower(c.getNetAttack());
|
||||||
|
origView.setToughness(c.getNetDefense());
|
||||||
|
origView.setLoyalty(c.getCurrentLoyalty());
|
||||||
|
origView.setText(c.getText());
|
||||||
|
origView.setChangedColorWords(c.getChangedTextColorWords());
|
||||||
|
origView.setChangedTypes(c.getChangedTextTypeWords());
|
||||||
|
origView.setManaCost(c.getManaCost());
|
||||||
|
|
||||||
|
final CardStateView altView = view.getAlternate();
|
||||||
|
CardCharacteristicName altState = null;
|
||||||
|
if (hasAltState) {
|
||||||
|
for (final CardCharacteristicName s : c.getStates()) {
|
||||||
|
if (!s.equals(CardCharacteristicName.Original) && !s.equals(CardCharacteristicName.FaceDown)) {
|
||||||
|
altState = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (altState != null) {
|
||||||
|
final CardCharacteristics alt = c.getState(altState);
|
||||||
|
altView.setName(alt.getName());
|
||||||
|
altView.setColors(alt.determineColor());
|
||||||
|
altView.setImageKey(alt.getImageKey());
|
||||||
|
altView.setType(Collections.unmodifiableList(alt.getType()));
|
||||||
|
altView.setManaCost(alt.getManaCost());
|
||||||
|
altView.setPower(alt.getBaseAttack());
|
||||||
|
altView.setPower(alt.getBaseDefense());
|
||||||
|
altView.setLoyalty(0); // FIXME why is loyalty not a property of CardCharacteristic?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (altState == null) {
|
||||||
|
altView.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user