Changes to show name and number of counter on a card.

This commit is contained in:
LevelX2 2013-03-04 00:03:21 +01:00
parent cc96a55523
commit dc131fa8dd
5 changed files with 60 additions and 13 deletions

View file

@ -57,10 +57,12 @@ import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static mage.constants.Constants.*;
import mage.view.CounterView;
/**
*
@ -243,7 +245,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
}
protected List<String> getRules() {
return card.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();
}
}
protected String getType(CardView card) {

View file

@ -57,8 +57,7 @@ public class ExileZoneDialog extends MageDialog {
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
this.title = exile.getName();
this.setTitelBarToolTip(exile.getName());
boolean changed = false;
changed = cards.loadCards(exile, bigCard, gameId);
boolean changed = cards.loadCards(exile, bigCard, gameId, null);
if (exile.size() > 0) {
show();
if (changed) {

View file

@ -32,15 +32,20 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
setBackground(Color.white);
}
@Override
public void setCard(final CardView card, final Component container) {
if (card == null) return;
if (isCurrentCard(card)) return;
if (card == null || isCurrentCard(card)) {
return;
}
currentCard = card;
ThreadUtils.threadPool.submit(new Runnable() {
@Override
public void run() {
try {
if (!card.equals(currentCard)) return;
if (!card.equals(currentCard)) {
return;
}
String manaCost = "";
for (String m : card.getManaCost()) {
@ -51,8 +56,9 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
int symbolCount = 0;
int offset = 0;
while ((offset = castingCost.indexOf("<img", offset) + 1) != 0)
while ((offset = castingCost.indexOf("<img", offset) + 1) != 0) {
symbolCount++;
}
List<String> rules = card.getRules();
List<String> rulings = new ArrayList<String>(rules);
@ -61,24 +67,33 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
if (card.getPairedCard() != null) {
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;
if (count > 0) {
StringBuilder sb = new StringBuilder();
int index = 0;
for (CounterView counter : ((PermanentView) card).getCounters()) {
for (CounterView counter : counters) {
if (counter.getCount() > 0) {
if (index == 0) {
sb.append("<b>Counters:</b> ");
} else {
sb.append(", ");
}
sb.append(counter.getCount() + "x<i>" + counter.getName() + "</i>");
sb.append(counter.getCount()).append("x<i>").append(counter.getName()).append("</i>");
index++;
}
}
rulings.add(sb.toString());
}
}
if (card instanceof PermanentView) {
int damage = ((PermanentView)card).getDamage();
if (damage > 0) {
rulings.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");

View file

@ -47,6 +47,8 @@ import mage.target.Targets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.counters.Counter;
import mage.counters.Counters;
/**
* @author BetaSteward_at_googlemail.com
@ -79,6 +81,7 @@ public class CardView extends SimpleCardView {
protected UUID pairedCard;
protected boolean paid;
protected List<CounterView> counters;
public CardView(Card card, UUID cardId) {
this(card);
@ -121,7 +124,12 @@ public class CardView extends SimpleCardView {
} else {
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) {
this.secondCardFace = new CardView(card.getSecondCardFace());
}
@ -161,6 +169,16 @@ public class CardView extends SimpleCardView {
this.color = card.getColor();
this.manaCost = card.getManaCost().getSymbols();
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) {
this.rarity = Rarity.COMMON;
this.expansionSetCode = ((PermanentToken) card).getExpansionSetCode();
@ -411,4 +429,8 @@ public class CardView extends SimpleCardView {
public void setPaid(boolean paid) {
this.paid = paid;
}
public List<CounterView> getCounters() {
return counters;
}
}

View file

@ -37,7 +37,7 @@ import mage.game.Game;
*
* @author BetaSteward_at_googlemail.com
*/
public class ExileView extends SimpleCardsView {
public class ExileView extends CardsView {
private static final long serialVersionUID = 1L;
private String name;
@ -47,7 +47,7 @@ public class ExileView extends SimpleCardsView {
this.name = exileZone.getName();
this.id = exileZone.getId();
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));
}
}