code simplifications in GameAction.java

This commit is contained in:
jendave
2011-08-07 01:00:06 +00:00
parent 7eaee90084
commit d342c1239a

View File

@@ -191,7 +191,7 @@ public class GameAction {
//Recover keyword //Recover keyword
if(c.isType("Creature") && origZone.is(Constant.Zone.Battlefield)) if(c.isType("Creature") && origZone.is(Constant.Zone.Battlefield))
{ {
for(final Card recoverable : grave.getCards()) for(final Card recoverable : AllZoneUtil.getPlayerGraveyard(c.getOwner()))
{ {
if(recoverable.hasStartOfKeyword("Recover")) if(recoverable.hasStartOfKeyword("Recover"))
{ {
@@ -789,12 +789,6 @@ public class GameAction {
} }
} }
@Deprecated
public boolean isCardInZone(Card card, PlayerZone p) {
ArrayList<Card> list = new ArrayList<Card>(Arrays.asList(p.getCards()));
return list.contains(card);
}
//removes all damage from player's creatures //removes all damage from player's creatures
public void removeDamage(Player player) { public void removeDamage(Player player) {
CardList list = AllZoneUtil.getCreaturesInPlay(player); CardList list = AllZoneUtil.getCreaturesInPlay(player);
@@ -840,7 +834,7 @@ public class GameAction {
private boolean Start_Cut = false; private boolean Start_Cut = false;
public void newGame(Deck humanDeck, Deck computerDeck) { public void newGame(Deck humanDeck, Deck computerDeck) {
// AllZone.Computer = new ComputerAI_Input(new ComputerAI_General()); //AllZone.Computer = new ComputerAI_Input(new ComputerAI_General());
Constant.Quest.fantasyQuest[0] = false; Constant.Quest.fantasyQuest[0] = false;
AllZone.GameInfo.setPreventCombatDamageThisTurn(false); AllZone.GameInfo.setPreventCombatDamageThisTurn(false);
@@ -1003,10 +997,10 @@ public class GameAction {
boolean smoothLand = Constant.Runtime.Smooth[0]; boolean smoothLand = Constant.Runtime.Smooth[0];
if(smoothLand) { if(smoothLand) {
Card[] c = smoothComputerManaCurve(AllZone.Computer_Library.getCards()); Card[] c = smoothComputerManaCurve(AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer).toArray());
AllZone.Computer_Library.setCards(c); AllZone.Computer_Library.setCards(c);
} else { } else {
AllZone.Computer_Library.setCards(AllZone.Computer_Library.getCards()); AllZone.Computer_Library.setCards(AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer).toArray());
AllZone.ComputerPlayer.shuffle(); AllZone.ComputerPlayer.shuffle();
} }
@@ -1185,18 +1179,10 @@ public class GameAction {
public void seeWhoPlaysFirst() { public void seeWhoPlaysFirst() {
CardList HLibrary = new CardList(AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer).getCards()); CardList HLibrary = AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer);
HLibrary = HLibrary.filter(new CardListFilter() { HLibrary = HLibrary.filter(AllZoneUtil.nonlands);
public boolean addCard(Card c) { CardList CLibrary = AllZoneUtil.getPlayerCardsInLibrary(AllZone.ComputerPlayer);
return !c.isLand(); CLibrary = CLibrary.filter(AllZoneUtil.nonlands);
}
});
CardList CLibrary = new CardList(AllZone.getZone(Constant.Zone.Library, AllZone.ComputerPlayer).getCards());
CLibrary = CLibrary.filter(new CardListFilter() {
public boolean addCard(Card c) {
return !c.isLand();
}
});
boolean Starter_Determined = false; boolean Starter_Determined = false;
int Cut_Count = 0; int Cut_Count = 0;
@@ -1407,42 +1393,31 @@ public class GameAction {
if(originalCard.getName().equals("Avatar of Woe")){ if(originalCard.getName().equals("Avatar of Woe")){
Player player = AllZone.Phase.getPlayerTurn(); Player player = AllZone.Phase.getPlayerTurn();
Player opponent = player.getOpponent(); Player opponent = player.getOpponent();
PlayerZone PlayerGraveyard = AllZone.getZone(Constant.Zone.Graveyard, player); CardList PlayerCreatureList = AllZoneUtil.getPlayerGraveyard(player);
CardList PlayerCreatureList = new CardList(PlayerGraveyard.getCards());
PlayerCreatureList = PlayerCreatureList.getType("Creature"); PlayerCreatureList = PlayerCreatureList.getType("Creature");
PlayerZone OpponentGraveyard = AllZone.getZone(Constant.Zone.Graveyard, opponent); CardList OpponentCreatureList = AllZoneUtil.getPlayerGraveyard(opponent);
CardList OpponentCreatureList = new CardList(OpponentGraveyard.getCards());
OpponentCreatureList = OpponentCreatureList.getType("Creature"); OpponentCreatureList = OpponentCreatureList.getType("Creature");
if((PlayerCreatureList.size() + OpponentCreatureList.size()) >= 10) { if((PlayerCreatureList.size() + OpponentCreatureList.size()) >= 10) {
manaCost = new ManaCost("B B"); manaCost = new ManaCost("B B");
} // Avatar of Woe } // Avatar of Woe
} else if(originalCard.getName().equals("Avatar of Will")) { } else if(originalCard.getName().equals("Avatar of Will")) {
Player player = AllZone.Phase.getPlayerTurn(); Player opponent = AllZone.Phase.getPlayerTurn().getOpponent();
Player opponent = player.getOpponent(); CardList opponentHandList = AllZoneUtil.getPlayerHand(opponent);
PlayerZone OpponentHand = AllZone.getZone(Constant.Zone.Hand, opponent); if(opponentHandList.size() == 0) {
CardList OpponentHandList = new CardList(OpponentHand.getCards());
if(OpponentHandList.size() == 0) {
manaCost = new ManaCost("U U"); manaCost = new ManaCost("U U");
} // Avatar of Will } // Avatar of Will
} else if(originalCard.getName().equals("Avatar of Fury")) { } else if(originalCard.getName().equals("Avatar of Fury")) {
Player player = AllZone.Phase.getPlayerTurn(); Player opponent = AllZone.Phase.getPlayerTurn().getOpponent();
Player opponent = player.getOpponent(); CardList opponentLand = AllZoneUtil.getPlayerLandsInPlay(opponent);
PlayerZone OpponentPlay = AllZone.getZone(Constant.Zone.Battlefield, opponent); if(opponentLand.size() >= 7) {
CardList OpponentLand = new CardList(OpponentPlay.getCards());
OpponentLand = OpponentLand.getType("Land");
if(OpponentLand.size() >= 7) {
manaCost = new ManaCost("R R"); manaCost = new ManaCost("R R");
} // Avatar of Fury } // Avatar of Fury
} else if(originalCard.getName().equals("Avatar of Might")) { } else if(originalCard.getName().equals("Avatar of Might")) {
Player player = AllZone.Phase.getPlayerTurn(); Player player = AllZone.Phase.getPlayerTurn();
Player opponent = player.getOpponent(); Player opponent = player.getOpponent();
PlayerZone PlayerPlay = AllZone.getZone(Constant.Zone.Battlefield, player); CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player);
CardList PlayerCreature = new CardList(PlayerPlay.getCards()); CardList opponentCreature = AllZoneUtil.getCreaturesInPlay(opponent);
PlayerCreature = PlayerCreature.getType("Creature"); if(opponentCreature.size() - playerCreature.size() >= 4) {
PlayerZone OpponentPlay = AllZone.getZone(Constant.Zone.Battlefield, opponent);
CardList OpponentCreature = new CardList(OpponentPlay.getCards());
OpponentCreature = OpponentCreature.getType("Creature");
if(OpponentCreature.size() - PlayerCreature.size() >= 4) {
manaCost = new ManaCost("G G"); manaCost = new ManaCost("G G");
} // Avatar of Might } // Avatar of Might
} }
@@ -1450,9 +1425,7 @@ public class GameAction {
// Get Cost Reduction // Get Cost Reduction
if(Phase.getGameBegins() == 1) { // Remove GameBegins from Phase and into The starting game code if(Phase.getGameBegins() == 1) { // Remove GameBegins from Phase and into The starting game code
CardList Cards_In_Play = new CardList(); CardList Cards_In_Play = AllZoneUtil.getCardsInPlay();
Cards_In_Play.addAll(AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer).getCards());
Cards_In_Play.addAll(AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer).getCards());
Cards_In_Play = Cards_In_Play.filter(new CardListFilter() { Cards_In_Play = Cards_In_Play.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
if(c.getKeyword().toString().contains("CostChange")) return true; if(c.getKeyword().toString().contains("CostChange")) return true;
@@ -1461,8 +1434,8 @@ public class GameAction {
}); });
Cards_In_Play.add(originalCard); Cards_In_Play.add(originalCard);
String Mana = manaCost.toString(); String Mana = manaCost.toString();
CardList Player_Play = new CardList(AllZone.getZone(Constant.Zone.Battlefield, sa.getSourceCard().getController()).getCards()); CardList Player_Play = AllZoneUtil.getPlayerCardsInPlay(sa.getSourceCard().getController());
CardList Player_Hand = new CardList(AllZone.getZone(Constant.Zone.Hand, sa.getSourceCard().getController()).getCards()); CardList Player_Hand = AllZoneUtil.getPlayerHand(sa.getSourceCard().getController());
int XBonus = 0; int XBonus = 0;
int Max = 25; int Max = 25;
if(sa.isXCost() && !sa.getSourceCard().isCopiedSpell()) sa.getSourceCard().setXManaCostPaid(0); if(sa.isXCost() && !sa.getSourceCard().isCopiedSpell()) sa.getSourceCard().setXManaCostPaid(0);
@@ -1549,8 +1522,7 @@ public class GameAction {
String spilt = k[7]; String spilt = k[7];
String color_spilt[] = spilt.split("/"); String color_spilt[] = spilt.split("/");
k[7] = color_spilt[1]; k[7] = color_spilt[1];
PlayerZone PlayerPlay = AllZone.getZone(Constant.Zone.Battlefield, originalCard.getController()); CardList PlayerList = AllZoneUtil.getPlayerCardsInPlay(originalCard.getController());
CardList PlayerList = new CardList(PlayerPlay.getCards());
PlayerList = PlayerList.getType(k[7]); PlayerList = PlayerList.getType(k[7]);
k[3] = String.valueOf(PlayerList.size()); k[3] = String.valueOf(PlayerList.size());
} }
@@ -1698,8 +1670,7 @@ public class GameAction {
String spilt = k[7]; String spilt = k[7];
String color_spilt[] = spilt.split("/"); String color_spilt[] = spilt.split("/");
k[7] = color_spilt[1]; k[7] = color_spilt[1];
PlayerZone PlayerPlay = AllZone.getZone(Constant.Zone.Battlefield, originalCard.getController()); CardList PlayerList = AllZoneUtil.getPlayerCardsInPlay(originalCard.getController());
CardList PlayerList = new CardList(PlayerPlay.getCards());
PlayerList = PlayerList.getType(k[7]); PlayerList = PlayerList.getType(k[7]);
k[3] = String.valueOf(PlayerList.size()); k[3] = String.valueOf(PlayerList.size());
} }
@@ -1782,22 +1753,16 @@ public class GameAction {
} }
if(originalCard.getName().equals("Khalni Hydra") && spell.isSpell() == true) { if(originalCard.getName().equals("Khalni Hydra") && spell.isSpell() == true) {
Player player = AllZone.Phase.getPlayerTurn(); Player player = AllZone.Phase.getPlayerTurn();
PlayerZone PlayerPlay = AllZone.getZone(Constant.Zone.Battlefield, player); CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player);
CardList PlayerCreature = new CardList(PlayerPlay.getCards()); playerCreature = playerCreature.filter(AllZoneUtil.green);
PlayerCreature = PlayerCreature.getType("Creature"); String mana = manaCost + " ";
PlayerCreature = PlayerCreature.filter(new CardListFilter() { if(playerCreature.size() > 0) {
public boolean addCard(Card c) { for(int i = 0; i < playerCreature.size(); i++) {
return c.isCreature() && c.isGreen(); mana = mana.replaceFirst("G ", "");
} }
}); mana = mana.trim();
String Mana = manaCost + " "; if(mana.equals("")) mana = "0";
if(PlayerCreature.size() > 0) { manaCost = new ManaCost(mana);
for(int i = 0; i < PlayerCreature.size(); i++) {
Mana = Mana.replaceFirst("G ", "");
}
Mana = Mana.trim();
if(Mana.equals("")) Mana = "0";
manaCost = new ManaCost(Mana);
} }
} // Khalni Hydra } // Khalni Hydra
return manaCost; return manaCost;
@@ -1988,9 +1953,8 @@ public class GameAction {
private void humanSearchTwoLand(String type, String Zone1, boolean tapFirstLand, String Zone2, boolean tapSecondLand) { private void humanSearchTwoLand(String type, String Zone1, boolean tapFirstLand, String Zone2, boolean tapSecondLand) {
PlayerZone firstZone = AllZone.getZone(Zone1, AllZone.HumanPlayer); PlayerZone firstZone = AllZone.getZone(Zone1, AllZone.HumanPlayer);
PlayerZone library = AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer);
CardList list = new CardList(library.getCards()); CardList list = AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer);
list = list.getType(type); list = list.getType(type);
//3 branches: 1-no land in deck, 2-one land in deck, 3-two or more land in deck //3 branches: 1-no land in deck, 2-one land in deck, 3-two or more land in deck