code cleanup in GameAction.java

This commit is contained in:
jendave
2011-08-06 09:29:27 +00:00
parent 1c53ee1664
commit 0cd83a7b74
2 changed files with 23 additions and 62 deletions

View File

@@ -555,4 +555,21 @@ public class AllZoneUtil {
return c.isWhite(); return c.isWhite();
} }
}; };
public static CardList getCardsInGame(){
CardList all = new CardList();
all.addAll(AllZone.Human_Graveyard.getCards());
all.addAll(AllZone.Human_Hand.getCards());
all.addAll(AllZone.Human_Library.getCards());
all.addAll(AllZone.Human_Play.getCards());
all.addAll(AllZone.Human_Removed.getCards());
all.addAll(AllZone.Computer_Graveyard.getCards());
all.addAll(AllZone.Computer_Hand.getCards());
all.addAll(AllZone.Computer_Library.getCards());
all.addAll(AllZone.Computer_Play.getCards());
all.addAll(AllZone.Computer_Removed.getCards());
return all;
}
} }

View File

@@ -36,7 +36,7 @@ public class GameAction {
} }
public void resetActivationsPerTurn(){ public void resetActivationsPerTurn(){
CardList all = getCardsInGame(); CardList all = AllZoneUtil.getCardsInGame();
// Reset Activations per Turn // Reset Activations per Turn
for(Card card : all){ for(Card card : all){
@@ -45,23 +45,6 @@ public class GameAction {
} }
} }
public CardList getCardsInGame(){
CardList all = new CardList();
all.addAll(AllZone.Human_Graveyard.getCards());
all.addAll(AllZone.Human_Hand.getCards());
all.addAll(AllZone.Human_Library.getCards());
all.addAll(AllZone.Human_Play.getCards());
all.addAll(AllZone.Human_Removed.getCards());
all.addAll(AllZone.Computer_Graveyard.getCards());
all.addAll(AllZone.Computer_Hand.getCards());
all.addAll(AllZone.Computer_Library.getCards());
all.addAll(AllZone.Computer_Play.getCards());
all.addAll(AllZone.Computer_Removed.getCards());
return all;
}
public Card moveTo(PlayerZone zone, Card c) { public Card moveTo(PlayerZone zone, Card c) {
//c = getCurrentCard(c); - breaks things, seems to not be needed //c = getCurrentCard(c); - breaks things, seems to not be needed
//not 100% sure though, this might be broken //not 100% sure though, this might be broken
@@ -138,13 +121,6 @@ public class GameAction {
if(c.length != 0) discard(CardUtil.getRandom(c), sa); if(c.length != 0) discard(CardUtil.getRandom(c), sa);
} }
/*
public void discardRandom(String player) {
Card[] c = AllZone.getZone(Constant.Zone.Hand, player).getCards();
if(c.length != 0) discard(CardUtil.getRandom(c));
}
*/
public void mill(Player player, int n) public void mill(Player player, int n)
{ {
CardList lib = AllZoneUtil.getPlayerCardsInLibrary(player); CardList lib = AllZoneUtil.getPlayerCardsInLibrary(player);
@@ -679,10 +655,7 @@ public class GameAction {
private void destroyPlaneswalkers() { private void destroyPlaneswalkers() {
//get all Planeswalkers //get all Planeswalkers
CardList list = new CardList(); CardList list = AllZoneUtil.getTypeInPlay("Planeswalker");
list.addAll(AllZone.Human_Play.getCards());
list.addAll(AllZone.Computer_Play.getCards());
list = list.getType("Planeswalker");
Card c; Card c;
for(int i = 0; i < list.size(); i++) { for(int i = 0; i < list.size(); i++) {
@@ -706,13 +679,7 @@ public class GameAction {
ArrayList<Card> a = PlayerZoneUtil.getCardType(AllZone.Human_Play, "Legendary"); ArrayList<Card> a = PlayerZoneUtil.getCardType(AllZone.Human_Play, "Legendary");
a.addAll(PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Legendary")); a.addAll(PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Legendary"));
CardList Mirror_Gallery = new CardList(); // Mirror Gallery suppresses the Legend rule while(!a.isEmpty() && !AllZoneUtil.isCardInPlay("Mirror Gallery")) {
Mirror_Gallery.addAll(AllZone.Human_Play.getCards());
Mirror_Gallery.addAll(AllZone.Computer_Play.getCards());
Mirror_Gallery = Mirror_Gallery.getName("Mirror Gallery");
while(!a.isEmpty() && Mirror_Gallery.isEmpty()) {
ArrayList<Card> b = getCardsNamed(a, (a.get(0)).getName()); ArrayList<Card> b = getCardsNamed(a, (a.get(0)).getName());
a.remove(0); a.remove(0);
if(1 < b.size()) { if(1 < b.size()) {
@@ -722,14 +689,8 @@ public class GameAction {
} }
}//destroyLegendaryCreatures() }//destroyLegendaryCreatures()
public boolean PlayerHasThreshold(Player player) public boolean PlayerHasThreshold(Player player) {
{ return AllZoneUtil.getPlayerGraveyard(player).size() >= 7;
PlayerZone pYard = AllZone.getZone(Constant.Zone.Graveyard, player);
if (pYard.size() >= 7)
return true;
return false;
} }
//ArrayList search is all Card objects, returns ArrayList of Cards //ArrayList search is all Card objects, returns ArrayList of Cards
@@ -2352,23 +2313,8 @@ public class GameAction {
return true; return true;
} }
/*
//because originally, MTGForge didn't keep track of cards removed from the game.
public void removeFromGame(Card c) {
if(AllZone.GameAction.isCardRemovedFromGame(c)) return;
PlayerZone zone = AllZone.getZone(c); //could be hand, grave, play, ...
PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner());
if (zone != null) // for suspend
zone.remove(c);
if(!c.isToken()) removed.add(c);
}*/
/** /**
* basically an alias for removeFromGame to bring the language in the code * exile a card
* to match the mechanics in Forge
* @param c the card to be exiled * @param c the card to be exiled
*/ */
public void exile(Card c) { public void exile(Card c) {
@@ -2383,8 +2329,6 @@ public class GameAction {
if(!c.isToken()) removed.add(c); if(!c.isToken()) removed.add(c);
} }
public void removeUnearth(Card c) public void removeUnearth(Card c)
{ {
PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner()); PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner());