- Added playerTurn, a string to keep track of whose turn

- Replaced getLastPlayerToDraw with isPlayerTurn in a few locations to play nice with cards that skip draw phases.
Note: Whenever keyword uses getLastPlayerToDraw but wasn't sure what it was doing. Probably should use isPlayerTurn instead.
This commit is contained in:
jendave
2011-08-06 05:33:35 +00:00
parent ac1bf0018f
commit 6a6dfbf4f2
7 changed files with 25 additions and 15 deletions

View File

@@ -16241,7 +16241,7 @@ public class CardFactory implements NewConstants {
@Override @Override
public boolean canPlay() { public boolean canPlay() {
if(AllZone.Human_Life.getLife() >= 5 && AllZone.GameAction.getLastPlayerToDraw().equals(Constant.Player.Human) && AllZone.GameAction.isCardInPlay(card) && super.canPlay()) if(AllZone.Human_Life.getLife() >= 5 && AllZone.GameAction.isPlayerTurn(Constant.Player.Human) && super.canPlay())
return true; return true;
else return false; else return false;
} }
@@ -16249,7 +16249,7 @@ public class CardFactory implements NewConstants {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
if (card.getController().equals(Constant.Player.Human) && AllZone.Computer_Life.getLife() >= 9 && if (card.getController().equals(Constant.Player.Human) && AllZone.Computer_Life.getLife() >= 9 &&
AllZone.GameAction.getLastPlayerToDraw().equals(Constant.Player.Computer) && AllZone.GameAction.isPlayerTurn(Constant.Player.Computer) &&
AllZone.GameAction.isCardInPlay(card)) AllZone.GameAction.isCardInPlay(card))
return true; return true;
else return false; else return false;
@@ -17174,7 +17174,7 @@ public class CardFactory implements NewConstants {
public boolean canPlay() { public boolean canPlay() {
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
return AllZone.GameAction.isCardInZone(card, grave) && AllZone.GameAction.getLastPlayerToDraw().equals(card.getController()); return AllZone.GameAction.isCardInZone(card, grave) && AllZone.GameAction.isPlayerTurn(card.getController());
} }
}; };

View File

@@ -4219,15 +4219,13 @@ public class CardFactoryUtil {
public static boolean canHumanPlayLand(){ public static boolean canHumanPlayLand(){
// LandsToPlay Left or Fastbond in play, Human's turn, Stack is Empty, In Main Phase // LandsToPlay Left or Fastbond in play, Human's turn, Stack is Empty, In Main Phase
return (AllZone.GameInfo.humanNumberLandPlaysLeft() > 0 || CardFactoryUtil.getCards("Fastbond", "Human").size() > 0) && return (AllZone.GameInfo.humanNumberLandPlaysLeft() > 0 || CardFactoryUtil.getCards("Fastbond", "Human").size() > 0) &&
AllZone.GameAction.getLastPlayerToDraw().equals("Human") && (AllZone.Stack.size() == 0) && Phase.canCastSorcery("Human");
(AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2));
} }
public static boolean canComputerPlayLand(){ public static boolean canComputerPlayLand(){
// LandsToPlay Left or Fastbond in play, Computer's turn, Stack is Empty, In Main Phase // LandsToPlay Left or Fastbond in play, Computer's turn, Stack is Empty, In Main Phase
return (AllZone.GameInfo.computerNumberLandPlaysLeft() > 0 || CardFactoryUtil.getCards("Fastbond", "Computer").size() > 0) && return (AllZone.GameInfo.computerNumberLandPlaysLeft() > 0 || CardFactoryUtil.getCards("Fastbond", "Computer").size() > 0) &&
AllZone.GameAction.getLastPlayerToDraw().equals("Computer") && (AllZone.Stack.size() == 0) && Phase.canCastSorcery("Computer");
(AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2));
} }
public static void playLandEffects(Card c){ public static void playLandEffects(Card c){

View File

@@ -11847,7 +11847,7 @@ public class CardFactory_Creatures {
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController()); PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
return AllZone.GameAction.isCardInZone(card, grave) && AllZone.GameAction.getLastPlayerToDraw().equals(card.getController()) && hand.size() > 0; return AllZone.GameAction.isCardInZone(card, grave) && AllZone.GameAction.isPlayerTurn(card.getController()) && hand.size() > 0;
} }
}; };
@@ -11880,7 +11880,7 @@ public class CardFactory_Creatures {
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController()); PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
return AllZone.GameAction.isCardInZone(card, grave) && AllZone.GameAction.getLastPlayerToDraw().equals(card.getController()) && hand.size() > 0; return AllZone.GameAction.isCardInZone(card, grave) && AllZone.GameAction.isPlayerTurn(card.getController()) && hand.size() > 0;
} }
}; };

View File

@@ -2193,6 +2193,15 @@ public class GameAction {
removed.add(c); removed.add(c);
} }
private String playerTurn = Constant.Player.Human;
public boolean isPlayerTurn(String player) {
return playerTurn.equals(player);
}
public void setPlayerTurn(String s) {
playerTurn = s;
}
private boolean shouldDraw = false; // Starts false to skip first draw private boolean shouldDraw = false; // Starts false to skip first draw
private String lastPlayerToDraw = Constant.Player.Human; private String lastPlayerToDraw = Constant.Player.Human;

View File

