mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
delete PlayerZoneUtil.java (very few things used these functions, and should have been using AllZoneUtil functions anyways); moved one function to AllZoneUtil
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -8705,7 +8705,6 @@ src/forge/PhaseUtil.java -text svneol=native#text/plain
|
||||
src/forge/Player.java -text svneol=native#text/plain
|
||||
src/forge/PlayerUtil.java -text svneol=native#text/plain
|
||||
src/forge/PlayerZone.java svneol=native#text/plain
|
||||
src/forge/PlayerZoneUtil.java svneol=native#text/plain
|
||||
src/forge/PlayerZone_ComesIntoPlay.java svneol=native#text/plain
|
||||
src/forge/PrintCardNames.java svneol=native#text/plain
|
||||
src/forge/PrintCardPictures.java svneol=native#text/plain
|
||||
|
||||
@@ -214,7 +214,7 @@ public class AllZoneUtil {
|
||||
*/
|
||||
|
||||
public static boolean isCardInPlayerGraveyard(Player player, Card card) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.getZone(Constant.Zone.Graveyard, player), card);
|
||||
return isCardInZone(AllZone.getZone(Constant.Zone.Graveyard, player), card);
|
||||
}
|
||||
|
||||
//////// HAND
|
||||
@@ -242,11 +242,24 @@ public class AllZoneUtil {
|
||||
* @return true if the card is present in this player's hand; false otherwise
|
||||
*/
|
||||
public static boolean isCardInPlayerHand(Player player, Card card) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.getZone(Constant.Zone.Hand, player), card);
|
||||
return isCardInZone(AllZone.getZone(Constant.Zone.Hand, player), card);
|
||||
}
|
||||
|
||||
public static boolean isCardInPlayerLibrary(Player player, Card card) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.getZone(Constant.Zone.Library, player), card);
|
||||
return isCardInZone(AllZone.getZone(Constant.Zone.Library, player), card);
|
||||
}
|
||||
|
||||
public static boolean isCardInZone(PlayerZone pz, Card card) {
|
||||
if(card == null)
|
||||
return false;
|
||||
|
||||
Card c[] = pz.getCards();
|
||||
|
||||
for(int i = 0; i < c.length; i++)
|
||||
if(c[i].equals(card))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////// EXILE
|
||||
@@ -338,8 +351,7 @@ public class AllZoneUtil {
|
||||
///Check if a certain card is in play
|
||||
|
||||
public static boolean isCardInPlay(Card card) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.Computer_Battlefield, card)
|
||||
|| PlayerZoneUtil.isCardInZone(AllZone.Human_Battlefield, card);
|
||||
return getCardsInPlay().contains(card);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,6 +630,15 @@ public class AllZoneUtil {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* a CardListFilter to get all equipment
|
||||
*/
|
||||
public static CardListFilter equipment = new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
return c.isEquipment();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* a CardListFilter to get all unenchanted cards in a list
|
||||
*/
|
||||
|
||||
@@ -774,32 +774,33 @@ public class ComputerUtil
|
||||
static public boolean chooseLandsToPlay()
|
||||
{
|
||||
Player computer = AllZone.ComputerPlayer;
|
||||
ArrayList<Card> landList = PlayerZoneUtil.getCardType(AllZone.Computer_Hand, "Land");
|
||||
CardList landList = AllZoneUtil.getPlayerHand(computer);
|
||||
landList = landList.filter(AllZoneUtil.lands);
|
||||
|
||||
if (AllZoneUtil.getPlayerCardsInPlay(computer, "Crucible of Worlds").size() > 0)
|
||||
{
|
||||
CardList lands = AllZoneUtil.getPlayerTypeInGraveyard(computer, "Land");
|
||||
for (Card crd : lands)
|
||||
landList.add(crd);
|
||||
}
|
||||
if (AllZoneUtil.getPlayerCardsInPlay(computer, "Crucible of Worlds").size() > 0)
|
||||
{
|
||||
CardList lands = AllZoneUtil.getPlayerTypeInGraveyard(computer, "Land");
|
||||
for (Card crd : lands)
|
||||
landList.add(crd);
|
||||
}
|
||||
|
||||
while(!landList.isEmpty() && computer.canPlayLand()){
|
||||
// play as many lands as you can
|
||||
int ix = 0;
|
||||
while (landList.get(ix).isReflectedLand() && (ix+1 < landList.size())) {
|
||||
// Skip through reflected lands. Choose last if they are all reflected.
|
||||
ix++;
|
||||
}
|
||||
while(!landList.isEmpty() && computer.canPlayLand()){
|
||||
// play as many lands as you can
|
||||
int ix = 0;
|
||||
while (landList.get(ix).isReflectedLand() && (ix+1 < landList.size())) {
|
||||
// Skip through reflected lands. Choose last if they are all reflected.
|
||||
ix++;
|
||||
}
|
||||
|
||||
Card land = landList.get(ix);
|
||||
landList.remove(ix);
|
||||
computer.playLand(land);
|
||||
Card land = landList.get(ix);
|
||||
landList.remove(ix);
|
||||
computer.playLand(land);
|
||||
|
||||
AllZone.GameAction.checkStateEffects();
|
||||
if (AllZone.Stack.size() != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
AllZone.GameAction.checkStateEffects();
|
||||
if (AllZone.Stack.size() != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static public Card getCardPreference(Card activate, String pref, CardList typeList){
|
||||
|
||||
@@ -507,8 +507,7 @@ public class GameAction {
|
||||
GameActionUtil.stPump.execute();
|
||||
|
||||
//System.out.println("checking state effects");
|
||||
ArrayList<Card> creature = PlayerZoneUtil.getCardType(AllZone.Computer_Battlefield, "Creature");
|
||||
creature.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Battlefield, "Creature"));
|
||||
CardList creature = AllZoneUtil.getCreaturesInPlay();
|
||||
|
||||
Card c;
|
||||
Iterator<Card> it = creature.iterator();
|
||||
@@ -538,8 +537,8 @@ public class GameAction {
|
||||
}//while it.hasNext()
|
||||
|
||||
|
||||
ArrayList<Card> enchantments = PlayerZoneUtil.getCardType(AllZone.Computer_Battlefield, "Enchantment");
|
||||
enchantments.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Battlefield, "Enchantment"));
|
||||
CardList enchantments = AllZoneUtil.getCardsInPlay();
|
||||
enchantments = enchantments.filter(AllZoneUtil.enchantments);
|
||||
|
||||
Iterator<Card> iterate = enchantments.iterator();
|
||||
while(iterate.hasNext()) {
|
||||
@@ -563,8 +562,8 @@ public class GameAction {
|
||||
}//while iterate.hasNext()
|
||||
|
||||
//Make sure all equipment stops equipping previously equipped creatures that have left play.
|
||||
ArrayList<Card> equip = PlayerZoneUtil.getCardType(AllZone.Computer_Battlefield, "Equipment");
|
||||
equip.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Battlefield, "Equipment"));
|
||||
CardList equip = AllZoneUtil.getCardsInPlay();
|
||||
equip = equip.filter(AllZoneUtil.equipment);
|
||||
|
||||
Iterator<Card> iter = equip.iterator();
|
||||
while(iter.hasNext()) {
|
||||
@@ -2176,18 +2175,17 @@ public class GameAction {
|
||||
|
||||
//is this card a permanent that is in play?
|
||||
public boolean isCardInPlay(Card c) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.Computer_Battlefield, c)
|
||||
|| PlayerZoneUtil.isCardInZone(AllZone.Human_Battlefield, c);
|
||||
return AllZoneUtil.isCardInPlay(c);
|
||||
}
|
||||
|
||||
public boolean isCardInGrave(Card c) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.Computer_Graveyard, c)
|
||||
|| PlayerZoneUtil.isCardInZone(AllZone.Human_Graveyard, c);
|
||||
return AllZoneUtil.isCardInZone(AllZone.Computer_Graveyard, c)
|
||||
|| AllZoneUtil.isCardInZone(AllZone.Human_Graveyard, c);
|
||||
}
|
||||
|
||||
public boolean isCardExiled(Card c) {
|
||||
return PlayerZoneUtil.isCardInZone(AllZone.Computer_Exile, c)
|
||||
|| PlayerZoneUtil.isCardInZone(AllZone.Human_Exile, c);
|
||||
return AllZoneUtil.isCardInZone(AllZone.Computer_Exile, c)
|
||||
|| AllZoneUtil.isCardInZone(AllZone.Human_Exile, c);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2213,11 +2211,9 @@ public class GameAction {
|
||||
|
||||
//removes all damage from player's creatures
|
||||
public void removeDamage(Player player) {
|
||||
PlayerZone p = AllZone.getZone(Constant.Zone.Battlefield, player);
|
||||
ArrayList<Card> a = PlayerZoneUtil.getCardType(p, "Creature");
|
||||
Card c[] = CardUtil.toCard(a);
|
||||
for(int i = 0; i < c.length; i++)
|
||||
c[i].setDamage(0);
|
||||
CardList list = AllZoneUtil.getCreaturesInPlay(player);
|
||||
for(Card c:list)
|
||||
c.setDamage(0);
|
||||
}
|
||||
|
||||
//for Quest fantasy mode
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package forge;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlayerZoneUtil
|
||||
{
|
||||
//TODO(sol) this whole class is pretty useless
|
||||
public static ArrayList<Card> getCardType(PlayerZone zone, String cardType)
|
||||
{
|
||||
Card c;
|
||||
ArrayList<Card> list = new ArrayList<Card>();
|
||||
|
||||
for(int i = 0; i < zone.size(); i++)
|
||||
{
|
||||
c = zone.get(i);
|
||||
if(c.isType(cardType))
|
||||
list.add(c);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList<Card> getUntappedCreatures(PlayerZone zone)
|
||||
{
|
||||
ArrayList<Card> all = getCardType(zone, "Creature");
|
||||
ArrayList<Card> untapped = new ArrayList<Card>();
|
||||
|
||||
for(int i = 0; i < all.size(); i++)
|
||||
if(((Card)all.get(i)).isUntapped())
|
||||
untapped.add(all.get(i));
|
||||
|
||||
return untapped;
|
||||
}
|
||||
|
||||
static public boolean isCardInZone(PlayerZone pz, Card card)
|
||||
{
|
||||
if(card == null)
|
||||
return false;
|
||||
|
||||
Card c[] = pz.getCards();
|
||||
|
||||
for(int i = 0; i < c.length; i++)
|
||||
if(c[i].equals(card))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user