mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Changes to show name and number of counter on a card.
This commit is contained in:
parent
cc96a55523
commit
dc131fa8dd
5 changed files with 60 additions and 13 deletions
|
|
@ -57,10 +57,12 @@ import javax.swing.text.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static mage.constants.Constants.*;
|
import static mage.constants.Constants.*;
|
||||||
|
import mage.view.CounterView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -243,8 +245,17 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> getRules() {
|
protected List<String> getRules() {
|
||||||
|
if (card.getCounters() != null) {
|
||||||
|
List<String> rules = new ArrayList<String>(card.getRules());
|
||||||
|
for (CounterView counter: card.getCounters()) {
|
||||||
|
rules.add(counter.getCount() + " x " + counter.getName());
|
||||||
|
}
|
||||||
|
return rules;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return card.getRules();
|
return card.getRules();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected String getType(CardView card) {
|
protected String getType(CardView card) {
|
||||||
StringBuilder sbType = new StringBuilder();
|
StringBuilder sbType = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,7 @@ public class ExileZoneDialog extends MageDialog {
|
||||||
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
||||||
this.title = exile.getName();
|
this.title = exile.getName();
|
||||||
this.setTitelBarToolTip(exile.getName());
|
this.setTitelBarToolTip(exile.getName());
|
||||||
boolean changed = false;
|
boolean changed = cards.loadCards(exile, bigCard, gameId, null);
|
||||||
changed = cards.loadCards(exile, bigCard, gameId);
|
|
||||||
if (exile.size() > 0) {
|
if (exile.size() > 0) {
|
||||||
show();
|
show();
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,20 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
setBackground(Color.white);
|
setBackground(Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setCard(final CardView card, final Component container) {
|
public void setCard(final CardView card, final Component container) {
|
||||||
if (card == null) return;
|
if (card == null || isCurrentCard(card)) {
|
||||||
if (isCurrentCard(card)) return;
|
return;
|
||||||
|
}
|
||||||
currentCard = card;
|
currentCard = card;
|
||||||
|
|
||||||
ThreadUtils.threadPool.submit(new Runnable() {
|
ThreadUtils.threadPool.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (!card.equals(currentCard)) return;
|
if (!card.equals(currentCard)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String manaCost = "";
|
String manaCost = "";
|
||||||
for (String m : card.getManaCost()) {
|
for (String m : card.getManaCost()) {
|
||||||
|
|
@ -51,8 +56,9 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
|
|
||||||
int symbolCount = 0;
|
int symbolCount = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
while ((offset = castingCost.indexOf("<img", offset) + 1) != 0)
|
while ((offset = castingCost.indexOf("<img", offset) + 1) != 0) {
|
||||||
symbolCount++;
|
symbolCount++;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> rules = card.getRules();
|
List<String> rules = card.getRules();
|
||||||
List<String> rulings = new ArrayList<String>(rules);
|
List<String> rulings = new ArrayList<String>(rules);
|
||||||
|
|
@ -61,24 +67,33 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
if (card.getPairedCard() != null) {
|
if (card.getPairedCard() != null) {
|
||||||
rulings.add("<span color='green'><i>Paired with another creature</i></span>");
|
rulings.add("<span color='green'><i>Paired with another creature</i></span>");
|
||||||
}
|
}
|
||||||
List<CounterView> counters = ((PermanentView) card).getCounters();
|
}
|
||||||
|
if (!card.isAbility() && (card instanceof PermanentView || card instanceof CardView)) {
|
||||||
|
List<CounterView> counters;
|
||||||
|
if (card instanceof PermanentView) {
|
||||||
|
counters = ((PermanentView) card).getCounters();
|
||||||
|
} else {
|
||||||
|
counters = ((CardView) card).getCounters();
|
||||||
|
}
|
||||||
int count = counters != null ? counters.size() : 0;
|
int count = counters != null ? counters.size() : 0;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (CounterView counter : ((PermanentView) card).getCounters()) {
|
for (CounterView counter : counters) {
|
||||||
if (counter.getCount() > 0) {
|
if (counter.getCount() > 0) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
sb.append("<b>Counters:</b> ");
|
sb.append("<b>Counters:</b> ");
|
||||||
} else {
|
} else {
|
||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
}
|
}
|
||||||
sb.append(counter.getCount() + "x<i>" + counter.getName() + "</i>");
|
sb.append(counter.getCount()).append("x<i>").append(counter.getName()).append("</i>");
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rulings.add(sb.toString());
|
rulings.add(sb.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (card instanceof PermanentView) {
|
||||||
int damage = ((PermanentView)card).getDamage();
|
int damage = ((PermanentView)card).getDamage();
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
rulings.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
rulings.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ import mage.target.Targets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.counters.Counter;
|
||||||
|
import mage.counters.Counters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -79,6 +81,7 @@ public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
protected UUID pairedCard;
|
protected UUID pairedCard;
|
||||||
protected boolean paid;
|
protected boolean paid;
|
||||||
|
protected List<CounterView> counters;
|
||||||
|
|
||||||
public CardView(Card card, UUID cardId) {
|
public CardView(Card card, UUID cardId) {
|
||||||
this(card);
|
this(card);
|
||||||
|
|
@ -121,7 +124,12 @@ public class CardView extends SimpleCardView {
|
||||||
} else {
|
} else {
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
}
|
}
|
||||||
|
if (card.getCounters() != null && !card.getCounters().isEmpty()) {
|
||||||
|
counters = new ArrayList<CounterView>();
|
||||||
|
for (Counter counter: card.getCounters().values()) {
|
||||||
|
counters.add(new CounterView(counter));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (card.getSecondCardFace() != null) {
|
if (card.getSecondCardFace() != null) {
|
||||||
this.secondCardFace = new CardView(card.getSecondCardFace());
|
this.secondCardFace = new CardView(card.getSecondCardFace());
|
||||||
}
|
}
|
||||||
|
|
@ -161,6 +169,16 @@ public class CardView extends SimpleCardView {
|
||||||
this.color = card.getColor();
|
this.color = card.getColor();
|
||||||
this.manaCost = card.getManaCost().getSymbols();
|
this.manaCost = card.getManaCost().getSymbols();
|
||||||
this.convertedManaCost = card.getManaCost().convertedManaCost();
|
this.convertedManaCost = card.getManaCost().convertedManaCost();
|
||||||
|
// if (card instanceof Card) {
|
||||||
|
// Counters cardCounters = ((Card) card).getCounters();
|
||||||
|
// if (cardCounters != null && !cardCounters.isEmpty()) {
|
||||||
|
// counters = new ArrayList<CounterView>();
|
||||||
|
// for (Counter counter: cardCounters.values()) {
|
||||||
|
// counters.add(new CounterView(counter));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (card instanceof PermanentToken) {
|
if (card instanceof PermanentToken) {
|
||||||
this.rarity = Rarity.COMMON;
|
this.rarity = Rarity.COMMON;
|
||||||
this.expansionSetCode = ((PermanentToken) card).getExpansionSetCode();
|
this.expansionSetCode = ((PermanentToken) card).getExpansionSetCode();
|
||||||
|
|
@ -411,4 +429,8 @@ public class CardView extends SimpleCardView {
|
||||||
public void setPaid(boolean paid) {
|
public void setPaid(boolean paid) {
|
||||||
this.paid = paid;
|
this.paid = paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CounterView> getCounters() {
|
||||||
|
return counters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ExileView extends SimpleCardsView {
|
public class ExileView extends CardsView {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
@ -47,7 +47,7 @@ public class ExileView extends SimpleCardsView {
|
||||||
this.name = exileZone.getName();
|
this.name = exileZone.getName();
|
||||||
this.id = exileZone.getId();
|
this.id = exileZone.getId();
|
||||||
for (Card card: exileZone.getCards(game)) {
|
for (Card card: exileZone.getCards(game)) {
|
||||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown(), card.getUsesVariousArt()));
|
this.put(card.getId(), new CardView(card));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue