mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
code simplifications in Target.java
This commit is contained in:
@@ -253,10 +253,10 @@ public class AllZoneUtil {
|
||||
if(card == null)
|
||||
return false;
|
||||
|
||||
Card c[] = pz.getCards();
|
||||
CardList cl = getCardsInZone(pz);
|
||||
|
||||
for(int i = 0; i < c.length; i++)
|
||||
if(c[i].equals(card))
|
||||
for(int i = 0; i < cl.size(); i++)
|
||||
if(cl.get(i).equals(card))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -482,6 +482,10 @@ public class AllZoneUtil {
|
||||
return getCardsInZone(zone, null);
|
||||
}
|
||||
|
||||
public static CardList getCardsInZone(PlayerZone zone){
|
||||
return new CardList(zone.getCards());
|
||||
}
|
||||
|
||||
public static CardList getCardsInZone(String zone, Player player){
|
||||
CardList all = new CardList();
|
||||
|
||||
@@ -519,6 +523,17 @@ public class AllZoneUtil {
|
||||
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...
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.card.spellability;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.Constant;
|
||||
import forge.Player;
|
||||
@@ -240,7 +241,7 @@ public class Target {
|
||||
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))
|
||||
{
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user