Renamed attachCard => attachCardByMindsDesire because it's the only way the field is uses. Hope someone will refactor the whole spell.

This commit is contained in:
Maxmtg
2011-09-20 15:31:21 +00:00
parent f451e59add
commit 71f00b3c8d
5 changed files with 24 additions and 23 deletions

View File

@@ -49,7 +49,7 @@ public class Card extends GameEntity implements Comparable<Card> {
//Hidden keywords won't be displayed on the card //Hidden keywords won't be displayed on the card
private ArrayList<String> hiddenExtrinsicKeyword = new ArrayList<String>(); private ArrayList<String> hiddenExtrinsicKeyword = new ArrayList<String>();
private ArrayList<String> prevIntrinsicKeyword = new ArrayList<String>(); private ArrayList<String> prevIntrinsicKeyword = new ArrayList<String>();
private ArrayList<Card> attached = new ArrayList<Card>(); private ArrayList<Card> attachedByMindsDesire = new ArrayList<Card>();
//which equipment cards are equipping this card? //which equipment cards are equipping this card?
private ArrayList<Card> equippedBy = new ArrayList<Card>(); private ArrayList<Card> equippedBy = new ArrayList<Card>();
//equipping size will always be 0 or 1 //equipping size will always be 0 or 1
@@ -3174,9 +3174,9 @@ public class Card extends GameEntity implements Comparable<Card> {
* *
* @return an array of {@link forge.Card} objects. * @return an array of {@link forge.Card} objects.
*/ */
public final Card[] getAttachedCards() { public final Card[] getAttachedCardsByMindsDesire() {
Card[] c = new Card[attached.size()]; Card[] c = new Card[attachedByMindsDesire.size()];
attached.toArray(c); attachedByMindsDesire.toArray(c);
return c; return c;
} }
@@ -3185,8 +3185,8 @@ public class Card extends GameEntity implements Comparable<Card> {
* *
* @return a boolean. * @return a boolean.
*/ */
public final boolean hasAttachedCards() { public final boolean hasAttachedCardsByMindsDesire() {
return getAttachedCards().length != 0; return getAttachedCardsByMindsDesire().length != 0;
} }
/** /**
@@ -3194,8 +3194,8 @@ public class Card extends GameEntity implements Comparable<Card> {
* *
* @param c a {@link forge.Card} object. * @param c a {@link forge.Card} object.
*/ */
public final void attachCard(final Card c) { public final void attachCardByMindsDesire(final Card c) {
attached.add(c); attachedByMindsDesire.add(c);
this.updateObservers(); this.updateObservers();
} }
@@ -3204,8 +3204,8 @@ public class Card extends GameEntity implements Comparable<Card> {
* *
* @param c a {@link forge.Card} object. * @param c a {@link forge.Card} object.
*/ */
public final void unattachCard(final Card c) { public final void unattachCardByMindDesire(final Card c) {
attached.remove(c); attachedByMindsDesire.remove(c);
this.updateObservers(); this.updateObservers();
} }

View File

@@ -32,6 +32,7 @@ import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT;
import forge.quest.gui.main.QuestChallenge; import forge.quest.gui.main.QuestChallenge;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -1530,12 +1531,12 @@ public class GameAction {
* @param c a {@link forge.Card} object. * @param c a {@link forge.Card} object.
* @return a boolean. * @return a boolean.
*/ */
public final boolean isAttachee(final Card c) { public final boolean isAttacheeByMindsDesire(final Card c) {
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
CardList check = new CardList(list.getCard(i).getAttachedCards()); Card [] cc = list.getCard(i).getAttachedCardsByMindsDesire();
if (check.contains(c)) { if (Arrays.binarySearch(cc, c) >= 0) {
return true; return true;
} }
} }

View File

@@ -277,7 +277,7 @@ public final class GuiDisplayUtil implements NewConstants {
for (int i = 0; i < c.length; i++) { for (int i = 0; i < c.length; i++) {
if ((!(c[i].isCreature() || c[i].isEnchantment() || c[i].isArtifact() || c[i].isPlaneswalker()) if ((!(c[i].isCreature() || c[i].isEnchantment() || c[i].isArtifact() || c[i].isPlaneswalker())
|| (c[i].isLand() && c[i].isArtifact() && !c[i].isCreature() && !c[i].isEnchantment())) || (c[i].isLand() && c[i].isArtifact() && !c[i].isCreature() && !c[i].isEnchantment()))
&& !AllZone.getGameAction().isAttachee(c[i]) && !AllZone.getGameAction().isAttacheeByMindsDesire(c[i])
|| (c[i].getName().startsWith("Mox") && !c[i].getName().equals("Mox Diamond"))) || (c[i].getName().startsWith("Mox") && !c[i].getName().equals("Mox Diamond")))
{ {
a.add(c[i]); a.add(c[i]);

View File

@@ -267,10 +267,10 @@ public class CardFactory_Sorceries {
Player player = card.getController(); Player player = card.getController();
PlayerZone play = player.getZone(Constant.Zone.Battlefield); PlayerZone play = player.getZone(Constant.Zone.Battlefield);
PlayerZone RFG = player.getZone(Constant.Zone.Exile); PlayerZone RFG = player.getZone(Constant.Zone.Exile);
Card[] Attached = card.getAttachedCards(); Card[] Attached = card.getAttachedCardsByMindsDesire();
RFG.remove(Attached[0]); RFG.remove(Attached[0]);
play.add(Attached[0]); play.add(Attached[0]);
card.unattachCard(Attached[0]); card.unattachCardByMindDesire(Attached[0]);
}//resolve() }//resolve()
};//SpellAbility };//SpellAbility
@@ -282,7 +282,7 @@ public class CardFactory_Sorceries {
Card c = null; Card c = null;
Player player = card.getController(); Player player = card.getController();
if (player.isHuman()) { if (player.isHuman()) {
Card[] Attached = getSourceCard().getAttachedCards(); Card[] Attached = getSourceCard().getAttachedCardsByMindsDesire();
Card[] Choices = new Card[Attached.length]; Card[] Choices = new Card[Attached.length];
boolean SystemsGo = true; boolean SystemsGo = true;
if (AllZone.getStack().size() > 0) { if (AllZone.getStack().size() > 0) {
@@ -334,17 +334,17 @@ public class CardFactory_Sorceries {
} }
// Clear Attached List // Clear Attached List
for (int i = 0; i < Attached.length; i++) { for (int i = 0; i < Attached.length; i++) {
card.unattachCard(Attached[i]); card.unattachCardByMindDesire(Attached[i]);
} }
// Re-add // Re-add
for (int i = 0; i < ReAttach.length; i++) { for (int i = 0; i < ReAttach.length; i++) {
if (ReAttach[i] != null) card.attachCard(ReAttach[i]); if (ReAttach[i] != null) card.attachCardByMindsDesire(ReAttach[i]);
} }
target.addSpellAbility(PlayCreature); target.addSpellAbility(PlayCreature);
AllZone.getStack().add(PlayCreature); AllZone.getStack().add(PlayCreature);
} else { } else {
AllZone.getGameAction().playCardNoCost(c); AllZone.getGameAction().playCardNoCost(c);
card.unattachCard(c); card.unattachCardByMindDesire(c);
} }
} else } else
JOptionPane.showMessageDialog(null, "Player cancelled or there is no more cards available on Mind's Desire.", "", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Player cancelled or there is no more cards available on Mind's Desire.", "", JOptionPane.INFORMATION_MESSAGE);
@@ -382,7 +382,7 @@ public class CardFactory_Sorceries {
c = libList.get(0); c = libList.get(0);
PlayerZone RFG = player.getZone(Constant.Zone.Exile); PlayerZone RFG = player.getZone(Constant.Zone.Exile);
AllZone.getGameAction().moveTo(RFG, c); AllZone.getGameAction().moveTo(RFG, c);
Minds_D.attachCard(c); Minds_D.attachCardByMindsDesire(c);
} }
final Card Minds = card; final Card Minds = card;
// AllZone.getGameAction().exile(Minds); // AllZone.getGameAction().exile(Minds);

View File

@@ -337,9 +337,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
area.append("This card can't be cast."); area.append("This card can't be cast.");
} }
if (card.hasAttachedCards()) { if (card.hasAttachedCardsByMindsDesire()) {
if (area.length() != 0) area.append("\n"); if (area.length() != 0) area.append("\n");
Card[] cards = card.getAttachedCards(); Card[] cards = card.getAttachedCardsByMindsDesire();
area.append("=Attached: "); area.append("=Attached: ");
for (Card c : cards) { for (Card c : cards) {
area.append(c.getName()); area.append(c.getName());