mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
fix Java warning in CardList.java and remove obsolete function
This commit is contained in:
@@ -33,7 +33,7 @@ public class CardList implements Iterable<Card> {
|
||||
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) {
|
||||
CardList list = new CardList();
|
||||
for(Card c : this){
|
||||
@@ -206,7 +206,7 @@ public class CardList implements Iterable<Card> {
|
||||
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<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) {
|
||||
return this.filter(new CardListFilter() {
|
||||
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) {
|
||||
return this.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
@@ -240,28 +239,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) {
|
||||
return this.filter(new CardListFilter() {
|
||||
@@ -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) {
|
||||
CardList c = new CardList();
|
||||
for(int i = 0; i < size(); i++)
|
||||
@@ -352,7 +319,7 @@ public class CardList implements Iterable<Card> {
|
||||
|
||||
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<Card> {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}//end class CardList
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -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 **************************
|
||||
|
||||
Reference in New Issue
Block a user