mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Now StackAbilityView has sourceCard. Added displaying source card for abilities. Fixed arrows offsets. Added "source" blue arrows (target arrows are red). Fixed NullPointerException happen for AbilityPicker. Fixed random order of spells in stack. Code clean up.
This commit is contained in:
parent
a910b59399
commit
03cb41f2aa
10 changed files with 110 additions and 139 deletions
|
|
@ -51,6 +51,8 @@ import java.util.UUID;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
import javax.swing.text.StyledDocument;
|
import javax.swing.text.StyledDocument;
|
||||||
|
|
||||||
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
|
||||||
import org.jdesktop.swingx.JXPanel;
|
import org.jdesktop.swingx.JXPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,10 +64,20 @@ public class BigCard extends javax.swing.JPanel {
|
||||||
protected Image bigImage;
|
protected Image bigImage;
|
||||||
protected UUID cardId;
|
protected UUID cardId;
|
||||||
protected JXPanel panel;
|
protected JXPanel panel;
|
||||||
|
protected boolean initState;
|
||||||
|
|
||||||
public BigCard() {
|
public BigCard() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||||
|
initBounds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void initBounds() {
|
||||||
|
initState = true;
|
||||||
|
scrollPane.setBounds(20, 230, 210, 120);
|
||||||
|
scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));
|
||||||
|
}
|
||||||
|
|
||||||
public void setCard(UUID cardId, Image image, List<String> strings) {
|
public void setCard(UUID cardId, Image image, List<String> strings) {
|
||||||
if (this.cardId == null || !this.cardId.equals(cardId)) {
|
if (this.cardId == null || !this.cardId.equals(cardId)) {
|
||||||
|
|
@ -99,16 +111,13 @@ public class BigCard extends javax.swing.JPanel {
|
||||||
graphics.drawImage(bigImage, 0, 0, this);
|
graphics.drawImage(bigImage, 0, 0, this);
|
||||||
super.paintComponent(graphics);
|
super.paintComponent(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeTextComponent() {
|
|
||||||
remove(this.scrollPane);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideTextComponent() {
|
public void hideTextComponent() {
|
||||||
this.scrollPane.setVisible(false);
|
this.scrollPane.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTextComponent() {
|
public void showTextComponent() {
|
||||||
|
if (!initState) {initBounds();}
|
||||||
this.scrollPane.setVisible(true);
|
this.scrollPane.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,8 +160,6 @@ public class BigCard extends javax.swing.JPanel {
|
||||||
scrollPane.setViewportView(text);
|
scrollPane.setViewportView(text);
|
||||||
|
|
||||||
add(scrollPane);
|
add(scrollPane);
|
||||||
//scrollPane.setBounds(20, 230, 210, 120);
|
|
||||||
//scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,20 +36,19 @@ package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.client.plugins.adapters.MageMouseAdapter;
|
|
||||||
import mage.client.plugins.adapters.MageMouseMotionAdapter;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
|
import mage.view.StackAbilityView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -57,7 +56,7 @@ import mage.view.CardsView;
|
||||||
*/
|
*/
|
||||||
public class Cards extends javax.swing.JPanel {
|
public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
private Map<UUID, MageCard> cards = new HashMap<UUID, MageCard>();
|
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
|
||||||
|
|
||||||
/** Creates new form Cards */
|
/** Creates new form Cards */
|
||||||
public Cards() {
|
public Cards() {
|
||||||
|
|
@ -73,13 +72,7 @@ public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
|
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (CardView card: cardsView.values()) {
|
|
||||||
if (!cards.containsKey(card.getId())) {
|
|
||||||
addCard(card, bigCard, gameId);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
cards.get(card.getId()).update(card);
|
|
||||||
}
|
|
||||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||||
Entry<UUID, MageCard> entry = i.next();
|
Entry<UUID, MageCard> entry = i.next();
|
||||||
if (!cardsView.containsKey(entry.getKey())) {
|
if (!cardsView.containsKey(entry.getKey())) {
|
||||||
|
|
@ -89,6 +82,21 @@ public class Cards extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (CardView card: cardsView.values()) {
|
||||||
|
if (card instanceof StackAbilityView) {
|
||||||
|
CardView tmp = ((StackAbilityView)card).getSourceCard();
|
||||||
|
tmp.overrideRules(card.getRules());
|
||||||
|
tmp.setIsAbility(true);
|
||||||
|
tmp.overrideTargets(card.getTargets());
|
||||||
|
card = tmp;
|
||||||
|
}
|
||||||
|
if (!cards.containsKey(card.getId())) {
|
||||||
|
addCard(card, bigCard, gameId);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
cards.get(card.getId()).update(card);
|
||||||
|
}
|
||||||
|
|
||||||
cardArea.setPreferredSize(new Dimension(cards.size() * Config.dimensions.frameWidth, Config.dimensions.frameHeight));
|
cardArea.setPreferredSize(new Dimension(cards.size() * Config.dimensions.frameWidth, Config.dimensions.frameHeight));
|
||||||
cardArea.revalidate();
|
cardArea.revalidate();
|
||||||
cardArea.repaint();
|
cardArea.repaint();
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(AbilityPickerView choices, Point p) {
|
public void show(AbilityPickerView choices, Point p) {
|
||||||
|
if (p == null) return;
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||||
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
|
|
@ -45,7 +44,6 @@ import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import javax.swing.Popup;
|
import javax.swing.Popup;
|
||||||
import javax.swing.PopupFactory;
|
import javax.swing.PopupFactory;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
|
|
@ -70,26 +71,45 @@ public class MageActionCallback implements ActionCallback {
|
||||||
// Draw Arrows for targets
|
// Draw Arrows for targets
|
||||||
List<UUID> targets = data.card.getTargets();
|
List<UUID> targets = data.card.getTargets();
|
||||||
if (targets != null) {
|
if (targets != null) {
|
||||||
|
Point parent = SwingUtilities.getRoot(data.component).getLocationOnScreen();
|
||||||
|
Point me = new Point(data.locationOnScreen);
|
||||||
|
me.translate(-parent.x, -parent.y);
|
||||||
for (UUID uuid : targets) {
|
for (UUID uuid : targets) {
|
||||||
//System.out.println("Getting play area panel for uuid: " + uuid);
|
//System.out.println("Getting play area panel for uuid: " + uuid);
|
||||||
|
|
||||||
PlayAreaPanel p = session.getGame().getPlayers().get(uuid);
|
PlayAreaPanel p = session.getGame().getPlayers().get(uuid);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Point target = p.getLocationOnScreen();
|
Point target = p.getLocationOnScreen();
|
||||||
Point me = data.locationOnScreen;
|
target.translate(-parent.x, -parent.y);
|
||||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red);
|
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red);
|
||||||
} else {
|
} else {
|
||||||
for (PlayAreaPanel pa : session.getGame().getPlayers().values()) {
|
for (PlayAreaPanel pa : session.getGame().getPlayers().values()) {
|
||||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point target = permanent.getLocationOnScreen();
|
Point target = permanent.getLocationOnScreen();
|
||||||
Point me = data.locationOnScreen;
|
target.translate(-parent.x, -parent.y);
|
||||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red);
|
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw Arrows for source
|
||||||
|
if (data.card.isAbility()) {
|
||||||
|
Point parent = SwingUtilities.getRoot(data.component).getLocationOnScreen();
|
||||||
|
Point me = new Point(data.locationOnScreen);
|
||||||
|
me.translate(-parent.x, -parent.y);
|
||||||
|
UUID uuid = data.card.getId();
|
||||||
|
for (PlayAreaPanel pa : session.getGame().getPlayers().values()) {
|
||||||
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
|
if (permanent != null) {
|
||||||
|
Point source = permanent.getLocationOnScreen();
|
||||||
|
source.translate(-parent.x, -parent.y);
|
||||||
|
ArrowBuilder.addArrow((int)source.getX() + 40, (int)source.getY() + 10, (int)me.getX() + 35, (int)me.getY() + 20, Color.blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -99,13 +119,18 @@ public class MageActionCallback implements ActionCallback {
|
||||||
|
|
||||||
MageCard card = (MageCard) data.component;
|
MageCard card = (MageCard) data.component;
|
||||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
||||||
synchronized (MageMouseAdapter.class) {
|
synchronized (MageActionCallback.class) {
|
||||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
||||||
Image image = card.getImage();
|
Image image = card.getImage();
|
||||||
if (image != null && image instanceof BufferedImage) {
|
if (image != null && image instanceof BufferedImage) {
|
||||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight());
|
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight());
|
||||||
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules());
|
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules());
|
||||||
bigCard.hideTextComponent();
|
bigCard.showTextComponent();
|
||||||
|
if (card.getOriginal().isAbility()) {
|
||||||
|
bigCard.showTextComponent();
|
||||||
|
} else {
|
||||||
|
bigCard.hideTextComponent();
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
||||||
panel.setVisible(true);
|
panel.setVisible(true);
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
package mage.client.plugins.adapters;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
|
||||||
import mage.client.MageFrame;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
|
||||||
import mage.client.util.DefaultActionCallback;
|
|
||||||
|
|
||||||
public class MageMouseAdapter extends MouseAdapter {
|
|
||||||
|
|
||||||
private Component parent;
|
|
||||||
private UUID gameId;
|
|
||||||
protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
|
||||||
|
|
||||||
public MageMouseAdapter(Component parent, UUID gameId) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.gameId = gameId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
if (!Plugins.getInstance().isCardPluginLoaded())
|
|
||||||
return;
|
|
||||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
|
||||||
int count = e.getClickCount();
|
|
||||||
if (count > 0) {
|
|
||||||
Object o = parent.getComponentAt(e.getPoint());
|
|
||||||
if (o instanceof MageCard) {
|
|
||||||
MageCard selectedCard = (MageCard) o;
|
|
||||||
// TODO: uncomment when attached cards works in plugin
|
|
||||||
/*
|
|
||||||
* int x = e.getX() - selectedCard.getX(); int y = e.getY()
|
|
||||||
* - selectedCard.getY(); CardView card =
|
|
||||||
* selectedCard.getCardByPosition(x, y);
|
|
||||||
*/
|
|
||||||
defaultCallback.mouseClicked(e, gameId, MageFrame.getSession(), selectedCard.getOriginal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
package mage.client.plugins.adapters;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseMotionAdapter;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
|
||||||
import mage.client.cards.BigCard;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
|
||||||
import mage.client.util.ImageHelper;
|
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
|
||||||
|
|
||||||
import org.jdesktop.swingx.JXPanel;
|
|
||||||
|
|
||||||
public class MageMouseMotionAdapter extends MouseMotionAdapter {
|
|
||||||
|
|
||||||
private Component parent;
|
|
||||||
private BigCard bigCard;
|
|
||||||
|
|
||||||
public MageMouseMotionAdapter(Component parent, BigCard bigCard) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.bigCard = bigCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
if (!Plugins.getInstance().isCardPluginLoaded()) {return;}
|
|
||||||
if (bigCard == null) {return;}
|
|
||||||
Object o = parent.getComponentAt(e.getPoint());
|
|
||||||
if (o instanceof MageCard) {
|
|
||||||
MageCard card = (MageCard) o;
|
|
||||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
|
||||||
synchronized (MageMouseAdapter.class) {
|
|
||||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
|
||||||
Image image = card.getImage();
|
|
||||||
if (image != null && image instanceof BufferedImage) {
|
|
||||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight());
|
|
||||||
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules());
|
|
||||||
bigCard.hideTextComponent();
|
|
||||||
} else {
|
|
||||||
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
|
||||||
panel.setVisible(true);
|
|
||||||
bigCard.hideTextComponent();
|
|
||||||
bigCard.addJXPanel(card.getOriginal().getId(), panel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -36,11 +36,13 @@ import java.util.UUID;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.abilities.Ability;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.PermanentToken;
|
import mage.game.permanent.PermanentToken;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
|
import mage.game.stack.StackObject;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.Targets;
|
import mage.target.Targets;
|
||||||
|
|
||||||
|
|
@ -65,6 +67,7 @@ public class CardView implements Serializable {
|
||||||
protected Rarity rarity;
|
protected Rarity rarity;
|
||||||
protected String expansionSetCode;
|
protected String expansionSetCode;
|
||||||
protected int cardNumber;
|
protected int cardNumber;
|
||||||
|
protected boolean isAbility;
|
||||||
|
|
||||||
public List<UUID> targets;
|
public List<UUID> targets;
|
||||||
|
|
||||||
|
|
@ -101,15 +104,7 @@ public class CardView implements Serializable {
|
||||||
if (card instanceof Spell) {
|
if (card instanceof Spell) {
|
||||||
Spell<?> spell = (Spell<?>)card;
|
Spell<?> spell = (Spell<?>)card;
|
||||||
if (spell.getSpellAbility().getTargets().size() > 0) {
|
if (spell.getSpellAbility().getTargets().size() > 0) {
|
||||||
Targets targets = spell.getSpellAbility().getTargets();
|
setTargets(spell.getSpellAbility().getTargets());
|
||||||
for (Target target : targets) {
|
|
||||||
if (target.isChosen()) {
|
|
||||||
for (UUID targetUUID : target.getTargets()) {
|
|
||||||
if (this.targets == null) this.targets = new ArrayList<UUID>();
|
|
||||||
this.targets.add(targetUUID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +130,17 @@ public class CardView implements Serializable {
|
||||||
this.expansionSetCode = "";
|
this.expansionSetCode = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setTargets(Targets targets) {
|
||||||
|
for (Target target : targets) {
|
||||||
|
if (target.isChosen()) {
|
||||||
|
for (UUID targetUUID : target.getTargets()) {
|
||||||
|
if (this.targets == null) this.targets = new ArrayList<UUID>();
|
||||||
|
this.targets.add(targetUUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected List<String> formatRules(List<String> rules) {
|
protected List<String> formatRules(List<String> rules) {
|
||||||
List<String> newRules = new ArrayList<String>();
|
List<String> newRules = new ArrayList<String>();
|
||||||
for (String rule: rules) {
|
for (String rule: rules) {
|
||||||
|
|
@ -156,7 +162,19 @@ public class CardView implements Serializable {
|
||||||
public List<String> getRules() {
|
public List<String> getRules() {
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void overrideRules(List<String> rules) {
|
||||||
|
this.rules = rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAbility(boolean isAbility) {
|
||||||
|
this.isAbility = isAbility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAbility() {
|
||||||
|
return isAbility;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPower() {
|
public String getPower() {
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
|
@ -218,6 +236,10 @@ public class CardView implements Serializable {
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void overrideTargets(List<UUID> newTargets) {
|
||||||
|
this.targets = newTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName() + " [" + getId() + "]";
|
return getName() + " [" + getId() + "]";
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,11 @@ package mage.view;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
import mage.Constants.PhaseStep;
|
import mage.Constants.PhaseStep;
|
||||||
import mage.Constants.TurnPhase;
|
import mage.Constants.TurnPhase;
|
||||||
import mage.MageObject;
|
import mage.cards.Card;
|
||||||
import mage.game.ExileZone;
|
import mage.game.ExileZone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameState;
|
import mage.game.GameState;
|
||||||
|
|
@ -68,10 +70,11 @@ public class GameView implements Serializable {
|
||||||
for (StackObject stackObject: state.getStack()) {
|
for (StackObject stackObject: state.getStack()) {
|
||||||
if (stackObject instanceof StackAbility) {
|
if (stackObject instanceof StackAbility) {
|
||||||
MageObject object = game.getObject(stackObject.getSourceId());
|
MageObject object = game.getObject(stackObject.getSourceId());
|
||||||
|
Card card = game.getCard(stackObject.getSourceId());
|
||||||
if (object != null)
|
if (object != null)
|
||||||
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName()));
|
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName(), new CardView(card)));
|
||||||
else
|
else
|
||||||
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, ""));
|
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import mage.game.stack.StackAbility;
|
import mage.game.stack.StackAbility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,11 +39,13 @@ import mage.game.stack.StackAbility;
|
||||||
public class StackAbilityView extends CardView {
|
public class StackAbilityView extends CardView {
|
||||||
|
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
|
private CardView sourceCard;
|
||||||
|
|
||||||
public StackAbilityView(StackAbility ability, String sourceName) {
|
public StackAbilityView(StackAbility ability, String sourceName, CardView sourceCard) {
|
||||||
this.id = ability.getId();
|
this.id = ability.getId();
|
||||||
this.name = "Ability";
|
this.name = "Ability";
|
||||||
this.sourceName = sourceName;
|
this.sourceName = sourceName;
|
||||||
|
this.sourceCard = sourceCard;
|
||||||
this.rules = new ArrayList<String>();
|
this.rules = new ArrayList<String>();
|
||||||
rules.add(formatRule(ability.getRule()));
|
rules.add(formatRule(ability.getRule()));
|
||||||
this.power = ability.getPower().toString();
|
this.power = ability.getPower().toString();
|
||||||
|
|
@ -54,6 +57,7 @@ public class StackAbilityView extends CardView {
|
||||||
this.color = ability.getColor();
|
this.color = ability.getColor();
|
||||||
this.manaCost = ability.getManaCost().getSymbols();
|
this.manaCost = ability.getManaCost().getSymbols();
|
||||||
this.art = "";
|
this.art = "";
|
||||||
|
setTargets(ability.getTargets());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -62,5 +66,8 @@ public class StackAbilityView extends CardView {
|
||||||
newRule.replace("{source}", this.sourceName);
|
newRule.replace("{source}", this.sourceName);
|
||||||
return newRule;
|
return newRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CardView getSourceCard() {
|
||||||
|
return this.sourceCard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue