diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 90f21edbcb0..c7938ddacf1 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -390,7 +390,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { commandZone.setObserver(new Command() { @Override public void execute() { - btnExileZoneActionPerformed(null); + btnCommandZoneActionPerformed(null); } }); commandZone.setBounds(0, 0, 21, 21); @@ -650,7 +650,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { DialogManager.getManager(gameId).showGraveyardDialog(CardsViewUtil.convertSimple(player.getGraveyard()), bigCard, gameId); } - private void btnExileZoneActionPerformed(java.awt.event.ActionEvent evt) { + private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) { DialogManager.getManager(gameId).showEmblemsDialog(CardsViewUtil.convertEmblems(player.getEmblemList()), bigCard, gameId); } diff --git a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java index c77c240dd14..56eca3d5b01 100644 --- a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java @@ -59,9 +59,7 @@ public class CardsViewUtil { CardsView cards = new CardsView(); for (EmblemView emblem : view) { - CardView cardView = new CardView(emblem.getName()); - cardView.overrideRules(emblem.getRules()); - cardView.setExpansionSetCode(emblem.getExpansionSetCode()); + CardView cardView = new CardView(emblem); cards.put(emblem.getId(), cardView); } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java index 16269a07503..9bd8b66e356 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java @@ -14,6 +14,7 @@ import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.List; +import mage.constants.MageObjectType; /** * Card info pane for displaying card rules. @@ -63,12 +64,12 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { List rules = card.getRules(); List rulings = new ArrayList(rules); - if (card instanceof PermanentView) { + if (card.getMageObjectType().equals(MageObjectType.PERMANENT)) { if (card.getPairedCard() != null) { rulings.add("Paired with another creature"); } } - if (!card.isAbility() && (card instanceof PermanentView || card instanceof CardView)) { + if (card.getMageObjectType().canHaveCounters()) { List counters; if (card instanceof PermanentView) { counters = ((PermanentView) card).getCounters(); @@ -93,7 +94,7 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { rulings.add(sb.toString()); } } - if (card instanceof PermanentView) { + if (card.getMageObjectType().isPermanent()) { int damage = ((PermanentView)card).getDamage(); if (damage > 0) { rulings.add("Damage dealt: " + damage + ""); @@ -155,15 +156,10 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { pt = card.getLoyalty().toString(); } - if (pt.length() > 0 || card.isToken()) { - buffer.append(""); - if (card.isToken()) { - buffer.append(""); - } - - buffer.append("
"); - buffer.append(pt).append("Token
"); - } + buffer.append(""); + buffer.append(""); + buffer.append("
"); + buffer.append(pt).append("").append(card.getMageObjectType().toString()).append("
"); StringBuilder rule = new StringBuilder("
"); if (card.isSplitCard()) { diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index d619065ea54..731a18fd452 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -28,31 +28,31 @@ package mage.view; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.MageObject; -import mage.ObjectColor; -import mage.cards.Card; -import mage.constants.SpellAbilityType; -import mage.constants.Zone; -import mage.counters.CounterType; -import mage.game.permanent.Permanent; -import mage.game.permanent.PermanentToken; -import mage.game.permanent.token.Token; -import mage.game.stack.StackAbility; -import mage.target.Target; -import mage.target.Targets; - import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.abilities.Mode; +import mage.MageObject; +import mage.ObjectColor; import mage.abilities.Modes; import mage.abilities.SpellAbility; import mage.abilities.costs.mana.ManaCosts; +import mage.cards.Card; import mage.cards.SplitCard; +import mage.constants.CardType; +import mage.constants.MageObjectType; +import mage.constants.Rarity; +import mage.constants.SpellAbilityType; +import mage.constants.Zone; import mage.counters.Counter; +import mage.counters.CounterType; +import mage.game.command.Emblem; +import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentToken; +import mage.game.permanent.token.Token; import mage.game.stack.Spell; +import mage.game.stack.StackAbility; +import mage.target.Target; +import mage.target.Targets; /** * @author BetaSteward_at_googlemail.com @@ -74,7 +74,12 @@ public class CardView extends SimpleCardView { protected List manaCost; protected int convertedManaCost; protected Rarity rarity; + + protected MageObjectType mageObjectType; + protected boolean isAbility; + protected boolean isToken; + protected CardView ability; protected int type; @@ -83,7 +88,6 @@ public class CardView extends SimpleCardView { protected boolean transformed; protected boolean isSplitCard; - protected boolean isToken; protected String leftSplitName; protected ManaCosts leftSplitCosts; protected List leftSplitRules; @@ -136,12 +140,19 @@ public class CardView extends SimpleCardView { this.convertedManaCost = card.getManaCost().convertedManaCost(); if (card instanceof Permanent) { + this.mageObjectType = MageObjectType.PERMANENT; Permanent permanent = (Permanent)card; this.power = Integer.toString(card.getPower().getValue()); this.toughness = Integer.toString(card.getToughness().getValue()); this.loyalty = Integer.toString(permanent.getCounters().getCount(CounterType.LOYALTY)); this.pairedCard = permanent.getPairedCard(); } else { + + if (card.isCopy()) { + this.mageObjectType = MageObjectType.COPY_CARD; + } else { + this.mageObjectType = MageObjectType.CARD; + } this.power = card.getPower().toString(); this.toughness = card.getToughness().toString(); this.loyalty = ""; @@ -155,6 +166,7 @@ public class CardView extends SimpleCardView { if (card instanceof PermanentToken) { this.isToken = true; + this.mageObjectType = MageObjectType.TOKEN; this.rarity = Rarity.COMMON; if (((PermanentToken) card).getToken().getOriginalCardNumber() > 0) { // a token copied from permanent @@ -183,6 +195,7 @@ public class CardView extends SimpleCardView { } if (card instanceof Spell) { + this.mageObjectType = MageObjectType.SPELL; Spell spell = (Spell) card; for (SpellAbility spellAbility: spell.getSpellAbilities()) { for(UUID modeId : spellAbility.getModes().getSelectedModes()) { @@ -204,34 +217,41 @@ public class CardView extends SimpleCardView { } - public CardView(MageObject card) { - super(card.getId(), "", 0, false, false); - this.name = card.getName(); - if (card instanceof Permanent) { - this.power = Integer.toString(card.getPower().getValue()); - this.toughness = Integer.toString(card.getToughness().getValue()); - this.loyalty = Integer.toString(((Permanent) card).getCounters().getCount(CounterType.LOYALTY)); + public CardView(MageObject object) { + super(object.getId(), "", 0, false, false); + this.name = object.getName(); + this.displayName = object.getName(); + if (object instanceof Permanent) { + this.mageObjectType = MageObjectType.PERMANENT; + this.power = Integer.toString(object.getPower().getValue()); + this.toughness = Integer.toString(object.getToughness().getValue()); + this.loyalty = Integer.toString(((Permanent) object).getCounters().getCount(CounterType.LOYALTY)); } else { - this.power = card.getPower().toString(); - this.toughness = card.getToughness().toString(); + this.power = object.getPower().toString(); + this.toughness = object.getToughness().toString(); this.loyalty = ""; } - this.cardTypes = card.getCardType(); - this.subTypes = card.getSubtype(); - this.superTypes = card.getSupertype(); - this.color = card.getColor(); - this.manaCost = card.getManaCost().getSymbols(); - this.convertedManaCost = card.getManaCost().convertedManaCost(); - - if (card instanceof PermanentToken) { - PermanentToken permanentToken = (PermanentToken) card; + this.cardTypes = object.getCardType(); + this.subTypes = object.getSubtype(); + this.superTypes = object.getSupertype(); + this.color = object.getColor(); + this.manaCost = object.getManaCost().getSymbols(); + this.convertedManaCost = object.getManaCost().convertedManaCost(); + if (object instanceof PermanentToken) { + this.mageObjectType = MageObjectType.TOKEN; + PermanentToken permanentToken = (PermanentToken) object; this.rarity = Rarity.COMMON; this.expansionSetCode = permanentToken.getExpansionSetCode(); this.rules = permanentToken.getRules(); this.type = permanentToken.getToken().getTokenType(); + } else if (object instanceof Emblem) { + this.mageObjectType = MageObjectType.EMBLEM; + Emblem emblem = (Emblem) object; + this.rarity = Rarity.SPECIAL; + this.rules = emblem.getAbilities().getRules(emblem.getName()); } - if (this.rarity == null && card instanceof StackAbility) { - StackAbility stackAbility = (StackAbility)card; + if (this.rarity == null && object instanceof StackAbility) { + StackAbility stackAbility = (StackAbility)object; this.rarity = Rarity.NA; this.rules = new ArrayList(); this.rules.add(stackAbility.getRule()); @@ -244,6 +264,15 @@ public class CardView extends SimpleCardView { protected CardView() { super(null, "", 0, false, false); } + + public CardView(EmblemView emblem) { + this(true); + this.mageObjectType = MageObjectType.EMBLEM; + this.name = emblem.getName(); + this.displayName = name; + this.rules = emblem.getRules(); + this.expansionSetCode = emblem.getExpansionSetCode(); + } public CardView(boolean empty) { super(null, "", 0, false, false); @@ -253,9 +282,11 @@ public class CardView extends SimpleCardView { fillEmpty(); } + public CardView(String name) { this(true); this.name = name; + this.displayName = name; } private void fillEmpty() { @@ -277,8 +308,10 @@ public class CardView extends SimpleCardView { CardView(Token token) { super(token.getId(), "", 0, false, false); + this.isToken = true; this.id = token.getId(); this.name = token.getName(); + this.displayName = token.getName(); this.rules = token.getAbilities().getRules(this.name); this.power = token.getPower().toString(); this.toughness = token.getToughness().toString(); @@ -490,6 +523,14 @@ public class CardView extends SimpleCardView { return type; } + public MageObjectType getMageObjectType() { + return mageObjectType; + } + + public void setMageObjectType(MageObjectType mageObjectType) { + this.mageObjectType = mageObjectType; + } + public boolean isPaid() { return paid; } diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index db5535cf492..6918dfbad93 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -44,6 +44,7 @@ import mage.game.Game; import mage.game.GameState; import mage.game.combat.CombatGroup; import mage.game.command.CommandObject; +import mage.game.command.Emblem; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentToken; import mage.game.stack.Spell; @@ -101,20 +102,21 @@ public class GameView implements Serializable { PermanentToken token = (PermanentToken)object; stack.put(stackObject.getId(), new CardView(token)); checkPaid(stackObject.getId(), (StackAbility)stackObject); + } else if (object instanceof Emblem) { + Card sourceCard = game.getCard(((Emblem)object).getSourceId()); + if (sourceCard != null) { + ((StackAbility)stackObject).setName("Emblem " + sourceCard.getName()); + ((StackAbility)stackObject).setExpansionSetCode(sourceCard.getExpansionSetCode()); + } else { + throw new IllegalArgumentException("Source card for emblem not found."); + } + stack.put(stackObject.getId(), new StackAbilityView(game, (StackAbility)stackObject, object.getName(), new CardView(((StackAbility)stackObject)))); + checkPaid(stackObject.getId(), ((StackAbility)stackObject)); } else { StackAbility stackAbility = ((StackAbility)object); stackAbility.newId(); - MageObject emblem = game.getEmblem(stackAbility.getSourceId()); - if (emblem != null) { - Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId()); - if (sourceCard != null) { - stackAbility.setName("Emblem " + sourceCard.getName()); - stackAbility.setExpansionSetCode(sourceCard.getExpansionSetCode()); - } - } - - stack.put(stackObject.getId(), new CardView(stackAbility)); - checkPaid(stackObject.getId(), stackAbility); + stack.put(stackObject.getId(), new CardView(((StackAbility)stackObject))); + checkPaid(stackObject.getId(), ((StackAbility)stackObject)); } } } diff --git a/Mage.Common/src/mage/view/StackAbilityView.java b/Mage.Common/src/mage/view/StackAbilityView.java index 1b4d35124fc..1ebe6c4bb66 100644 --- a/Mage.Common/src/mage/view/StackAbilityView.java +++ b/Mage.Common/src/mage/view/StackAbilityView.java @@ -34,6 +34,7 @@ import java.util.UUID; import mage.MageObject; import mage.abilities.Modes; import mage.abilities.effects.Effect; +import mage.constants.MageObjectType; import mage.game.Game; import mage.game.stack.StackAbility; import mage.target.targetpointer.FixedTarget; @@ -46,14 +47,14 @@ import mage.target.targetpointer.TargetPointer; public class StackAbilityView extends CardView { private static final long serialVersionUID = 1L; - private String sourceName; private CardView sourceCard; public StackAbilityView(Game game, StackAbility ability, String sourceName, CardView sourceCard) { this.id = ability.getId(); - this.name = "Ability"; - this.sourceName = sourceName; + this.mageObjectType = MageObjectType.ABILITY_STACK; this.sourceCard = sourceCard; + this.sourceCard.setMageObjectType(mageObjectType); + this.name = "Ability"; this.rules = new ArrayList(); rules.add(ability.getRule(sourceName)); this.power = ability.getPower().toString(); diff --git a/Mage/src/mage/constants/MageObjectType.java b/Mage/src/mage/constants/MageObjectType.java new file mode 100644 index 00000000000..a478dfbd970 --- /dev/null +++ b/Mage/src/mage/constants/MageObjectType.java @@ -0,0 +1,60 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package mage.constants; + +/** + * 109.1. An object is an ability on the stack, a card, a copy of a card, a token, a spell, a permanent, or an emblem. + * 109.2. If a spell or ability uses a description of an object that includes a card type + * or subtype, but doesn't include the word "card," "spell," "source," or "scheme," it + * means a permanent of that card type or subtype on the battlefield. + * 109.2a If a spell or ability uses a description of an object that includes the word "card" and the name of a zone, it means a card matching that description in the stated zone. # + * 109.2b If a spell or ability uses a description of an object that includes the word "spell," it means a spell matching that description on the stack. # + * 109.2c If a spell or ability uses a description of an object that includes the word "source," it means a source matching that description -- either a source of an ability or a source of damage -- in any zone. See rule 609.7. # + * 109.2d If an ability of a scheme card includes the text "this scheme," it means the scheme card in the command zone on which that ability is printed. # + * 109.3. An object's characteristics are name, mana cost, color, color indicator, card type, subtype, supertype, expansion symbol, rules text, abilities, power, toughness, loyalty, hand modifier, and life modifier. Objects can have some or all of these characteristics. Any other information about an object isn't a characteristic. For example, characteristics don't include whether a permanent is tapped, a spell's target, an object's owner or controller, what an Aura enchants, and so on. # + * 109.4. Only objects on the stack or on the battlefield have a controller. Objects that are neither on the stack nor on the battlefield aren't controlled by any player. See rule 108.4. There are four exceptions to this rule: # + * 109.4a An emblem is controlled by the player that puts it into the command zone. See rule 113, "Emblems." # + * 109.4b In a Planechase game, a face-up plane or phenomenon card is controlled by the player designated as the planar controller. This is usually the active player. See rule 901.6. # + * 109.4c In a Vanguard game, each vanguard card is controlled by its owner. See rule 902.6. # + * 109.4d In an Archenemy game, each scheme card is controlled by its owner. See rule 904.7. # + * 109.5. The words "you" and "your" on an object refer to the object's controller, its would-be controller (if a player is attempting to play, cast, or activate it), or its owner (if it has no controller). For a static ability, this is the current controller of the object it's on. For an activated ability, this is the player who activated the ability. For a triggered ability, this is the controller of the object when the ability triggered, unless it's a delayed triggered ability. To determine the controller of a delayed triggered ability, see rules 603.7d-f + * + * @author LevelX2 + */ + +public enum MageObjectType { + ABILITY_STACK ("Ability on the Stack", false, false), + CARD ("Card", false, true), + COPY_CARD ("Copy of a Card", false, true), + TOKEN ("Token", true, true), + SPELL ("Spell", false, false), + PERMANENT ("Permanent", true, true), + EMBLEM ("Emblem", false, false); + + private String text; + private boolean permanent; + private boolean canHaveCounters; + + + MageObjectType(String text, boolean permanent, boolean canHaveCounters) { + this.text = text; + this.permanent = permanent; + this.canHaveCounters = canHaveCounters; + } + + @Override + public String toString() { + return text; + } + + public boolean isPermanent() { + return permanent; + } + + public boolean canHaveCounters() { + return canHaveCounters; + } + +} diff --git a/Mage/src/mage/game/command/Emblem.java b/Mage/src/mage/game/command/Emblem.java index a7ea369671a..67256c97681 100644 --- a/Mage/src/mage/game/command/Emblem.java +++ b/Mage/src/mage/game/command/Emblem.java @@ -47,6 +47,7 @@ import java.util.UUID; */ public class Emblem implements CommandObject { + private String name; private static List emptyList = new ArrayList(); private static ObjectColor emptyColor = new ObjectColor(); private static ManaCosts emptyCost = new ManaCostsImpl(); @@ -94,7 +95,7 @@ public class Emblem implements CommandObject { @Override public String getName() { - return ""; + return name; } @Override @@ -103,7 +104,9 @@ public class Emblem implements CommandObject { } @Override - public void setName(String name) {} + public void setName(String name) { + this.name = name; + } @Override public List getCardType() {