diff --git a/res/card-pictures.txt b/res/card-pictures.txt index 0db524c107c..6d1bf831b09 100644 --- a/res/card-pictures.txt +++ b/res/card-pictures.txt @@ -38,6 +38,8 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg +summer_bloom.jpg http://www.wizards.com/global/images/magic/general/summer_bloom.jpg +horn_of_greed.jpg http://www.wizards.com/global/images/magic/general/horn_of_greed.jpg dune_brood_nephilim.jpg http://www.wizards.com/global/images/magic/general/dune_brood_nephilim.jpg akuta_born_of_ash.jpg http://www.wizards.com/global/images/magic/general/akuta_born_of_ash.jpg agent_of_masks.jpg http://www.wizards.com/global/images/magic/general/agent_of_masks.jpg diff --git a/res/cards.txt b/res/cards.txt index a9e8744f763..407463317dc 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,13 @@ +Summer Bloom +1 G +Sorcery +You may play up to three additional lands this turn. + +Horn of Greed +3 +Artifact +When a player plays a land, that player draws a card. + Dune-Brood Nephilim B R G W Creature Nephilim @@ -526,7 +536,7 @@ spDiscardTgt:TgtChoose:2:Target player discards two cards.:Mind Rot - target pla Mind Sludge 4 B -Sorcery +ry no text spDiscardTgt:TgtChoose:X:Target player discards a card for each Swamp you control.:Mind Sludge - target player discards cards SVar:X:Count$TypeYouCtrl.Swamp diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index fdec1d60faf..4f4fc40b256 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -8514,62 +8514,63 @@ public class CardFactory implements NewConstants { for(int i = 0; i < Attached.length; i++) { if(Attached[i].isInstant() == true || Attached[i].hasKeyword("Flash") == true) Config.add(Attached[i]); } - for(int i = 0; i < Config.size(); i++) { - Card crd = Config.get(i); - Choices[i] = crd; - } - if(Config.size() == 0) SystemsGo = false; + for(int i = 0; i < Config.size(); i++) { + Card crd = Config.get(i); + Choices[i] = crd; + } + if(Config.size() == 0) SystemsGo = false; } else { for(int i = 0; i < Attached.length; i++) { Choices[i] = Attached[i]; } - } - Object check = null; - if(SystemsGo == true) { - check = AllZone.Display.getChoiceOptional("Select Card to play for free", Choices); - if(check != null) { - target = ((Card) check); - } - if(target != null) c = copyCard(target); - - if(c != null) { - if(c.isLand() == true) { - if(AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0) { - PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); - play.add(c); - card.unattachCard(c); - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); - } else { - JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE); - } - } else if(c.isPermanent() == true && c.isAura() == false) { - c.removeIntrinsicKeyword("Flash"); // Stops the player from re-casting the flash spell. - PlayCreature.setStackDescription(c.getName() + " - Copied from Mind's Desire"); - Card [] ReAttach = new Card[Attached.length]; - ReAttach[0] = c; - int ReAttach_Count = 0; - for(int i = 0; i < Attached.length; i++) { - if(Attached[i] != target) { - ReAttach_Count = ReAttach_Count + 1; - ReAttach[ReAttach_Count] = Attached[i]; - } - } - // Clear Attached List - for(int i = 0; i < Attached.length; i++) { - card.unattachCard(Attached[i]); - } - // Re-add - for(int i = 0; i < ReAttach.length; i++) { - if(ReAttach[i] != null) card.attachCard(ReAttach[i]); - } - target.addSpellAbility(PlayCreature); - AllZone.Stack.add(PlayCreature); - } else { - AllZone.GameAction.playCardNoCost(c); - card.unattachCard(c); - } - } else JOptionPane.showMessageDialog(null, "Player cancelled or there is no more cards available on Mind's Desire.", "", JOptionPane.INFORMATION_MESSAGE); + } + Object check = null; + if(SystemsGo == true) { + check = AllZone.Display.getChoiceOptional("Select Card to play for free", Choices); + if(check != null) { + target = ((Card) check); + } + if(target != null) c = copyCard(target); + + if(c != null) { + if(c.isLand() == true) { + if(CardFactoryUtil.canHumanPlayLand()) { + // todo(sol): would prefer this in GameAction.playLand somehow + PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); + play.add(c); + card.unattachCard(c); + CardFactoryUtil.playLandEffects(c); + AllZone.GameInfo.incrementHumanPlayedLands(); + } else { + JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE); + } + } else if(c.isPermanent() == true && c.isAura() == false) { + c.removeIntrinsicKeyword("Flash"); // Stops the player from re-casting the flash spell. + PlayCreature.setStackDescription(c.getName() + " - Copied from Mind's Desire"); + Card [] ReAttach = new Card[Attached.length]; + ReAttach[0] = c; + int ReAttach_Count = 0; + for(int i = 0; i < Attached.length; i++) { + if(Attached[i] != target) { + ReAttach_Count = ReAttach_Count + 1; + ReAttach[ReAttach_Count] = Attached[i]; + } + } + // Clear Attached List + for(int i = 0; i < Attached.length; i++) { + card.unattachCard(Attached[i]); + } + // Re-add + for(int i = 0; i < ReAttach.length; i++) { + if(ReAttach[i] != null) card.attachCard(ReAttach[i]); + } + target.addSpellAbility(PlayCreature); + AllZone.Stack.add(PlayCreature); + } else { + AllZone.GameAction.playCardNoCost(c); + card.unattachCard(c); + } + } else JOptionPane.showMessageDialog(null, "Player cancelled or there is no more cards available on Mind's Desire.", "", JOptionPane.INFORMATION_MESSAGE); } else JOptionPane.showMessageDialog(null, "You can only play an instant at this point in time, but none are attached to Mind's Desire.", "", JOptionPane.INFORMATION_MESSAGE); } } @@ -8804,11 +8805,9 @@ public class CardFactory implements NewConstants { Object check = AllZone.Display.getChoiceOptional("Select spells to play in reserve order: ", Pile1.toArray()); if(check != null) { if(((Card) check).isLand() == true) { - if(AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0) { - PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); - play.add(check); - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); + if(CardFactoryUtil.canHumanPlayLand()) { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + GameAction.playLand((Card)check, play); } else { JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE); } @@ -8828,11 +8827,9 @@ public class CardFactory implements NewConstants { Object check = AllZone.Display.getChoiceOptional("Select spells to play in reserve order: ", Pile2.toArray()); if(check != null) { if(((Card) check).isLand() == true) { - if(AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0) { - PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); - play.add(check); - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); + if(CardFactoryUtil.canHumanPlayLand()) { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + GameAction.playLand((Card)check, play); } else { JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "", JOptionPane.INFORMATION_MESSAGE); } @@ -20658,7 +20655,55 @@ public class CardFactory implements NewConstants { card.addSpellAbility(spell); }//*************** END ************ END ************************** + //*************** START *********** START ************************** + else if(cardName.equals("Summer Bloom")) + { + final SpellAbility spell = new Spell(card) { + private static final long serialVersionUID = 5559004016728325736L; + public boolean canPlayAI() { + // The computer should only play this card if it has at least + // one land in its hand. Because of the way the computer turn + // is structured, it will already have played land to it's limit + PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, + Constant.Player.Computer); + + CardList list = new CardList(hand.getCards()); + + list = list.getType("Land"); + if (list.size() > 0) + return true; + else + return false; + } + + public void resolve() { + final String thePlayer = card.getController(); + if (thePlayer.equals(Constant.Player.Human)) + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(3); + else + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(3); + + Command untilEOT = new Command() + { + private static final long serialVersionUID = 1665720009691293263L; + + public void execute(){ + if (thePlayer.equals(Constant.Player.Human)) + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(-3); + else + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(-3); + } + }; + AllZone.EndOfTurn.addUntil(untilEOT); + } + }; + card.clearSpellAbility(); + card.addSpellAbility(spell); + + card.setSVar("PlayMain1", "TRUE"); + } //*************** END ************ END ************************** + //*************** START *********** START ************************** else if(cardName.equals("Explore")) { @@ -20684,25 +20729,23 @@ public class CardFactory implements NewConstants { public void resolve() { final String thePlayer = card.getController(); if (thePlayer.equals(Constant.Player.Human)) - AllZone.GameInfo.addHumanCanPlayNumberOfLands(1); + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(1); else - AllZone.GameInfo.addComputerCanPlayNumberOfLands(1); + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(1); Command untilEOT = new Command() { private static final long serialVersionUID = -2618916698575607634L; - public void execute() - { + public void execute(){ if (thePlayer.equals(Constant.Player.Human)) - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - // There's no corresponding 'if' for the computer - // The computer's land total gets reset to the right value - // every turn - } - }; - AllZone.EndOfTurn.addUntil(untilEOT); + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(-1); + else + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(-1); + } + }; + AllZone.EndOfTurn.addUntil(untilEOT); } }; card.clearSpellAbility(); @@ -22311,7 +22354,7 @@ public class CardFactory implements NewConstants { ability.setStackDescription(cardName+" - Player shuffles grave into library."); card.addSpellAbility(ability); }//*************** END ************ END ************************** - + //*************** START *********** START ************************** else if(cardName.equals("Fabricate")) { SpellAbility spell = new Spell(card) { diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index f3c8629c724..369525c41ad 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -3800,27 +3800,7 @@ public class CardFactoryUtil { list = list.getName("Necropotence"); return list.size() > 0; } - - public static int getCanPlayNumberOfLands(String player) { - int count = 1; - CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, player).getCards()); - list = list.filter(new CardListFilter() { - public boolean addCard(Card c) { - return c.getName().equals("Exploration") || c.getName().equals("Azusa, Lost but Seeking") - || c.getName().equals("Fastbond") || c.getName().equals("Oracle of Mul Daya"); - } - }); - for(Card var:list) { - if(var.getName().equals("Exploration")) count++; - else if(var.getName().equals("Azusa, Lost but Seeking")) count = count + 2; - else if(var.getName().equals("Oracle of Mul Daya")) count = count + 1; - else if(var.getName().equals("Fastbond")) count = 100; - } - - return count; - } - public static CardList getCards(String cardName) { CardList list = new CardList(); @@ -3831,17 +3811,12 @@ public class CardFactoryUtil { } public static CardList getCards(String cardName, String player) { - CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, player).getCards()); + PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); + CardList list = new CardList(play.getCards()); list = list.getName(cardName); return list; } - public static CardList getFastbonds(String player) { - CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, player).getCards()); - list = list.getName("Fastbond"); - return list; - } - public static int countBasicLandTypes(String player) { String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"}; PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); @@ -4211,6 +4186,53 @@ public class CardFactoryUtil { c.setManaCost(cost); } + public static boolean canHumanPlayLand(){ + return (AllZone.GameInfo.humanNumberLandPlaysLeft() > 0 || CardFactoryUtil.getCards("Fastbond", "Human").size() > 0); + } + + public static boolean canComputerPlayLand(){ + return (AllZone.GameInfo.computerNumberLandPlaysLeft() > 0 || CardFactoryUtil.getCards("Fastbond", "Computer").size() > 0); + } + + public static void playLandEffects(Card c){ + final String player = c.getController(); + boolean extraLand; + if (player.equals("Human")){ + extraLand = AllZone.GameInfo.humanPlayedFirstLandThisTurn(); + } + else{ + extraLand = AllZone.GameInfo.computerPlayedFirstLandThisTurn(); + } + + if(extraLand) { + CardList fastbonds = CardFactoryUtil.getCards("Fastbond", player); + for(final Card f : fastbonds){ + SpellAbility ability = new Ability(f, "0") { + @Override + public void resolve() { + AllZone.GameAction.getPlayerLife(f.getController()).subtractLife(1,f); + } + }; + ability.setStackDescription("Fastbond - Deals 1 damage to you."); + AllZone.Stack.add(ability); + } + } + + CardList greedy = CardFactoryUtil.getCards("Horn of Greed"); + if (!greedy.isEmpty()){ + for(final Card g : greedy){ + SpellAbility ability = new Ability(g, "0") { + @Override + public void resolve() { + AllZone.GameAction.drawCard(player); + } + }; + ability.setStackDescription("Horn of Greed - " + player + " draws a card."); + AllZone.Stack.add(ability); + } + } + } + public static void main(String[] args) { CardList in = AllZone.CardFactory.getAllCards(); diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 5711cc1cf20..67578c127d8 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -2704,29 +2704,28 @@ public class CardFactory_Creatures { @Override public void resolve() { CardList library = new CardList(AllZone.getZone(Constant.Zone.Library, card.getController()).getCards()); - CardList Fastbond = new CardList(AllZone.getZone(Constant.Zone.Play, card.getController()).getCards()); - Fastbond = Fastbond.getName("Fastbond"); - if(library.size() > 0) { - if(library.get(0).getType().contains("Land")) { - PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); - AllZone.GameAction.moveTo(play, library.get(0)); - if(card.getController() == Constant.Player.Human) { - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - if(AllZone.GameInfo.humanPlayedFirstLandThisTurn() == true) { - for(int i = 0; i < Fastbond.size(); i++) - AllZone.GameAction.addDamage(card.getController(), 1,Fastbond.get(0)); - } - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); + Card top = library.get(0); + + if(library.size() > 0 && top.getType().contains("Land") ) { + boolean canPlayLand = false; + boolean isHuman = false; + if(card.getController() == Constant.Player.Human){ + canPlayLand = CardFactoryUtil.canHumanPlayLand(); + isHuman = true; + } + else{ + canPlayLand = CardFactoryUtil.canComputerPlayLand(); } - else { - AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1); - if(AllZone.GameInfo.computerPlayedFirstLandThisTurn() == true) { - for(int i = 0; i < Fastbond.size(); i++) - AllZone.GameAction.addDamage(card.getController(), 1,Fastbond.get(0)); - } - AllZone.GameInfo.setComputerPlayedFirstLandThisTurn(true); - } - } + if (canPlayLand){ + //todo(sol): would prefer to use GameAction.playLand(top, play) but it doesn't work + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + Card land = AllZone.GameAction.moveTo(play, top); + CardFactoryUtil.playLandEffects(land); + if (isHuman) + AllZone.GameInfo.incrementHumanPlayedLands(); + else + AllZone.GameInfo.incrementComputerPlayedLands(); + } } }//resolve() @@ -2735,11 +2734,11 @@ public class CardFactory_Creatures { CardList library = new CardList(AllZone.getZone(Constant.Zone.Library, card.getController()).getCards()); if(library.size() == 0) return false; PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); - int PlayLand = 0; - if(card.getController() == Constant.Player.Human) PlayLand = AllZone.GameInfo.getHumanCanPlayNumberOfLands(); - else PlayLand = AllZone.GameInfo.getComputerCanPlayNumberOfLands(); + boolean canPlayLand = false; + if(card.getController() == Constant.Player.Human) canPlayLand = CardFactoryUtil.canHumanPlayLand(); + else canPlayLand = CardFactoryUtil.canComputerPlayLand(); - return (AllZone.GameAction.isCardInZone(card, play) && library.get(0).getType().contains("Land") && PlayLand > 0) + return (AllZone.GameAction.isCardInZone(card, play) && library.get(0).getType().contains("Land") && canPlayLand) && (AllZone.Stack.size() == 0) && AllZone.GameAction.getLastPlayerToDraw().equals(card.getController()); } }; diff --git a/src/forge/ComputerAI_Burn.java b/src/forge/ComputerAI_Burn.java index 9bb18b7ea36..a9dfdaac795 100644 --- a/src/forge/ComputerAI_Burn.java +++ b/src/forge/ComputerAI_Burn.java @@ -8,13 +8,9 @@ import forge.error.ErrorViewer; public class ComputerAI_Burn implements Computer { - private volatile int numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); public void main1() { - if(numberPlayLand > 0) { - numberPlayLand--; - ComputerUtil.playLand(); - } + ComputerUtil.chooseLandsToPlay(); Runnable run = new Runnable() { public void run() { synchronized(ComputerAI_Burn.this) { @@ -56,8 +52,7 @@ public class ComputerAI_Burn implements Computer { }//main1() public void main2() { - numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); - + ComputerUtil.chooseLandsToPlay(); //AllZone.Phase.nextPhase(); //for debugging: System.out.println("need to nextPhase(ComputerAI_Burn.main2) = true; Note, this is untested, did it work?"); AllZone.Phase.setNeedToNextPhase(true); @@ -137,16 +132,6 @@ public class ComputerAI_Burn implements Computer { return library.toArray(); } - public void addNumberPlayLands(int n) - { - numberPlayLand += n; - } - - public void setNumberPlayLands(int n) - { - numberPlayLand = n; - } - public void stack_not_empty() { //same as Input.stop() method //ends the method diff --git a/src/forge/ComputerAI_Burn2.java b/src/forge/ComputerAI_Burn2.java index 6e74c613e70..7c056cb153f 100644 --- a/src/forge/ComputerAI_Burn2.java +++ b/src/forge/ComputerAI_Burn2.java @@ -6,21 +6,9 @@ import forge.error.ErrorViewer; public class ComputerAI_Burn2 implements Computer { - private volatile int numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); - + public void main1() { - if(numberPlayLand > 0 ) { - numberPlayLand--; - ComputerUtil.playLand(); - - Card c[] = AllZone.Computer_Hand.getCards(); - if(c.length != 0) { -// System.out.print("hand - "); -// for(int i = 0; i < c.length; i++) -// System.out.print(c[i] +" "); -// System.out.println(); - } - } + ComputerUtil.chooseLandsToPlay(); Runnable run = new Runnable() { public void run() { synchronized(ComputerAI_Burn2.this) { @@ -71,8 +59,7 @@ public class ComputerAI_Burn2 implements Computer { }//main1() public void main2() { - numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); - + ComputerUtil.chooseLandsToPlay(); //AllZone.Phase.nextPhase(); //for debugging: System.out.println("need to nextPhase(ComputerAI_Burn2.main2) = true; Note, this is not tested, did it work?"); AllZone.Phase.setNeedToNextPhase(true); @@ -175,17 +162,7 @@ public class ComputerAI_Burn2 implements Computer { return library.toArray(); } - - public void addNumberPlayLands(int n) - { - numberPlayLand += n; - } - - public void setNumberPlayLands(int n) - { - numberPlayLand = n; - } - + public void stack_not_empty() { //same as Input.stop() method //ends the method diff --git a/src/forge/ComputerAI_General.java b/src/forge/ComputerAI_General.java index 84c7f58f358..cb2f59c4700 100644 --- a/src/forge/ComputerAI_General.java +++ b/src/forge/ComputerAI_General.java @@ -22,40 +22,13 @@ public class ComputerAI_General implements Computer { } public void main1() { - if(AllZone.GameInfo.getComputerCanPlayNumberOfLands() > 0) { - - AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1); - ComputerUtil.playLand(); - for(String effect:AllZone.StaticEffects.getStateBasedMap().keySet()) { - Command com = GameActionUtil.commands.get(effect); - com.execute(); - } - GameActionUtil.executeCardStateEffects(); - } - - // AllZone.Phase.nextPhase(); - + ComputerUtil.chooseLandsToPlay(); playCards(Constant.Phase.Main1); - - //for cards like Exploration, Fastbond, Azusa, ... - while(AllZone.GameInfo.getComputerCanPlayNumberOfLands() > 0) - { - AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1); - ComputerUtil.playLand(); - - for(String effect:AllZone.StaticEffects.getStateBasedMap().keySet()) { - Command com = GameActionUtil.commands.get(effect); - com.execute(); - } - GameActionUtil.executeCardStateEffects(); - } }//main1() public void main2() { - AllZone.GameInfo.setComputerCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer)); - + ComputerUtil.chooseLandsToPlay(); // in case we can play more lands now, or drew cards since first main phase playCards(Constant.Phase.Main2); - } private void playCards(final String phase) { diff --git a/src/forge/ComputerAI_Rats2.java b/src/forge/ComputerAI_Rats2.java index 155ea845bb8..17943aea269 100644 --- a/src/forge/ComputerAI_Rats2.java +++ b/src/forge/ComputerAI_Rats2.java @@ -3,35 +3,30 @@ import java.util.*; public class ComputerAI_Rats2 implements Computer { - private int numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); - private static Random random = new Random(); public void main1() { - if(numberPlayLand > 0) - { - numberPlayLand--; - ComputerUtil.playLand(); - } - -// if(playActivatedAbilities() || playSorcery()) -// return; - Card[] c = AllZone.Computer_Hand.getCards(); - System.out.println("Computer Thinking " +new CardList(c)); + ComputerUtil.chooseLandsToPlay(); - //AllZone.Phase.nextPhase(); - //for debugging: System.out.println("need to nextPhase(ComputerAI_Rats2.main1) = true"); - AllZone.Phase.setNeedToNextPhase(true); + // if(playActivatedAbilities() || playSorcery()) + // return; + Card[] c = AllZone.Computer_Hand.getCards(); + System.out.println("Computer Thinking " +new CardList(c)); + + //AllZone.Phase.nextPhase(); + //for debugging: System.out.println("need to nextPhase(ComputerAI_Rats2.main1) = true"); + AllZone.Phase.setNeedToNextPhase(true); } + public void main2() { - numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); - + ComputerUtil.chooseLandsToPlay(); //AllZone.Phase.nextPhase(); //for debugging: System.out.println("need to nextPhase(ComputerAI_Rats2.main2) = true"); - AllZone.Phase.setNeedToNextPhase(true); + AllZone.Phase.setNeedToNextPhase(true); } + public void declare_blockers() { if(random.nextBoolean() || AllZone.Computer_Life.getLife() < 10) @@ -145,16 +140,6 @@ public class ComputerAI_Rats2 implements Computer AllZone.Phase.setNeedToNextPhase(true); } - public void addNumberPlayLands(int n) - { - numberPlayLand += n; - } - - public void setNumberPlayLands(int n) - { - numberPlayLand = n; - } - public void stack_not_empty() { AllZone.InputControl.resetInput(); diff --git a/src/forge/ComputerAI_Testing.java b/src/forge/ComputerAI_Testing.java index 1e3984e19e9..fa855097a5f 100644 --- a/src/forge/ComputerAI_Testing.java +++ b/src/forge/ComputerAI_Testing.java @@ -1,20 +1,17 @@ package forge; public class ComputerAI_Testing implements Computer { - - private int numberPlayLand = CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Computer); - //must shuffle this public Card[] getLibrary() {return new Card[] {};} public void stack_not_empty() { - System.out.println("Computer: not empty"); - //same as Input.stop() method - //ends the method - //different than methods because this isn't a phase like Main1 or Declare Attackers - AllZone.InputControl.resetInput(); - AllZone.InputControl.updateObservers(); + System.out.println("Computer: not empty"); + //same as Input.stop() method + //ends the method + //different than methods because this isn't a phase like Main1 or Declare Attackers + AllZone.InputControl.resetInput(); + AllZone.InputControl.updateObservers(); } public void main1() {AllZone.Phase.nextPhase();} @@ -70,15 +67,5 @@ public class ComputerAI_Testing implements Computer //AllZone.Phase.nextPhase(); //for debugging: System.out.println("need to nextPhase(ComputerAI_Testing.end_of_turn) = true"); AllZone.Phase.setNeedToNextPhase(true); - } - - public void addNumberPlayLands(int n) - { - numberPlayLand += n; - } - - public void setNumberPlayLands(int n) - { - numberPlayLand = n; } } \ No newline at end of file diff --git a/src/forge/ComputerUtil.java b/src/forge/ComputerUtil.java index 97ad8a11b79..efb98cca410 100644 --- a/src/forge/ComputerUtil.java +++ b/src/forge/ComputerUtil.java @@ -370,32 +370,34 @@ public class ComputerUtil }//getAvailableMana() //plays a land if one is available - static public void playLand() + static public void chooseLandsToPlay() { - ArrayList landList = PlayerZoneUtil.getCardType(AllZone.Computer_Hand, "Land"); - if(! landList.isEmpty()) - { - int ix = 0; - while (landList.get(ix).isReflectedLand() && (ix+1 < landList.size())) { - // Play reflected lands LAST so that there is colored mana in play - // Don't increment past the end of the list! - ix++; - } - AllZone.Computer_Hand.remove(landList.get(ix)); - AllZone.Computer_Play.add(landList.get(ix)); - - if (!AllZone.GameInfo.computerPlayedFirstLandThisTurn()) { - AllZone.GameInfo.setComputerPlayedFirstLandThisTurn(true); - } - else - { - if (CardFactoryUtil.getFastbonds(Constant.Player.Computer).size() > 0) - AllZone.GameAction.getPlayerLife(Constant.Player.Computer).subtractLife(1,CardFactoryUtil.getFastbonds(Constant.Player.Computer).get(0)); - } - - AllZone.GameAction.checkStateEffects(); - } + ArrayList landList = PlayerZoneUtil.getCardType(AllZone.Computer_Hand, "Land"); + while(!landList.isEmpty() && (AllZone.GameInfo.computerNumberLandPlaysLeft() > 0 || + CardFactoryUtil.getCards("Fastbond", "Computer").size() > 0)){ + // 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); + playLand(land, AllZone.Computer_Hand); + + AllZone.GameAction.checkStateEffects(); + } } + + static public void playLand(Card land, PlayerZone zone) + { + zone.remove(land); + AllZone.Computer_Play.add(land); + CardFactoryUtil.playLandEffects(land); + AllZone.GameInfo.incrementComputerPlayedLands(); + } + static public void untapDraw() { AllZone.GameAction.drawCard(Constant.Player.Computer); diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index b7a8f19d69e..6a88f7f0490 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -1654,8 +1654,8 @@ public class GameAction { lastPlayerToDraw = Constant.Player.Human; - AllZone.GameInfo.setComputerCanPlayNumberOfLands(1); - AllZone.GameInfo.setHumanCanPlayNumberOfLands(1); + AllZone.GameInfo.setComputerMaxPlayNumberOfLands(1); + AllZone.GameInfo.setHumanMaxPlayNumberOfLands(1); AllZone.GameInfo.setPreventCombatDamageThisTurn(false); AllZone.GameInfo.setHumanNumberOfTimesMulliganed(0); @@ -2043,8 +2043,7 @@ public class GameAction { ArrayList choices = new ArrayList(); - if(AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0 - && AllZone.Stack.size() == 0 + if(AllZone.Stack.size() == 0 && CardFactoryUtil.canHumanPlayLand() && (AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals( Constant.Phase.Main2))) choices.add("Play land"); @@ -2066,10 +2065,7 @@ public class GameAction { if(choice == null) ; else if(choice.equals("Play land")) { - AllZone.Human_Hand.remove(c); - AllZone.Human_Play.add(c); - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); + playLand(c, AllZone.Human_Hand); } else { SpellAbility sa = map.get(choice); playSpellAbility(sa); @@ -2094,6 +2090,16 @@ public class GameAction { } } + static public void playLand(Card land, PlayerZone zone) + { + if (CardFactoryUtil.canHumanPlayLand()){ + zone.remove(land); + AllZone.Human_Play.add(land); + CardFactoryUtil.playLandEffects(land); + AllZone.GameInfo.incrementHumanPlayedLands(); + } + } + public void playCardNoCost(Card c) { //SpellAbility[] choices = (SpellAbility[]) c.getSpells().toArray(); ArrayList choices = c.getBasicSpells(); diff --git a/src/forge/GameInfo.java b/src/forge/GameInfo.java index b5ed5d9a25d..c30b4bacd6d 100644 --- a/src/forge/GameInfo.java +++ b/src/forge/GameInfo.java @@ -1,14 +1,14 @@ package forge; public class GameInfo { - private int computerCanPlayNumberOfLands; - private int humanCanPlayNumberOfLands; + private int computerMaxPlayNumberOfLands = 1; + private int humanMaxPlayNumberOfLands = 1; + + private int computerLandsPlayedThisTurn = 0; + private int humanLandsPlayedThisTurn = 0; private boolean computerStartedThisGame = false; - private boolean computerPlayedFirstLandThisTurn; - private boolean humanPlayedFirstLandThisTurn; - private int humanNumberOfTimesMulliganed; private boolean humanMulliganedToZero; @@ -16,47 +16,66 @@ public class GameInfo { private boolean assignedFirstStrikeDamageThisCombat; private boolean resolvedFirstStrikeDamageThisCombat; - public void setComputerCanPlayNumberOfLands(int n) { - computerCanPlayNumberOfLands = n; + public void setComputerMaxPlayNumberOfLands(int n) { + computerMaxPlayNumberOfLands = n; } - public int getComputerCanPlayNumberOfLands() { - return computerCanPlayNumberOfLands; - } - - public void addComputerCanPlayNumberOfLands(int n) + public void addComputerMaxPlayNumberOfLands(int n) { - computerCanPlayNumberOfLands += n; + computerMaxPlayNumberOfLands += n; } - public void setHumanCanPlayNumberOfLands(int n) { - humanCanPlayNumberOfLands = n; - } - - public int getHumanCanPlayNumberOfLands() { - return humanCanPlayNumberOfLands; + public void setHumanMaxPlayNumberOfLands(int n) { + humanMaxPlayNumberOfLands = n; } - public void addHumanCanPlayNumberOfLands(int n) + public void addHumanMaxPlayNumberOfLands(int n) { - humanCanPlayNumberOfLands += n; + humanMaxPlayNumberOfLands += n; } - - public void setComputerPlayedFirstLandThisTurn(boolean b) { - computerPlayedFirstLandThisTurn = b; + 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 computerPlayedFirstLandThisTurn; - } - - public void setHumanPlayedFirstLandThisTurn(boolean b) { - humanPlayedFirstLandThisTurn = b; + return (computerLandsPlayedThisTurn > 0); } public boolean humanPlayedFirstLandThisTurn() { - return humanPlayedFirstLandThisTurn; + return (humanLandsPlayedThisTurn > 0); } public int getHumanNumberOfTimesMulliganed() diff --git a/src/forge/InputUtil.java b/src/forge/InputUtil.java index e3e000a0dd9..e1f43c44765 100644 --- a/src/forge/InputUtil.java +++ b/src/forge/InputUtil.java @@ -13,39 +13,28 @@ public class InputUtil //plays activated abilities and any card including land, sorceries, and instants static public void playAnyCard(Card card, PlayerZone zone) { - if(zone.is(Constant.Zone.Hand, Constant.Player.Human) && - (card.isLand())) - { - - //hacky stuff: see if there's cycling/transmute/other hand abilities on the land: - SpellAbility[] sa = card.getSpellAbility(); - if (sa.length > 0) + if(zone.is(Constant.Zone.Hand, Constant.Player.Human) && + (card.isLand())) { - int count = 0; - for (SpellAbility s : sa) + + //hacky stuff: see if there's cycling/transmute/other hand abilities on the land: + SpellAbility[] sa = card.getSpellAbility(); + if (sa.length > 0) { - if (s.canPlay() && (s instanceof Ability_Hand)) - count++; + int count = 0; + for (SpellAbility s : sa) + { + if (s.canPlay() && (s instanceof Ability_Hand)) + count++; + } + if (count > 0) + AllZone.GameAction.playCard(card); + else //play the land + GameAction.playLand(card, zone); } - if (count > 0) - AllZone.GameAction.playCard(card); else //play the land - { - AllZone.Human_Hand.remove(card); - AllZone.Human_Play.add(card); - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); - - } - } - else //play the land - { - AllZone.Human_Hand.remove(card); - AllZone.Human_Play.add(card); - AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(true); - } - } //land + GameAction.playLand(card, zone); + } //land /** else if(zone.is(Constant.Zone.Hand, Constant.Player.Human) && card.getManaCost().equals("0"))//for Mox Ruby and the like diff --git a/src/forge/Input_Draw.java b/src/forge/Input_Draw.java index 73dc437d4b9..a6f2da34b08 100644 --- a/src/forge/Input_Draw.java +++ b/src/forge/Input_Draw.java @@ -22,9 +22,7 @@ public class Input_Draw extends Input { || humanCards.containsName("Yawgmoth's Bargain"); if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw) && humanSkipsDrawPhase) { - //Input_Main.canPlayLand = true; - AllZone.GameInfo.setHumanCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human)); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(false); + AllZone.GameInfo.setHumanPlayedLands(0); AllZone.Phase.setNeedToNextPhase(true); } else { //continue with draw phase @@ -54,8 +52,7 @@ public class Input_Draw extends Input { if(drawCard && AllZone.Phase.getTurn() > 1) AllZone.GameAction.drawCard(Constant.Player.Human); if(AllZone.Phase.getPhase().equals(Constant.Phase.Draw)) { - AllZone.GameInfo.setHumanCanPlayNumberOfLands(CardFactoryUtil.getCanPlayNumberOfLands(Constant.Player.Human)); - AllZone.GameInfo.setHumanPlayedFirstLandThisTurn(false); + AllZone.GameInfo.setHumanPlayedLands(0); //AllZone.Phase.nextPhase(); //for debugging: System.out.println("need to nextPhase(from Input_Draw on human's draw) = true"); diff --git a/src/forge/Input_Main.java b/src/forge/Input_Main.java index 4272d29db7f..b5c0e225101 100644 --- a/src/forge/Input_Main.java +++ b/src/forge/Input_Main.java @@ -29,16 +29,8 @@ public class Input_Main extends Input { public void selectCard(Card card, PlayerZone zone) { //these if statements cannot be combined if(card.isLand() && zone.is(Constant.Zone.Hand, Constant.Player.Human)) { - if(AllZone.GameInfo.getHumanCanPlayNumberOfLands() > 0) { - CardList fastbonds = CardFactoryUtil.getFastbonds(Constant.Player.Human); - if(fastbonds.size() > 0) { - if(AllZone.GameInfo.humanPlayedFirstLandThisTurn()) { - AllZone.GameAction.getPlayerLife(Constant.Player.Human).subtractLife(1,fastbonds.get(0)); - } - } + if(CardFactoryUtil.canHumanPlayLand()) { InputUtil.playAnyCard(card, zone); - //canPlayNumberOfLands--; - //firstLandHasBeenPlayed = true; AllZone.GameAction.checkStateEffects(); } @@ -53,13 +45,9 @@ public class Input_Main extends Input { if(count > 0) InputUtil.playAnyCard(card, zone); } } - //TODO: add code for exploration / fastbond here - } else { - // SpellAbility sa = card.getSpellAbility()[0]; - // sa.setRandomTargetAI(); - // AllZone.Stack.add(sa); InputUtil.playAnyCard(card, zone); } + AllZone.GameAction.checkStateEffects(); }//selectCard() } diff --git a/src/forge/Phase.java b/src/forge/Phase.java index 9036905fd1c..bac14b6519b 100644 --- a/src/forge/Phase.java +++ b/src/forge/Phase.java @@ -240,6 +240,7 @@ public class Phase extends MyObservable PlayerCreatureSpellCount = 0; ComputerSpellCount = 0; ComputerCreatureSpellCount = 0; + AllZone.GameInfo.setHumanPlayedLands(0); turn++; /* if (humanExtraTurns > 0) @@ -255,7 +256,7 @@ public class Phase extends MyObservable PlayerCreatureSpellCount = 0; ComputerSpellCount = 0; ComputerCreatureSpellCount = 0; - AllZone.GameInfo.setComputerPlayedFirstLandThisTurn(false); + AllZone.GameInfo.setComputerPlayedLands(0); turn++; /* @@ -265,14 +266,12 @@ public class Phase extends MyObservable computerExtraTurns++; */ } - if(is(Constant.Phase.Main1, Constant.Player.Human)) { - if(turn == 1) { + if(turn == 1 && is(Constant.Phase.Main1, Constant.Player.Human)) { StormCount = 0; PlayerSpellCount = 0; PlayerCreatureSpellCount = 0; ComputerSpellCount = 0; ComputerCreatureSpellCount = 0; - } } //for debugging: System.out.println(getPhase()); //System.out.println(getPhase() + " " + getActivePlayer()); diff --git a/src/forge/PlayerZone_ComesIntoPlay.java b/src/forge/PlayerZone_ComesIntoPlay.java index a7b4dff829a..ddbb9191f2e 100644 --- a/src/forge/PlayerZone_ComesIntoPlay.java +++ b/src/forge/PlayerZone_ComesIntoPlay.java @@ -29,18 +29,37 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { && (c.isLand() || c.isCreature() || c.isArtifact())) c.tap(); //cannot use addComesIntoPlayCommand - trigger might be set to false; - if(c.getName().equals("Exploration")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(1); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(1); - } else if(c.getName().equals("Azusa, Lost but Seeking")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(2); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(2); - } else if(c.getName().equals("Oracle of Mul Daya")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(1); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(1); - } else if(c.getName().equals("Fastbond")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(100); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(100); + // Keep track of max lands can play per turn + int addMax = 0; + boolean isHuman = c.getController().equals(Constant.Player.Human); + boolean adjustLandPlays = false; + boolean eachPlayer = false; + + if(c.getName().equals("Exploration") || c.getName().equals("Oracle of Mul Daya")) { + addMax = 1; + adjustLandPlays = true; + } + else if(c.getName().equals("Azusa, Lost but Seeking")) { + addMax = 2; + adjustLandPlays = true; + } + else if (c.getName().equals("Storm Cauldron") || c.getName().equals("Rites of Flourishing")){ + // these two aren't in yet, but will just need the other part of the card to work with more lands + adjustLandPlays = true; + eachPlayer = true; + addMax = 1; + } + // 7/13: fastbond code removed, fastbond should be unlimited and will be handled elsewhere. + + if (adjustLandPlays){ + if (eachPlayer){ + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax); + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax); + } + else if (isHuman) + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax); + else + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax); } if(trigger) { @@ -234,19 +253,36 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { Card c = (Card) o; - //cannot use addLeavesPlayCommand - trigger might be set to false - if(c.getName().equals("Exploration")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1); + // Keep track of max lands can play per turn + int addMax = 0; + boolean isHuman = c.getController().equals(Constant.Player.Human); + boolean adjustLandPlays = false; + boolean eachPlayer = false; + + if(c.getName().equals("Exploration") || c.getName().equals("Oracle of Mul Daya")) { + addMax = -1; + adjustLandPlays = true; } else if(c.getName().equals("Azusa, Lost but Seeking")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(-2); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(-2); - } else if(c.getName().equals("Oracle of Mul Daya")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(-1); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(-1); - } else if(c.getName().equals("Fastbond")) { - if(c.getController().equals(Constant.Player.Human)) AllZone.GameInfo.addHumanCanPlayNumberOfLands(-100); - else AllZone.GameInfo.addComputerCanPlayNumberOfLands(-100); + addMax = -2; + adjustLandPlays = true; + } + else if (c.getName().equals("Storm Cauldron") || c.getName().equals("Rites of Flourishing")){ + // once their second half of their abilities are programmed these two can be added in + adjustLandPlays = true; + eachPlayer = true; + addMax = -1; + } + // 7/12: fastbond code removed, fastbond should be unlimited and will be handled elsewhere. + + if (adjustLandPlays){ + if (eachPlayer){ + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax); + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax); + } + else if (isHuman) + AllZone.GameInfo.addHumanMaxPlayNumberOfLands(addMax); + else + AllZone.GameInfo.addComputerMaxPlayNumberOfLands(addMax); }