Added multitarget arrows (Fireball).

This commit is contained in:
magenoxx 2010-10-28 11:52:54 +00:00
parent b0e4549959
commit 875614b96c
3 changed files with 39 additions and 30 deletions

View file

@ -365,22 +365,24 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou
popupShowing = true; popupShowing = true;
// Draw Arrows for targets // Draw Arrows for targets
UUID uuid = card.getFirstTarget(); List<UUID> targets = card.getTargets();
if (uuid != null) { if (targets != null) {
System.out.println("Getting play area panel for uuid: " + uuid); for (UUID uuid : targets) {
System.out.println("Getting play area panel for uuid: " + uuid);
PlayAreaPanel p = session.getGame().getPlayers().get(uuid); PlayAreaPanel p = session.getGame().getPlayers().get(uuid);
if (p != null) { if (p != null) {
Point target = p.getLocationOnScreen(); Point target = p.getLocationOnScreen();
Point me = this.getLocationOnScreen(); Point me = this.getLocationOnScreen();
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red); ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red);
} else { } else {
for (PlayAreaPanel pa : session.getGame().getPlayers().values()) { for (PlayAreaPanel pa : session.getGame().getPlayers().values()) {
Permanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid); Permanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
if (permanent != null) { if (permanent != null) {
Point target = permanent.getLocationOnScreen(); Point target = permanent.getLocationOnScreen();
Point me = this.getLocationOnScreen(); Point me = this.getLocationOnScreen();
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red); ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red);
}
} }
} }
} }

View file

@ -36,13 +36,13 @@ import java.util.UUID;
import mage.ObjectColor; import mage.ObjectColor;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.cards.Card; import mage.cards.Card;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken; import mage.game.permanent.PermanentToken;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.target.Target; import mage.target.Target;
import mage.target.Targets;
/** /**
* *
@ -65,7 +65,7 @@ public class CardView implements Serializable {
protected Rarity rarity; protected Rarity rarity;
protected String expansionSetCode; protected String expansionSetCode;
public UUID firstTarget; //TODO: there may be several targets public List<UUID> targets;
public CardView(Card card) { public CardView(Card card) {
this.id = card.getId(); this.id = card.getId();
@ -99,10 +99,15 @@ public class CardView implements Serializable {
if (card instanceof Spell) { if (card instanceof Spell) {
Spell<?> spell = (Spell<?>)card; Spell<?> spell = (Spell<?>)card;
if (spell.getSpellAbility().getTargets().size() > 0) { if (spell.getSpellAbility().getTargets().size() > 0) {
Target target = spell.getSpellAbility().getTargets().get(0); Targets targets = spell.getSpellAbility().getTargets();
if (target.isChosen()) { for (Target target : targets) {
firstTarget = target.getFirstTarget(); if (target.isChosen()) {
System.out.println("First target: " + firstTarget); for (UUID targetUUID : target.getTargets()) {
if (this.targets == null) this.targets = new ArrayList<UUID>();
this.targets.add(targetUUID);
System.out.println("Added target: " + targetUUID);
}
}
} }
} }
} }
@ -199,7 +204,12 @@ public class CardView implements Serializable {
return id; return id;
} }
public UUID getFirstTarget() { /**
return firstTarget; * Returns UUIDs for targets.
* Can be null if there is no target selected.
* @return
*/
public List<UUID> getTargets() {
return targets;
} }
} }

View file

@ -6,9 +6,6 @@
# nickname - Player's name you connect to the game with # nickname - Player's name you connect to the game with
# #
# #
hand:player:mage.sets.magic2010.LightningBolt:1 hand:player:Fireball:2
hand:player:mage.sets.magic2011.Fireball:2 battlefield:player:Mountain:6
battlefield:player:mage.sets.magic2011.BrindleBoar:2 battlefield:computer:Brindle Boar:2
graveyard:player:mage.sets.magic2011.BrindleBoar:1
hand:player:mage.sets.magic2011.DoomBlade:1
battlefield:player:mage.cards.basiclands.Swamp:2