code simplifications in Target.java

This commit is contained in:
jendave
2011-08-07 01:12:03 +00:00
parent b64d9c9976
commit d7209a5d08
2 changed files with 21 additions and 5 deletions

View File

@@ -253,10 +253,10 @@ public class AllZoneUtil {
if(card == null) if(card == null)
return false; return false;
Card c[] = pz.getCards(); CardList cl = getCardsInZone(pz);
for(int i = 0; i < c.length; i++) for(int i = 0; i < cl.size(); i++)
if(c[i].equals(card)) if(cl.get(i).equals(card))
return true; return true;
return false; return false;
@@ -482,6 +482,10 @@ public class AllZoneUtil {
return getCardsInZone(zone, null); return getCardsInZone(zone, null);
} }
public static CardList getCardsInZone(PlayerZone zone){
return new CardList(zone.getCards());
}
public static CardList getCardsInZone(String zone, Player player){ public static CardList getCardsInZone(String zone, Player player){
CardList all = new CardList(); CardList all = new CardList();
@@ -519,6 +523,17 @@ public class AllZoneUtil {
return all; return all;
} }
public static CardList getPlayerCardsWithPhasing(final Player player) {
CardList cards = new CardList();
cards.addAll(AllZone.getZone(Constant.Zone.Battlefield, player).getCards());
cards = cards.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.hasPhasing();
}
});
return cards;
}
//zone manipulation, maybe be better off in GameAction.java... //zone manipulation, maybe be better off in GameAction.java...
/** /**

View File

@@ -3,6 +3,7 @@ package forge.card.spellability;
import java.util.ArrayList; import java.util.ArrayList;
import forge.AllZone; import forge.AllZone;
import forge.AllZoneUtil;
import forge.Card; import forge.Card;
import forge.Constant; import forge.Constant;
import forge.Player; import forge.Player;
@@ -240,7 +241,7 @@ public class Target {
return true; return true;
} }
for(Card c : AllZone.getZone(tgtZone,AllZone.HumanPlayer).getCards()) for(Card c : AllZoneUtil.getCardsInZone(tgtZone, AllZone.HumanPlayer))
{ {
if(c.isValidCard(ValidTgts, srcCard.getController(), srcCard) && CardFactoryUtil.canTarget(srcCard, c)) if(c.isValidCard(ValidTgts, srcCard.getController(), srcCard) && CardFactoryUtil.canTarget(srcCard, c))
{ {
@@ -248,7 +249,7 @@ public class Target {
} }
} }
for(Card c : AllZone.getZone(tgtZone,AllZone.ComputerPlayer).getCards()) for(Card c : AllZoneUtil.getCardsInZone(tgtZone, AllZone.ComputerPlayer))
{ {
if(c.isValidCard(ValidTgts, srcCard.getController(), srcCard) && CardFactoryUtil.canTarget(srcCard, c)) if(c.isValidCard(ValidTgts, srcCard.getController(), srcCard) && CardFactoryUtil.canTarget(srcCard, c))
{ {