From e759f8a0fc54408bcc6ba02fbd18c1df4ddb22a0 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Tue, 12 Jun 2012 12:55:15 +0400 Subject: [PATCH] Added possibility to display any data on card's tooltip --- Mage/src/mage/cards/Card.java | 2 ++ Mage/src/mage/cards/CardImpl.java | 24 ++++++++++++++++++++---- Mage/src/mage/game/stack/Spell.java | 5 +++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Mage/src/mage/cards/Card.java b/Mage/src/mage/cards/Card.java index 45988f0135..f143144949 100644 --- a/Mage/src/mage/cards/Card.java +++ b/Mage/src/mage/cards/Card.java @@ -68,6 +68,8 @@ public interface Card extends MageObject { public void assignNewId(); public int getZoneChangeCounter(); + + public void addInfo(String key, String value); /** * Moves the card to the specified zone diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index 1fc0102aad..c93f16cfc0 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -45,10 +45,7 @@ import mage.watchers.Watcher; import org.apache.log4j.Logger; import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; +import java.util.*; public abstract class CardImpl> extends MageObjectImpl implements Card { private static final long serialVersionUID = 1L; @@ -67,6 +64,7 @@ public abstract class CardImpl> extends MageObjectImpl protected SpellAbility spellAbility; protected boolean flipCard; protected int zoneChangeCounter = 1; + protected Map info; public CardImpl(UUID ownerId, int cardNumber, String name, Rarity rarity, CardType[] cardTypes, String costs) { this(ownerId, name); @@ -107,6 +105,11 @@ public abstract class CardImpl> extends MageObjectImpl secondSideCard = card.secondSideCard; nightCard = card.nightCard; } + + if (card.info != null) { + info = new HashMap(); + info.putAll(card.info); + } } @Override @@ -154,6 +157,11 @@ public abstract class CardImpl> extends MageObjectImpl if (cardType.contains(CardType.INSTANT) || cardType.contains(CardType.SORCERY)) { rules.add(0, getSpellAbility().getRule(this.name)); } + if (info != null) { + for (String data : info.values()) { + rules.add(data); + } + } return rules; } @@ -437,4 +445,12 @@ public abstract class CardImpl> extends MageObjectImpl private void updateZoneChangeCounter() { zoneChangeCounter++; } + + @Override + public void addInfo(String key, String value) { + if (info == null) { + info = new HashMap(); + } + info.put(key, value); + } } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 9455bb4148..a81f03e5c0 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -442,6 +442,11 @@ public class Spell> implements StackObject, Card { return card.getZoneChangeCounter(); } + @Override + public void addInfo(String key, String value) { + // do nothing + } + public void setCopiedSpell(boolean isCopied) { this.copiedSpell = isCopied; }