@@ -15,6 +15,8 @@ public class Input_Draw extends Input {
return; return;
} }
AllZone.GameInfo.setHumanPlayedLands(0);
//check if human should skip their draw phase //check if human should skip their draw phase
CardList humanCards = new CardList(); CardList humanCards = new CardList();
humanCards.addAll(AllZone.Human_Play.getCards()); humanCards.addAll(AllZone.Human_Play.getCards());
@@ -22,7 +24,6 @@ public class Input_Draw extends Input {
|| humanCards.containsName("Yawgmoth's Bargain"); || humanCards.containsName("Yawgmoth's Bargain");
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw) && humanSkipsDrawPhase) { if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw) && humanSkipsDrawPhase) {
AllZone.GameInfo.setHumanPlayedLands(0);
AllZone.Phase.setNeedToNextPhase(true); AllZone.Phase.setNeedToNextPhase(true);
} else { //continue with draw phase } else { //continue with draw phase
@@ -52,7 +53,6 @@ public class Input_Draw extends Input {
if(drawCard && AllZone.Phase.getTurn() > 1) AllZone.GameAction.drawCard(Constant.Player.Human); if(drawCard && AllZone.Phase.getTurn() > 1) AllZone.GameAction.drawCard(Constant.Player.Human);
if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw)) { if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw)) {
AllZone.GameInfo.setHumanPlayedLands(0);
//AllZone.Phase.nextPhase(); //AllZone.Phase.nextPhase();
//for debugging: System.out.println("need to nextPhase(from Input_Draw on human's draw) = true"); //for debugging: System.out.println("need to nextPhase(from Input_Draw on human's draw) = true");

View File

@@ -12,6 +12,8 @@ public class Input_Untap extends Input {
PlayerZone p = AllZone.getZone(Constant.Zone.Play, AllZone.Phase.getActivePlayer()); PlayerZone p = AllZone.getZone(Constant.Zone.Play, AllZone.Phase.getActivePlayer());
Card[] c = p.getCards(); Card[] c = p.getCards();
AllZone.GameAction.setPlayerTurn(AllZone.Phase.getActivePlayer());
if (AllZone.Phase.getTurn() != 1 && if (AllZone.Phase.getTurn() != 1 &&
!(AllZone.Phase.getActivePlayer().equals(Constant.Player.Human) && AllZone.Phase.getTurn() == 2) ) !(AllZone.Phase.getActivePlayer().equals(Constant.Player.Human) && AllZone.Phase.getTurn() == 2) )
{ {

View File

@@ -30,8 +30,8 @@ public class Phase extends MyObservable
private String phases[][] = private String phases[][] =
{ {
//human's turn //human's turn
{Constant.Player.Human , Constant.Phase.Untap} , {Constant.Player.Human, Constant.Phase.Untap},
// {Constant.Player.Human , Constant.Phase.Upkeep} , // {Constant.Player.Human, Constant.Phase.Upkeep},
{Constant.Player.Human, Constant.Phase.Draw}, {Constant.Player.Human, Constant.Phase.Draw},
{Constant.Player.Human, Constant.Phase.Main1}, {Constant.Player.Human, Constant.Phase.Main1},
{Constant.Player.Human, Constant.Phase.Combat_Declare_Attackers}, {Constant.Player.Human, Constant.Phase.Combat_Declare_Attackers},
@@ -45,12 +45,13 @@ public class Phase extends MyObservable
{Constant.Player.Human, Constant.Phase.End_Of_Combat}, {Constant.Player.Human, Constant.Phase.End_Of_Combat},
{Constant.Player.Human, Constant.Phase.Main2}, {Constant.Player.Human, Constant.Phase.Main2},
{Constant.Player.Human, Constant.Phase.At_End_Of_Turn}, {Constant.Player.Human, Constant.Phase.At_End_Of_Turn},
// {Constant.Player.Computer , Constant.Phase.End_Of_Turn} , // {Constant.Player.Computer , Constant.Phase.End_Of_Turn},
{Constant.Player.Human, Constant.Phase.Until_End_Of_Turn}, {Constant.Player.Human, Constant.Phase.Until_End_Of_Turn},
{Constant.Player.Human, Constant.Phase.Cleanup}, {Constant.Player.Human, Constant.Phase.Cleanup},
//computer's turn //computer's turn
{Constant.Player.Computer, Constant.Phase.Untap}, {Constant.Player.Computer, Constant.Phase.Untap},
// {Constant.Player.Computer, Constant.Phase.Upkeep},
{Constant.Player.Computer, Constant.Phase.Draw}, {Constant.Player.Computer, Constant.Phase.Draw},
{Constant.Player.Computer, Constant.Phase.Main1}, {Constant.Player.Computer, Constant.Phase.Main1},
{Constant.Player.Human, Constant.Phase.Combat_Before_Declare_Attackers_InstantAbility}, {Constant.Player.Human, Constant.Phase.Combat_Before_Declare_Attackers_InstantAbility},
@@ -405,6 +406,6 @@ public class Phase extends MyObservable
public static boolean canCastSorcery(String player) public static boolean canCastSorcery(String player)
{ {
return (AllZone.Phase.getPhase().equals(Constant.Phase.Main2) || (AllZone.Phase.getPhase().equals(Constant.Phase.Main1) return (AllZone.Phase.getPhase().equals(Constant.Phase.Main2) || (AllZone.Phase.getPhase().equals(Constant.Phase.Main1)
&& AllZone.GameAction.getLastPlayerToDraw().equals(player)) && AllZone.Stack.size() == 0); && AllZone.GameAction.isPlayerTurn(player)) && AllZone.Stack.size() == 0);
} }
} }