From 294af27d7965fc881ca30dd70a76c62739ca60bf Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 23:50:59 +0000 Subject: [PATCH] fix Java warning in CardList.java and remove obsolete function --- src/forge/CardList.java | 46 ++----- .../card/cardFactory/CardFactoryUtil.java | 2 +- .../card/cardFactory/CardFactory_Lands.java | 115 +++++++++--------- 3 files changed, 64 insertions(+), 99 deletions(-) diff --git a/src/forge/CardList.java b/src/forge/CardList.java index f4ae3f6112e..89fa958aef1 100644 --- a/src/forge/CardList.java +++ b/src/forge/CardList.java @@ -33,7 +33,7 @@ public class CardList implements Iterable { addAll(c); } -// get any cards that exist in the passed in sets list + // get any cards that exist in the passed in sets list public CardList getSets(ArrayList sets) { CardList list = new CardList(); for(Card c : this){ @@ -206,7 +206,7 @@ public class CardList implements Iterable { public CardList getRarity(final String rarity) { return this.filter(new CardListFilter() { public boolean addCard(Card c) { - // TODO spin off Mythic from Rare when the time comes + // TODO spin off Mythic from Rare when the time comes String r = c.getSVar("Rarity"); return r.equals(rarity) || rarity.equals(Constant.Rarity.Rare) && r.equals(Constant.Rarity.Mythic); @@ -214,8 +214,7 @@ public class CardList implements Iterable { }); } - - //cardType is like "Land" or "Goblin", returns a new CardList that is a subset of current CardList + //cardType is like "Land" or "Goblin", returns a new CardList that is a subset of current CardList public CardList getType(final String cardType) { return this.filter(new CardListFilter() { public boolean addCard(Card c) { @@ -224,7 +223,7 @@ public class CardList implements Iterable { }); } - //cardType is like "Land" or "Goblin", returns a new CardList with cards that do not have this type + //cardType is like "Land" or "Goblin", returns a new CardList with cards that do not have this type public CardList getNotType(final String cardType) { return this.filter(new CardListFilter() { public boolean addCard(Card c) { @@ -240,28 +239,6 @@ public class CardList implements Iterable { } }); } - - public CardList getTapState(String TappedOrUntapped) - { - CardList cl = new CardList(); - Card c; - for (int i=0; i { }); } - /*no longer needed - public CardList canBeDamagedBy(final Card card) { - return this.filter(new CardListFilter() { - public boolean addCard(Card c) { - return CardFactoryUtil.canDamage(card, c); - } - }); - } - */ - public CardList filter(CardListFilter f) { CardList c = new CardList(); for(int i = 0; i < size(); i++) @@ -352,7 +319,7 @@ public class CardList implements Iterable { public void shuffle() { // reseed Random each time we want to Shuffle - MyRandom.random = MyRandom.random; + //MyRandom.random = MyRandom.random; Collections.shuffle(list, MyRandom.random); Collections.shuffle(list, MyRandom.random); Collections.shuffle(list, MyRandom.random); @@ -416,4 +383,5 @@ public class CardList implements Iterable { } }); } -} + +}//end class CardList diff --git a/src/forge/card/cardFactory/CardFactoryUtil.java b/src/forge/card/cardFactory/CardFactoryUtil.java index 7ee56a30ad1..fb06279ef09 100644 --- a/src/forge/card/cardFactory/CardFactoryUtil.java +++ b/src/forge/card/cardFactory/CardFactoryUtil.java @@ -3916,7 +3916,7 @@ public class CardFactoryUtil { { CardList list = new CardList(AllZone.Computer_Battlefield.getCards()); list = list.getType(d[2]); - list = list.getTapState("Tapped"); + list = list.filter(AllZoneUtil.tapped); for(int i = 0; i < n && i < list.size(); i++) { diff --git a/src/forge/card/cardFactory/CardFactory_Lands.java b/src/forge/card/cardFactory/CardFactory_Lands.java index 71a05c29346..ce10f5f2c74 100644 --- a/src/forge/card/cardFactory/CardFactory_Lands.java +++ b/src/forge/card/cardFactory/CardFactory_Lands.java @@ -443,67 +443,64 @@ class CardFactory_Lands { //*************** START *********** START ************************** else if(cardName.equals("Scorched Ruins")) { - final Command comesIntoPlay = new Command() { - private static final long serialVersionUID = 6175830918425915833L; - final Player player = card.getController(); - public void execute() { - PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); - CardList plains = new CardList(play.getCards()); - plains = plains.getType("Land"); - plains = plains.getTapState("Untapped"); + final Command comesIntoPlay = new Command() { + private static final long serialVersionUID = 6175830918425915833L; + final Player player = card.getController(); + public void execute() { + CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController()); + plains = plains.filter(AllZoneUtil.untapped); - if( player.isComputer()) { - if( plains.size() > 1 ) { - CardList tappedPlains = new CardList(plains.toArray()); - tappedPlains = tappedPlains.getType("Basic"); - for(Card c : tappedPlains) - AllZone.GameAction.sacrifice(c); - for(int i = 0; i < tappedPlains.size(); i++){ - AllZone.GameAction.sacrifice(plains.get(i)); - } - //if any are tapped, sacrifice it - //else sacrifice random - } - else { - AllZone.GameAction.sacrifice(card); - } - } - else { //this is the human resolution - final int[] paid = {0}; - if ((new CardList(AllZone.Human_Battlefield.getCards()) - .getType("Land").getTapState("Untapped").size() < 2)) - { - AllZone.GameAction.sacrifice(card); - return; - } - Input target = new Input() { - private static final long serialVersionUID = 6653677835621129465L; - public void showMessage() { - AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice"); - ButtonUtil.enableOnlyCancel(); - } - public void selectButtonCancel() { - AllZone.GameAction.sacrifice(card); - stop(); - } - public void selectCard(Card c, PlayerZone zone) { - if(c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { - AllZone.GameAction.sacrifice(c); - if(paid[0] < 1){ - paid[0]++; - AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice"); - } - else stop(); - } - }//selectCard() - };//Input - AllZone.InputControl.setInput(target); - } - } - }; + if( player.isComputer()) { + if( plains.size() > 1 ) { + CardList tappedPlains = new CardList(plains.toArray()); + tappedPlains = tappedPlains.getType("Basic"); + for(Card c : tappedPlains) + AllZone.GameAction.sacrifice(c); + for(int i = 0; i < tappedPlains.size(); i++){ + AllZone.GameAction.sacrifice(plains.get(i)); + } + //if any are tapped, sacrifice it + //else sacrifice random + } + else { + AllZone.GameAction.sacrifice(card); + } + } + else { //this is the human resolution + final int[] paid = {0}; + if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer).filter(AllZoneUtil.untapped).size() < 2)) + { + AllZone.GameAction.sacrifice(card); + return; + } + Input target = new Input() { + private static final long serialVersionUID = 6653677835621129465L; + public void showMessage() { + AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice"); + ButtonUtil.enableOnlyCancel(); + } + public void selectButtonCancel() { + AllZone.GameAction.sacrifice(card); + stop(); + } + public void selectCard(Card c, PlayerZone zone) { + if(c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { + AllZone.GameAction.sacrifice(c); + if(paid[0] < 1){ + paid[0]++; + AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice"); + } + else stop(); + } + }//selectCard() + };//Input + AllZone.InputControl.setInput(target); + } + } + }; - card.addComesIntoPlayCommand(comesIntoPlay); - }//*************** END ************ END ************************** + card.addComesIntoPlayCommand(comesIntoPlay); + }//*************** END ************ END ************************** //*************** START ************ START **************************