mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
a few Checkstyle fixes
This commit is contained in:
@@ -27,8 +27,7 @@ public class CardFilter {
|
|||||||
* @param substring a {@link java.lang.String} object.
|
* @param substring a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public CardList cardListNameFilter(Iterable<Card> toBeFiltered, String substring)
|
public CardList cardListNameFilter(Iterable<Card> toBeFiltered, String substring) {
|
||||||
{
|
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
CardList listFilter = new CardList();
|
CardList listFilter = new CardList();
|
||||||
@@ -48,23 +47,23 @@ public class CardFilter {
|
|||||||
/**
|
/**
|
||||||
* <p>CardListTextFilter.</p>
|
* <p>CardListTextFilter.</p>
|
||||||
*
|
*
|
||||||
* TODO: style: rename this method so it starts with a lowercase letter
|
* TODO style: rename this method so it starts with a lowercase letter
|
||||||
*
|
*
|
||||||
* @param all a {@link forge.CardList} object.
|
* @param all a {@link forge.CardList} object.
|
||||||
* @param name a {@link java.lang.String} object.
|
* @param name a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public CardList CardListTextFilter(CardList all, String name) {
|
public final CardList CardListTextFilter(CardList all, String name) {
|
||||||
Card CardName;
|
Card cardName;
|
||||||
String s;
|
String s;
|
||||||
s = "";
|
s = "";
|
||||||
CardList listFilter = new CardList();
|
CardList listFilter = new CardList();
|
||||||
for (int i = 0; i < all.size(); i++) {
|
for (int i = 0; i < all.size(); i++) {
|
||||||
CardName = all.getCard(i);
|
cardName = all.getCard(i);
|
||||||
s = CardName.getText().toLowerCase();
|
s = cardName.getText().toLowerCase();
|
||||||
|
|
||||||
if (s.indexOf(name.toLowerCase()) >= 0) {
|
if (s.indexOf(name.toLowerCase()) >= 0) {
|
||||||
listFilter.add(CardName);
|
listFilter.add(cardName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,13 +76,13 @@ public class CardFilter {
|
|||||||
/**
|
/**
|
||||||
* <p>CardListColorFilter.</p>
|
* <p>CardListColorFilter.</p>
|
||||||
*
|
*
|
||||||
* TODO: style: rename this method so it starts with a lowercase letter
|
* TODO style: rename this method so it starts with a lowercase letter
|
||||||
*
|
*
|
||||||
* @param all a {@link forge.CardList} object.
|
* @param all a {@link forge.CardList} object.
|
||||||
* @param name a {@link java.lang.String} object.
|
* @param name a {@link java.lang.String} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public CardList CardListColorFilter(CardList all, String name) {
|
public final CardList CardListColorFilter(CardList all, String name) {
|
||||||
Card CardName = new Card();
|
Card CardName = new Card();
|
||||||
CardList listFilter = new CardList();
|
CardList listFilter = new CardList();
|
||||||
|
|
||||||
@@ -153,7 +152,7 @@ public class CardFilter {
|
|||||||
/**
|
/**
|
||||||
* <p>CardListTypeFilter.</p>
|
* <p>CardListTypeFilter.</p>
|
||||||
*
|
*
|
||||||
* TODO: style: rename this method so it starts with a lowercase letter
|
* TODO style: rename this method so it starts with a lowercase letter
|
||||||
*
|
*
|
||||||
* @param all a {@link forge.CardList} object.
|
* @param all a {@link forge.CardList} object.
|
||||||
* @param name a {@link java.lang.String} object.
|
* @param name a {@link java.lang.String} object.
|
||||||
@@ -248,21 +247,21 @@ public class CardFilter {
|
|||||||
*
|
*
|
||||||
* @return a sequence Generator whose cards only have the given rarity
|
* @return a sequence Generator whose cards only have the given rarity
|
||||||
*/
|
*/
|
||||||
public static Generator<Card> getRarity(Generator<Card> inputGenerator, final String rarity) {
|
public static Generator<Card> getRarity(final Generator<Card> inputGenerator, final String rarity) {
|
||||||
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
||||||
UtilFunctions.checkNotNull("rarity", rarity);
|
UtilFunctions.checkNotNull("rarity", rarity);
|
||||||
|
|
||||||
Lambda1<Boolean,Card> predicate = new Lambda1<Boolean,Card>() {
|
Lambda1<Boolean, Card> predicate = new Lambda1<Boolean, Card>() {
|
||||||
public Boolean apply(Card c) {
|
public Boolean apply(final Card c) {
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 != null &&
|
return (r != null
|
||||||
(r.equals(rarity) ||
|
&& (r.equals(rarity) || rarity.equals(Constant.Rarity.Rare)
|
||||||
rarity.equals(Constant.Rarity.Rare) && r.equals(Constant.Rarity.Mythic)));
|
&& r.equals(Constant.Rarity.Mythic)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -280,12 +279,13 @@ public class CardFilter {
|
|||||||
* @return a list of Cards that meet the filtering criteria; may be empty,
|
* @return a list of Cards that meet the filtering criteria; may be empty,
|
||||||
* but never null
|
* but never null
|
||||||
*/
|
*/
|
||||||
public static CardList filter(Iterable<Card> iterable, CardListFilter filt) {
|
public static CardList filter(final Iterable<Card> iterable, final CardListFilter filt) {
|
||||||
CardList result = new CardList();
|
CardList result = new CardList();
|
||||||
for (Card card : iterable)
|
for (Card card : iterable) {
|
||||||
if (filt.addCard(card)) {
|
if (filt.addCard(card)) {
|
||||||
result.add(card);
|
result.add(card);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -304,32 +304,31 @@ public class CardFilter {
|
|||||||
* @return a new Generator containing cards only of the desired color or
|
* @return a new Generator containing cards only of the desired color or
|
||||||
* multicolored cards.
|
* multicolored cards.
|
||||||
*/
|
*/
|
||||||
public static Generator<Card> getColor(Generator<Card> inputGenerator, final String cardColor)
|
public static Generator<Card> getColor(final Generator<Card> inputGenerator, final String cardColor) {
|
||||||
{
|
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
||||||
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
UtilFunctions.checkNotNull("cardColor", cardColor);
|
||||||
UtilFunctions.checkNotNull("cardColor", cardColor);
|
|
||||||
|
|
||||||
final boolean weWantMulticolor = cardColor.equals("Multicolor");
|
final boolean weWantMulticolor = cardColor.equals("Multicolor");
|
||||||
|
|
||||||
Lambda1<Boolean,Card> predicate = new Lambda1<Boolean,Card>() {
|
Lambda1<Boolean, Card> predicate = new Lambda1<Boolean, Card>() {
|
||||||
public Boolean apply(Card c) {
|
public Boolean apply(final Card c) {
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weWantMulticolor && c.getColor() != null && c.getColor().size() > 1) {
|
if (weWantMulticolor && c.getColor() != null && c.getColor().size() > 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (c.isColor(cardColor) && c.getColor() != null && c.getColor().size() == 1) {
|
else if (c.isColor(cardColor) && c.getColor() != null && c.getColor().size() == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return GeneratorFunctions.filterGenerator(predicate, inputGenerator);
|
return GeneratorFunctions.filterGenerator(predicate, inputGenerator);
|
||||||
}//getColor()
|
} //getColor()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter a Generator of cards so that it contains only the ones that exist in certain sets.
|
* Filter a Generator of cards so that it contains only the ones that exist in certain sets.
|
||||||
@@ -340,13 +339,13 @@ public class CardFilter {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static Generator<Card> getSets(Generator<Card> inputGenerator, final List<String> sets)
|
public static Generator<Card> getSets(final Generator<Card> inputGenerator, final List<String> sets)
|
||||||
{
|
{
|
||||||
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
||||||
UtilFunctions.checkNotNull("sets", sets);
|
UtilFunctions.checkNotNull("sets", sets);
|
||||||
|
|
||||||
Lambda1<Boolean, Card> predicate = new Lambda1<Boolean, Card>() {
|
Lambda1<Boolean, Card> predicate = new Lambda1<Boolean, Card>() {
|
||||||
public Boolean apply(Card c) {
|
public Boolean apply(final Card c) {
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -362,7 +361,6 @@ public class CardFilter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return GeneratorFunctions.filterGenerator(predicate, inputGenerator);
|
return GeneratorFunctions.filterGenerator(predicate, inputGenerator);
|
||||||
}//getSets(Generator,ArrayList)
|
} //getSets(Generator,ArrayList)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class Card_Color {
|
|||||||
*
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean getAdditional() {
|
public final boolean getAdditional() {
|
||||||
return additional;
|
return additional;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,12 +33,12 @@ public class Card_Color {
|
|||||||
*
|
*
|
||||||
* @return a long.
|
* @return a long.
|
||||||
*/
|
*/
|
||||||
public long getStamp() {
|
public final long getStamp() {
|
||||||
return stamp;
|
return stamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant <code>timeStamp=0</code>
|
* Constant <code>timeStamp=0</code>.
|
||||||
*/
|
*/
|
||||||
private static long timeStamp = 0;
|
private static long timeStamp = 0;
|
||||||
|
|
||||||
@@ -59,14 +59,15 @@ public class Card_Color {
|
|||||||
* @param addToColors a boolean.
|
* @param addToColors a boolean.
|
||||||
* @param baseColor a boolean.
|
* @param baseColor a boolean.
|
||||||
*/
|
*/
|
||||||
Card_Color(ManaCost mc, Card c, boolean addToColors, boolean baseColor) {
|
Card_Color(final ManaCost mc, final Card c, final boolean addToColors, final boolean baseColor) {
|
||||||
additional = addToColors;
|
additional = addToColors;
|
||||||
col = Color.ConvertManaCostToColor(mc);
|
col = Color.ConvertManaCostToColor(mc);
|
||||||
effectingCard = c;
|
effectingCard = c;
|
||||||
if (baseColor)
|
if (baseColor) {
|
||||||
stamp = 0;
|
stamp = 0;
|
||||||
else
|
} else {
|
||||||
stamp = timeStamp;
|
stamp = timeStamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +75,7 @@ public class Card_Color {
|
|||||||
*
|
*
|
||||||
* @param c a {@link forge.Card} object.
|
* @param c a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public Card_Color(Card c) {
|
public Card_Color(final Card c) {
|
||||||
col = Color.Colorless();
|
col = Color.Colorless();
|
||||||
additional = false;
|
additional = false;
|
||||||
stamp = 0;
|
stamp = 0;
|
||||||
@@ -87,7 +88,7 @@ public class Card_Color {
|
|||||||
* @param s a {@link java.lang.String} object.
|
* @param s a {@link java.lang.String} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
boolean addToCardColor(String s) {
|
final boolean addToCardColor(final String s) {
|
||||||
Color c = Color.ConvertFromString(s);
|
Color c = Color.ConvertFromString(s);
|
||||||
if (!col.contains(c)) {
|
if (!col.contains(c)) {
|
||||||
col.add(c);
|
col.add(c);
|
||||||
@@ -99,9 +100,10 @@ public class Card_Color {
|
|||||||
/**
|
/**
|
||||||
* <p>fixColorless.</p>
|
* <p>fixColorless.</p>
|
||||||
*/
|
*/
|
||||||
void fixColorless() {
|
final void fixColorless() {
|
||||||
if (col.size() > 1 && col.contains(Color.Colorless))
|
if (col.size() > 1 && col.contains(Color.Colorless)) {
|
||||||
col.remove(Color.Colorless);
|
col.remove(Color.Colorless);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +122,7 @@ public class Card_Color {
|
|||||||
* @param time a long.
|
* @param time a long.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean equals(String cost, Card c, boolean addToColors, long time) {
|
public final boolean equals(final String cost, final Card c, final boolean addToColors, final long time) {
|
||||||
return effectingCard == c && addToColors == additional && stamp == time;
|
return effectingCard == c && addToColors == additional && stamp == time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,10 +131,11 @@ public class Card_Color {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public ArrayList<String> toStringArray() {
|
public final ArrayList<String> toStringArray() {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
for (Color c : col)
|
for (Color c : col) {
|
||||||
list.add(c.toString());
|
list.add(c.toString());
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user