From 875614b96c202922fc0db572f2d4a15cbc3deef2 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Thu, 28 Oct 2010 11:52:54 +0000 Subject: [PATCH] Added multitarget arrows (Fireball). --- .../src/main/java/mage/client/cards/Card.java | 34 ++++++++++--------- Mage.Common/src/mage/view/CardView.java | 26 +++++++++----- Mage.Server/config/init.txt | 9 ++--- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java index 37d3e00238..f613c1122c 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Card.java +++ b/Mage.Client/src/main/java/mage/client/cards/Card.java @@ -365,22 +365,24 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou popupShowing = true; // Draw Arrows for targets - UUID uuid = card.getFirstTarget(); - if (uuid != null) { - System.out.println("Getting play area panel for uuid: " + uuid); - - PlayAreaPanel p = session.getGame().getPlayers().get(uuid); - if (p != null) { - Point target = p.getLocationOnScreen(); - Point me = this.getLocationOnScreen(); - ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red); - } else { - for (PlayAreaPanel pa : session.getGame().getPlayers().values()) { - Permanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); - if (permanent != null) { - Point target = permanent.getLocationOnScreen(); - Point me = this.getLocationOnScreen(); - ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red); + List targets = card.getTargets(); + if (targets != null) { + for (UUID uuid : targets) { + System.out.println("Getting play area panel for uuid: " + uuid); + + PlayAreaPanel p = session.getGame().getPlayers().get(uuid); + if (p != null) { + Point target = p.getLocationOnScreen(); + Point me = this.getLocationOnScreen(); + ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red); + } else { + for (PlayAreaPanel pa : session.getGame().getPlayers().values()) { + Permanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); + if (permanent != null) { + Point target = permanent.getLocationOnScreen(); + Point me = this.getLocationOnScreen(); + ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red); + } } } } diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index aaefb3c58e..467ef8fe13 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -36,13 +36,13 @@ import java.util.UUID; import mage.ObjectColor; import mage.Constants.CardType; import mage.Constants.Rarity; -import mage.abilities.Ability; import mage.cards.Card; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentToken; import mage.game.permanent.token.Token; import mage.game.stack.Spell; import mage.target.Target; +import mage.target.Targets; /** * @@ -65,7 +65,7 @@ public class CardView implements Serializable { protected Rarity rarity; protected String expansionSetCode; - public UUID firstTarget; //TODO: there may be several targets + public List targets; public CardView(Card card) { this.id = card.getId(); @@ -99,10 +99,15 @@ public class CardView implements Serializable { if (card instanceof Spell) { Spell spell = (Spell)card; if (spell.getSpellAbility().getTargets().size() > 0) { - Target target = spell.getSpellAbility().getTargets().get(0); - if (target.isChosen()) { - firstTarget = target.getFirstTarget(); - System.out.println("First target: " + firstTarget); + Targets targets = spell.getSpellAbility().getTargets(); + for (Target target : targets) { + if (target.isChosen()) { + for (UUID targetUUID : target.getTargets()) { + if (this.targets == null) this.targets = new ArrayList(); + this.targets.add(targetUUID); + System.out.println("Added target: " + targetUUID); + } + } } } } @@ -199,7 +204,12 @@ public class CardView implements Serializable { return id; } - public UUID getFirstTarget() { - return firstTarget; + /** + * Returns UUIDs for targets. + * Can be null if there is no target selected. + * @return + */ + public List getTargets() { + return targets; } } diff --git a/Mage.Server/config/init.txt b/Mage.Server/config/init.txt index 74cdea018a..e21f4e2791 100644 --- a/Mage.Server/config/init.txt +++ b/Mage.Server/config/init.txt @@ -6,9 +6,6 @@ # nickname - Player's name you connect to the game with # # -hand:player:mage.sets.magic2010.LightningBolt:1 -hand:player:mage.sets.magic2011.Fireball:2 -battlefield:player:mage.sets.magic2011.BrindleBoar:2 -graveyard:player:mage.sets.magic2011.BrindleBoar:1 -hand:player:mage.sets.magic2011.DoomBlade:1 -battlefield:player:mage.cards.basiclands.Swamp:2 +hand:player:Fireball:2 +battlefield:player:Mountain:6 +battlefield:computer:Brindle Boar:2