mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Migrate PlayLand from GameInfo to Player
- Cleanup some code near calls to playLand
This commit is contained in:
@@ -7925,13 +7925,8 @@ public class CardFactory implements NewConstants {
|
|||||||
Player player = card.getController();
|
Player player = card.getController();
|
||||||
if(freeCard != null) {
|
if(freeCard != null) {
|
||||||
if(freeCard.isLand() == true) {
|
if(freeCard.isLand() == true) {
|
||||||
if(CardFactoryUtil.canHumanPlayLand()) {
|
if(card.getController().canPlayLand()) {
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player);
|
card.getController().playLand(freeCard);
|
||||||
PlayerZone orig = AllZone.getZone(freeCard);
|
|
||||||
orig.remove(freeCard);
|
|
||||||
play.add(freeCard);
|
|
||||||
CardFactoryUtil.playLandEffects(freeCard);
|
|
||||||
AllZone.GameInfo.incrementHumanPlayedLands();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
|||||||
@@ -4288,7 +4288,6 @@ public class CardFactoryUtil {
|
|||||||
return getRandomCard(new CardList(zone.getCards()));
|
return getRandomCard(new CardList(zone.getCards()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void revertManland(Card c, String[] removeTypes, String[] removeKeywords, String cost, long timeStamp) {
|
public static void revertManland(Card c, String[] removeTypes, String[] removeKeywords, String cost, long timeStamp) {
|
||||||
c.setBaseAttack(0);
|
c.setBaseAttack(0);
|
||||||
c.setBaseDefense(0);
|
c.setBaseDefense(0);
|
||||||
@@ -4328,31 +4327,12 @@ public class CardFactoryUtil {
|
|||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canHumanPlayLand(){
|
|
||||||
return canPlayerPlayLand(AllZone.HumanPlayer, AllZone.GameInfo.humanNumberLandPlaysLeft());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canComputerPlayLand(){
|
|
||||||
return canPlayerPlayLand(AllZone.ComputerPlayer, AllZone.GameInfo.computerNumberLandPlaysLeft());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canPlayerPlayLand(Player player, int landPlaysLeft){
|
|
||||||
// LandsToPlay Left or Fastbond in play, Computer's turn, Stack is Empty, In Main Phase
|
|
||||||
return (Phase.canCastSorcery(player) && (landPlaysLeft > 0 ||
|
|
||||||
AllZoneUtil.getPlayerCardsInPlay(player, "Fastbond").size() > 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playLandEffects(Card c){
|
public static void playLandEffects(Card c){
|
||||||
final Player player = c.getController();
|
final Player player = c.getController();
|
||||||
CardList cityOfTraitors = AllZoneUtil.getPlayerCardsInPlay(player, "City of Traitors");
|
CardList cityOfTraitors = AllZoneUtil.getPlayerCardsInPlay(player, "City of Traitors");
|
||||||
cityOfTraitors.remove(c);
|
cityOfTraitors.remove(c);
|
||||||
boolean extraLand;
|
// > 0 because land amount isn't incremented until after playLandEffects
|
||||||
if (player.equals(AllZone.HumanPlayer)){
|
boolean extraLand = player.getNumLandsPlayed() > 0;
|
||||||
extraLand = AllZone.GameInfo.humanPlayedFirstLandThisTurn();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
extraLand = AllZone.GameInfo.computerPlayedFirstLandThisTurn();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(extraLand) {
|
if(extraLand) {
|
||||||
CardList fastbonds = AllZoneUtil.getPlayerCardsInPlay(player, "Fastbond");
|
CardList fastbonds = AllZoneUtil.getPlayerCardsInPlay(player, "Fastbond");
|
||||||
|
|||||||
@@ -1354,30 +1354,14 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
CardList library = new CardList(AllZone.getZone(Constant.Zone.Library, card.getController()).getCards());
|
// todo: change to static ability?
|
||||||
Card top = library.get(0);
|
CardList library = AllZoneUtil.getPlayerCardsInLibrary(card.getController());
|
||||||
|
if(library.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if(library.size() > 0 && top.getType().contains("Land") ) {
|
Card top = library.get(0);
|
||||||
boolean canPlayLand = false;
|
if(top.isLand())
|
||||||
boolean isHuman = false;
|
card.getController().playLand(top);
|
||||||
if(card.getController() == AllZone.HumanPlayer){
|
|
||||||
canPlayLand = CardFactoryUtil.canHumanPlayLand();
|
|
||||||
isHuman = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
canPlayLand = CardFactoryUtil.canComputerPlayLand();
|
|
||||||
}
|
|
||||||
if (canPlayLand){
|
|
||||||
//todo(sol): would prefer to use GameAction.playLand(top, play) but it doesn't work
|
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
|
||||||
Card land = AllZone.GameAction.moveTo(play, top);
|
|
||||||
CardFactoryUtil.playLandEffects(land);
|
|
||||||
if (isHuman)
|
|
||||||
AllZone.GameInfo.incrementHumanPlayedLands();
|
|
||||||
else
|
|
||||||
AllZone.GameInfo.incrementComputerPlayedLands();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}//resolve()
|
}//resolve()
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1385,11 +1369,9 @@ public class CardFactory_Creatures {
|
|||||||
CardList library = new CardList(AllZone.getZone(Constant.Zone.Library, card.getController()).getCards());
|
CardList library = new CardList(AllZone.getZone(Constant.Zone.Library, card.getController()).getCards());
|
||||||
if(library.size() == 0) return false;
|
if(library.size() == 0) return false;
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||||
boolean canPlayLand = false;
|
boolean canPlayLand = card.getController().canPlayLand();
|
||||||
if(card.getController() == AllZone.HumanPlayer) canPlayLand = CardFactoryUtil.canHumanPlayLand();
|
|
||||||
else canPlayLand = CardFactoryUtil.canComputerPlayLand();
|
|
||||||
|
|
||||||
return (AllZone.GameAction.isCardInZone(card, play) && library.get(0).getType().contains("Land") && canPlayLand);
|
return (AllZone.GameAction.isCardInZone(card, play) && library.get(0).isLand() && canPlayLand);
|
||||||
}
|
}
|
||||||
};//SpellAbility
|
};//SpellAbility
|
||||||
|
|
||||||
|
|||||||
@@ -991,14 +991,9 @@ public class CardFactory_Sorceries {
|
|||||||
if(target != null) c = AllZone.CardFactory.copyCard(target);
|
if(target != null) c = AllZone.CardFactory.copyCard(target);
|
||||||
|
|
||||||
if(c != null) {
|
if(c != null) {
|
||||||
if(c.isLand() == true) {
|
if(c.isLand()) {
|
||||||
if(CardFactoryUtil.canHumanPlayLand()) {
|
if(player.canPlayLand()) {
|
||||||
// todo(sol): would prefer this in GameAction.playLand somehow
|
player.playLand(c);
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player);
|
|
||||||
play.add(c);
|
|
||||||
card.unattachCard(c);
|
|
||||||
CardFactoryUtil.playLandEffects(c);
|
|
||||||
AllZone.GameInfo.incrementHumanPlayedLands();
|
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
@@ -1234,21 +1229,19 @@ public class CardFactory_Sorceries {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else//Computer chooses (It picks the highest converted mana cost card and 1 random card.)
|
}
|
||||||
{
|
else{//Computer chooses (It picks the highest converted mana cost card and 1 random card.)
|
||||||
Card biggest = null;
|
Card biggest = Exiled.get(0);
|
||||||
biggest = Exiled.get(0);
|
|
||||||
|
for(Card c : Exiled)
|
||||||
|
if(CardUtil.getConvertedManaCost(biggest.getManaCost()) < CardUtil.getConvertedManaCost(c.getManaCost()))
|
||||||
|
biggest = c;
|
||||||
|
|
||||||
for(int i = 0; i < Count; i++) {
|
|
||||||
if(CardUtil.getConvertedManaCost(biggest.getManaCost()) >= CardUtil.getConvertedManaCost(biggest.getManaCost())) {
|
|
||||||
biggest = cards.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Pile1.add(biggest);
|
Pile1.add(biggest);
|
||||||
cards.remove(biggest);
|
cards.remove(biggest);
|
||||||
if(cards.size() > 0) {
|
if(cards.size() > 2) {
|
||||||
Card Random = CardUtil.getRandom(cards.toArray());
|
Card Random = CardUtil.getRandom(cards.toArray());
|
||||||
Pile1.add(Random);
|
Pile1.add(Random);
|
||||||
}
|
}
|
||||||
for(int i = 0; i < Count; i++) if(!Pile1.contains(Exiled.get(i))) Pile2.add(Exiled.get(i));
|
for(int i = 0; i < Count; i++) if(!Pile1.contains(Exiled.get(i))) Pile2.add(Exiled.get(i));
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -1261,52 +1254,32 @@ public class CardFactory_Sorceries {
|
|||||||
Object q = JOptionPane.showOptionDialog(null, sb, "Brilliant Ultimatum",
|
Object q = JOptionPane.showOptionDialog(null, sb, "Brilliant Ultimatum",
|
||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
||||||
null, possibleValues, possibleValues[0]);
|
null, possibleValues, possibleValues[0]);
|
||||||
boolean stop2 = false;
|
|
||||||
if(q.equals(0)) {
|
CardList chosen;
|
||||||
int Spells = Pile1.size();
|
if (q.equals(0))
|
||||||
for( int i = 0; i < Spells; i++) {
|
chosen = Pile1;
|
||||||
if(stop2 == false) {
|
else
|
||||||
Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", Pile1.toArray());
|
chosen = Pile2;
|
||||||
if(check != null) {
|
|
||||||
if(((Card) check).isLand() == true) {
|
int numChosen = chosen.size();
|
||||||
if(CardFactoryUtil.canHumanPlayLand()) {
|
for( int i = 0; i < numChosen; i++) {
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", chosen.toArray());
|
||||||
GameAction.playLand((Card)check, play);
|
if (check == null)
|
||||||
} else {
|
break;
|
||||||
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
}
|
Card playing = (Card)check;
|
||||||
} else if(((Card) check).isPermanent() == true && ((Card) check).isAura() == false) {
|
if(playing.isLand()) {
|
||||||
AllZone.Stack.add(((Card) check).getSpellAbility()[0]);
|
if(card.getController().canPlayLand()) {
|
||||||
} else {
|
card.getController().playLand(playing);
|
||||||
AllZone.GameAction.playCardNoCost(((Card) check));
|
} else {
|
||||||
}
|
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
Pile1.remove((Card) check);
|
}
|
||||||
}
|
} else {
|
||||||
} else stop2 = true;
|
AllZone.GameAction.playCardNoCost(playing);
|
||||||
}
|
}
|
||||||
} else {
|
chosen.remove(playing);
|
||||||
int Spells = Pile2.size();
|
}
|
||||||
for( int i = 0; i < Spells; i++) {
|
|
||||||
if(stop2 == false) {
|
|
||||||
Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", Pile2.toArray());
|
|
||||||
if(check != null) {
|
|
||||||
if(((Card) check).isLand() == true) {
|
|
||||||
if(CardFactoryUtil.canHumanPlayLand()) {
|
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
|
||||||
GameAction.playLand((Card)check, play);
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
}
|
|
||||||
} else if(((Card) check).isPermanent() == true && ((Card) check).isAura() == false) {
|
|
||||||
AllZone.Stack.add(((Card) check).getSpellAbility()[0]);
|
|
||||||
} else {
|
|
||||||
AllZone.GameAction.playCardNoCost(((Card) check));
|
|
||||||
}
|
|
||||||
Pile2.remove((Card) check);
|
|
||||||
}
|
|
||||||
} else stop2 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Pile1.clear();
|
Pile1.clear();
|
||||||
Pile2.clear();
|
Pile2.clear();
|
||||||
@@ -4732,23 +4705,17 @@ public class CardFactory_Sorceries {
|
|||||||
|
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
final Player thePlayer = card.getController();
|
final Player thePlayer = card.getController();
|
||||||
if (thePlayer.equals(AllZone.HumanPlayer))
|
thePlayer.addMaxLandsToPlay(3);
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(3);
|
|
||||||
else
|
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(3);
|
|
||||||
|
|
||||||
Command untilEOT = new Command()
|
Command untilEOT = new Command()
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1665720009691293263L;
|
private static final long serialVersionUID = 1665720009691293263L;
|
||||||
|
|
||||||
public void execute(){
|
public void execute(){
|
||||||
if (thePlayer.equals(AllZone.HumanPlayer))
|
thePlayer.addMaxLandsToPlay(-3);
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(-3);
|
|
||||||
else
|
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(-3);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AllZone.EndOfTurn.addUntil(untilEOT);
|
AllZone.EndOfTurn.addUntil(untilEOT);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
card.clearSpellAbility();
|
card.clearSpellAbility();
|
||||||
@@ -4782,10 +4749,7 @@ public class CardFactory_Sorceries {
|
|||||||
|
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
final Player thePlayer = card.getController();
|
final Player thePlayer = card.getController();
|
||||||
if (thePlayer.equals(AllZone.HumanPlayer))
|
thePlayer.addMaxLandsToPlay(1);
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(1);
|
|
||||||
else
|
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(1);
|
|
||||||
|
|
||||||
Command untilEOT = new Command()
|
Command untilEOT = new Command()
|
||||||
{
|
{
|
||||||
@@ -4793,10 +4757,7 @@ public class CardFactory_Sorceries {
|
|||||||
private static final long serialVersionUID = -2618916698575607634L;
|
private static final long serialVersionUID = -2618916698575607634L;
|
||||||
|
|
||||||
public void execute(){
|
public void execute(){
|
||||||
if (thePlayer.equals(AllZone.HumanPlayer))
|
thePlayer.addMaxLandsToPlay(-1);
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(-1);
|
|
||||||
else
|
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(-1);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AllZone.EndOfTurn.addUntil(untilEOT);
|
AllZone.EndOfTurn.addUntil(untilEOT);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public class ComputerUtil
|
|||||||
if(canPayCost(all[i]) && all[i].canPlay() && all[i].canPlayAI())
|
if(canPayCost(all[i]) && all[i].canPlay() && all[i].canPlayAI())
|
||||||
{
|
{
|
||||||
AllZone.Stack.freezeStack();
|
AllZone.Stack.freezeStack();
|
||||||
|
|
||||||
|
// todo(sol) this conditional will be removed when Stack Zone is in
|
||||||
if(all[i].isSpell() && AllZone.GameAction.isCardInZone(all[i].getSourceCard(),AllZone.Computer_Hand))
|
if(all[i].isSpell() && AllZone.GameAction.isCardInZone(all[i].getSourceCard(),AllZone.Computer_Hand))
|
||||||
AllZone.Computer_Hand.remove(all[i].getSourceCard());
|
AllZone.Computer_Hand.remove(all[i].getSourceCard());
|
||||||
|
|
||||||
@@ -547,17 +549,17 @@ public class ComputerUtil
|
|||||||
//plays a land if one is available
|
//plays a land if one is available
|
||||||
static public void chooseLandsToPlay()
|
static public void chooseLandsToPlay()
|
||||||
{
|
{
|
||||||
|
Player computer = AllZone.ComputerPlayer;
|
||||||
ArrayList<Card> landList = PlayerZoneUtil.getCardType(AllZone.Computer_Hand, "Land");
|
ArrayList<Card> landList = PlayerZoneUtil.getCardType(AllZone.Computer_Hand, "Land");
|
||||||
|
|
||||||
if (AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer, "Crucible of Worlds").size() > 0)
|
if (AllZoneUtil.getPlayerCardsInPlay(computer, "Crucible of Worlds").size() > 0)
|
||||||
{
|
{
|
||||||
CardList lands = AllZoneUtil.getPlayerTypeInGraveyard(AllZone.ComputerPlayer, "Land");
|
CardList lands = AllZoneUtil.getPlayerTypeInGraveyard(computer, "Land");
|
||||||
for (Card crd : lands)
|
for (Card crd : lands)
|
||||||
landList.add(crd);
|
landList.add(crd);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!landList.isEmpty() && (AllZone.GameInfo.computerNumberLandPlaysLeft() > 0 ||
|
while(!landList.isEmpty() && computer.canPlayLand()){
|
||||||
AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer, "Fastbond").size() > 0)){
|
|
||||||
// play as many lands as you can
|
// play as many lands as you can
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
while (landList.get(ix).isReflectedLand() && (ix+1 < landList.size())) {
|
while (landList.get(ix).isReflectedLand() && (ix+1 < landList.size())) {
|
||||||
@@ -567,21 +569,12 @@ public class ComputerUtil
|
|||||||
|
|
||||||
Card land = landList.get(ix);
|
Card land = landList.get(ix);
|
||||||
landList.remove(ix);
|
landList.remove(ix);
|
||||||
playLand(land, AllZone.getZone(land));
|
computer.playLand(land);
|
||||||
|
|
||||||
AllZone.GameAction.checkStateEffects();
|
AllZone.GameAction.checkStateEffects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void playLand(Card land, PlayerZone zone)
|
|
||||||
{
|
|
||||||
AllZone.GameAction.moveToPlay(land);
|
|
||||||
/*zone.remove(land);
|
|
||||||
AllZone.Computer_Battlefield.add(land);*/
|
|
||||||
CardFactoryUtil.playLandEffects(land);
|
|
||||||
AllZone.GameInfo.incrementComputerPlayedLands();
|
|
||||||
}
|
|
||||||
|
|
||||||
static public Card getCardPreference(Card activate, String pref, CardList typeList){
|
static public Card getCardPreference(Card activate, String pref, CardList typeList){
|
||||||
String[] prefValid = activate.getSVar("AIPreference").split("\\$");
|
String[] prefValid = activate.getSVar("AIPreference").split("\\$");
|
||||||
if (prefValid[0].equals(pref)){
|
if (prefValid[0].equals(pref)){
|
||||||
|
|||||||
@@ -2223,9 +2223,6 @@ public class GameAction {
|
|||||||
// 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.setComputerMaxPlayNumberOfLands(1);
|
|
||||||
AllZone.GameInfo.setHumanMaxPlayNumberOfLands(1);
|
|
||||||
|
|
||||||
AllZone.GameInfo.setPreventCombatDamageThisTurn(false);
|
AllZone.GameInfo.setPreventCombatDamageThisTurn(false);
|
||||||
AllZone.GameInfo.setHumanNumberOfTimesMulliganed(0);
|
AllZone.GameInfo.setHumanNumberOfTimesMulliganed(0);
|
||||||
AllZone.GameInfo.setHumanMulliganedToZero(false);
|
AllZone.GameInfo.setHumanMulliganedToZero(false);
|
||||||
@@ -2649,7 +2646,7 @@ public class GameAction {
|
|||||||
SpellAbility[] abilities = canPlaySpellAbility(c.getSpellAbility());
|
SpellAbility[] abilities = canPlaySpellAbility(c.getSpellAbility());
|
||||||
ArrayList<String> choices = new ArrayList<String>();
|
ArrayList<String> choices = new ArrayList<String>();
|
||||||
|
|
||||||
if(c.isLand() && isCardInZone(c, AllZone.Human_Hand) && CardFactoryUtil.canHumanPlayLand())
|
if(c.isLand() && isCardInZone(c, AllZone.Human_Hand) && AllZone.HumanPlayer.canPlayLand())
|
||||||
choices.add("Play land");
|
choices.add("Play land");
|
||||||
|
|
||||||
for(SpellAbility sa:abilities) {
|
for(SpellAbility sa:abilities) {
|
||||||
@@ -2673,7 +2670,7 @@ public class GameAction {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(choice.equals("Play land")){
|
if(choice.equals("Play land")){
|
||||||
playLand(c, AllZone.Human_Hand);
|
AllZone.HumanPlayer.playLand(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2685,17 +2682,6 @@ public class GameAction {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void playLand(Card land, PlayerZone zone)
|
|
||||||
{
|
|
||||||
if (CardFactoryUtil.canHumanPlayLand()){
|
|
||||||
AllZone.GameAction.moveToPlay(land);
|
|
||||||
/*zone.remove(land);
|
|
||||||
AllZone.Human_Battlefield.add(land);*/
|
|
||||||
CardFactoryUtil.playLandEffects(land);
|
|
||||||
AllZone.GameInfo.incrementHumanPlayedLands();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playCardNoCost(Card c) {
|
public void playCardNoCost(Card c) {
|
||||||
//SpellAbility[] choices = (SpellAbility[]) c.getSpells().toArray();
|
//SpellAbility[] choices = (SpellAbility[]) c.getSpells().toArray();
|
||||||
ArrayList<SpellAbility> choices = c.getBasicSpells();
|
ArrayList<SpellAbility> choices = c.getBasicSpells();
|
||||||
|
|||||||
@@ -3,12 +3,6 @@ package forge;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class GameInfo {
|
public class GameInfo {
|
||||||
private int computerMaxPlayNumberOfLands = 1;
|
|
||||||
private int humanMaxPlayNumberOfLands = 1;
|
|
||||||
|
|
||||||
private int computerLandsPlayedThisTurn = 0;
|
|
||||||
private int humanLandsPlayedThisTurn = 0;
|
|
||||||
|
|
||||||
private boolean computerStartedThisGame = false;
|
private boolean computerStartedThisGame = false;
|
||||||
|
|
||||||
private int humanNumberOfTimesMulliganed;
|
private int humanNumberOfTimesMulliganed;
|
||||||
@@ -20,68 +14,6 @@ public class GameInfo {
|
|||||||
|
|
||||||
private ArrayList<Card_Color> globalColorChanges = new ArrayList<Card_Color>();
|
private ArrayList<Card_Color> globalColorChanges = new ArrayList<Card_Color>();
|
||||||
|
|
||||||
public void setComputerMaxPlayNumberOfLands(int n) {
|
|
||||||
computerMaxPlayNumberOfLands = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComputerMaxPlayNumberOfLands(int n)
|
|
||||||
{
|
|
||||||
computerMaxPlayNumberOfLands += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHumanMaxPlayNumberOfLands(int n) {
|
|
||||||
humanMaxPlayNumberOfLands = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addHumanMaxPlayNumberOfLands(int n)
|
|
||||||
{
|
|
||||||
humanMaxPlayNumberOfLands += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComputerPlayedLands(int n) {
|
|
||||||
computerLandsPlayedThisTurn = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getComputerPlayedLands() {
|
|
||||||
return computerLandsPlayedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementComputerPlayedLands()
|
|
||||||
{
|
|
||||||
computerLandsPlayedThisTurn++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHumanPlayedLands(int n) {
|
|
||||||
humanLandsPlayedThisTurn = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHumanPlayedLands() {
|
|
||||||
return humanLandsPlayedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementHumanPlayedLands()
|
|
||||||
{
|
|
||||||
humanLandsPlayedThisTurn++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int computerNumberLandPlaysLeft()
|
|
||||||
{
|
|
||||||
return computerMaxPlayNumberOfLands - computerLandsPlayedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int humanNumberLandPlaysLeft()
|
|
||||||
{
|
|
||||||
return humanMaxPlayNumberOfLands - humanLandsPlayedThisTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean computerPlayedFirstLandThisTurn() {
|
|
||||||
return (computerLandsPlayedThisTurn > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean humanPlayedFirstLandThisTurn() {
|
|
||||||
return (humanLandsPlayedThisTurn > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHumanNumberOfTimesMulliganed()
|
public int getHumanNumberOfTimesMulliganed()
|
||||||
{
|
{
|
||||||
return humanNumberOfTimesMulliganed;
|
return humanNumberOfTimesMulliganed;
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo
|
|||||||
sa[1].setActivatingPlayer(AllZone.HumanPlayer);
|
sa[1].setActivatingPlayer(AllZone.HumanPlayer);
|
||||||
if(sa[1].canPlay() && !c.isUnCastable()) AllZone.GameAction.playSpellAbility(sa[1]);
|
if(sa[1].canPlay() && !c.isUnCastable()) AllZone.GameAction.playSpellAbility(sa[1]);
|
||||||
}
|
}
|
||||||
else if (CardFactoryUtil.canHumanPlayLand())
|
else // PlayLand checks if the land can be played
|
||||||
GameAction.playLand(c, AllZone.Human_Graveyard);
|
AllZone.HumanPlayer.playLand(c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
COMPUTER_GRAVEYARD_ACTION = new ZoneAction(AllZone.Computer_Graveyard, COMPUTER_GRAVEYARD);
|
COMPUTER_GRAVEYARD_ACTION = new ZoneAction(AllZone.Computer_Graveyard, COMPUTER_GRAVEYARD);
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
|
|||||||
sa[1].setActivatingPlayer(AllZone.HumanPlayer);
|
sa[1].setActivatingPlayer(AllZone.HumanPlayer);
|
||||||
if(sa[1].canPlay() && !c.isUnCastable()) AllZone.GameAction.playSpellAbility(sa[1]);
|
if(sa[1].canPlay() && !c.isUnCastable()) AllZone.GameAction.playSpellAbility(sa[1]);
|
||||||
}
|
}
|
||||||
else if (CardFactoryUtil.canHumanPlayLand())
|
else // PlayLand checks if the land can be played
|
||||||
GameAction.playLand(c, AllZone.Human_Graveyard);
|
AllZone.HumanPlayer.playLand(c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
COMPUTER_GRAVEYARD_ACTION = new ZoneAction(AllZone.Computer_Graveyard, COMPUTER_GRAVEYARD);
|
COMPUTER_GRAVEYARD_ACTION = new ZoneAction(AllZone.Computer_Graveyard, COMPUTER_GRAVEYARD);
|
||||||
|
|||||||
@@ -143,10 +143,7 @@ public class Phase extends MyObservable
|
|||||||
PlayerCreatureSpellCount = 0;
|
PlayerCreatureSpellCount = 0;
|
||||||
ComputerSpellCount = 0;
|
ComputerSpellCount = 0;
|
||||||
ComputerCreatureSpellCount = 0;
|
ComputerCreatureSpellCount = 0;
|
||||||
if (playerTurn.isHuman())
|
playerTurn.setNumLandsPlayed(0);
|
||||||
AllZone.GameInfo.setHumanPlayedLands(0);
|
|
||||||
else
|
|
||||||
AllZone.GameInfo.setComputerPlayedLands(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleBeginPhase(){
|
public void handleBeginPhase(){
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ public abstract class Player extends MyObservable{
|
|||||||
protected int nTurns = 0;
|
protected int nTurns = 0;
|
||||||
protected boolean skipNextUntap = false;
|
protected boolean skipNextUntap = false;
|
||||||
|
|
||||||
|
protected int maxLandsToPlay = 1;
|
||||||
|
protected int numLandsPlayed = 0;
|
||||||
|
|
||||||
protected Card lastDrawnCard;
|
protected Card lastDrawnCard;
|
||||||
protected int numDrawnThisTurn = 0;
|
protected int numDrawnThisTurn = 0;
|
||||||
protected CardList slowtripList = new CardList();
|
protected CardList slowtripList = new CardList();
|
||||||
@@ -49,6 +52,8 @@ public abstract class Player extends MyObservable{
|
|||||||
altLose = false;
|
altLose = false;
|
||||||
winCondition = "";
|
winCondition = "";
|
||||||
loseCondition = "";
|
loseCondition = "";
|
||||||
|
maxLandsToPlay = 1;
|
||||||
|
numLandsPlayed = 0;
|
||||||
|
|
||||||
handSizeOperations = new ArrayList<HandSizeOp>();
|
handSizeOperations = new ArrayList<HandSizeOp>();
|
||||||
}
|
}
|
||||||
@@ -66,6 +71,8 @@ public abstract class Player extends MyObservable{
|
|||||||
altLose = false;
|
altLose = false;
|
||||||
winCondition = "";
|
winCondition = "";
|
||||||
loseCondition = "";
|
loseCondition = "";
|
||||||
|
maxLandsToPlay = 1;
|
||||||
|
numLandsPlayed = 0;
|
||||||
this.updateObservers();
|
this.updateObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,6 +752,19 @@ public abstract class Player extends MyObservable{
|
|||||||
}
|
}
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
|
public void playLand(Card land){
|
||||||
|
if (canPlayLand()){
|
||||||
|
AllZone.GameAction.moveToPlay(land);
|
||||||
|
CardFactoryUtil.playLandEffects(land);
|
||||||
|
numLandsPlayed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlayLand(){
|
||||||
|
return Phase.canCastSorcery(this) && (numLandsPlayed < maxLandsToPlay ||
|
||||||
|
AllZoneUtil.getPlayerCardsInPlay(this, "Fastbond").size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
////
|
////
|
||||||
//// properties about the player and his/her cards/game status
|
//// properties about the player and his/her cards/game status
|
||||||
@@ -1003,6 +1023,26 @@ public abstract class Player extends MyObservable{
|
|||||||
return channelCard;
|
return channelCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxLandsToPlay(){
|
||||||
|
return maxLandsToPlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxLandsToPlay(int n){
|
||||||
|
maxLandsToPlay = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMaxLandsToPlay(int n){
|
||||||
|
maxLandsToPlay += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumLandsPlayed(){
|
||||||
|
return numLandsPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumLandsPlayed(int n){
|
||||||
|
numLandsPlayed = n;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//
|
//
|
||||||
// Clash
|
// Clash
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
|||||||
//cannot use addComesIntoPlayCommand - trigger might be set to false;
|
//cannot use addComesIntoPlayCommand - trigger might be set to false;
|
||||||
// Keep track of max lands can play per turn
|
// Keep track of max lands can play per turn
|
||||||
int addMax = 0;
|
int addMax = 0;
|
||||||
boolean isHuman = c.getController().equals(AllZone.HumanPlayer);
|
|
||||||
boolean adjustLandPlays = false;
|
boolean adjustLandPlays = false;
|
||||||
boolean eachPlayer = false;
|
boolean eachPlayer = false;
|
||||||
|
|
||||||
@@ -55,13 +55,11 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
|||||||
|
|
||||||
if (adjustLandPlays){
|
if (adjustLandPlays){
|
||||||
if (eachPlayer){
|
if (eachPlayer){
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax);
|
AllZone.HumanPlayer.addMaxLandsToPlay(addMax);
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax);
|
AllZone.ComputerPlayer.addMaxLandsToPlay(addMax);
|
||||||
}
|
}
|
||||||
else if (isHuman)
|
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax);
|
|
||||||
else
|
else
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax);
|
c.getController().addMaxLandsToPlay(addMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(trigger) {
|
if(trigger) {
|
||||||
@@ -398,7 +396,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
|||||||
|
|
||||||
// Keep track of max lands can play per turn
|
// Keep track of max lands can play per turn
|
||||||
int addMax = 0;
|
int addMax = 0;
|
||||||
boolean isHuman = c.getController().equals(AllZone.HumanPlayer);
|
|
||||||
boolean adjustLandPlays = false;
|
boolean adjustLandPlays = false;
|
||||||
boolean eachPlayer = false;
|
boolean eachPlayer = false;
|
||||||
|
|
||||||
@@ -419,13 +417,11 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
|||||||
|
|
||||||
if (adjustLandPlays){
|
if (adjustLandPlays){
|
||||||
if (eachPlayer){
|
if (eachPlayer){
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax);
|
AllZone.HumanPlayer.addMaxLandsToPlay(addMax);
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax);
|
AllZone.ComputerPlayer.addMaxLandsToPlay(addMax);
|
||||||
}
|
}
|
||||||
else if (isHuman)
|
|
||||||
AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax);
|
|
||||||
else
|
else
|
||||||
AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax);
|
c.getController().addMaxLandsToPlay(addMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user