fix Java warning in CardList.java and remove obsolete function

This commit is contained in:
jendave
2011-08-06 23:50:59 +00:00
parent 0420af1c82
commit 294af27d79
3 changed files with 64 additions and 99 deletions

View File

@@ -33,7 +33,7 @@ public class CardList implements Iterable<Card> {
addAll(c); 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<String> sets) { public CardList getSets(ArrayList<String> sets) {
CardList list = new CardList(); CardList list = new CardList();
for(Card c : this){ for(Card c : this){
@@ -206,7 +206,7 @@ public class CardList implements Iterable<Card> {
public CardList getRarity(final String rarity) { public CardList getRarity(final String rarity) {
return this.filter(new CardListFilter() { return this.filter(new CardListFilter() {
public boolean addCard(Card c) { 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"); String r = c.getSVar("Rarity");
return r.equals(rarity) || return r.equals(rarity) ||
rarity.equals(Constant.Rarity.Rare) && r.equals(Constant.Rarity.Mythic); rarity.equals(Constant.Rarity.Rare) && r.equals(Constant.Rarity.Mythic);
@@ -214,8 +214,7 @@ public class CardList implements Iterable<Card> {
}); });
} }
//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) { public CardList getType(final String cardType) {
return this.filter(new CardListFilter() { return this.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -224,7 +223,7 @@ public class CardList implements Iterable<Card> {
}); });
} }
//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) { public CardList getNotType(final String cardType) {
return this.filter(new CardListFilter() { return this.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -241,28 +240,6 @@ public class CardList implements Iterable<Card> {
}); });
} }
public CardList getTapState(String TappedOrUntapped)
{
CardList cl = new CardList();
Card c;
for (int i=0; i<size(); i++)
{
c = getCard(i);
if (TappedOrUntapped.equals("Tapped"))
{
if (c.isTapped() == true)
cl.add(c);
}
else if (TappedOrUntapped.equals("Untapped"))
{
if (c.isUntapped() == true)
cl.add(c);
}
}
return cl;
}
public CardList getKeyword(final String keyword) { public CardList getKeyword(final String keyword) {
return this.filter(new CardListFilter() { return this.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -305,16 +282,6 @@ public class CardList implements Iterable<Card> {
}); });
} }
/*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) { public CardList filter(CardListFilter f) {
CardList c = new CardList(); CardList c = new CardList();
for(int i = 0; i < size(); i++) for(int i = 0; i < size(); i++)
@@ -352,7 +319,7 @@ public class CardList implements Iterable<Card> {
public void shuffle() { public void shuffle() {
// reseed Random each time we want to 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); Collections.shuffle(list, MyRandom.random);
Collections.shuffle(list, MyRandom.random); Collections.shuffle(list, MyRandom.random);
@@ -416,4 +383,5 @@ public class CardList implements Iterable<Card> {
} }
}); });
} }
}
}//end class CardList

View File

@@ -3916,7 +3916,7 @@ public class CardFactoryUtil {
{ {
CardList list = new CardList(AllZone.Computer_Battlefield.getCards()); CardList list = new CardList(AllZone.Computer_Battlefield.getCards());
list = list.getType(d[2]); list = list.getType(d[2]);
list = list.getTapState("Tapped"); list = list.filter(AllZoneUtil.tapped);
for(int i = 0; i < n && i < list.size(); i++) for(int i = 0; i < n && i < list.size(); i++)
{ {

View File

@@ -443,67 +443,64 @@ class CardFactory_Lands {
//*************** START *********** START ************************** //*************** START *********** START **************************
else if(cardName.equals("Scorched Ruins")) { else if(cardName.equals("Scorched Ruins")) {
final Command comesIntoPlay = new Command() { final Command comesIntoPlay = new Command() {
private static final long serialVersionUID = 6175830918425915833L; private static final long serialVersionUID = 6175830918425915833L;
final Player player = card.getController(); final Player player = card.getController();
public void execute() { public void execute() {
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController());
CardList plains = new CardList(play.getCards()); plains = plains.filter(AllZoneUtil.untapped);
plains = plains.getType("Land");
plains = plains.getTapState("Untapped");
if( player.isComputer()) { if( player.isComputer()) {
if( plains.size() > 1 ) { if( plains.size() > 1 ) {
CardList tappedPlains = new CardList(plains.toArray()); CardList tappedPlains = new CardList(plains.toArray());
tappedPlains = tappedPlains.getType("Basic"); tappedPlains = tappedPlains.getType("Basic");
for(Card c : tappedPlains) for(Card c : tappedPlains)
AllZone.GameAction.sacrifice(c); AllZone.GameAction.sacrifice(c);
for(int i = 0; i < tappedPlains.size(); i++){ for(int i = 0; i < tappedPlains.size(); i++){
AllZone.GameAction.sacrifice(plains.get(i)); AllZone.GameAction.sacrifice(plains.get(i));
} }
//if any are tapped, sacrifice it //if any are tapped, sacrifice it
//else sacrifice random //else sacrifice random
} }
else { else {
AllZone.GameAction.sacrifice(card); AllZone.GameAction.sacrifice(card);
} }
} }
else { //this is the human resolution else { //this is the human resolution
final int[] paid = {0}; final int[] paid = {0};
if ((new CardList(AllZone.Human_Battlefield.getCards()) if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer).filter(AllZoneUtil.untapped).size() < 2))
.getType("Land").getTapState("Untapped").size() < 2)) {
{ AllZone.GameAction.sacrifice(card);
AllZone.GameAction.sacrifice(card); return;
return; }
} Input target = new Input() {
Input target = new Input() { private static final long serialVersionUID = 6653677835621129465L;
private static final long serialVersionUID = 6653677835621129465L; public void showMessage() {
public void showMessage() { AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice");
AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice"); ButtonUtil.enableOnlyCancel();
ButtonUtil.enableOnlyCancel(); }
} public void selectButtonCancel() {
public void selectButtonCancel() { AllZone.GameAction.sacrifice(card);
AllZone.GameAction.sacrifice(card); stop();
stop(); }
} public void selectCard(Card c, PlayerZone zone) {
public void selectCard(Card c, PlayerZone zone) { if(c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
if(c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { AllZone.GameAction.sacrifice(c);
AllZone.GameAction.sacrifice(c); if(paid[0] < 1){
if(paid[0] < 1){ paid[0]++;
paid[0]++; AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice");
AllZone.Display.showMessage("Scorched Ruins - Select an untapped land to sacrifice"); }
} else stop();
else stop(); }
} }//selectCard()
}//selectCard() };//Input
};//Input AllZone.InputControl.setInput(target);
AllZone.InputControl.setInput(target); }
} }
} };
};
card.addComesIntoPlayCommand(comesIntoPlay); card.addComesIntoPlayCommand(comesIntoPlay);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START ************ START ************************** //*************** START ************ START **************************