mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Code cleanup: make a lot of methods static and remove some unnecessary interface implements and casts.
This commit is contained in:
@@ -185,9 +185,9 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
}
|
||||
|
||||
private PaperCard getFirstWithImage(Collection<PaperCard> cards) {
|
||||
private static PaperCard getFirstWithImage(final Collection<PaperCard> cards) {
|
||||
//NOTE: this is written this way to avoid checking final card in list
|
||||
Iterator<PaperCard> iterator = cards.iterator();
|
||||
final Iterator<PaperCard> iterator = cards.iterator();
|
||||
PaperCard pc = iterator.next();
|
||||
while (iterator.hasNext()) {
|
||||
if (pc.hasImage()) {
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
*/
|
||||
package forge.card;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.mana.IParserManaCost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* A collection of methods containing full
|
||||
@@ -65,7 +65,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
colorIdentity = newRules.colorIdentity;
|
||||
}
|
||||
|
||||
private byte calculateColorIdentity(ICardFace face) {
|
||||
private static byte calculateColorIdentity(final ICardFace face) {
|
||||
byte res = face.getColor().getColor();
|
||||
boolean isReminder = false;
|
||||
boolean isSymbol = false;
|
||||
@@ -154,7 +154,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canCastFace(ICardFace face, byte colorCode) {
|
||||
private static boolean canCastFace(final ICardFace face, final byte colorCode) {
|
||||
if (face.getManaCost().isNoCost()) {
|
||||
//if card face has no cost, assume castable only by mana of its defined color
|
||||
return face.getColor().hasNoColorsExcept(colorCode);
|
||||
@@ -214,22 +214,6 @@ public final class CardRules implements ICardCharacteristics {
|
||||
public String getPictureUrl(boolean backface ) { return backface ? dlUrlOtherSide : dlUrl; }
|
||||
public void setDlUrls(String[] dlUrls) { this.dlUrl = dlUrls[0]; this.dlUrlOtherSide = dlUrls[1]; }
|
||||
|
||||
public final List<String> getReplacements() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final List<String> getTriggers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final List<String> getStaticAbilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final List<String> getAbilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ColorSet getColorIdentity() {
|
||||
return colorIdentity;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
||||
|
||||
return subtypes.contains(creatureType) || subtypes.contains("AllCreatureTypes");
|
||||
}
|
||||
private String toMixedCase(final String s) {
|
||||
private static String toMixedCase(final String s) {
|
||||
if (s.equals("")) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public enum DeckFormat {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getPlaneSectionConformanceProblem(CardPool planes) {
|
||||
public static String getPlaneSectionConformanceProblem(final CardPool planes) {
|
||||
//Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
|
||||
if (planes == null || planes.countAll() < 10) {
|
||||
return "should have at least 10 planes";
|
||||
@@ -214,7 +214,7 @@ public enum DeckFormat {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSchemeSectionConformanceProblem(CardPool schemes) {
|
||||
public static String getSchemeSectionConformanceProblem(final CardPool schemes) {
|
||||
//Must contain at least 20 schemes, max 2 of each.
|
||||
if (schemes == null || schemes.countAll() < 20) {
|
||||
return "must contain at least 20 schemes";
|
||||
|
||||
@@ -88,7 +88,7 @@ public class DeckStorage extends StorageReaderFolder<Deck> implements IItemSeria
|
||||
return result;
|
||||
}
|
||||
|
||||
private void adjustFileLocation(final File file, final Deck result) {
|
||||
private static void adjustFileLocation(final File file, final Deck result) {
|
||||
if (result == null) {
|
||||
file.delete();
|
||||
} else {
|
||||
|
||||
@@ -272,7 +272,7 @@ public final class NameGenerator {
|
||||
}
|
||||
|
||||
/** Generates a specified number of random names. */
|
||||
public List<String> getRandomNames(int generateAmount, final List<String> excludeNames) {
|
||||
public static List<String> getRandomNames(final int generateAmount, final List<String> excludeNames) {
|
||||
usedNames = excludeNames;
|
||||
final List<String> names = new ArrayList<String>(generateAmount);
|
||||
for (int i = 0; i < generateAmount; i++) {
|
||||
|
||||
Reference in New Issue
Block a user