Fixed a lot of Checkstyle stuff. Removed some checks - method, class and line length

This commit is contained in:
jendave
2011-11-15 19:34:53 +00:00
parent 4061f07391
commit 9f98b07d61
57 changed files with 3171 additions and 2857 deletions

View File

@@ -469,7 +469,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<version>2.6</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>utf-8</sourceEncoding>

View File

@@ -53,7 +53,7 @@
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>
<!-- <module name="FileLength"/> -->
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
@@ -131,11 +131,11 @@
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<!-- <module name="LineLength">
<property name="max" value="180"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<module name="ParameterNumber"/> -->
<!-- Checks for whitespace -->

File diff suppressed because it is too large Load Diff

View File

@@ -96,7 +96,7 @@ public class CardReader implements Runnable {
private transient Enumeration<? extends ZipEntry> zipEnum;
private transient long estimatedFilesRemaining = // NOPMD by Braids on
// 8/18/11 10:56 PM
CardReader.// 8/18/11 10:56 PM
UNKNOWN_NUMBER_OF_FILES_REMAINING;
private transient Iterable<File> findNonDirsIterable; // NOPMD by Braids on
@@ -182,7 +182,7 @@ public class CardReader implements Runnable {
if (useZip && zipFile.exists()) {
try {
this.zip = new ZipFile(zipFile);
} catch (Exception exn) {
} catch (final Exception exn) {
System.err.println("Error reading zip file \"" // NOPMD by
// Braids on
// 8/18/11 10:53
@@ -197,12 +197,12 @@ public class CardReader implements Runnable {
}
if (useZip && zip != null) {
zipEnum = zip.entries();
estimatedFilesRemaining = zip.size();
if (useZip && (this.zip != null)) {
this.zipEnum = this.zip.entries();
this.estimatedFilesRemaining = this.zip.size();
}
setEncoding(DEFAULT_CHARSET_NAME);
this.setEncoding(CardReader.DEFAULT_CHARSET_NAME);
} // CardReader()
@@ -213,12 +213,13 @@ public class CardReader implements Runnable {
* @throws Throwable
* indirectly
*/
@Override
protected final void finalize() throws Throwable {
try {
if (findNonDirsIterable != null) {
if (this.findNonDirsIterable != null) {
for (@SuppressWarnings("unused")
// Do nothing; just exercising the Iterable.
File ignored : findNonDirsIterable) {
final// Do nothing; just exercising the Iterable.
File ignored : this.findNonDirsIterable) {
}
}
} finally {
@@ -229,8 +230,9 @@ public class CardReader implements Runnable {
/**
* Reads the rest of ALL the cards into memory. This is not lazy.
*/
@Override
public final void run() {
loadCardsUntilYouFind(null);
this.loadCardsUntilYouFind(null);
}
/**
@@ -261,27 +263,28 @@ public class CardReader implements Runnable {
// Iterate through txt files or zip archive.
// Report relevant numbers to progress monitor model.
if (zip == null) {
if (estimatedFilesRemaining == UNKNOWN_NUMBER_OF_FILES_REMAINING) {
final Generator<File> findNonDirsGen = new FindNonDirectoriesSkipDotDirectoriesGenerator(cardsfolder);
estimatedFilesRemaining = GeneratorFunctions.estimateSize(findNonDirsGen);
findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen);
if (this.zip == null) {
if (this.estimatedFilesRemaining == CardReader.UNKNOWN_NUMBER_OF_FILES_REMAINING) {
final Generator<File> findNonDirsGen = new FindNonDirectoriesSkipDotDirectoriesGenerator(
this.cardsfolder);
this.estimatedFilesRemaining = GeneratorFunctions.estimateSize(findNonDirsGen);
this.findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen);
}
if (monitor != null) {
monitor.setTotalUnitsThisPhase(estimatedFilesRemaining);
monitor.setTotalUnitsThisPhase(this.estimatedFilesRemaining);
}
for (File cardTxtFile : findNonDirsIterable) {
if (!cardTxtFile.getName().endsWith(CARD_FILE_DOT_EXTENSION)) {
for (final File cardTxtFile : this.findNonDirsIterable) {
if (!cardTxtFile.getName().endsWith(CardReader.CARD_FILE_DOT_EXTENSION)) {
monitor.incrementUnitsCompletedThisPhase(1L);
continue;
}
result = loadCard(cardTxtFile);
result = this.loadCard(cardTxtFile);
monitor.incrementUnitsCompletedThisPhase(1L);
if (cardName != null && cardName.equals(result.getName())) {
if ((cardName != null) && cardName.equals(result.getName())) {
break; // no thread leak here if entire card DB is loaded,
// or if this object is finalized.
}
@@ -289,22 +292,22 @@ public class CardReader implements Runnable {
} // endfor
} else {
monitor.setTotalUnitsThisPhase(estimatedFilesRemaining);
monitor.setTotalUnitsThisPhase(this.estimatedFilesRemaining);
ZipEntry entry;
// zipEnum was initialized in the constructor.
while (zipEnum.hasMoreElements()) {
entry = (ZipEntry) zipEnum.nextElement();
while (this.zipEnum.hasMoreElements()) {
entry = this.zipEnum.nextElement();
if (entry.isDirectory() || !entry.getName().endsWith(CARD_FILE_DOT_EXTENSION)) {
if (entry.isDirectory() || !entry.getName().endsWith(CardReader.CARD_FILE_DOT_EXTENSION)) {
monitor.incrementUnitsCompletedThisPhase(1L);
continue;
}
result = loadCard(entry);
result = this.loadCard(entry);
monitor.incrementUnitsCompletedThisPhase(1L);
if (cardName != null && cardName.equals(result.getName())) {
if ((cardName != null) && cardName.equals(result.getName())) {
break;
}
}
@@ -348,7 +351,7 @@ public class CardReader implements Runnable {
line = line.trim();
}
return line;
} catch (Exception ex) {
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("CardReader : readLine(Card) error", ex); // NOPMD
// by
@@ -372,17 +375,17 @@ public class CardReader implements Runnable {
*/
protected final Card loadCard(final InputStream inputStream) {
final Card card = new Card();
rulesReader.reset();
this.rulesReader.reset();
InputStreamReader inputStreamReader = null;
BufferedReader reader = null;
try {
inputStreamReader = new InputStreamReader(inputStream, charset);
inputStreamReader = new InputStreamReader(inputStream, this.charset);
reader = new BufferedReader(inputStreamReader);
String line = readLine(reader);
String line = CardReader.readLine(reader);
while (!"End".equals(line)) {
rulesReader.parseLine(line);
this.rulesReader.parseLine(line);
if (line.isEmpty()) {
// Ignore empty lines.
} else if (line.charAt(0) == '#') { // NOPMD by Braids on
@@ -391,7 +394,7 @@ public class CardReader implements Runnable {
} else if (line.startsWith("Name:")) {
final String value = line.substring(5);
// System.out.println(s);
if (mapToFill.containsKey(value)) {
if (this.mapToFill.containsKey(value)) {
break; // this card has already been loaded.
} else {
card.setName(value);
@@ -403,7 +406,7 @@ public class CardReader implements Runnable {
card.setManaCost(value);
}
} else if (line.startsWith("Types:")) {
addTypes(card, line.substring("Types:".length()));
CardReader.addTypes(card, line.substring("Types:".length()));
} else if (line.startsWith("Text:")) {
String value = line.substring("Text:".length());
// if (!t.equals("no text"));
@@ -459,8 +462,7 @@ public class CardReader implements Runnable {
String mode;
if (card.isFlip()) {
mode = "Flipped";
}
else {
} else {
mode = "Transformed";
}
card.addAlternateState(mode);
@@ -474,9 +476,9 @@ public class CardReader implements Runnable {
}
} else if (line.startsWith("Colors:")) {
final String value = line.substring("Colors:".length());
ArrayList<CardColor> newCols = new ArrayList<CardColor>();
for (String col : value.split(",")) {
CardColor newCol = new CardColor(card);
final ArrayList<CardColor> newCols = new ArrayList<CardColor>();
for (final String col : value.split(",")) {
final CardColor newCol = new CardColor(card);
newCol.addToCardColor(col);
newCols.add(newCol);
}
@@ -485,17 +487,19 @@ public class CardReader implements Runnable {
card.setCardColorsOverridden(true);
}
line = readLine(reader);
line = CardReader.readLine(reader);
} // while !End
} finally {
try {
reader.close();
} catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08
} catch (final IOException ignored) { // NOPMD by Braids on 8/18/11
// 11:08
// PM
}
try {
inputStreamReader.close();
} catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08
} catch (final IOException ignored) { // NOPMD by Braids on 8/18/11
// 11:08
// PM
}
}
@@ -504,8 +508,8 @@ public class CardReader implements Runnable {
card.setState("Original");
}
listRulesToFill.add(rulesReader.getCard());
mapToFill.put(card.getName(), card);
this.listRulesToFill.add(this.rulesReader.getCard());
this.mapToFill.put(card.getName(), card);
return card;
}
@@ -531,15 +535,16 @@ public class CardReader implements Runnable {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(pathToTxtFile);
return loadCard(fileInputStream);
} catch (FileNotFoundException ex) {
return this.loadCard(fileInputStream);
} catch (final FileNotFoundException ex) {
ErrorViewer.showError(ex, "File \"%s\" exception", pathToTxtFile.getAbsolutePath());
throw new RuntimeException(// NOPMD by Braids on 8/18/11 10:53 PM
"CardReader : run error -- file exception -- filename is " + pathToTxtFile.getPath(), ex);
} finally {
try {
fileInputStream.close();
} catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08
} catch (final IOException ignored) { // NOPMD by Braids on 8/18/11
// 11:08
// PM
}
}
@@ -556,10 +561,10 @@ public class CardReader implements Runnable {
protected final Card loadCard(final ZipEntry entry) {
InputStream zipInputStream = null;
try {
zipInputStream = zip.getInputStream(entry);
return loadCard(zipInputStream);
zipInputStream = this.zip.getInputStream(entry);
return this.loadCard(zipInputStream);
} catch (IOException exn) {
} catch (final IOException exn) {
throw new RuntimeException(exn); // NOPMD by Braids on 8/18/11 10:53
// PM
} finally {
@@ -567,7 +572,8 @@ public class CardReader implements Runnable {
if (zipInputStream != null) {
zipInputStream.close();
}
} catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08
} catch (final IOException ignored) { // NOPMD by Braids on 8/18/11
// 11:08
// PM
}
}
@@ -597,19 +603,20 @@ public class CardReader implements Runnable {
* http://www.slightlymagic.net/forum/viewtopic.php?f=52&t=4887#p63189
*/
baseFileName = HYPHEN_OR_SPACE.matcher(baseFileName).replaceAll("_");
baseFileName = MULTIPLE_UNDERSCORES.matcher(baseFileName).replaceAll("_");
baseFileName = PUNCTUATION_TO_ZAP.matcher(baseFileName).replaceAll("");
baseFileName = CardReader.HYPHEN_OR_SPACE.matcher(baseFileName).replaceAll("_");
baseFileName = CardReader.MULTIPLE_UNDERSCORES.matcher(baseFileName).replaceAll("_");
baseFileName = CardReader.PUNCTUATION_TO_ZAP.matcher(baseFileName).replaceAll("");
// Place the file within a single-letter subdirectory.
final StringBuffer buf = new StringBuffer(1 + 1 + baseFileName.length() + CARD_FILE_DOT_EXTENSION.length());
final StringBuffer buf = new StringBuffer(1 + 1 + baseFileName.length()
+ CardReader.CARD_FILE_DOT_EXTENSION.length());
buf.append(Character.toLowerCase(baseFileName.charAt(0)));
// Zip file is always created with unix-style path names.
buf.append('/');
buf.append(baseFileName.toLowerCase(Locale.ENGLISH));
buf.append(CARD_FILE_DOT_EXTENSION);
buf.append(CardReader.CARD_FILE_DOT_EXTENSION);
return buf.toString();
}
@@ -628,25 +635,25 @@ public class CardReader implements Runnable {
// 11:08 PM
UtilFunctions.checkNotNull("canonicalASCIIName", canonicalASCIIName);
final String cardFilePath = toMostLikelyPath(canonicalASCIIName);
final String cardFilePath = this.toMostLikelyPath(canonicalASCIIName);
Card result = null;
if (zip != null) {
final ZipEntry entry = zip.getEntry(cardFilePath);
if (this.zip != null) {
final ZipEntry entry = this.zip.getEntry(cardFilePath);
if (entry != null) {
result = loadCard(entry);
result = this.loadCard(entry);
}
}
if (result == null) {
result = loadCard(new File(cardsfolder, cardFilePath));
result = this.loadCard(new File(this.cardsfolder, cardFilePath));
}
if (result == null || !(result.getName().equals(canonicalASCIIName))) {
if ((result == null) || !(result.getName().equals(canonicalASCIIName))) {
// System.err.println(":Could not find \"" + cardFilePath + "\".");
result = loadCardsUntilYouFind(canonicalASCIIName);
result = this.loadCardsUntilYouFind(canonicalASCIIName);
}
return result;

View File

@@ -51,11 +51,11 @@ public final class CardUtil {
* @return a int.
*/
public static int getRandomIndex(final Object[] o) {
if (o == null || o.length == 0) {
if ((o == null) || (o.length == 0)) {
throw new RuntimeException("CardUtil : getRandomIndex() argument is null or length is 0");
}
return RANDOM.nextInt(o.length);
return CardUtil.RANDOM.nextInt(o.length);
}
/**
@@ -68,7 +68,7 @@ public final class CardUtil {
* @return a {@link forge.Card} object.
*/
public static Card getRandom(final Card[] o) {
return o[getRandomIndex(o)];
return o[CardUtil.getRandomIndex(o)];
}
/**
@@ -81,11 +81,11 @@ public final class CardUtil {
* @return a int.
*/
public static int getRandomIndex(final SpellAbilityList list) {
if (list == null || list.size() == 0) {
if ((list == null) || (list.size() == 0)) {
throw new RuntimeException("CardUtil : getRandomIndex(SpellAbilityList) argument is null or length is 0");
}
return RANDOM.nextInt(list.size());
return CardUtil.RANDOM.nextInt(list.size());
}
/**
@@ -98,7 +98,7 @@ public final class CardUtil {
* @return a int.
*/
public static int getRandomIndex(final CardList c) {
return RANDOM.nextInt(c.size());
return CardUtil.RANDOM.nextInt(c.size());
}
// returns Card Name (unique number) attack/defense
@@ -126,11 +126,11 @@ public final class CardUtil {
* @return an array of {@link forge.Card} objects.
*/
public static Card[] toCard(final Collection<Card> col) {
Object[] o = col.toArray();
Card[] c = new Card[o.length];
final Object[] o = col.toArray();
final Card[] c = new Card[o.length];
for (int i = 0; i < c.length; i++) {
Object swap = o[i];
final Object swap = o[i];
if (swap instanceof Card) {
c[i] = (Card) o[i];
} else {
@@ -152,7 +152,7 @@ public final class CardUtil {
* @return an array of {@link forge.Card} objects.
*/
public static Card[] toCard(final ArrayList<Card> list) {
Card[] c = new Card[list.size()];
final Card[] c = new Card[list.size()];
list.toArray(c);
return c;
}
@@ -167,9 +167,9 @@ public final class CardUtil {
* @return a {@link java.util.ArrayList} object.
*/
public static ArrayList<Card> toList(final Card[] c) {
ArrayList<Card> a = new ArrayList<Card>();
for (int i = 0; i < c.length; i++) {
a.add(c[i]);
final ArrayList<Card> a = new ArrayList<Card>();
for (final Card element : c) {
a.add(element);
}
return a;
}
@@ -185,14 +185,14 @@ public final class CardUtil {
* @return a {@link java.lang.String} object.
*/
public static String getShortColor(final String longColor) {
Map<String, String> map = new HashMap<String, String>();
final Map<String, String> map = new HashMap<String, String>();
map.put(Constant.Color.BLACK.toString(), "B");
map.put(Constant.Color.BLUE.toString(), "U");
map.put(Constant.Color.GREEN.toString(), "G");
map.put(Constant.Color.RED.toString(), "R");
map.put(Constant.Color.WHITE.toString(), "W");
Object o = map.get(longColor);
final Object o = map.get(longColor);
if (o == null) {
throw new RuntimeException("CardUtil : getShortColor() invalid argument - " + longColor);
}
@@ -212,7 +212,7 @@ public final class CardUtil {
* @return a boolean.
*/
public static boolean isColor(final Card c, final String col) {
ArrayList<String> list = getColors(c);
final ArrayList<String> list = CardUtil.getColors(c);
return list.contains(col);
}
@@ -239,8 +239,8 @@ public final class CardUtil {
* @return a {@link java.util.ArrayList} object.
*/
public static ArrayList<String> getOnlyColors(final Card c) {
String m = c.getManaCost();
Set<String> colors = new HashSet<String>();
final String m = c.getManaCost();
final Set<String> colors = new HashSet<String>();
for (int i = 0; i < m.length(); i++) {
switch (m.charAt(i)) {
@@ -265,9 +265,9 @@ public final class CardUtil {
break;
}
}
for (String kw : c.getKeyword()) {
for (final String kw : c.getKeyword()) {
if (kw.startsWith(c.getName() + " is ") || kw.startsWith("CARDNAME is ")) {
for (String color : Constant.Color.COLORS) {
for (final String color : Constant.Color.COLORS) {
if (kw.endsWith(color + ".")) {
colors.add(color);
}
@@ -313,7 +313,7 @@ public final class CardUtil {
* @return a int.
*/
public static int getConvertedManaCost(final SpellAbility sa) {
return getConvertedManaCost(sa.getManaCost());
return CardUtil.getConvertedManaCost(sa.getManaCost());
}
/**
@@ -329,7 +329,7 @@ public final class CardUtil {
if (c.isToken() && !c.isCopiedToken()) {
return 0;
}
return getConvertedManaCost(c.getManaCost());
return CardUtil.getConvertedManaCost(c.getManaCost());
}
/**
@@ -346,7 +346,7 @@ public final class CardUtil {
return 0;
}
ManaCost cost = new ManaCost(manaCost);
final ManaCost cost = new ManaCost(manaCost);
return cost.getConvertedManaCost();
}
@@ -413,8 +413,7 @@ public final class CardUtil {
return c.getEquipping().get(0);
// else if(relation.startsWith("target ")) return c.getTargetCard();
} else {
throw new IllegalArgumentException("Error at CardUtil.getRelative: "
+ relation + "is not a valid relation");
throw new IllegalArgumentException("Error at CardUtil.getRelative: " + relation + "is not a valid relation");
}
}
@@ -428,7 +427,7 @@ public final class CardUtil {
* @return a boolean.
*/
public static boolean isACardType(final String cardType) {
return getAllCardTypes().contains(cardType);
return CardUtil.getAllCardTypes().contains(cardType);
}
/**
@@ -439,7 +438,7 @@ public final class CardUtil {
* @return a {@link java.util.ArrayList} object.
*/
public static ArrayList<String> getAllCardTypes() {
ArrayList<String> types = new ArrayList<String>();
final ArrayList<String> types = new ArrayList<String>();
// types.addAll(getCardTypes());
types.addAll(Constant.CardTypes.CARD_TYPES[0].getList());
@@ -460,7 +459,7 @@ public final class CardUtil {
* @return a {@link java.util.ArrayList} object.
*/
public static ArrayList<String> getCardTypes() {
ArrayList<String> types = new ArrayList<String>();
final ArrayList<String> types = new ArrayList<String>();
// types.add("Artifact");
// types.add("Creature");
@@ -485,7 +484,7 @@ public final class CardUtil {
* @since 1.1.3
*/
public static ArrayList<String> getBasicTypes() {
ArrayList<String> types = new ArrayList<String>();
final ArrayList<String> types = new ArrayList<String>();
types.addAll(Constant.CardTypes.BASIC_TYPES[0].getList());
@@ -498,7 +497,7 @@ public final class CardUtil {
* @return the land types
*/
public static ArrayList<String> getLandTypes() {
ArrayList<String> types = new ArrayList<String>();
final ArrayList<String> types = new ArrayList<String>();
types.addAll(Constant.CardTypes.BASIC_TYPES[0].getList());
types.addAll(Constant.CardTypes.LAND_TYPES[0].getList());
@@ -515,7 +514,7 @@ public final class CardUtil {
* @since 1.1.6
*/
public static ArrayList<String> getCreatureTypes() {
ArrayList<String> types = new ArrayList<String>();
final ArrayList<String> types = new ArrayList<String>();
types.addAll(Constant.CardTypes.CREATURE_TYPES[0].getList());
@@ -546,7 +545,7 @@ public final class CardUtil {
* @return a boolean.
*/
public static boolean isASubType(final String cardType) {
return (!isASuperType(cardType) && !isACardType(cardType));
return (!CardUtil.isASuperType(cardType) && !CardUtil.isACardType(cardType));
}
/**
@@ -624,7 +623,7 @@ public final class CardUtil {
* @return a boolean.
*/
public static boolean isStackingKeyword(final String keyword) {
return !isNonStackingKeyword(keyword);
return !CardUtil.isNonStackingKeyword(keyword);
}
/**
@@ -639,8 +638,8 @@ public final class CardUtil {
* @return the string
*/
public static String buildIdealFilename(final String cardName, final int artIndex, final int artIndexMax) {
String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : "";
String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName);
final String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : "";
final String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName);
// 3 letter set code with MWS filename format
return String.format("%s%s.full.jpg", mwsCardName, nn);
}
@@ -655,18 +654,19 @@ public final class CardUtil {
* @return a {@link java.lang.String} object.
*/
public static String buildFilename(final Card card) {
boolean token = card.isToken() && !card.isCopiedToken();
final boolean token = card.isToken() && !card.isCopiedToken();
final String set = card.getCurSetCode();
Predicate<SetInfo> findSetInfo = new Predicate<SetInfo>() {
final Predicate<SetInfo> findSetInfo = new Predicate<SetInfo>() {
@Override
public boolean isTrue(final SetInfo subject) {
return subject.getCode().equals(set);
}
};
SetInfo neededSet = findSetInfo.first(card.getSets());
int cntPictures = neededSet == null ? 1 : neededSet.getPicCount();
return buildFilename(card.getName(), card.getCurSetCode(), card.getRandomPicture(), cntPictures, token);
final SetInfo neededSet = findSetInfo.first(card.getSets());
final int cntPictures = neededSet == null ? 1 : neededSet.getPicCount();
return CardUtil
.buildFilename(card.getName(), card.getCurSetCode(), card.getRandomPicture(), cntPictures, token);
}
/**
@@ -677,41 +677,48 @@ public final class CardUtil {
* @return the string
*/
public static String buildFilename(final CardPrinted card) {
int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
return buildFilename(card.getName(), card.getSet(), card.getArtIndex(), maxIndex, false);
final int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
return CardUtil.buildFilename(card.getName(), card.getSet(), card.getArtIndex(), maxIndex, false);
}
public static String buildFilename(final CardPrinted card, String nameToUse) {
int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
return buildFilename(nameToUse, card.getSet(), card.getArtIndex(), maxIndex, false);
/**
* Builds the filename.
*
* @param card the card
* @param nameToUse the name to use
* @return the string
*/
public static String buildFilename(final CardPrinted card, final String nameToUse) {
final int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
return CardUtil.buildFilename(nameToUse, card.getSet(), card.getArtIndex(), maxIndex, false);
}
private static String buildFilename(final String cardName, final String setName, final int artIndex,
final int artIndexMax, final boolean isToken) {
File path = ForgeProps.getFile(isToken ? NewConstants.IMAGE_TOKEN : NewConstants.IMAGE_BASE);
String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : "";
String cleanCardName = GuiDisplayUtil.cleanString(cardName);
final File path = ForgeProps.getFile(isToken ? NewConstants.IMAGE_TOKEN : NewConstants.IMAGE_BASE);
final String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : "";
final String cleanCardName = GuiDisplayUtil.cleanString(cardName);
File f = null;
if (StringUtils.isNotBlank(setName)) {
String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName);
final String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName);
// First, try 3 letter set code with MWS filename format
String mwsSet3 = String.format("%s/%s%s.full", setName, mwsCardName, nn);
final String mwsSet3 = String.format("%s/%s%s.full", setName, mwsCardName, nn);
f = new File(path, mwsSet3 + ".jpg");
if (f.exists()) {
return mwsSet3;
}
// Second, try 2 letter set code with MWS filename format
String mwsSet2 = String.format("%s/%s%s.full", SetUtils.getCode2ByCode(setName), mwsCardName, nn);
final String mwsSet2 = String.format("%s/%s%s.full", SetUtils.getCode2ByCode(setName), mwsCardName, nn);
f = new File(path, mwsSet2 + ".jpg");
if (f.exists()) {
return mwsSet2;
}
// Third, try 3 letter set code with Forge filename format
String forgeSet3 = String.format("%s/%s%s", setName, cleanCardName, nn);
final String forgeSet3 = String.format("%s/%s%s", setName, cleanCardName, nn);
f = new File(path, forgeSet3 + ".jpg");
if (f.exists()) {
return forgeSet3;
@@ -719,7 +726,7 @@ public final class CardUtil {
}
// Last, give up with set images, go with the old picture type
String forgePlain = String.format("%s%s", cleanCardName, nn);
final String forgePlain = String.format("%s%s", cleanCardName, nn);
f = new File(path, forgePlain + ".jpg");
if (f.exists()) {
@@ -750,7 +757,7 @@ public final class CardUtil {
return 0;
}
ManaCost cost = new ManaCost(manaCost);
final ManaCost cost = new ManaCost(manaCost);
return cost.getWeightedManaCost();
}
@@ -765,7 +772,7 @@ public final class CardUtil {
*/
public static String getShortColorsString(final ArrayList<String> colors) {
String colorDesc = "";
for (String col : colors) {
for (final String col : colors) {
if (col.equalsIgnoreCase("White")) {
colorDesc += "W";
} else if (col.equalsIgnoreCase("Blue")) {
@@ -888,7 +895,7 @@ public final class CardUtil {
* @return a copy of C with LastKnownInfo stuff retained.
*/
public static Card getLKICopy(final Card c) {
Card res = AllZone.getCardFactory().copyCard(c);
final Card res = AllZone.getCardFactory().copyCard(c);
res.setControllerObjects(c.getControllerObjects());
res.addTempAttackBoost(c.getTempAttackBoost());
res.addTempDefenseBoost(c.getTempDefenseBoost());
@@ -899,7 +906,7 @@ public final class CardUtil {
res.setNewPT(c.getNewPT());
res.setReceivedDamageFromThisTurn(c.getReceivedDamageFromThisTurn());
res.setHaunting(c.getHaunting());
for (Card haunter : c.getHauntedBy()) {
for (final Card haunter : c.getHauntedBy()) {
res.addHauntedBy(haunter);
}
@@ -918,14 +925,14 @@ public final class CardUtil {
* @return the radiance
*/
public static CardList getRadiance(final Card source, final Card origin, final String[] valid) {
CardList res = new CardList();
final CardList res = new CardList();
for (CardColor col : origin.getColor()) {
for (String strCol : col.toStringArray()) {
for (final CardColor col : origin.getColor()) {
for (final String strCol : col.toStringArray()) {
if (strCol.equalsIgnoreCase("Colorless")) {
continue;
}
for (Card c : AllZoneUtil.getColorInPlay(strCol)) {
for (final Card c : AllZoneUtil.getColorInPlay(strCol)) {
if (!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) {
res.add(c);
}
@@ -936,24 +943,25 @@ public final class CardUtil {
return res;
}
public static ArrayList<String> getConvokableColors(final Card cardToConvoke, ManaCost cost)
{
ArrayList<String> usableColors = new ArrayList<String>();
/**
* Gets the convokable colors.
*
* @param cardToConvoke the card to convoke
* @param cost the cost
* @return the convokable colors
*/
public static ArrayList<String> getConvokableColors(final Card cardToConvoke, final ManaCost cost) {
final ArrayList<String> usableColors = new ArrayList<String>();
if(cost.getColorlessManaAmount() > 0)
{
if (cost.getColorlessManaAmount() > 0) {
usableColors.add("colorless");
}
for(CardColor col : cardToConvoke.getColor())
{
for(String strCol : col.toStringArray())
{
if(strCol.equals("colorless"))
{
for (final CardColor col : cardToConvoke.getColor()) {
for (final String strCol : col.toStringArray()) {
if (strCol.equals("colorless")) {
continue;
}
if(cost.toString().contains(InputPayManaCostUtil.getShortColorString(strCol)))
{
if (cost.toString().contains(InputPayManaCostUtil.getShortColorString(strCol))) {
usableColors.add(strCol.toString());
}
}
@@ -962,11 +970,16 @@ public final class CardUtil {
return usableColors;
}
/**
* Gets the face down characteristic.
*
* @return the face down characteristic
*/
public static CardCharacteristics getFaceDownCharacteristic() {
ArrayList<String> types = new ArrayList<String>();
final ArrayList<String> types = new ArrayList<String>();
types.add("Creature");
CardCharacteristics ret = new CardCharacteristics();
final CardCharacteristics ret = new CardCharacteristics();
ret.setBaseAttack(2);
ret.setBaseDefense(2);

View File

@@ -225,7 +225,9 @@ public class Combat {
if (attackingPlayer != null) {
return attackingPlayer;
}
else return AllZone.getPhase().getPlayerTurn();
else {
return AllZone.getPhase().getPlayerTurn();
}
}
/**
@@ -239,7 +241,9 @@ public class Combat {
if (attackingPlayer != null) {
return defendingPlayer;
}
else return AllZone.getPhase().getPlayerTurn().getOpponent();
else {
return AllZone.getPhase().getPlayerTurn().getOpponent();
}
}
/**

File diff suppressed because it is too large Load Diff

View File

@@ -35,13 +35,14 @@ public class ComputerAIGeneral implements Computer {
* main1.
* </p>
*/
@Override
public final void main1() {
ComputerUtil.chooseLandsToPlay();
if (AllZone.getStack().size() == 0) {
playCards(Constant.Phase.MAIN1);
this.playCards(Constant.Phase.MAIN1);
} else {
stackResponse();
this.stackResponse();
}
} // main1()
@@ -50,13 +51,14 @@ public class ComputerAIGeneral implements Computer {
* main2.
* </p>
*/
@Override
public final void main2() {
ComputerUtil.chooseLandsToPlay();
if (AllZone.getStack().size() == 0) {
playCards(Constant.Phase.MAIN2);
this.playCards(Constant.Phase.MAIN2);
} else {
stackResponse();
this.stackResponse();
}
}
@@ -69,9 +71,9 @@ public class ComputerAIGeneral implements Computer {
* a {@link java.lang.String} object.
*/
private void playCards(final String phase) {
SpellAbility[] sp = phase.equals(Constant.Phase.MAIN1) ? getMain1() : getMain2();
final SpellAbility[] sp = phase.equals(Constant.Phase.MAIN1) ? this.getMain1() : this.getMain2();
boolean nextPhase = ComputerUtil.playAbilities(sp);
final boolean nextPhase = ComputerUtil.playAbilities(sp);
if (nextPhase) {
AllZone.getPhase().passPriority();
@@ -89,10 +91,11 @@ public class ComputerAIGeneral implements Computer {
// Card list of all cards to consider
CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
final boolean hasACardGivingHaste = hasACardGivingHaste();
final boolean hasACardGivingHaste = this.hasACardGivingHaste();
if (AllZone.getComputerPlayer().getManaPool().isEmpty()) {
hand = hand.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
if (c.getSVar("PlayMain1").equals("TRUE")) {
@@ -104,17 +107,17 @@ public class ComputerAIGeneral implements Computer {
return true;
}
if (c.isCreature() && (hasACardGivingHaste || c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) {
if ((c.isCreature() && (hasACardGivingHaste || c.hasKeyword("Haste"))) || c.hasKeyword("Exalted")) {
return true;
}
// get all cards the computer controls with BuffedBy
CardList buffed = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
final CardList buffed = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
for (int j = 0; j < buffed.size(); j++) {
Card buffedcard = buffed.get(j);
final Card buffedcard = buffed.get(j);
if (buffedcard.getSVar("BuffedBy").length() > 0) {
String buffedby = buffedcard.getSVar("BuffedBy");
String[] bffdby = buffedby.split(",");
final String buffedby = buffedcard.getSVar("BuffedBy");
final String[] bffdby = buffedby.split(",");
if (c.isValid(bffdby, c.getController(), c)) {
return true;
}
@@ -122,12 +125,12 @@ public class ComputerAIGeneral implements Computer {
} // BuffedBy
// get all cards the human controls with AntiBuffedBy
CardList antibuffed = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
final CardList antibuffed = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
for (int k = 0; k < antibuffed.size(); k++) {
Card buffedcard = antibuffed.get(k);
final Card buffedcard = antibuffed.get(k);
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
String buffedby = buffedcard.getSVar("AntiBuffedBy");
String[] bffdby = buffedby.split(",");
final String buffedby = buffedcard.getSVar("AntiBuffedBy");
final String[] bffdby = buffedby.split(",");
if (c.isValid(bffdby, c.getController(), c)) {
return true;
}
@@ -138,19 +141,20 @@ public class ComputerAIGeneral implements Computer {
return false;
}
CardList vengevines = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard, "Vengevine");
final CardList vengevines = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard, "Vengevine");
if (vengevines.size() > 0) {
CardList creatures = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
CardList creatures2 = new CardList();
final CardList creatures = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
final CardList creatures2 = new CardList();
for (int i = 0; i < creatures.size(); i++) {
if (creatures.get(i).isCreature()
&& CardUtil.getConvertedManaCost(creatures.get(i).getManaCost()) <= 3) {
&& (CardUtil.getConvertedManaCost(creatures.get(i).getManaCost()) <= 3)) {
creatures2.add(creatures.get(i));
}
}
if (creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl",
vengevines.get(0)).size() > 1
&& c.isCreature() && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) {
if (((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0))
.size()) > 1)
&& c.isCreature()
&& (CardUtil.getConvertedManaCost(c.getManaCost()) <= 3)) {
return true;
}
} // AI Improvement for Vengevine
@@ -159,12 +163,13 @@ public class ComputerAIGeneral implements Computer {
}
});
}
CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
final CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer()));
all.addAll(hand);
CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
humanPlayable = humanPlayable.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return (c.canAnyPlayerActivate());
}
@@ -172,7 +177,7 @@ public class ComputerAIGeneral implements Computer {
all.addAll(humanPlayable);
return getPlayable(all);
return this.getPlayable(all);
} // getMain1()
/**
@@ -183,17 +188,17 @@ public class ComputerAIGeneral implements Computer {
* @return a boolean.
*/
public boolean hasACardGivingHaste() {
CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
final CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer()));
all.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand));
for (Card c : all) {
for (SpellAbility sa : c.getSpellAbility()) {
for (final Card c : all) {
for (final SpellAbility sa : c.getSpellAbility()) {
if (sa.getAbilityFactory() == null) {
continue;
}
AbilityFactory af = sa.getAbilityFactory();
HashMap<String, String> abilityParams = af.getMapParams();
final AbilityFactory af = sa.getAbilityFactory();
final HashMap<String, String> abilityParams = af.getMapParams();
if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump")) {
continue;
}
@@ -221,6 +226,7 @@ public class ComputerAIGeneral implements Computer {
CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
// Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
if (c.isPermanent()
&& c.hasKeyword("Flash")
@@ -239,6 +245,7 @@ public class ComputerAIGeneral implements Computer {
all = all.getNotKeyword("At the beginning of the end step, sacrifice CARDNAME.");
all = all.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
if (c.isLand()) {
return false;
@@ -249,13 +256,14 @@ public class ComputerAIGeneral implements Computer {
CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
humanPlayable = humanPlayable.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return (c.canAnyPlayerActivate());
}
});
all.addAll(humanPlayable);
return getPlayable(all);
return this.getPlayable(all);
} // getMain2()
/**
@@ -269,6 +277,7 @@ public class ComputerAIGeneral implements Computer {
CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
// Don't play permanents with Flash before humans declare attackers step
all = all.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
if (c.isPermanent()
&& c.hasKeyword("Flash")
@@ -284,6 +293,7 @@ public class ComputerAIGeneral implements Computer {
CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
humanPlayable = humanPlayable.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return (c.canAnyPlayerActivate());
}
@@ -300,7 +310,7 @@ public class ComputerAIGeneral implements Computer {
* @return an array of {@link forge.card.spellability.SpellAbility} objects.
*/
private SpellAbility[] getOtherPhases() {
return getPlayable(getAvailableSpellAbilities());
return this.getPlayable(this.getAvailableSpellAbilities());
}
/**
@@ -311,7 +321,7 @@ public class ComputerAIGeneral implements Computer {
* @return a {@link java.util.ArrayList} object.
*/
private ArrayList<SpellAbility> getPossibleCounters() {
return getPlayableCounters(getAvailableSpellAbilities());
return this.getPlayableCounters(this.getAvailableSpellAbilities());
}
/**
@@ -322,7 +332,7 @@ public class ComputerAIGeneral implements Computer {
* @return a {@link java.util.ArrayList} object.
*/
private ArrayList<SpellAbility> getPossibleETBCounters() {
return getETBCounters(getAvailableSpellAbilities());
return this.getETBCounters(this.getAvailableSpellAbilities());
}
/**
@@ -334,9 +344,9 @@ public class ComputerAIGeneral implements Computer {
* @return an array of {@link forge.card.spellability.SpellAbility} objects.
*/
private SpellAbility[] getPlayable(final CardList l) {
ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
for (Card c : l) {
for (SpellAbility sa : c.getSpellAbility()) {
final ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
for (final Card c : l) {
for (final SpellAbility sa : c.getSpellAbility()) {
spellAbility.add(sa);
}
}
@@ -353,11 +363,11 @@ public class ComputerAIGeneral implements Computer {
* @return a {@link java.util.ArrayList} object.
*/
private ArrayList<SpellAbility> getPlayableCounters(final CardList l) {
ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
for (Card c : l) {
for (SpellAbility sa : c.getSpellAbility()) {
final ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
for (final Card c : l) {
for (final SpellAbility sa : c.getSpellAbility()) {
// Check if this AF is a Counterpsell
if (sa.getAbilityFactory() != null && sa.getAbilityFactory().getAPI().equals("Counter")) {
if ((sa.getAbilityFactory() != null) && sa.getAbilityFactory().getAPI().equals("Counter")) {
spellAbility.add(sa);
}
}
@@ -376,9 +386,9 @@ public class ComputerAIGeneral implements Computer {
* @return a {@link java.util.ArrayList} object.
*/
private ArrayList<SpellAbility> getETBCounters(final CardList l) {
ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
for (Card c : l) {
for (SpellAbility sa : c.getSpellAbility()) {
final ArrayList<SpellAbility> spellAbility = new ArrayList<SpellAbility>();
for (final Card c : l) {
for (final SpellAbility sa : c.getSpellAbility()) {
// Or if this Permanent has an ETB ability with Counter
if (sa instanceof SpellPermanent) {
if (SpellPermanent.checkETBEffects(c, sa, "Counter")) {
@@ -396,8 +406,9 @@ public class ComputerAIGeneral implements Computer {
* begin_combat.
* </p>
*/
@Override
public final void beginCombat() {
stackResponse();
this.stackResponse();
}
/**
@@ -405,20 +416,21 @@ public class ComputerAIGeneral implements Computer {
* declare_attackers.
* </p>
*/
@Override
public final void declareAttackers() {
// 12/2/10(sol) the decision making here has moved to getAttackers()
AllZone.setCombat(ComputerUtil.getAttackers());
Card[] att = AllZone.getCombat().getAttackers();
final Card[] att = AllZone.getCombat().getAttackers();
if (att.length > 0) {
AllZone.getPhase().setCombat(true);
}
for (int i = 0; i < att.length; i++) {
for (final Card element : att) {
// tapping of attackers happens after Propaganda is paid for
// if (!att[i].hasKeyword("Vigilance")) att[i].tap();
Log.debug("Computer just assigned " + att[i].getName() + " as an attacker.");
Log.debug("Computer just assigned " + element.getName() + " as an attacker.");
}
AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers();
@@ -432,8 +444,9 @@ public class ComputerAIGeneral implements Computer {
* declare_attackers_after.
* </p>
*/
@Override
public final void declareAttackersAfter() {
stackResponse();
this.stackResponse();
}
/**
@@ -441,8 +454,9 @@ public class ComputerAIGeneral implements Computer {
* declare_blockers.
* </p>
*/
@Override
public final void declareBlockers() {
CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
final CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
AllZone.setCombat(ComputerUtilBlock.getBlockers(AllZone.getCombat(), blockers));
@@ -456,8 +470,9 @@ public class ComputerAIGeneral implements Computer {
* declare_blockers_after.
* </p>
*/
@Override
public final void declareBlockersAfter() {
stackResponse();
this.stackResponse();
}
/**
@@ -465,8 +480,9 @@ public class ComputerAIGeneral implements Computer {
* end_of_combat.
* </p>
*/
@Override
public final void endOfCombat() {
stackResponse();
this.stackResponse();
}
// end of Human's turn
@@ -475,8 +491,9 @@ public class ComputerAIGeneral implements Computer {
* end_of_turn.
* </p>
*/
@Override
public final void endOfTurn() {
stackResponse();
this.stackResponse();
}
/**
@@ -484,8 +501,9 @@ public class ComputerAIGeneral implements Computer {
* stack_not_empty.
* </p>
*/
@Override
public final void stackNotEmpty() {
stackResponse();
this.stackResponse();
}
/**
@@ -495,7 +513,7 @@ public class ComputerAIGeneral implements Computer {
*/
public final void stackResponse() {
// if top of stack is empty
SpellAbility[] sas = getOtherPhases();
final SpellAbility[] sas = this.getOtherPhases();
if (AllZone.getStack().size() == 0) {
boolean pass = (sas.length == 0)
@@ -519,9 +537,9 @@ public class ComputerAIGeneral implements Computer {
}
// top of stack is owned by human,
ArrayList<SpellAbility> possibleCounters = getPossibleCounters();
ArrayList<SpellAbility> possibleCounters = this.getPossibleCounters();
if (possibleCounters.size() > 0 && ComputerUtil.playCounterSpell(possibleCounters)) {
if ((possibleCounters.size() > 0) && ComputerUtil.playCounterSpell(possibleCounters)) {
// Responding CounterSpell is on the Stack trying to Counter the
// Spell
// If playCounterSpell returns true, a Spell is hitting the Stack
@@ -529,8 +547,8 @@ public class ComputerAIGeneral implements Computer {
}
possibleCounters.clear();
possibleCounters = getPossibleETBCounters();
if (possibleCounters.size() > 0 && !ComputerUtil.playAbilities(possibleCounters)) {
possibleCounters = this.getPossibleETBCounters();
if ((possibleCounters.size() > 0) && !ComputerUtil.playAbilities(possibleCounters)) {
// Responding Permanent w/ ETB Counter is on the Stack
// AllZone.getPhase().passPriority();
return;

File diff suppressed because it is too large Load Diff

View File

@@ -20,12 +20,12 @@ import forge.card.trigger.Trigger;
public class ComputerUtilAttack {
// possible attackers and blockers
private CardList attackers;
private CardList blockers;
private final CardList attackers;
private final CardList blockers;
private CardList playerCreatures;
private Random random = MyRandom.getRandom();
private final int randomInt = random.nextInt();
private final Random random = MyRandom.getRandom();
private final int randomInt = this.random.nextInt();
private CardList humanList; // holds human player creatures
private CardList computerList; // holds computer creatures
@@ -42,8 +42,6 @@ public class ComputerUtilAttack {
* an array of {@link forge.Card} objects.
* @param possibleBlockers
* an array of {@link forge.Card} objects.
* @param blockerLife
* a int.
*/
public ComputerUtilAttack(final Card[] possibleAttackers, final Card[] possibleBlockers) {
this(new CardList(possibleAttackers), new CardList(possibleBlockers));
@@ -58,20 +56,18 @@ public class ComputerUtilAttack {
* a {@link forge.CardList} object.
* @param possibleBlockers
* a {@link forge.CardList} object.
* @param blockerLife
* a int.
*/
public ComputerUtilAttack(final CardList possibleAttackers, final CardList possibleBlockers) {
humanList = new CardList(possibleBlockers.toArray());
humanList = humanList.getType("Creature");
this.humanList = new CardList(possibleBlockers.toArray());
this.humanList = this.humanList.getType("Creature");
computerList = new CardList(possibleAttackers.toArray());
computerList = computerList.getType("Creature");
playerCreatures = new CardList(possibleBlockers.toArray());
playerCreatures = playerCreatures.getType("Creature");
this.computerList = new CardList(possibleAttackers.toArray());
this.computerList = this.computerList.getType("Creature");
this.playerCreatures = new CardList(possibleBlockers.toArray());
this.playerCreatures = this.playerCreatures.getType("Creature");
attackers = getPossibleAttackers(possibleAttackers);
blockers = getPossibleBlockers(possibleBlockers, attackers);
this.attackers = this.getPossibleAttackers(possibleAttackers);
this.blockers = this.getPossibleBlockers(possibleBlockers, this.attackers);
} // constructor
/**
@@ -84,20 +80,20 @@ public class ComputerUtilAttack {
* @return a {@link forge.CardList} object.
*/
public final CardList sortAttackers(final CardList in) {
CardList list = new CardList();
final CardList list = new CardList();
// Cards with triggers should come first (for Battle Cry)
for (Card attacker : in) {
ArrayList<Trigger> registeredTriggers = attacker.getTriggers();
for (Trigger trigger : registeredTriggers) {
HashMap<String, String> trigParams = trigger.getMapParams();
for (final Card attacker : in) {
final ArrayList<Trigger> registeredTriggers = attacker.getTriggers();
for (final Trigger trigger : registeredTriggers) {
final HashMap<String, String> trigParams = trigger.getMapParams();
if (trigParams.get("Mode").equals("Attacks")) {
list.add(attacker);
}
}
}
for (Card attacker : in) {
for (final Card attacker : in) {
if (!list.contains(attacker)) {
list.add(attacker);
}
@@ -121,7 +117,7 @@ public class ComputerUtilAttack {
public final boolean isEffectiveAttacker(final Card attacker, final Combat combat) {
// if the attacker will die when attacking don't attack
if (attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat) <= 0) {
if ((attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat)) <= 0) {
return false;
}
@@ -132,10 +128,10 @@ public class ComputerUtilAttack {
return true;
}
CardList controlledByCompy = AllZone.getComputerPlayer().getAllCards();
final CardList controlledByCompy = AllZone.getComputerPlayer().getAllCards();
for (Card c : controlledByCompy) {
for (Trigger trigger : c.getTriggers()) {
for (final Card c : controlledByCompy) {
for (final Trigger trigger : c.getTriggers()) {
if (CombatUtil.combatTriggerWillTrigger(attacker, null, trigger, combat)) {
return true;
}
@@ -157,6 +153,7 @@ public class ComputerUtilAttack {
public final CardList getPossibleAttackers(final CardList in) {
CardList list = new CardList(in.toArray());
list = list.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return CombatUtil.canAttack(c);
}
@@ -179,11 +176,12 @@ public class ComputerUtilAttack {
CardList possibleBlockers = new CardList(blockers.toArray());
final CardList attackerList = new CardList(attackers.toArray());
possibleBlockers = possibleBlockers.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
if (!c.isCreature()) {
return false;
}
for (Card attacker : attackerList) {
for (final Card attacker : attackerList) {
if (CombatUtil.canBlock(attacker, c)) {
return true;
}
@@ -209,15 +207,15 @@ public class ComputerUtilAttack {
* @return a {@link forge.CardList} object.
*/
public final CardList notNeededAsBlockers(final CardList attackers, final Combat combat) {
CardList notNeededAsBlockers = new CardList(attackers.toArray());
final CardList notNeededAsBlockers = new CardList(attackers.toArray());
CardListUtil.sortAttackLowFirst(attackers);
int blockersNeeded = attackers.size();
// don't hold back creatures that can't block any of the human creatures
CardList list = getPossibleBlockers(attackers, humanList);
final CardList list = this.getPossibleBlockers(attackers, this.humanList);
for (int i = 0; i < list.size(); i++) {
if (!doesHumanAttackAndWin(i)) {
if (!this.doesHumanAttackAndWin(i)) {
blockersNeeded = i;
break;
} else {
@@ -236,34 +234,33 @@ public class ComputerUtilAttack {
// In addition, if the computer guesses it needs no blockers, make sure
// that
// it won't be surprised by Exalted
int humanExaltedBonus = countExaltedBonus(AllZone.getHumanPlayer());
final int humanExaltedBonus = this.countExaltedBonus(AllZone.getHumanPlayer());
if (humanExaltedBonus > 0) {
int nFinestHours = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size();
final int nFinestHours = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size();
if ((blockersNeeded == 0 || nFinestHours > 0) && humanList.size() > 0) {
if (((blockersNeeded == 0) || (nFinestHours > 0)) && (this.humanList.size() > 0)) {
//
// total attack = biggest creature + exalted, *2 if Rafiq is in
// play
int humanBaseAttack = getAttack(humanList.get(0)) + humanExaltedBonus;
int humanBaseAttack = this.getAttack(this.humanList.get(0)) + humanExaltedBonus;
if (nFinestHours > 0) {
// For Finest Hour, one creature could attack and get the
// bonus TWICE
humanBaseAttack = humanBaseAttack + humanExaltedBonus;
}
int totalExaltedAttack = AllZoneUtil.isCardInPlay("Rafiq of the Many",
AllZone.getHumanPlayer()) ? 2 * humanBaseAttack
final int totalExaltedAttack = AllZoneUtil.isCardInPlay("Rafiq of the Many", AllZone.getHumanPlayer()) ? 2 * humanBaseAttack
: humanBaseAttack;
if ((AllZone.getComputerPlayer().getLife() - 3) <= totalExaltedAttack) {
// We will lose if there is an Exalted attack -- keep one
// blocker
if (blockersNeeded == 0 && notNeededAsBlockers.size() > 0) {
if ((blockersNeeded == 0) && (notNeededAsBlockers.size() > 0)) {
notNeededAsBlockers.remove(0);
}
// Finest Hour allows a second Exalted attack: keep a
// blocker for that too
if (nFinestHours > 0 && notNeededAsBlockers.size() > 0) {
if ((nFinestHours > 0) && (notNeededAsBlockers.size() > 0)) {
notNeededAsBlockers.remove(0);
}
}
@@ -271,7 +268,7 @@ public class ComputerUtilAttack {
}
// re-add creatures with vigilance
for (Card c : attackers) {
for (final Card c : attackers) {
if (c.hasKeyword("Vigilance")) {
notNeededAsBlockers.add(c);
}
@@ -292,10 +289,10 @@ public class ComputerUtilAttack {
*/
public final boolean doesHumanAttackAndWin(final int nBlockingCreatures) {
int totalAttack = 0;
int stop = humanList.size() - nBlockingCreatures;
final int stop = this.humanList.size() - nBlockingCreatures;
for (int i = 0; i < stop; i++) {
totalAttack += getAttack(humanList.get(i));
totalAttack += this.getAttack(this.humanList.get(i));
}
// originally -3 so the computer will try to stay at 3 life
@@ -313,41 +310,43 @@ public class ComputerUtilAttack {
*/
private boolean doAssault() {
// Beastmaster Ascension
if (AllZoneUtil.isCardInPlay("Beastmaster Ascension", AllZone.getComputerPlayer()) && attackers.size() > 1) {
CardList beastions = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Battlefield)
if (AllZoneUtil.isCardInPlay("Beastmaster Ascension", AllZone.getComputerPlayer())
&& (this.attackers.size() > 1)) {
final CardList beastions = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Battlefield)
.getName("Beastmaster Ascension");
int minCreatures = 7;
for (Card beastion : beastions) {
int counters = beastion.getCounters(Counters.QUEST);
for (final Card beastion : beastions) {
final int counters = beastion.getCounters(Counters.QUEST);
minCreatures = Math.min(minCreatures, 7 - counters);
}
if (attackers.size() >= minCreatures) {
if (this.attackers.size() >= minCreatures) {
return true;
}
}
CardListUtil.sortAttack(attackers);
CardListUtil.sortAttack(this.attackers);
CardList remainingAttackers = new CardList(attackers.toArray());
CardList blockableAttackers = new CardList(attackers.toArray());
final CardList remainingAttackers = new CardList(this.attackers.toArray());
final CardList blockableAttackers = new CardList(this.attackers.toArray());
for (int i = 0; i < attackers.size(); i++) {
if(!CombatUtil.canBeBlocked(attackers.get(i), blockers)) {
blockableAttackers.remove(attackers.get(i));
for (int i = 0; i < this.attackers.size(); i++) {
if (!CombatUtil.canBeBlocked(this.attackers.get(i), this.blockers)) {
blockableAttackers.remove(this.attackers.get(i));
}
}
// presumes the Human will block
for (int i = 0; i < blockers.size() && i < blockableAttackers.size(); i++) {
for (int i = 0; (i < this.blockers.size()) && (i < blockableAttackers.size()); i++) {
remainingAttackers.remove(blockableAttackers.get(i));
}
if(CombatUtil.sumDamageIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) > AllZone.getHumanPlayer().getLife()
&& AllZone.getHumanPlayer().canLoseLife()) {
if ((CombatUtil.sumDamageIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) > AllZone.getHumanPlayer()
.getLife()) && AllZone.getHumanPlayer().canLoseLife()) {
return true;
}
if(CombatUtil.sumPoisonIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) >= 10 - AllZone.getHumanPlayer().getPoisonCounters()) {
if (CombatUtil.sumPoisonIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) >= (10 - AllZone
.getHumanPlayer().getPoisonCounters())) {
return true;
}
@@ -367,15 +366,15 @@ public class ComputerUtilAttack {
public final void chooseDefender(final Combat c, final boolean bAssault) {
// TODO split attackers to different planeswalker/human
// AI will only attack one Defender per combat for now
ArrayList<Object> defs = c.getDefenders();
final ArrayList<Object> defs = c.getDefenders();
// Randomly determine who EVERYONE is attacking
// would be better to determine more individually
int n = MyRandom.getRandom().nextInt(defs.size());
Object entity = AllZone.getComputerPlayer().getMustAttackEntity();
final Object entity = AllZone.getComputerPlayer().getMustAttackEntity();
if (null != entity) {
ArrayList<Object> defenders = AllZone.getCombat().getDefenders();
final ArrayList<Object> defenders = AllZone.getCombat().getDefenders();
n = defenders.indexOf(entity);
if (-1 == n) {
System.out.println("getMustAttackEntity() returned something not in defenders.");
@@ -384,7 +383,7 @@ public class ComputerUtilAttack {
c.setCurrentDefender(n);
}
} else {
if (defs.size() == 1 || bAssault) {
if ((defs.size() == 1) || bAssault) {
c.setCurrentDefender(0);
} else {
c.setCurrentDefender(n);
@@ -407,22 +406,22 @@ public class ComputerUtilAttack {
// randomInt is used so that the computer doesn't always
// do the same thing on turn 3 if he had the same creatures in play
// I know this is a little confusing
random.setSeed(AllZone.getPhase().getTurn() + randomInt);
this.random.setSeed(AllZone.getPhase().getTurn() + this.randomInt);
Combat combat = new Combat();
final Combat combat = new Combat();
combat.setAttackingPlayer(AllZone.getCombat().getAttackingPlayer());
combat.setDefendingPlayer(AllZone.getCombat().getDefendingPlayer());
combat.setDefenders(AllZone.getCombat().getDefenders());
boolean bAssault = doAssault();
final boolean bAssault = this.doAssault();
// Determine who will be attacked
chooseDefender(combat, bAssault);
this.chooseDefender(combat, bAssault);
CardList attackersLeft = new CardList(attackers.toArray());
CardList attackersLeft = new CardList(this.attackers.toArray());
// Attackers that don't really have a choice
for (Card attacker : attackers) {
for (final Card attacker : this.attackers) {
if ((attacker.hasKeyword("CARDNAME attacks each turn if able.")
|| attacker.hasKeyword("At the beginning of the end step, destroy CARDNAME.")
|| attacker.hasKeyword("At the beginning of the end step, exile CARDNAME.")
@@ -443,10 +442,10 @@ public class ComputerUtilAttack {
int playerForcesForAttritionalAttack = 0;
// examine the potential forces
CardList nextTurnAttackers = new CardList();
final CardList nextTurnAttackers = new CardList();
int candidateCounterAttackDamage = 0;
// int candidateTotalBlockDamage = 0;
for (Card pCard : playerCreatures) {
for (final Card pCard : this.playerCreatures) {
// if the creature can attack next turn add it to counter attackers
// list
@@ -472,9 +471,9 @@ public class ComputerUtilAttack {
}
// get the potential damage and strength of the AI forces
CardList candidateAttackers = new CardList();
final CardList candidateAttackers = new CardList();
int candidateUnblockedDamage = 0;
for (Card pCard : computerList) {
for (final Card pCard : this.computerList) {
// if the creature can attack then it's a potential attacker this
// turn, assume summoning sickness creatures will be able to
if (CombatUtil.canAttackNextTurn(pCard)) {
@@ -502,10 +501,10 @@ public class ComputerUtilAttack {
*/
// determine if the ai outnumbers the player
int outNumber = computerForces - playerForces;
final int outNumber = computerForces - playerForces;
// compare the ratios, higher = better for ai
double ratioDiff = aiLifeToPlayerDamageRatio - playerLifeToDamageRatio;
final double ratioDiff = aiLifeToPlayerDamageRatio - playerLifeToDamageRatio;
/*
* System.out.println(String.valueOf(ratioDiff) +
* " = ratio difference, higher = better for ai");
@@ -524,17 +523,17 @@ public class ComputerUtilAttack {
// *********************
boolean doAttritionalAttack = false;
// get list of attackers ordered from low power to high
CardListUtil.sortAttackLowFirst(attackers);
CardListUtil.sortAttackLowFirst(this.attackers);
// get player life total
int playerLife = AllZone.getHumanPlayer().getLife();
// get the list of attackers up to the first blocked one
CardList attritionalAttackers = new CardList();
for (int x = 0; x < attackers.size() - playerForces; x++) {
attritionalAttackers.add(attackers.getCard(x));
final CardList attritionalAttackers = new CardList();
for (int x = 0; x < (this.attackers.size() - playerForces); x++) {
attritionalAttackers.add(this.attackers.getCard(x));
}
// until the attackers are used up or the player would run out of life
int attackRounds = 1;
while (attritionalAttackers.size() > 0 && playerLife > 0 && attackRounds < 99) {
while ((attritionalAttackers.size() > 0) && (playerLife > 0) && (attackRounds < 99)) {
// sum attacker damage
int damageThisRound = 0;
for (int y = 0; y < attritionalAttackers.size(); y++) {
@@ -565,11 +564,11 @@ public class ComputerUtilAttack {
double unblockableDamage = 0;
double turnsUntilDeathByUnblockable = 0;
boolean doUnblockableAttack = false;
for (Card attacker : attackers) {
for (final Card attacker : this.attackers) {
boolean isUnblockableCreature = true;
// check blockers individually, as the bulk canBeBlocked doesn't
// check all circumstances
for (Card blocker : blockers) {
for (final Card blocker : this.blockers) {
if (CombatUtil.canBlock(attacker, blocker)) {
isUnblockableCreature = false;
}
@@ -592,56 +591,58 @@ public class ComputerUtilAttack {
// totals and other considerations
// some bad "magic numbers" here, TODO replace with nice descriptive
// variable names
if ((ratioDiff > 0 && doAttritionalAttack)) { // (playerLifeToDamageRatio
// <= 1 && ratioDiff >= 1
if (((ratioDiff > 0) && doAttritionalAttack)) { // (playerLifeToDamageRatio
// <= 1 && ratioDiff >=
// 1
// && outNumber > 0) ||
aiAggression = 5; // attack at all costs
} else if ((playerLifeToDamageRatio < 2 && ratioDiff >= 0)
|| ratioDiff > 3 || (ratioDiff > 0 && outNumber > 0)) {
aiAggression = 3; // attack expecting to kill creatures or damage
this.aiAggression = 5; // attack at all costs
} else if (((playerLifeToDamageRatio < 2) && (ratioDiff >= 0)) || (ratioDiff > 3)
|| ((ratioDiff > 0) && (outNumber > 0))) {
this.aiAggression = 3; // attack expecting to kill creatures or
// damage
// player.
} else if (ratioDiff >= 0 || ratioDiff + outNumber >= -1) {
} else if ((ratioDiff >= 0) || ((ratioDiff + outNumber) >= -1)) {
// at 0 ratio expect to potentially gain an advantage by attacking
// first
// if the ai has a slight advantage
// or the ai has a significant advantage numerically but only a
// slight disadvantage damage/life
aiAggression = 2; // attack expecting to destroy creatures/be
this.aiAggression = 2; // attack expecting to destroy creatures/be
// unblockable
} else if (ratioDiff < 0 && aiLifeToPlayerDamageRatio > 1) {
} else if ((ratioDiff < 0) && (aiLifeToPlayerDamageRatio > 1)) {
// the player is overmatched but there are a few turns before death
aiAggression = 2; // attack expecting to destroy creatures/be
this.aiAggression = 2; // attack expecting to destroy creatures/be
// unblockable
} else if (doUnblockableAttack || ((ratioDiff * -1) < turnsUntilDeathByUnblockable)) {
aiAggression = 1; // look for unblockable creatures that might be
this.aiAggression = 1; // look for unblockable creatures that might
// be
// able to attack for a bit of
// fatal damage even if the player is significantly better
} else if (ratioDiff < 0) {
aiAggression = 0;
this.aiAggression = 0;
} // stay at home to block
System.out.println(String.valueOf(aiAggression) + " = ai aggression");
System.out.println(String.valueOf(this.aiAggression) + " = ai aggression");
// ****************
// End of edits
// ****************
// Exalted
if (combat.getAttackers().length == 0
&& (countExaltedBonus(AllZone.getComputerPlayer()) >= 3
if ((combat.getAttackers().length == 0)
&& ((this.countExaltedBonus(AllZone.getComputerPlayer()) >= 3)
|| AllZoneUtil.isCardInPlay("Rafiq of the Many", AllZone.getComputerPlayer())
|| AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield,
"Battlegrace Angel").size() >= 2 || (AllZone
.getComputerPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size() >= 1)
&& AllZone.getPhase().isFirstCombat()) && !bAssault) {
|| (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Battlegrace Angel").size() >= 2) || ((AllZone
.getComputerPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size() >= 1) && AllZone
.getPhase().isFirstCombat())) && !bAssault) {
int biggest = 0;
Card att = null;
for (int i = 0; i < attackersLeft.size(); i++) {
if (getAttack(attackersLeft.get(i)) > biggest) {
biggest = getAttack(attackersLeft.get(i));
if (this.getAttack(attackersLeft.get(i)) > biggest) {
biggest = this.getAttack(attackersLeft.get(i));
att = attackersLeft.get(i);
}
}
if (att != null && CombatUtil.canAttack(att, combat)) {
if ((att != null) && CombatUtil.canAttack(att, combat)) {
combat.addAttacker(att);
}
@@ -661,21 +662,21 @@ public class ComputerUtilAttack {
} else {
System.out.println("Normal attack");
attackersLeft = notNeededAsBlockers(attackersLeft, combat);
attackersLeft = this.notNeededAsBlockers(attackersLeft, combat);
System.out.println(attackersLeft.size());
attackersLeft = sortAttackers(attackersLeft);
attackersLeft = this.sortAttackers(attackersLeft);
for (int i = 0; i < attackersLeft.size(); i++) {
Card attacker = attackersLeft.get(i);
final Card attacker = attackersLeft.get(i);
int totalFirstStrikeBlockPower = 0;
if (!attacker.hasFirstStrike() && !attacker.hasDoubleStrike()) {
totalFirstStrikeBlockPower = CombatUtil.getTotalFirstStrikeBlockPower(attacker,
AllZone.getHumanPlayer());
}
if (shouldAttack(attacker, blockers, combat)
&& (totalFirstStrikeBlockPower < attacker.getKillDamage() || aiAggression == 5)
if (this.shouldAttack(attacker, this.blockers, combat)
&& ((totalFirstStrikeBlockPower < attacker.getKillDamage()) || (this.aiAggression == 5))
&& CombatUtil.canAttack(attacker, combat)) {
combat.addAttacker(attacker);
}
@@ -697,6 +698,7 @@ public class ComputerUtilAttack {
public final int countExaltedBonus(final Player player) {
CardList list = player.getCardsIn(Zone.Battlefield);
list = list.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return c.hasKeyword("Exalted");
}
@@ -748,7 +750,7 @@ public class ComputerUtilAttack {
boolean isWorthLessThanAllKillers = true;
boolean canBeBlocked = false;
if (!isEffectiveAttacker(attacker, combat)) {
if (!this.isEffectiveAttacker(attacker, combat)) {
return false;
}
@@ -756,7 +758,7 @@ public class ComputerUtilAttack {
// number of factors about the attacking
// context that will be relevant to the attackers decision according to
// the selected strategy
for (Card defender : defenders) {
for (final Card defender : defenders) {
if (CombatUtil.canBlock(attacker, defender)) { // , combat )) {
canBeBlocked = true;
if (CombatUtil.canDestroyAttacker(attacker, defender, combat, false)) {
@@ -793,7 +795,7 @@ public class ComputerUtilAttack {
// decide if the creature should attack based on the prevailing strategy
// choice in aiAggression
switch (aiAggression) {
switch (this.aiAggression) {
case 5: // all out attacking
System.out.println(attacker.getName() + " = all out attacking");
return true;

View File

@@ -541,8 +541,7 @@ public class GameAction {
return c;
}
if(c.isInAlternateState())
{
if (c.isInAlternateState()) {
c.setState("Original");
}
@@ -893,7 +892,8 @@ public class GameAction {
if (entity instanceof Card) {
final Card perm = (Card) entity;
if (!AllZoneUtil.isCardInPlay(perm) || perm.hasProtectionFrom(c) || perm.hasKeyword("CARDNAME can't be enchanted.")
if (!AllZoneUtil.isCardInPlay(perm) || perm.hasProtectionFrom(c)
|| perm.hasKeyword("CARDNAME can't be enchanted.")
|| ((tgt != null) && !perm.isValid(tgt.getValidTgts(), c.getController(), c))) {
c.unEnchantEntity(perm);
this.moveToGraveyard(c);
@@ -1634,9 +1634,8 @@ public class GameAction {
}
if (((flip == 0) && q.equals(0)) || ((flip == 1) && q.equals(1))) {
JOptionPane.showMessageDialog(null,
humanFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), "",
JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, humanFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN),
"", JOptionPane.INFORMATION_MESSAGE);
} else {
this.computerStartsGame();
JOptionPane.showMessageDialog(null,
@@ -1800,11 +1799,14 @@ public class GameAction {
// check for flashback keywords
if (c.isInZone(Constant.Zone.Graveyard) && sa.isSpell() && (c.isInstant() || c.isSorcery())) {
for(String keyword : c.getKeyword()) {
for (final String keyword : c.getKeyword()) {
if (keyword.startsWith("Flashback")) {
SpellAbility flashback = sa.copy();
final SpellAbility flashback = sa.copy();
flashback.setFlashBackAbility(true);
if (!keyword.equals("Flashback")) {//there is a flashback cost (and not the cards cost)
if (!keyword.equals("Flashback")) { // there is a
// flashback cost
// (and not the
// cards cost)
final Cost fbCost = new Cost(keyword.substring(10), c.getName(), false);
flashback.setPayCosts(fbCost);
}
@@ -2072,89 +2074,86 @@ public class GameAction {
} else if (spell.getSourceCard().hasKeyword("Convoke")) {
CardList untappedCreats = spell.getActivatingPlayer().getCardsIn(Zone.Battlefield).getType("Creature");
untappedCreats = untappedCreats.filter(new CardListFilter() {
public boolean addCard(Card c) {
@Override
public boolean addCard(final Card c) {
return !c.isTapped();
}
});
if(untappedCreats.size() != 0)
{
ArrayList<Object> choices = new ArrayList<Object>();
for(Card c : untappedCreats) {
if (untappedCreats.size() != 0) {
final ArrayList<Object> choices = new ArrayList<Object>();
for (final Card c : untappedCreats) {
choices.add(c);
}
choices.add("DONE");
ArrayList<String> usableColors = new ArrayList<String>();
ManaCost newCost = new ManaCost(originalCost.toString());
Object tapForConvoke = null;
if(sa.getActivatingPlayer().isHuman())
{
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), choices.toArray());
}
else {
if (sa.getActivatingPlayer().isHuman()) {
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(),
choices.toArray());
} else {
// TODO: AI to choose a creature to tap would go here
//Probably along with deciding how many creatures to tap
// Probably along with deciding how many creatures to
// tap
}
while(tapForConvoke != null && (tapForConvoke instanceof Card) && untappedCreats.size() != 0) {
Card workingCard = (Card) tapForConvoke;
while ((tapForConvoke != null) && (tapForConvoke instanceof Card) && (untappedCreats.size() != 0)) {
final Card workingCard = (Card) tapForConvoke;
usableColors = CardUtil.getConvokableColors(workingCard, newCost);
if(usableColors.size() != 0)
{
if (usableColors.size() != 0) {
String chosenColor = usableColors.get(0);
if(usableColors.size() > 1)
{
if(sa.getActivatingPlayer().isHuman())
{
chosenColor = (String)GuiUtils.getChoice("Convoke for which color?", usableColors.toArray());
}
else
{
//TODO: AI for choosing which color to convoke goes here.
if (usableColors.size() > 1) {
if (sa.getActivatingPlayer().isHuman()) {
chosenColor = (String) GuiUtils.getChoice("Convoke for which color?",
usableColors.toArray());
} else {
// TODO: AI for choosing which color to
// convoke goes here.
}
}
if(chosenColor.equals("colorless"))
{
if (chosenColor.equals("colorless")) {
newCost.decreaseColorlessMana(1);
}
else
{
} else {
String newCostStr = newCost.toString();
newCostStr = newCostStr.replaceFirst(InputPayManaCostUtil.getShortColorString(chosenColor), "");
newCostStr = newCostStr.replaceFirst(
InputPayManaCostUtil.getShortColorString(chosenColor), "");
newCost = new ManaCost(newCostStr.trim());
}
sa.addTappedForConvoke(workingCard);
choices.remove(workingCard);
untappedCreats.remove(workingCard);
if(choices.size() < 2 || newCost.getConvertedManaCost() == 0) {
if ((choices.size() < 2) || (newCost.getConvertedManaCost() == 0)) {
break;
}
}
else
{
} else {
untappedCreats.remove(workingCard);
}
if(sa.getActivatingPlayer().isHuman())
{
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), choices.toArray());
}
else {
//TODO: AI to choose a creature to tap would go here
if (sa.getActivatingPlayer().isHuman()) {
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(),
choices.toArray());
} else {
// TODO: AI to choose a creature to tap would go
// here
}
}
// will only be null if user cancelled.
if (tapForConvoke != null) {
//Convoked creats are tapped here with triggers suppressed,
//Then again when payment is done(In InputPayManaCost.done()) with suppression cleared.
//This is to make sure that triggers go off at the right time
//AND that you can't use mana tapabilities of convoked creatures
// Convoked creats are tapped here with triggers
// suppressed,
// Then again when payment is done(In
// InputPayManaCost.done()) with suppression cleared.
// This is to make sure that triggers go off at the
// right time
// AND that you can't use mana tapabilities of convoked
// creatures
// to pay the convoked cost.
AllZone.getTriggerHandler().suppressMode("Taps");
for(Card c : sa.getTappedForConvoke()) {
for (final Card c : sa.getTappedForConvoke()) {
c.tap();
}
AllZone.getTriggerHandler().clearSuppression("Taps");
@@ -2540,8 +2539,8 @@ public class GameAction {
// Not Included as X Costs are not in
// Colored Mana
if (sa.isMultiKicker()) {
this.setCostCuttingGetMultiMickerManaCostPaidColored(this.getCostCuttingGetMultiMickerManaCostPaidColored()
+ k[3]);
this.setCostCuttingGetMultiMickerManaCostPaidColored(this
.getCostCuttingGetMultiMickerManaCostPaidColored() + k[3]);
// JOptionPane.showMessageDialog(null,
// CostCutting_GetMultiMickerManaCostPaid_Colored,
// "", JOptionPane.INFORMATION_MESSAGE);
@@ -2820,30 +2819,49 @@ public class GameAction {
}
/**
* Gets the cost cutting get multi micker mana cost paid.
*
* @return the costCuttingGetMultiMickerManaCostPaid
*/
public int getCostCuttingGetMultiMickerManaCostPaid() {
return costCuttingGetMultiMickerManaCostPaid;
return this.costCuttingGetMultiMickerManaCostPaid;
}
/**
* Sets the cost cutting get multi micker mana cost paid.
*
* @param costCuttingGetMultiMickerManaCostPaid the costCuttingGetMultiMickerManaCostPaid to set
*/
public void setCostCuttingGetMultiMickerManaCostPaid(int costCuttingGetMultiMickerManaCostPaid) {
this.costCuttingGetMultiMickerManaCostPaid = costCuttingGetMultiMickerManaCostPaid; // TODO: Add 0 to parameter's name.
public void setCostCuttingGetMultiMickerManaCostPaid(final int costCuttingGetMultiMickerManaCostPaid) {
this.costCuttingGetMultiMickerManaCostPaid = costCuttingGetMultiMickerManaCostPaid; // TODO:
// Add
// 0
// to
// parameter's
// name.
}
/**
* Gets the cost cutting get multi micker mana cost paid colored.
*
* @return the costCuttingGetMultiMickerManaCostPaidColored
*/
public String getCostCuttingGetMultiMickerManaCostPaidColored() {
return costCuttingGetMultiMickerManaCostPaidColored;
return this.costCuttingGetMultiMickerManaCostPaidColored;
}
/**
* Sets the cost cutting get multi micker mana cost paid colored.
*
* @param costCuttingGetMultiMickerManaCostPaidColored the costCuttingGetMultiMickerManaCostPaidColored to set
*/
public void setCostCuttingGetMultiMickerManaCostPaidColored(String costCuttingGetMultiMickerManaCostPaidColored) {
this.costCuttingGetMultiMickerManaCostPaidColored = costCuttingGetMultiMickerManaCostPaidColored; // TODO: Add 0 to parameter's name.
public void setCostCuttingGetMultiMickerManaCostPaidColored(
final String costCuttingGetMultiMickerManaCostPaidColored) {
this.costCuttingGetMultiMickerManaCostPaidColored = costCuttingGetMultiMickerManaCostPaidColored; // TODO:
// Add
// 0
// to
// parameter's
// name.
}
}

View File

@@ -39,26 +39,31 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
}
protected final void addCardToList(ArrayList<DownloadObject> cList, CardPrinted c, String cardName)
{
/**
* Adds the card to list.
*
* @param cList the c list
* @param c the c
* @param cardName the card name
*/
protected final void addCardToList(final ArrayList<DownloadObject> cList, final CardPrinted c, final String cardName) {
final String urlBase = "http://cardforge.org/fpics/";
String setCode3 = c.getSet();
CardSet thisSet = SetUtils.getSetByCode(setCode3);
String setCode2 = thisSet.getCode2();
final String setCode3 = c.getSet();
final CardSet thisSet = SetUtils.getSetByCode(setCode3);
final String setCode2 = thisSet.getCode2();
String imgFN = CardUtil.buildFilename(c, cardName);
boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2);
final String imgFN = CardUtil.buildFilename(c, cardName);
final boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2);
if(picturesPath == null)
{
if (this.picturesPath == null) {
System.out.println("Oh snap!");
}
if (!foundSetImage) {
int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount();
String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt);
final int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount();
final String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt);
cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true),
picturesPath + File.separator + setCode3));
this.picturesPath + File.separator + setCode3));
System.out.println(String.format("%s [%s - %s]", cardName, setCode3, thisSet.getName()));
}
}
@@ -70,40 +75,40 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
*
* @return an array of {@link forge.GuiDownloader.DownloadObject} objects.
*/
@Override
protected final DownloadObject[] getNeededImages() {
if(picturesPath == null)
{
picturesPath = ForgeProps.getFile(NewConstants.IMAGE_BASE).getPath();
if (this.picturesPath == null) {
this.picturesPath = ForgeProps.getFile(NewConstants.IMAGE_BASE).getPath();
}
// read token names and urls
DownloadObject[] cardTokenLQ = readFileWithNames(NewConstants.TOKEN_IMAGES, ForgeProps.getFile(NewConstants.IMAGE_TOKEN));
ArrayList<DownloadObject> cList = new ArrayList<DownloadObject>();
final DownloadObject[] cardTokenLQ = GuiDownloader.readFileWithNames(NewConstants.TOKEN_IMAGES,
ForgeProps.getFile(NewConstants.IMAGE_TOKEN));
final ArrayList<DownloadObject> cList = new ArrayList<DownloadObject>();
for (CardPrinted c : CardDb.instance().getAllCards()) {
String setCode3 = c.getSet();
for (final CardPrinted c : CardDb.instance().getAllCards()) {
final String setCode3 = c.getSet();
if (StringUtils.isBlank(setCode3) || "???".equals(setCode3)) {
continue; // we don't want cards from unknown sets
}
addCardToList(cList, c, c.getCard().getName());
if ( c.getCard().isDoubleFaced() )
{
addCardToList(cList, c, c.getCard().getSlavePart().getName());
this.addCardToList(cList, c, c.getCard().getName());
if (c.getCard().isDoubleFaced()) {
this.addCardToList(cList, c, c.getCard().getSlavePart().getName());
}
}
// add missing tokens to the list of things to download
File file;
File filebase = ForgeProps.getFile(NewConstants.IMAGE_TOKEN);
for (int i = 0; i < cardTokenLQ.length; i++) {
file = new File(filebase, cardTokenLQ[i].getName());
final File filebase = ForgeProps.getFile(NewConstants.IMAGE_TOKEN);
for (final DownloadObject element : cardTokenLQ) {
file = new File(filebase, element.getName());
if (!file.exists()) {
cList.add(cardTokenLQ[i]);
cList.add(element);
}
}
// return all card names and urls that are needed
DownloadObject[] out = new DownloadObject[cList.size()];
final DownloadObject[] out = new DownloadObject[cList.size()];
cList.toArray(out);
return out;

View File

@@ -503,7 +503,8 @@ public class Upkeep implements java.io.Serializable {
for (final Card c : cards) {
final Card abyss = c;
final CardList abyssGetTargets = AllZoneUtil.getCreaturesInPlay(player).filter(CardListFilter.NON_ARTIFACTS);
final CardList abyssGetTargets = AllZoneUtil.getCreaturesInPlay(player)
.filter(CardListFilter.NON_ARTIFACTS);
final Ability sacrificeCreature = new Ability(abyss, "") {
@Override
@@ -2482,7 +2483,8 @@ public class Upkeep implements java.io.Serializable {
* add new to play
*/
final Card newCopy = AllZone.getCardFactory().getCard(newTarget[0].getState("Original").getName(), player);
final Card newCopy = AllZone.getCardFactory().getCard(
newTarget[0].getState("Original").getName(), player);
newCopy.setCurSetCode(newTarget[0].getCurSetCode());
newCopy.setImageFilename(newTarget[0].getImageFilename());

View File

@@ -26,8 +26,7 @@ public class BoosterGenerator {
// Function to open a booster as it is.
/** The Constant IDENTITY_PICK. */
public static final Lambda1<List<CardPrinted>, BoosterGenerator> IDENTITY_PICK
= new Lambda1<List<CardPrinted>, BoosterGenerator>() {
public static final Lambda1<List<CardPrinted>, BoosterGenerator> IDENTITY_PICK = new Lambda1<List<CardPrinted>, BoosterGenerator>() {
@Override
public List<CardPrinted> apply(final BoosterGenerator arg1) {
return arg1.getBoosterPack();
@@ -133,8 +132,7 @@ public class BoosterGenerator {
return this.pickRandomCards(source, count, false);
}
private List<CardPrinted> pickRandomCards(final List<CardPrinted> source,
final int count, final boolean singleton) {
private List<CardPrinted> pickRandomCards(final List<CardPrinted> source, final int count, final boolean singleton) {
int listSize = source == null ? 0 : source.size();
if ((count <= 0) || (listSize == 0)) {
return BoosterGenerator.EMPTY_LIST;
@@ -206,7 +204,8 @@ public class BoosterGenerator {
/**
* Gets the singleton booster pack.
*
* @param nAnyCard the n any card
* @param nAnyCard
* the n any card
* @return the singleton booster pack
*/
public final List<CardPrinted> getSingletonBoosterPack(final int nAnyCard) {
@@ -266,17 +265,17 @@ public class BoosterGenerator {
temp.addAll(this.pickRandomCards(this.mythics, nMythics));
}
if (nDoubls > 0) {
int dblFacedRarity = MyRandom.getRandom().nextInt(14);
final int dblFacedRarity = MyRandom.getRandom().nextInt(14);
List<CardPrinted> listToUse;
if (dblFacedRarity < 9) { // Common
listToUse = doubleFacedCommons;
listToUse = this.doubleFacedCommons;
} else if (dblFacedRarity < 13) { // Uncommon
listToUse = doubleFacedUncommons;
listToUse = this.doubleFacedUncommons;
} else { // Rare or Mythic
if (MyRandom.getRandom().nextInt(8) == 0) {
listToUse = doubleFacedMythics;
listToUse = this.doubleFacedMythics;
} else {
listToUse = doubleFacedRares;
listToUse = this.doubleFacedRares;
}
}
temp.addAll(this.pickRandomCards(listToUse, nDoubls));

View File

@@ -48,7 +48,7 @@ public final class CardRules {
* @return the name
*/
public String getName() {
return characteristics.getCardName();
return this.characteristics.getCardName();
}
/**
@@ -57,7 +57,7 @@ public final class CardRules {
* @return the type
*/
public CardType getType() {
return characteristics.getCardType();
return this.characteristics.getCardType();
}
/**
@@ -66,7 +66,7 @@ public final class CardRules {
* @return the mana cost
*/
public CardManaCost getManaCost() {
return characteristics.getManaCost();
return this.characteristics.getManaCost();
}
/**
@@ -75,7 +75,7 @@ public final class CardRules {
* @return the color
*/
public CardColor getColor() {
return characteristics.getColor();
return this.characteristics.getColor();
}
/**
@@ -84,10 +84,17 @@ public final class CardRules {
* @return the rules
*/
public String[] getRules() {
return characteristics.getCardRules();
return this.characteristics.getCardRules();
}
public final CardRules getSlavePart() { return slavePart; }
/**
*
* Gets Slave Part.
* @return CardRules
*/
public CardRules getSlavePart() {
return this.slavePart;
}
/**
* Gets the sets printed.
@@ -95,7 +102,7 @@ public final class CardRules {
* @return the sets printed
*/
public Set<Entry<String, CardInSet>> getSetsPrinted() {
return characteristics.getSetsData().entrySet();
return this.characteristics.getSetsData().entrySet();
}
/**
@@ -104,7 +111,7 @@ public final class CardRules {
* @return the power
*/
public String getPower() {
return power;
return this.power;
}
/**
@@ -113,7 +120,7 @@ public final class CardRules {
* @return the int power
*/
public int getIntPower() {
return iPower;
return this.iPower;
}
/**
@@ -122,7 +129,7 @@ public final class CardRules {
* @return the toughness
*/
public String getToughness() {
return toughness;
return this.toughness;
}
/**
@@ -131,7 +138,7 @@ public final class CardRules {
* @return the int toughness
*/
public int getIntToughness() {
return iToughness;
return this.iToughness;
}
/**
@@ -140,7 +147,7 @@ public final class CardRules {
* @return the loyalty
*/
public String getLoyalty() {
return loyalty;
return this.loyalty;
}
/**
@@ -149,7 +156,7 @@ public final class CardRules {
* @return the rem ai decks
*/
public boolean getRemAIDecks() {
return isRemovedFromAIDecks;
return this.isRemovedFromAIDecks;
}
/**
@@ -158,7 +165,7 @@ public final class CardRules {
* @return the rem random decks
*/
public boolean getRemRandomDecks() {
return isRemovedFromRandomDecks;
return this.isRemovedFromRandomDecks;
}
/**
@@ -167,11 +174,11 @@ public final class CardRules {
* @return the p tor loyalty
*/
public String getPTorLoyalty() {
if (getType().isCreature()) {
return power + "/" + toughness;
if (this.getType().isCreature()) {
return this.power + "/" + this.toughness;
}
if (getType().isPlaneswalker()) {
return loyalty;
if (this.getType().isPlaneswalker()) {
return this.loyalty;
}
return "";
}
@@ -182,7 +189,7 @@ public final class CardRules {
* @return true, if is alt state
*/
public boolean isAltState() {
return isDoubleFaced() && slavePart == null;
return this.isDoubleFaced() && (this.slavePart == null);
}
/**
@@ -191,7 +198,7 @@ public final class CardRules {
* @return true, if is double faced
*/
public boolean isDoubleFaced() {
return hasOtherFace;
return this.hasOtherFace;
}
/**
@@ -201,8 +208,8 @@ public final class CardRules {
* the chars
* @param isDoubleFacedCard
* the is double faced card
* @param isAlt0
* the is alt0
* @param otherPart
* the otherPart
* @param removedFromRandomDecks
* the removed from random decks
* @param removedFromAIDecks
@@ -210,31 +217,33 @@ public final class CardRules {
*/
public CardRules(final CardRuleCharacteristics chars, final boolean isDoubleFacedCard, final CardRules otherPart,
final boolean removedFromRandomDecks, final boolean removedFromAIDecks) {
characteristics = chars;
slavePart = otherPart;
hasOtherFace = isDoubleFacedCard;
this.characteristics = chars;
this.slavePart = otherPart;
this.hasOtherFace = isDoubleFacedCard;
this.isRemovedFromAIDecks = removedFromAIDecks;
this.isRemovedFromRandomDecks = removedFromRandomDecks;
// System.out.println(cardName);
if (getType().isCreature()) {
int slashPos = characteristics.getPtLine() == null ? -1 : characteristics.getPtLine().indexOf('/');
if (this.getType().isCreature()) {
final int slashPos = this.characteristics.getPtLine() == null ? -1 : this.characteristics.getPtLine()
.indexOf('/');
if (slashPos == -1) {
throw new RuntimeException(String.format("Creature '%s' has bad p/t stats", getName()));
throw new RuntimeException(String.format("Creature '%s' has bad p/t stats", this.getName()));
}
this.power = characteristics.getPtLine().substring(0, slashPos);
this.toughness = characteristics.getPtLine().substring(slashPos + 1, characteristics.getPtLine().length());
this.iPower = StringUtils.isNumeric(power) ? Integer.parseInt(power) : 0;
this.iToughness = StringUtils.isNumeric(toughness) ? Integer.parseInt(toughness) : 0;
} else if (getType().isPlaneswalker()) {
this.loyalty = characteristics.getPtLine();
this.power = this.characteristics.getPtLine().substring(0, slashPos);
this.toughness = this.characteristics.getPtLine().substring(slashPos + 1,
this.characteristics.getPtLine().length());
this.iPower = StringUtils.isNumeric(this.power) ? Integer.parseInt(this.power) : 0;
this.iToughness = StringUtils.isNumeric(this.toughness) ? Integer.parseInt(this.toughness) : 0;
} else if (this.getType().isPlaneswalker()) {
this.loyalty = this.characteristics.getPtLine();
}
if (characteristics.getSetsData().isEmpty()) {
characteristics.getSetsData().put("???", new CardInSet(CardRarity.Unknown, 1));
if (this.characteristics.getSetsData().isEmpty()) {
this.characteristics.getSetsData().put("???", new CardInSet(CardRarity.Unknown, 1));
}
setsPrinted = characteristics.getSetsData();
this.setsPrinted = this.characteristics.getSetsData();
}
/**
@@ -245,10 +254,10 @@ public final class CardRules {
* @return true, if successful
*/
public boolean rulesContain(final String text) {
if (characteristics.getCardRules() == null) {
if (this.characteristics.getCardRules() == null) {
return false;
}
for (String r : characteristics.getCardRules()) {
for (final String r : this.characteristics.getCardRules()) {
if (StringUtils.containsIgnoreCase(r, text)) {
return true;
}
@@ -264,7 +273,7 @@ public final class CardRules {
public String getLatestSetPrinted() {
String lastSet = null;
// TODO: Make a true release-date based sorting
for (String cs : setsPrinted.keySet()) {
for (final String cs : this.setsPrinted.keySet()) {
lastSet = cs;
}
return lastSet;
@@ -278,11 +287,11 @@ public final class CardRules {
* @return the sets the info
*/
public CardInSet getSetInfo(final String setCode) {
CardInSet result = setsPrinted.get(setCode);
final CardInSet result = this.setsPrinted.get(setCode);
if (result != null) {
return result;
}
throw new RuntimeException(String.format("Card '%s' was never printed in set '%s'", getName(), setCode));
throw new RuntimeException(String.format("Card '%s' was never printed in set '%s'", this.getName(), setCode));
}
@@ -292,7 +301,7 @@ public final class CardRules {
* @return the rarity from latest set
*/
public CardRarity getRarityFromLatestSet() {
CardInSet cis = setsPrinted.get(getLatestSetPrinted());
final CardInSet cis = this.setsPrinted.get(this.getLatestSetPrinted());
return cis.getRarity();
}
@@ -302,8 +311,8 @@ public final class CardRules {
* @return the ai status
*/
public String getAiStatus() {
return isRemovedFromAIDecks ? (isRemovedFromRandomDecks ? "AI ?" : "AI")
: (isRemovedFromRandomDecks ? "?" : "");
return this.isRemovedFromAIDecks ? (this.isRemovedFromRandomDecks ? "AI ?" : "AI")
: (this.isRemovedFromRandomDecks ? "?" : "");
}
/**
@@ -312,11 +321,11 @@ public final class CardRules {
* @return the ai status comparable
*/
public Integer getAiStatusComparable() {
if (isRemovedFromAIDecks && isRemovedFromRandomDecks) {
if (this.isRemovedFromAIDecks && this.isRemovedFromRandomDecks) {
return Integer.valueOf(3);
} else if (isRemovedFromAIDecks) {
} else if (this.isRemovedFromAIDecks) {
return Integer.valueOf(4);
} else if (isRemovedFromRandomDecks) {
} else if (this.isRemovedFromRandomDecks) {
return Integer.valueOf(2);
} else {
return Integer.valueOf(1);
@@ -447,8 +456,8 @@ public final class CardRules {
*/
public static Predicate<CardRules> coreType(final boolean isEqual, final String what) {
try {
return coreType(isEqual, CardCoreType.valueOf(CardCoreType.class, what));
} catch (Exception e) {
return Predicates.coreType(isEqual, Enum.valueOf(CardCoreType.class, what));
} catch (final Exception e) {
return Predicate.getFalse(CardRules.class);
}
}
@@ -477,8 +486,8 @@ public final class CardRules {
*/
public static Predicate<CardRules> superType(final boolean isEqual, final String what) {
try {
return superType(isEqual, CardSuperType.valueOf(CardSuperType.class, what));
} catch (Exception e) {
return Predicates.superType(isEqual, Enum.valueOf(CardSuperType.class, what));
} catch (final Exception e) {
return Predicate.getFalse(CardRules.class);
}
}
@@ -564,17 +573,19 @@ public final class CardRules {
@Override
public boolean isTrue(final CardRules card) {
boolean shouldConatin;
switch (field) {
switch (this.field) {
case NAME:
return op(card.getName(), operand);
return this.op(card.getName(), this.operand);
case SUBTYPE:
shouldConatin = getOperator() == StringOp.CONTAINS || getOperator() == StringOp.EQUALS;
return shouldConatin == card.getType().subTypeContains(operand);
shouldConatin = (this.getOperator() == StringOp.CONTAINS)
|| (this.getOperator() == StringOp.EQUALS);
return shouldConatin == card.getType().subTypeContains(this.operand);
case RULES:
shouldConatin = getOperator() == StringOp.CONTAINS || getOperator() == StringOp.EQUALS;
return shouldConatin == card.rulesContain(operand);
shouldConatin = (this.getOperator() == StringOp.CONTAINS)
|| (this.getOperator() == StringOp.EQUALS);
return shouldConatin == card.rulesContain(this.operand);
case JOINED_TYPE:
return op(card.getType().toString(), operand);
return this.op(card.getType().toString(), this.operand);
default:
return false;
}
@@ -596,23 +607,23 @@ public final class CardRules {
private final byte color;
public LeafColor(final ColorOperator operator, final byte thatColor) {
op = operator;
color = thatColor;
this.op = operator;
this.color = thatColor;
}
@Override
public boolean isTrue(final CardRules subject) {
switch (op) {
switch (this.op) {
case CountColors:
return subject.getColor().countColors() == color;
return subject.getColor().countColors() == this.color;
case CountColorsGreaterOrEqual:
return subject.getColor().countColors() >= color;
return subject.getColor().countColors() >= this.color;
case Equals:
return subject.getColor().isEqual(color);
return subject.getColor().isEqual(this.color);
case HasAllOf:
return subject.getColor().hasAllColors(color);
return subject.getColor().hasAllColors(this.color);
case HasAnyOf:
return subject.getColor().hasAnyColor(color);
return subject.getColor().hasAnyColor(this.color);
default:
return false;
}
@@ -630,29 +641,29 @@ public final class CardRules {
public LeafNumber(final CardField field, final ComparableOp op, final int what) {
this.field = field;
operand = what;
operator = op;
this.operand = what;
this.operator = op;
}
@Override
public boolean isTrue(final CardRules card) {
int value;
switch (field) {
switch (this.field) {
case CMC:
return op(card.getManaCost().getCMC(), operand);
return this.op(card.getManaCost().getCMC(), this.operand);
case POWER:
value = card.getIntPower();
return value >= 0 ? op(value, operand) : false;
return value >= 0 ? this.op(value, this.operand) : false;
case TOUGHNESS:
value = card.getIntToughness();
return value >= 0 ? op(value, operand) : false;
return value >= 0 ? this.op(value, this.operand) : false;
default:
return false;
}
}
private boolean op(final int op1, final int op2) {
switch (operator) {
switch (this.operator) {
case EQUALS:
return op1 == op2;
case GREATER_THAN:
@@ -677,12 +688,12 @@ public final class CardRules {
@Override
public boolean isTrue(final CardRules card) {
return shouldBeEqual == card.getType().typeContains(operand);
return this.shouldBeEqual == card.getType().typeContains(this.operand);
}
public PredicateCoreType(final CardCoreType type, final boolean wantEqual) {
operand = type;
shouldBeEqual = wantEqual;
this.operand = type;
this.shouldBeEqual = wantEqual;
}
}
@@ -692,12 +703,12 @@ public final class CardRules {
@Override
public boolean isTrue(final CardRules card) {
return shouldBeEqual == card.getType().superTypeContains(operand);
return this.shouldBeEqual == card.getType().superTypeContains(this.operand);
}
public PredicateSuperType(final CardSuperType type, final boolean wantEqual) {
operand = type;
shouldBeEqual = wantEqual;
this.operand = type;
this.shouldBeEqual = wantEqual;
}
}
@@ -707,12 +718,12 @@ public final class CardRules {
@Override
public boolean isTrue(final CardRules card) {
return card.getRarityFromLatestSet().equals(operand) == shouldBeEqual;
return card.getRarityFromLatestSet().equals(this.operand) == this.shouldBeEqual;
}
public PredicateLastesSetRarity(final CardRarity type, final boolean wantEqual) {
operand = type;
shouldBeEqual = wantEqual;
this.operand = type;
this.shouldBeEqual = wantEqual;
}
}
@@ -720,12 +731,12 @@ public final class CardRules {
private final List<String> sets;
public PredicateExitsInSets(final List<String> wantSets) {
sets = wantSets; // maybe should make a copy here?
this.sets = wantSets; // maybe should make a copy here?
}
@Override
public boolean isTrue(final CardRules subject) {
for (String s : sets) {
for (final String s : this.sets) {
if (subject.setsPrinted.containsKey(s)) {
return true;
}
@@ -740,13 +751,13 @@ public final class CardRules {
public static class Presets {
/** The Constant isCreature. */
public static final Predicate<CardRules> IS_CREATURE = coreType(true, CardCoreType.Creature);
public static final Predicate<CardRules> IS_CREATURE = Predicates.coreType(true, CardCoreType.Creature);
/** The Constant isArtifact. */
public static final Predicate<CardRules> IS_ARTIFACT = coreType(true, CardCoreType.Artifact);
public static final Predicate<CardRules> IS_ARTIFACT = Predicates.coreType(true, CardCoreType.Artifact);
/** The Constant isLand. */
public static final Predicate<CardRules> IS_LAND = coreType(true, CardCoreType.Land);
public static final Predicate<CardRules> IS_LAND = Predicates.coreType(true, CardCoreType.Land);
/** The Constant isBasicLand. */
public static final Predicate<CardRules> IS_BASIC_LAND = new Predicate<CardRules>() {
@@ -757,54 +768,56 @@ public final class CardRules {
};
/** The Constant isPlaneswalker. */
public static final Predicate<CardRules> IS_PLANESWALKER = coreType(true, CardCoreType.Planeswalker);
public static final Predicate<CardRules> IS_PLANESWALKER = Predicates.coreType(true,
CardCoreType.Planeswalker);
/** The Constant isInstant. */
public static final Predicate<CardRules> IS_INSTANT = coreType(true, CardCoreType.Instant);
public static final Predicate<CardRules> IS_INSTANT = Predicates.coreType(true, CardCoreType.Instant);
/** The Constant isSorcery. */
public static final Predicate<CardRules> IS_SORCERY = coreType(true, CardCoreType.Sorcery);
public static final Predicate<CardRules> IS_SORCERY = Predicates.coreType(true, CardCoreType.Sorcery);
/** The Constant isEnchantment. */
public static final Predicate<CardRules> IS_ENCHANTMENT = coreType(true, CardCoreType.Enchantment);
public static final Predicate<CardRules> IS_ENCHANTMENT = Predicates.coreType(true,
CardCoreType.Enchantment);
/** The Constant isNonLand. */
public static final Predicate<CardRules> IS_NON_LAND = coreType(false, CardCoreType.Land);
public static final Predicate<CardRules> IS_NON_LAND = Predicates.coreType(false, CardCoreType.Land);
/** The Constant isNonCreatureSpell. */
public static final Predicate<CardRules> IS_NON_CREATURE_SPELL = Predicate.compose(IS_CREATURE,
PredicatesOp.NOR, IS_LAND);
public static final Predicate<CardRules> IS_NON_CREATURE_SPELL = Predicate.compose(Presets.IS_CREATURE,
PredicatesOp.NOR, Presets.IS_LAND);
/** The Constant isWhite. */
public static final Predicate<CardRules> IS_WHITE = isColor(CardColor.WHITE);
public static final Predicate<CardRules> IS_WHITE = Predicates.isColor(CardColor.WHITE);
/** The Constant isBlue. */
public static final Predicate<CardRules> IS_BLUE = isColor(CardColor.BLUE);
public static final Predicate<CardRules> IS_BLUE = Predicates.isColor(CardColor.BLUE);
/** The Constant isBlack. */
public static final Predicate<CardRules> IS_BLACK = isColor(CardColor.BLACK);
public static final Predicate<CardRules> IS_BLACK = Predicates.isColor(CardColor.BLACK);
/** The Constant isRed. */
public static final Predicate<CardRules> IS_RED = isColor(CardColor.RED);
public static final Predicate<CardRules> IS_RED = Predicates.isColor(CardColor.RED);
/** The Constant isGreen. */
public static final Predicate<CardRules> IS_GREEN = isColor(CardColor.GREEN);
public static final Predicate<CardRules> IS_GREEN = Predicates.isColor(CardColor.GREEN);
/** The Constant isColorless. */
public static final Predicate<CardRules> IS_COLORLESS = hasCntColors((byte) 0);
public static final Predicate<CardRules> IS_COLORLESS = Predicates.hasCntColors((byte) 0);
/** The Constant isMulticolor. */
public static final Predicate<CardRules> IS_MULTICOLOR = hasAtLeastCntColors((byte) 2);
public static final Predicate<CardRules> IS_MULTICOLOR = Predicates.hasAtLeastCntColors((byte) 2);
/** The Constant colors. */
public static final List<Predicate<CardRules>> COLORS = new ArrayList<Predicate<CardRules>>();
static {
COLORS.add(IS_WHITE);
COLORS.add(IS_BLUE);
COLORS.add(IS_BLACK);
COLORS.add(IS_RED);
COLORS.add(IS_GREEN);
COLORS.add(IS_COLORLESS);
Presets.COLORS.add(Presets.IS_WHITE);
Presets.COLORS.add(Presets.IS_BLUE);
Presets.COLORS.add(Presets.IS_BLACK);
Presets.COLORS.add(Presets.IS_RED);
Presets.COLORS.add(Presets.IS_GREEN);
Presets.COLORS.add(Presets.IS_COLORLESS);
}
/** The Constant constantTrue. */
@@ -813,22 +826,23 @@ public final class CardRules {
// Think twice before using these, since rarity is a prop of printed
// card.
/** The Constant isInLatestSetCommon. */
public static final Predicate<CardRules> IS_IN_LATEST_SET_COMMON = rarityInCardsLatestSet(true,
public static final Predicate<CardRules> IS_IN_LATEST_SET_COMMON = Predicates.rarityInCardsLatestSet(true,
CardRarity.Common);
/** The Constant isInLatestSetUncommon. */
public static final Predicate<CardRules> IS_IN_LATEST_SET_UNCOMMON = rarityInCardsLatestSet(true,
CardRarity.Uncommon);
public static final Predicate<CardRules> IS_IN_LATEST_SET_UNCOMMON = Predicates.rarityInCardsLatestSet(
true, CardRarity.Uncommon);
/** The Constant isInLatestSetRare. */
public static final Predicate<CardRules> IS_IN_LATEST_SET_RARE = rarityInCardsLatestSet(true, CardRarity.Rare);
public static final Predicate<CardRules> IS_IN_LATEST_SET_RARE = Predicates.rarityInCardsLatestSet(true,
CardRarity.Rare);
/** The Constant isInLatestSetMythicRare. */
public static final Predicate<CardRules> IS_IN_LATEST_SET_MYTHIC_RARE = rarityInCardsLatestSet(true,
CardRarity.MythicRare);
public static final Predicate<CardRules> IS_IN_LATEST_SET_MYTHIC_RARE = Predicates.rarityInCardsLatestSet(
true, CardRarity.MythicRare);
/** The Constant isInLatestSetSpecial. */
public static final Predicate<CardRules> IS_IN_LATEST_SET_SPECIAL = rarityInCardsLatestSet(true,
public static final Predicate<CardRules> IS_IN_LATEST_SET_SPECIAL = Predicates.rarityInCardsLatestSet(true,
CardRarity.Special);
}
}

View File

@@ -63,8 +63,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getAbilityDealDamage() {
final SpellAbility abDamage = new AbilityActivated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
final SpellAbility abDamage = new AbilityActivated(this.abilityFactory.getHostCard(),
this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -7560349014757367722L;
@Override
@@ -74,7 +74,8 @@ public class AbilityFactoryDealDamage {
@Override
public String getStackDescription() {
return AbilityFactoryDealDamage.this.dealDamageStackDescription(AbilityFactoryDealDamage.this.abilityFactory, this);
return AbilityFactoryDealDamage.this.dealDamageStackDescription(
AbilityFactoryDealDamage.this.abilityFactory, this);
}
@Override
@@ -84,8 +85,8 @@ public class AbilityFactoryDealDamage {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this,
mandatory);
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
}
}; // Ability_Activated
@@ -100,7 +101,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getSpellDealDamage() {
final SpellAbility spDealDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility spDealDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = 7239608350643325111L;
@Override
@@ -111,7 +113,8 @@ public class AbilityFactoryDealDamage {
@Override
public String getStackDescription() {
return AbilityFactoryDealDamage.this.dealDamageStackDescription(AbilityFactoryDealDamage.this.abilityFactory, this);
return AbilityFactoryDealDamage.this.dealDamageStackDescription(
AbilityFactoryDealDamage.this.abilityFactory, this);
}
@Override
@@ -132,7 +135,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getDrawbackDealDamage() {
final SpellAbility dbDealDamage = new AbilitySub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) {
final SpellAbility dbDealDamage = new AbilitySub(this.abilityFactory.getHostCard(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = 7239608350643325111L;
@Override
@@ -143,7 +147,8 @@ public class AbilityFactoryDealDamage {
@Override
public String getStackDescription() {
return AbilityFactoryDealDamage.this.dealDamageStackDescription(AbilityFactoryDealDamage.this.abilityFactory, this);
return AbilityFactoryDealDamage.this.dealDamageStackDescription(
AbilityFactoryDealDamage.this.abilityFactory, this);
}
@Override
@@ -153,8 +158,8 @@ public class AbilityFactoryDealDamage {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this,
mandatory);
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
}
}; // Drawback
@@ -428,7 +433,8 @@ public class AbilityFactoryDealDamage {
* a boolean.
* @return a {@link forge.Card} object.
*/
private Card dealDamageChooseTgtC(final SpellAbility saMe, final int d, final boolean noPrevention, final Player pl, final boolean mandatory) {
private Card dealDamageChooseTgtC(final SpellAbility saMe, final int d, final boolean noPrevention,
final Player pl, final boolean mandatory) {
final Target tgt = this.abilityFactory.getAbTgt();
final Card source = this.abilityFactory.getHostCard();
CardList hPlay = pl.getCardsIn(Zone.Battlefield);
@@ -594,8 +600,8 @@ public class AbilityFactoryDealDamage {
*/
private boolean damageChooseNontargeted(final SpellAbility saMe, final int dmg) {
// TODO: Improve circumstances where the Defined Damage is unwanted
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), this.abilityFactory.getMapParams()
.get("Defined"), saMe);
final ArrayList<Object> objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), this.abilityFactory
.getMapParams().get("Defined"), saMe);
for (final Object o : objects) {
if (o instanceof Card) {
@@ -643,7 +649,8 @@ public class AbilityFactoryDealDamage {
while (tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe)) {
// TODO: Consider targeting the planeswalker
if (tgt.canTgtCreature()) {
final Card c = this.dealDamageChooseTgtC(saMe, dmg, noPrevention, AllZone.getComputerPlayer(), mandatory);
final Card c = this.dealDamageChooseTgtC(saMe, dmg, noPrevention, AllZone.getComputerPlayer(),
mandatory);
if (c != null) {
tgt.addTarget(c);
continue;
@@ -806,8 +813,8 @@ public class AbilityFactoryDealDamage {
*/
public final SpellAbility getAbilityDamageAll() {
final SpellAbility abDamageAll = new AbilityActivated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
final SpellAbility abDamageAll = new AbilityActivated(this.abilityFactory.getHostCard(),
this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -1831356710492849854L;
private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory;
@@ -828,8 +835,8 @@ public class AbilityFactoryDealDamage {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this,
mandatory);
return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory,
this, mandatory);
}
};
@@ -844,7 +851,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getSpellDamageAll() {
final SpellAbility spDamageAll = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility spDamageAll = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = 8004957182752984818L;
private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory;
private final HashMap<String, String> params = this.af.getMapParams();
@@ -881,7 +889,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getDrawbackDamageAll() {
final SpellAbility dbDamageAll = new AbilitySub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) {
final SpellAbility dbDamageAll = new AbilitySub(this.abilityFactory.getHostCard(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -6169562107675964474L;
private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory;
@@ -903,8 +912,8 @@ public class AbilityFactoryDealDamage {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this,
mandatory);
return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory,
this, mandatory);
}
};
@@ -1220,8 +1229,8 @@ public class AbilityFactoryDealDamage {
*/
public final SpellAbility getAbilityEachDamage() {
final SpellAbility abEachDamage = new AbilityActivated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
final SpellAbility abEachDamage = new AbilityActivated(this.abilityFactory.getHostCard(),
this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -1831356710492849854L;
private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory;
@@ -1242,8 +1251,8 @@ public class AbilityFactoryDealDamage {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this,
mandatory);
return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI(
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
}
};
@@ -1258,7 +1267,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getSpellEachDamage() {
final SpellAbility spEachDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility spEachDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = 8004957182752984818L;
private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory;
private final HashMap<String, String> params = this.af.getMapParams();
@@ -1295,7 +1305,8 @@ public class AbilityFactoryDealDamage {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getDrawbackEachDamage() {
final SpellAbility dbEachDamage = new AbilitySub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) {
final SpellAbility dbEachDamage = new AbilitySub(this.abilityFactory.getHostCard(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -6169562107675964474L;
private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory;
@@ -1317,8 +1328,8 @@ public class AbilityFactoryDealDamage {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this,
mandatory);
return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI(
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
}
};
@@ -1348,7 +1359,7 @@ public class AbilityFactoryDealDamage {
ArrayList<Player> tgtPlayers;
Target tgt = af.getAbTgt();
final Target tgt = af.getAbTgt();
if (tgt != null) {
tgtPlayers = tgt.getTargetPlayers();
} else {
@@ -1364,11 +1375,11 @@ public class AbilityFactoryDealDamage {
if (params.containsKey("DamageDesc")) {
dmg = params.get("DamageDesc");
} else {
dmg += getNumDamage(sa) + " damage";
dmg += this.getNumDamage(sa) + " damage";
}
sb.append("Each ").append(desc).append(" deals ").append(dmg).append(" to ");
for (Player p : tgtPlayers) {
for (final Player p : tgtPlayers) {
sb.append(p);
}
if (params.containsKey("DefinedCards")) {
@@ -1395,7 +1406,7 @@ public class AbilityFactoryDealDamage {
sa.getTarget().addTarget(AllZone.getHumanPlayer());
}
return shouldTgtP(sa, getNumDamage(sa), false);
return this.shouldTgtP(sa, this.getNumDamage(sa), false);
}
private boolean eachDamageDoTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
@@ -1407,7 +1418,7 @@ public class AbilityFactoryDealDamage {
return sa.getSubAbility().doTrigger(mandatory);
}
return eachDamageCanPlayAI(af, sa);
return this.eachDamageCanPlayAI(af, sa);
}
private void eachDamageResolve(final AbilityFactory af, final SpellAbility sa) {
@@ -1429,8 +1440,8 @@ public class AbilityFactoryDealDamage {
final boolean targeted = (this.abilityFactory.getAbTgt() != null);
for (final Object o : tgts) {
for (Card source : sources) {
int dmg = CardFactoryUtil.xCount(source, card.getSVar("X"));
for (final Card source : sources) {
final int dmg = CardFactoryUtil.xCount(source, card.getSVar("X"));
// System.out.println(source+" deals "+dmg+" damage to "+o.toString());
if (o instanceof Card) {
final Card c = (Card) o;
@@ -1448,8 +1459,8 @@ public class AbilityFactoryDealDamage {
}
if (params.containsKey("DefinedCards") && params.get("DefinedCards").equals("Self")) {
for (Card source : sources) {
int dmg = CardFactoryUtil.xCount(source, card.getSVar("X"));
for (final Card source : sources) {
final int dmg = CardFactoryUtil.xCount(source, card.getSVar("X"));
// System.out.println(source+" deals "+dmg+" damage to "+source);
source.addDamage(dmg, source);
}

View File

@@ -93,7 +93,8 @@ public class AbilityFactoryPump {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getSpellPump() {
final SpellAbility spPump = new Spell(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility spPump = new Spell(this.hostCard, this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = 42244224L;
@Override
@@ -123,7 +124,8 @@ public class AbilityFactoryPump {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getAbilityPump() {
final SpellAbility abPump = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility abPump = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -1118592153328758083L;
@Override
@@ -368,7 +370,8 @@ public class AbilityFactoryPump {
list = list.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return !c.hasAnyKeyword(keywords); // don't add duplicate
return !c.hasAnyKeyword(keywords); // don't add
// duplicate
// negative keywords
}
});
@@ -530,8 +533,10 @@ public class AbilityFactoryPump {
* @return a boolean.
*/
private boolean pumpTgtAI(final SpellAbility sa, final int defense, final int attack, final boolean mandatory) {
if (!mandatory && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
&& !(this.abilityFactory.isCurse() && ((defense < 0) || !this.containsCombatRelevantKeyword(this.keywords)))) {
if (!mandatory
&& AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
&& !(this.abilityFactory.isCurse() && ((defense < 0) || !this
.containsCombatRelevantKeyword(this.keywords)))) {
return false;
}
@@ -970,7 +975,8 @@ public class AbilityFactoryPump {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getAbilityPumpAll() {
final SpellAbility abPumpAll = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility abPumpAll = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -8299417521903307630L;
@Override
@@ -990,7 +996,8 @@ public class AbilityFactoryPump {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryPump.this.pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory);
return AbilityFactoryPump.this
.pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory);
}
}; // SpellAbility
@@ -1006,7 +1013,8 @@ public class AbilityFactoryPump {
* @return a {@link forge.card.spellability.SpellAbility} object.
*/
public final SpellAbility getSpellPumpAll() {
final SpellAbility spPumpAll = new Spell(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) {
final SpellAbility spPumpAll = new Spell(this.hostCard, this.abilityFactory.getAbCost(),
this.abilityFactory.getAbTgt()) {
private static final long serialVersionUID = -4055467978660824703L;
@Override
@@ -1056,7 +1064,8 @@ public class AbilityFactoryPump {
@Override
public boolean doTrigger(final boolean mandatory) {
return AbilityFactoryPump.this.pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory);
return AbilityFactoryPump.this
.pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory);
}
}; // SpellAbility
@@ -1167,28 +1176,25 @@ public class AbilityFactoryPump {
}
if (this.params.containsKey("PumpZone")) {
for(String zone : this.params.get("PumpZone").split(",")) {
for (final String zone : this.params.get("PumpZone").split(",")) {
affectedZones.add(Zone.valueOf(zone));
}
}
else {
} else {
affectedZones.add(Zone.Battlefield);
}
list = new CardList();
if ((tgtPlayers == null) || tgtPlayers.isEmpty()) {
for(Zone zone : affectedZones) {
for (final Zone zone : affectedZones) {
list.addAll(AllZoneUtil.getCardsIn(zone));
}
} else {
for(Zone zone : affectedZones) {
for (final Zone zone : affectedZones) {
list.addAll(tgtPlayers.get(0).getCardsIn(zone));
}
}
String valid = "";
if (this.params.containsKey("ValidCards")) {
valid = this.params.get("ValidCards");
@@ -1204,7 +1210,7 @@ public class AbilityFactoryPump {
// only pump things in the affected zones.
boolean found = false;
for(Zone z : affectedZones) {
for (final Zone z : affectedZones) {
if (c.isInZone(z)) {
found = true;
break;

View File

@@ -373,14 +373,14 @@ public final class AbilityFactoryReveal {
// - for when it exists
} else if (params.containsKey("RevealOptional")) {
String question = "Reveal: ";
for (Card c : top) {
for (final Card c : top) {
question += c + " ";
}
if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) {
GuiUtils.getChoice("Revealing cards from library", top.toArray());
// AllZone.getGameAction().revealToCopmuter(top.toArray());
if (params.containsKey("RememberRevealed")) {
for (Card one : top) {
for (final Card one : top) {
host.addRemembered(one);
}
}

View File

@@ -193,30 +193,23 @@ public class AbilityFactorySetState {
continue;
}
}
if(abilityFactory.getMapParams().containsKey("Transform"))
{
if (abilityFactory.getMapParams().containsKey("Transform")) {
if (tgt.getCurState().equals("Transformed")) {
tgt.setState("Original");
}
else if(tgt.hasAlternateState() && tgt.getCurState().equals("Original")) {
} else if (tgt.hasAlternateState() && tgt.getCurState().equals("Original")) {
if (tgt.isDoubleFaced()) {
tgt.setState("Transformed");
}
}
}
else if(abilityFactory.getMapParams().containsKey("Flip"))
{
} else if (abilityFactory.getMapParams().containsKey("Flip")) {
if (tgt.getCurState().equals("Flipped")) {
tgt.setState("Original");
}
else if(tgt.hasAlternateState()) {
} else if (tgt.hasAlternateState()) {
if (tgt.isFlip() && tgt.getCurState().equals("Original")) {
tgt.setState("Flipped");
}
}
}
else
{
} else {
tgt.setState(abilityFactory.getMapParams().get("NewState"));
}
}
@@ -365,32 +358,26 @@ public class AbilityFactorySetState {
for (int i = 0; i < list.size(); i++) {
String mode = list.get(i).getCurState();
if (list.get(i).isDoubleFaced()) {
if(list.get(i).getCurState().equals("Original"))
{
if (list.get(i).getCurState().equals("Original")) {
mode = "Transformed";
}
else {
} else {
mode = "Original";
}
if (list.get(i).setState(mode) && remChanged) {
card.addRemembered(list.get(i));
}
}
else if(list.get(i).isFlip()) {
if(list.get(i).getCurState().equals("Original"))
{
} else if (list.get(i).isFlip()) {
if (list.get(i).getCurState().equals("Original")) {
mode = "Flipped";
}
else if(list.get(i).getCurState().equals("Flipped")){
} else if (list.get(i).getCurState().equals("Flipped")) {
mode = "Original";
}
if (list.get(i).setState(mode) && remChanged) {
card.addRemembered(list.get(i));
}
}
else {
} else {
if (list.get(i).setState(abilityFactory.getMapParams().get("NewState")) && remChanged) {
card.addRemembered(list.get(i));
}

View File

@@ -1098,8 +1098,9 @@ public class AbilityFactoryZoneAffecting {
for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
if (mode.equals("Defined")) {
final ArrayList<Card> toDiscard = AbilityFactory.getDefinedCards(host, params.get("DefinedCards"), sa);
for (Card c : toDiscard) {
final ArrayList<Card> toDiscard = AbilityFactory.getDefinedCards(host, params.get("DefinedCards"),
sa);
for (final Card c : toDiscard) {
discarded.addAll(p.discard(c, sa));
}
if (params.containsKey("RememberDiscarded")) {

View File

@@ -171,8 +171,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
CardFactoryUtil.copyCharacteristics(in, out);
if (in.hasAlternateState()) {
String curState = in.getCurState();
for(String state : in.getStates()) {
final String curState = in.getCurState();
for (final String state : in.getStates()) {
in.setState(state);
out.setState(state);
CardFactoryUtil.copyCharacteristics(in, out);
@@ -503,7 +503,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
}
if (card.hasAlternateState()) {
for(String state : card.getStates()) {
for (final String state : card.getStates()) {
card.setState(state);
this.addAbilityFactoryAbilities(card);
stAbs = card.getStaticAbilityStrings();
@@ -1252,57 +1252,44 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} // *************** END ************ END **************************
// *************** START *********** START **************************
/*else if (cardName.equals("Pithing Needle")) {
final SpellAbility ability = new AbilityStatic(card, "0") {
@Override
public void resolve() {
String cardName = "";
if (card.getController().isHuman()) {
final List<String> cards = new ArrayList<String>();
for (final CardPrinted c : CardDb.instance().getAllUniqueCards()) {
cards.add(c.getName());
}
Collections.sort(cards);
// use standard forge's list selection dialog
final ListChooser<String> c = new ListChooser<String>(
"Name a card to disable activation of its non-mana abilities", 1, 1, cards);
c.show();
// still missing a listener to display the card preview
// in the right
cardName = c.getSelectedValue();
} else {
// AI CODE WILL EVENTUALLY GO HERE!
}
card.setSVar("PithingTarget", cardName);
card.setChosenType(cardName);
}
}; // ability
ability.setStackDescription("As Pithing Needle enters the battlefield, name a card.");
final Command intoPlay = new Command() {
private static final long serialVersionUID = 2266471224097876143L;
@Override
public void execute() {
AllZone.getStack().addSimultaneousStackEntry(ability);
}
};
final Command leavesPlay = new Command() {
private static final long serialVersionUID = 7079781778752377760L;
@Override
public void execute() {
card.setSVar("Pithing Target", "");
}
};
card.addComesIntoPlayCommand(intoPlay);
card.addLeavesPlayCommand(leavesPlay);
}*/ // *************** END ************ END **************************
/*
* else if (cardName.equals("Pithing Needle")) { final SpellAbility
* ability = new AbilityStatic(card, "0") {
*
* @Override public void resolve() { String cardName = ""; if
* (card.getController().isHuman()) { final List<String> cards = new
* ArrayList<String>(); for (final CardPrinted c :
* CardDb.instance().getAllUniqueCards()) { cards.add(c.getName()); }
* Collections.sort(cards);
*
* // use standard forge's list selection dialog final
* ListChooser<String> c = new ListChooser<String>(
* "Name a card to disable activation of its non-mana abilities", 1, 1,
* cards); c.show(); // still missing a listener to display the card
* preview // in the right cardName = c.getSelectedValue(); } else { //
* AI CODE WILL EVENTUALLY GO HERE! } card.setSVar("PithingTarget",
* cardName); card.setChosenType(cardName); } }; // ability
* ability.setStackDescription
* ("As Pithing Needle enters the battlefield, name a card."); final
* Command intoPlay = new Command() {
*
* private static final long serialVersionUID = 2266471224097876143L;
*
* @Override public void execute() {
* AllZone.getStack().addSimultaneousStackEntry(ability);
*
* } };
*
* final Command leavesPlay = new Command() {
*
* private static final long serialVersionUID = 7079781778752377760L;
*
* @Override public void execute() { card.setSVar("Pithing Target", "");
* } };
*
* card.addComesIntoPlayCommand(intoPlay);
* card.addLeavesPlayCommand(leavesPlay); }
*/// *************** END ************ END **************************
// *************** START *********** START **************************
else if (cardName.equals("Phyrexian Processor")) {

View File

@@ -536,8 +536,8 @@ public class CardFactoryCreatures {
@Override
public boolean canPlayAI() {
return (!AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Artifact").isEmpty()
&& AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand));
return (!AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Artifact").isEmpty() && AllZone
.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand));
}
});
card.addComesIntoPlayCommand(intoPlay);
@@ -2257,8 +2257,8 @@ public class CardFactoryCreatures {
CardFactoryUtil.copyCharacteristics(cloned, card);
this.grantExtras();
//If target is a flipped card, also copy the flipped state.
// If target is a flipped card, also copy the flipped
// state.
if (copyTarget[0].isFlip()) {
cloned.setState("Flipped");
cloned.setImageFilename(CardUtil.buildFilename(cloned));
@@ -2270,12 +2270,10 @@ public class CardFactoryCreatures {
card.setFlip(true);
card.setState("Original");
}
else {
} else {
card.setFlip(false);
}
}
AllZone.getGameAction().moveToPlay(card);
@@ -2289,32 +2287,37 @@ public class CardFactoryCreatures {
+ "creature's color. If you do, this creature gains this ability.";
card.addIntrinsicKeyword(keyword);
card.addColor("U");
}
else if(cardName.equals("Quicksilver Gargantuan")) {
} else if (cardName.equals("Quicksilver Gargantuan")) {
card.setBaseAttack(7);
card.setBaseDefense(7);
}
else if(cardName.equals("Phyrexian Metamorph")) {
} else if (cardName.equals("Phyrexian Metamorph")) {
card.addType("Artifact");
}
else if(cardName.equals("Phantasmal Image")) {
Trigger t = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ BecomesTarget | ValidTarget$ Card.Self | Execute$ TrigSac | TriggerDescription$ When this creature becomes the target of a spell or ability, sacrifice it.", card, true);
} else if (cardName.equals("Phantasmal Image")) {
final Trigger t = forge.card.trigger.TriggerHandler
.parseTrigger(
"Mode$ BecomesTarget | ValidTarget$ Card.Self | Execute$ TrigSac | TriggerDescription$ When this creature becomes the target of a spell or ability, sacrifice it.",
card, true);
card.addTrigger(t);
card.setSVar("TrigSac", "AB$Sacrifice | Cost$ 0 | Defined$ Self");
}
else if(cardName.equals("Evil Twin")) {
AbilityFactory af = new AbilityFactory();
} else if (cardName.equals("Evil Twin")) {
final AbilityFactory af = new AbilityFactory();
SpellAbility ab = af.getAbility("AB$Destroy | Cost$ U B T | ValidTgts$ Creature.sameName | TgtPrompt$ Select target creature with the same name. | SpellDescription$ Destroy target creature with the same name as this creature.", card);
final SpellAbility ab = af
.getAbility(
"AB$Destroy | Cost$ U B T | ValidTgts$ Creature.sameName | TgtPrompt$ Select target creature with the same name. | SpellDescription$ Destroy target creature with the same name as this creature.",
card);
card.addSpellAbility(ab);
}
else if(cardName.equals("Sakashima the Impostor")) {
AbilityFactory af = new AbilityFactory();
SpellAbility ab = af.getAbility("AB$DelayedTrigger | Cost$ 2 U U | Mode$ Phase | Phase$ End of Turn | Execute$ TrigReturnSak | TriggerDescription$ Return CARDNAME to it's owners hand at the beginning of the next end step.",card);
} else if (cardName.equals("Sakashima the Impostor")) {
final AbilityFactory af = new AbilityFactory();
final SpellAbility ab = af
.getAbility(
"AB$DelayedTrigger | Cost$ 2 U U | Mode$ Phase | Phase$ End of Turn | Execute$ TrigReturnSak | TriggerDescription$ Return CARDNAME to it's owners hand at the beginning of the next end step.",
card);
card.addSpellAbility(ab);
card.setSVar("TrigReturnSak","AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Battlefield | Destination$ Hand");
card.setSVar("TrigReturnSak",
"AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Battlefield | Destination$ Hand");
card.setName("Sakashima the Impostor");
card.addType("Legendary");
}
@@ -2609,8 +2612,8 @@ public class CardFactoryCreatures {
theCost = "R";
}
final SpellAbility finalAb = new AbilityActivated(card, new Cost(theCost, cardName, true), new Target(
card, "Select target creature.", "Creature")) {
final SpellAbility finalAb = new AbilityActivated(card, new Cost(theCost, cardName, true), new Target(card,
"Select target creature.", "Creature")) {
private static final long serialVersionUID = 2391351140880148283L;
@Override
@@ -2694,11 +2697,12 @@ public class CardFactoryCreatures {
ability.setStackDescription(sbStack.toString());
} // *************** END ************ END **************************
// *************** START *********** START **************************
else if (cardName.equals("Ixidron")) {
Trigger tfdTrigger = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, turn all other nontoken creatures face down. (They're 2/2 creatures.)", card, true);
final Trigger tfdTrigger = forge.card.trigger.TriggerHandler
.parseTrigger(
"Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, turn all other nontoken creatures face down. (They're 2/2 creatures.)",
card, true);
final SpellAbility triggeredAbility = new Ability(card, "0") {
@Override
@@ -2707,12 +2711,12 @@ public class CardFactoryCreatures {
creatsInPlay = creatsInPlay.filter(new CardListFilter() {
@Override
public boolean addCard(Card c) {
public boolean addCard(final Card c) {
return !c.isToken() && !c.equals(card);
}
});
for(Card c : creatsInPlay) {
for (final Card c : creatsInPlay) {
c.turnFaceDown();
}
}

View File

@@ -15,7 +15,6 @@ import forge.AllZone;
import forge.AllZoneUtil;
import forge.ButtonUtil;
import forge.Card;
import forge.CardColor;
import forge.CardList;
import forge.CardListFilter;
import forge.CardUtil;
@@ -958,11 +957,6 @@ public class CardFactoryUtil {
*/
public static AbilityActivated abilityMorphUp(final Card sourceCard, final Cost cost, final String orgManaCost,
final int a, final int d) {
// final String player = sourceCard.getController();
// final String manaCost = cost;
final int attack = a;
final int defense = d;
final String origManaCost = orgManaCost;
final AbilityActivated morphUp = new AbilityActivated(sourceCard, cost, null) {
private static final long serialVersionUID = -3663857013937085953L;
@@ -978,9 +972,6 @@ public class CardFactoryUtil {
@Override
public boolean canPlay() {
// unMorphing a card is a Special Action, and not affected by
// Linvala
Card c = sourceCard;
return sourceCard.getController().equals(this.getActivatingPlayer()) && sourceCard.isFaceDown()
&& AllZoneUtil.isCardInPlay(sourceCard);
}
@@ -2306,15 +2297,13 @@ public class CardFactoryUtil {
* canBeTargetedBy.
* </p>
*
* @param ability
* a {@link forge.card.spellability.SpellAbility} object.
* @param target
* a {@link forge.Card} object.
* @param c the c
* @return a boolean.
*/
/*public static boolean canBeTargetedBy(final SpellAbility ability, final Card target) {
return target.canBeTargetedBy(ability);
}*/
/*
* public static boolean canBeTargetedBy(final SpellAbility ability, final
* Card target) { return target.canBeTargetedBy(ability); }
*/
/**
* <p>
@@ -2334,90 +2323,56 @@ public class CardFactoryUtil {
* canBeTargetedBy.
* </p>
*
* @param spell
* a {@link forge.Card} object.
* @param target
* a {@link forge.Card} object.
* @param card the card
* @param target a {@link forge.Card} object.
* @return a boolean.
*/
/*public static boolean canBeTargetedBy(final Card spell, final Card target) {
if (target == null) {
return true;
}
if (target.isImmutable()) {
return false;
}
final PlayerZone zone = AllZone.getZoneOf(target);
// if zone is null, it means its on the stack
if ((zone == null) || !zone.is(Constant.Zone.Battlefield)) {
// targets not in play, can normally be targeted
return true;
}
if (AllZoneUtil.isCardInPlay("Spellbane Centaur", target.getController()) && target.isCreature()
&& spell.isBlue()) {
return false;
}
if (target.getName().equals("Gaea's Revenge") && !spell.isGreen()) {
return false;
}
if (CardFactoryUtil.hasProtectionFrom(spell, target)) {
return false;
}
if (target.getKeyword() != null) {
final ArrayList<String> list = target.getKeyword();
String kw = "";
for (int i = 0; i < list.size(); i++) {
kw = list.get(i);
if (kw.equals("Shroud")) {
return false;
}
if (kw.equals("Hexproof")) {
if (!spell.getController().equals(target.getController())) {
return false;
}
}
if (kw.equals("CARDNAME can't be the target of Aura spells.") || kw.equals("CARDNAME can't be enchanted.")) {
if (spell.isAura() && spell.isSpell()) {
return false;
}
}
if (kw.equals("CARDNAME can't be the target of red spells or abilities from red sources.")) {
if (spell.isRed()) {
return false;
}
}
if (kw.equals("CARDNAME can't be the target of black spells.")) {
if (spell.isBlack() && spell.isSpell()) {
return false;
}
}
if (kw.equals("CARDNAME can't be the target of blue spells.")) {
if (spell.isBlue() && spell.isSpell()) {
return false;
}
}
if (kw.equals("CARDNAME can't be the target of spells.")) {
if (spell.isSpell()) {
return false;
}
}
}
}
return true;
}*/
/*
* public static boolean canBeTargetedBy(final Card spell, final Card
* target) { if (target == null) { return true; }
*
* if (target.isImmutable()) { return false; }
*
* final PlayerZone zone = AllZone.getZoneOf(target); // if zone is null, it
* means its on the stack if ((zone == null) ||
* !zone.is(Constant.Zone.Battlefield)) { // targets not in play, can
* normally be targeted return true; }
*
* if (AllZoneUtil.isCardInPlay("Spellbane Centaur", target.getController())
* && target.isCreature() && spell.isBlue()) { return false; }
*
* if (target.getName().equals("Gaea's Revenge") && !spell.isGreen()) {
* return false; }
*
* if (CardFactoryUtil.hasProtectionFrom(spell, target)) { return false; }
*
* if (target.getKeyword() != null) { final ArrayList<String> list =
* target.getKeyword();
*
* String kw = ""; for (int i = 0; i < list.size(); i++) { kw = list.get(i);
* if (kw.equals("Shroud")) { return false; }
*
* if (kw.equals("Hexproof")) { if
* (!spell.getController().equals(target.getController())) { return false; }
* }
*
* if (kw.equals("CARDNAME can't be the target of Aura spells.") ||
* kw.equals("CARDNAME can't be enchanted.")) { if (spell.isAura() &&
* spell.isSpell()) { return false; } }
*
* if (kw.equals(
* "CARDNAME can't be the target of red spells or abilities from red sources."
* )) { if (spell.isRed()) { return false; } }
*
* if (kw.equals("CARDNAME can't be the target of black spells.")) { if
* (spell.isBlack() && spell.isSpell()) { return false; } }
*
* if (kw.equals("CARDNAME can't be the target of blue spells.")) { if
* (spell.isBlue() && spell.isSpell()) { return false; } }
*
* if (kw.equals("CARDNAME can't be the target of spells.")) { if
* (spell.isSpell()) { return false; } } } } return true; }
*/
// does "target" have protection from "card"?
/**
@@ -2544,9 +2499,10 @@ public class CardFactoryUtil {
return true;
}
if (sa.isSpell() && !zone.is(Zone.Battlefield) && (c.hasStartOfKeyword("May be played")
|| (c.hasStartOfKeyword("Flashback") && zone.is(Zone.Graveyard)))
&& restrictZone.equals(Zone.Hand)) {
if (sa.isSpell()
&& !zone.is(Zone.Battlefield)
&& (c.hasStartOfKeyword("May be played") || (c.hasStartOfKeyword("Flashback") && zone
.is(Zone.Graveyard))) && restrictZone.equals(Zone.Hand)) {
return true;
}
}
@@ -2640,7 +2596,7 @@ public class CardFactoryUtil {
}
if (sq[0].contains("DomainPlayer")) {
CardList someCards = new CardList();
final CardList someCards = new CardList();
someCards.addAll(players.get(0).getCardsIn(Zone.Battlefield));
final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" };
@@ -2698,7 +2654,6 @@ public class CardFactoryUtil {
return CardFactoryUtil.doXMath(n, m, source);
}
/**
* parseSVar TODO - flesh out javadoc for this method.
*
@@ -4218,8 +4173,8 @@ public class CardFactoryUtil {
CardFactoryUtil.copyCharacteristics(sim, c);
if (sim.hasAlternateState()) {
String origState = sim.getCurState();
for(String state : sim.getStates()) {
final String origState = sim.getCurState();
for (final String state : sim.getStates()) {
c.addAlternateState(state);
c.setState(state);
sim.setState(state);
@@ -4720,8 +4675,8 @@ public class CardFactoryUtil {
sbHaunter.append("Destination$ Graveyard | ValidCard$ Card.Self | ");
sbHaunter.append("Static$ True | Secondary$ True | TriggerDescription$ Blank");
final Trigger haunterDies = forge.card.trigger.TriggerHandler.parseTrigger(
sbHaunter.toString(), card, true);
final Trigger haunterDies = forge.card.trigger.TriggerHandler
.parseTrigger(sbHaunter.toString(), card, true);
final Ability haunterDiesWork = new Ability(card, "0") {
@Override
@@ -4796,8 +4751,7 @@ public class CardFactoryUtil {
sbDies.append("ValidCard$ Creature.HauntedBy | Execute$ ").append(hauntSVarName);
sbDies.append(" | TriggerDescription$ ").append(hauntDescription);
final Trigger hauntedDies = forge.card.trigger.TriggerHandler.parseTrigger(
sbDies.toString(), card, true);
final Trigger hauntedDies = forge.card.trigger.TriggerHandler.parseTrigger(sbDies.toString(), card, true);
// Third, create the trigger that runs when the haunting creature
// enters the battlefield
@@ -4806,8 +4760,7 @@ public class CardFactoryUtil {
sbETB.append(hauntSVarName).append(" | Secondary$ True | TriggerDescription$ ");
sbETB.append(hauntDescription);
final Trigger haunterETB = forge.card.trigger.TriggerHandler.parseTrigger(
sbETB.toString(), card, true);
final Trigger haunterETB = forge.card.trigger.TriggerHandler.parseTrigger(sbETB.toString(), card, true);
// Fourth, create a trigger that removes the haunting status if the
// haunter leaves the exile
@@ -4816,8 +4769,8 @@ public class CardFactoryUtil {
sbUnExiled.append("ValidCard$ Card.Self | Static$ True | Secondary$ True | ");
sbUnExiled.append("TriggerDescription$ Blank");
final Trigger haunterUnExiled = forge.card.trigger.TriggerHandler.parseTrigger(
sbUnExiled.toString(), card, true);
final Trigger haunterUnExiled = forge.card.trigger.TriggerHandler.parseTrigger(sbUnExiled.toString(), card,
true);
final Ability haunterUnExiledWork = new Ability(card, "0") {
@Override

View File

@@ -271,8 +271,8 @@ public class CostMana extends CostPart {
this.manaCost = InputPayManaCostUtil.activateManaAbility(sa, card, this.manaCost);
if (this.manaCost.isPaid()) {
if (!colorsPaid.contains(this.manaCost.getColorsPaid())) {
colorsPaid += this.manaCost.getColorsPaid();
if (!this.colorsPaid.contains(this.manaCost.getColorsPaid())) {
this.colorsPaid += this.manaCost.getColorsPaid();
}
this.manaCost = new ManaCost(Integer.toString(numX));
this.xPaid++;
@@ -295,8 +295,8 @@ public class CostMana extends CostPart {
this.stop();
payment.getCard().setXManaCostPaid(this.xPaid);
payment.paidCost(costMana);
payment.getCard().setColorsPaid(colorsPaid);
payment.getCard().setSunburstValue(colorsPaid.length());
payment.getCard().setColorsPaid(this.colorsPaid);
payment.getCard().setSunburstValue(this.colorsPaid.length());
}
};
@@ -394,15 +394,18 @@ public class CostMana extends CostPart {
CostUtil.setInput(CostMana.inputPayXMana(sa, payment, costMana, costMana.getXMana()));
}
//If this is a spell with convoke, re-tap all creatures used for it.
//This is done to make sure Taps triggers go off at the right time
//(i.e. AFTER cost payment, they are tapped previously as well so that
//any mana tapabilities can't be used in payment as well as being tapped for convoke)
// If this is a spell with convoke, re-tap all creatures used
// for it.
// This is done to make sure Taps triggers go off at the right
// time
// (i.e. AFTER cost payment, they are tapped previously as well
// so that
// any mana tapabilities can't be used in payment as well as
// being tapped for convoke)
if(sa.getTappedForConvoke() != null)
{
if (sa.getTappedForConvoke() != null) {
AllZone.getTriggerHandler().suppressMode("Untaps");
for(Card c : sa.getTappedForConvoke()) {
for (final Card c : sa.getTappedForConvoke()) {
c.untap();
c.tap();
}
@@ -414,11 +417,11 @@ public class CostMana extends CostPart {
@Override
public void selectButtonCancel() {
//If we're paying for a spell with convoke, untap all creatures used for it.
if(sa.getTappedForConvoke() != null)
{
// If we're paying for a spell with convoke, untap all creatures
// used for it.
if (sa.getTappedForConvoke() != null) {
AllZone.getTriggerHandler().suppressMode("Untaps");
for(Card c : sa.getTappedForConvoke()) {
for (final Card c : sa.getTappedForConvoke()) {
c.untap();
}
AllZone.getTriggerHandler().clearSuppression("Untaps");

View File

@@ -7,7 +7,6 @@ import forge.AllZoneUtil;
import forge.Card;
import forge.CardList;
import forge.Constant.Zone;
import forge.Player;
import forge.card.cost.Cost;
import forge.card.cost.CostPayment;
import forge.card.staticability.StaticAbility;

View File

@@ -700,8 +700,7 @@ public abstract class SpellAbility {
* Getter for the field <code>restrictions</code>.
* </p>
*
* @return a {@link forge.card.spellability.SpellAbilityRestriction}
* object.
* @return a {@link forge.card.spellability.SpellAbilityRestriction} object.
*/
public SpellAbilityRestriction getRestrictions() {
return this.restrictions;
@@ -1051,6 +1050,7 @@ public abstract class SpellAbility {
* </p>
*
* Extrinsic or Intrinsic:
*
* @param s
* a {@link java.lang.String} object.
*/
@@ -1682,53 +1682,69 @@ public abstract class SpellAbility {
}
/**
* Gets the ability.
*
* @return the ability
*/
public static int getAbility() {
return ABILITY;
return SpellAbility.ABILITY;
}
/**
* Gets the spell.
*
* @return the spell
*/
public static int getSpell() {
return SPELL;
return SpellAbility.SPELL;
}
/**
* Gets the chosen target.
*
* @return the chosenTarget
*/
public Target getChosenTarget() {
return chosenTarget;
return this.chosenTarget;
}
/**
* Sets the chosen target.
*
* @param chosenTarget the chosenTarget to set
*/
public void setChosenTarget(Target chosenTarget) {
public void setChosenTarget(final Target chosenTarget) {
this.chosenTarget = chosenTarget; // TODO: Add 0 to parameter's name.
}
public void addTappedForConvoke(Card c)
{
if(tappedForConvoke == null)
{
tappedForConvoke = new CardList();
/**
* Adds the tapped for convoke.
*
* @param c the c
*/
public void addTappedForConvoke(final Card c) {
if (this.tappedForConvoke == null) {
this.tappedForConvoke = new CardList();
}
tappedForConvoke.add(c);
this.tappedForConvoke.add(c);
}
public CardList getTappedForConvoke()
{
return tappedForConvoke;
/**
* Gets the tapped for convoke.
*
* @return the tapped for convoke
*/
public CardList getTappedForConvoke() {
return this.tappedForConvoke;
}
public void clearTappedForConvoke()
{
if(tappedForConvoke != null)
{
tappedForConvoke.clear();
/**
* Clear tapped for convoke.
*/
public void clearTappedForConvoke() {
if (this.tappedForConvoke != null) {
this.tappedForConvoke.clear();
}
}

View File

@@ -614,9 +614,8 @@ public class Target {
* hasCandidates.
* </p>
*
* @param isTargeted
* Check Valid Candidates and Targeting
*
* @param sa the sa
* @param isTargeted Check Valid Candidates and Targeting
* @return a boolean.
*/
public final boolean hasCandidates(final SpellAbility sa, final boolean isTargeted) {

View File

@@ -25,7 +25,7 @@ public class StaticAbility {
private boolean temporarilySuppressed = false;
/** The suppressed. */
private boolean suppressed = false;
private final boolean suppressed = false;
/**
* <p>
@@ -293,13 +293,11 @@ public class StaticAbility {
* the mode
* @param card
* the card
* @param activator
* the activator
* @param sa
* @param spellAbility
* the ability
* @return true, if successful
*/
public final boolean applyAbility(final String mode, final Card card, SpellAbility sa) {
public final boolean applyAbility(final String mode, final Card card, final SpellAbility spellAbility) {
// don't apply the ability if it hasn't got the right mode
if (!this.mapParams.get("Mode").equals(mode)) {
@@ -311,11 +309,11 @@ public class StaticAbility {
}
if (mode.equals("CantBeActivated")) {
return StaticAbilityCantBeCast.applyCantBeActivatedAbility(this, card, sa);
return StaticAbilityCantBeCast.applyCantBeActivatedAbility(this, card, spellAbility);
}
if (mode.equals("CantTarget")) {
return StaticAbilityCantTarget.applyCantTargetAbility(this, card, sa);
return StaticAbilityCantTarget.applyCantTargetAbility(this, card, spellAbility);
}
return false;
@@ -331,36 +329,36 @@ public class StaticAbility {
Zone effectZone = Zone.Battlefield; // default
if (mapParams.containsKey("EffectZone")) {
if (this.mapParams.containsKey("EffectZone")) {
effectZone = Zone.smartValueOf(this.mapParams.get("EffectZone"));
}
if ((effectZone != null) && (!hostCard.isInZone(effectZone) || hostCard.isPhasedOut())) {
if ((effectZone != null) && (!this.hostCard.isInZone(effectZone) || this.hostCard.isPhasedOut())) {
return false;
}
if (mapParams.containsKey("Threshold") && !controller.hasThreshold()) {
if (this.mapParams.containsKey("Threshold") && !controller.hasThreshold()) {
return false;
}
if (mapParams.containsKey("Hellbent") && !controller.hasHellbent()) {
if (this.mapParams.containsKey("Hellbent") && !controller.hasHellbent()) {
return false;
}
if (mapParams.containsKey("Metalcraft") && !controller.hasMetalcraft()) {
if (this.mapParams.containsKey("Metalcraft") && !controller.hasMetalcraft()) {
return false;
}
if (mapParams.containsKey("PlayerTurn") && !AllZone.getPhase().isPlayerTurn(controller)) {
if (this.mapParams.containsKey("PlayerTurn") && !AllZone.getPhase().isPlayerTurn(controller)) {
return false;
}
if (mapParams.containsKey("OpponentTurn") && !AllZone.getPhase().isPlayerTurn(controller.getOpponent())) {
if (this.mapParams.containsKey("OpponentTurn") && !AllZone.getPhase().isPlayerTurn(controller.getOpponent())) {
return false;
}
if (mapParams.containsKey("Phases")) {
String phases = mapParams.get("Phases");
if (this.mapParams.containsKey("Phases")) {
String phases = this.mapParams.get("Phases");
if (phases.contains("->")) {
// If phases lists a Range, split and Build Activate String

View File

@@ -46,20 +46,20 @@ public class StaticAbilityCantBeCast {
}
/**
* TODO Write javadoc for this method.
* Applies Cant Be Activated ability.
*
* @param stAb
* @param staticAbility
* a StaticAbility
* @param card
* the card
* @param activator
* the activator
* @param spellAbility
* a SpellAbility
* @return true, if successful
*/
public static boolean applyCantBeActivatedAbility(final StaticAbility stAb, final Card card, SpellAbility sa) {
final HashMap<String, String> params = stAb.getMapParams();
final Card hostCard = stAb.getHostCard();
final Player activator = sa.getActivatingPlayer();
public static boolean applyCantBeActivatedAbility(final StaticAbility staticAbility, final Card card, final SpellAbility spellAbility) {
final HashMap<String, String> params = staticAbility.getMapParams();
final Card hostCard = staticAbility.getHostCard();
final Player activator = spellAbility.getActivatingPlayer();
if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
@@ -71,7 +71,7 @@ public class StaticAbilityCantBeCast {
return false;
}
if (params.containsKey("NonMana") && sa instanceof AbilityMana) {
if (params.containsKey("NonMana") && (spellAbility instanceof AbilityMana)) {
return false;
}

View File

@@ -4,8 +4,8 @@ import java.util.HashMap;
import forge.Card;
import forge.Constant;
import forge.Player;
import forge.Constant.Zone;
import forge.Player;
import forge.card.spellability.SpellAbility;
/**
@@ -13,11 +13,19 @@ import forge.card.spellability.SpellAbility;
*/
public class StaticAbilityCantTarget {
public static boolean applyCantTargetAbility(final StaticAbility stAb, final Card card, SpellAbility sa) {
final HashMap<String, String> params = stAb.getMapParams();
final Card hostCard = stAb.getHostCard();
final Card source = sa.getSourceCard();
final Player activator = sa.getActivatingPlayer();
/**
* Apply can't target ability.
*
* @param staticAbility the static ability
* @param card the card
* @param spellAbility the spell Ability
* @return true, if successful
*/
public static boolean applyCantTargetAbility(final StaticAbility staticAbility, final Card card, final SpellAbility spellAbility) {
final HashMap<String, String> params = staticAbility.getMapParams();
final Card hostCard = staticAbility.getHostCard();
final Card source = spellAbility.getSourceCard();
final Player activator = spellAbility.getActivatingPlayer();
if (params.containsKey("AffectedZone")) {
if (!card.isInZone(Zone.smartValueOf(params.get("AffectedZone")))) {
@@ -29,7 +37,7 @@ public class StaticAbilityCantTarget {
}
}
if (params.containsKey("Spell") && !sa.isSpell()) {
if (params.containsKey("Spell") && !spellAbility.isSpell()) {
return false;
}
@@ -48,7 +56,6 @@ public class StaticAbilityCantTarget {
return false;
}
return true;
}

View File

@@ -65,7 +65,7 @@ public class Generate2ColorDeck {
this.notColors.add("green");
if (Singletons.getModel().getPreferences().isDeckGenSingletons()) {
maxDuplicates = 1;
this.maxDuplicates = 1;
}
if (clr1.equals("AI")) {
@@ -226,7 +226,7 @@ public class Generate2ColorDeck {
Card c = cr12.get(this.r.nextInt(cr12.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) {
c = cr12.get(this.r.nextInt(cr12.size()));
lc++;
}
@@ -244,7 +244,7 @@ public class Generate2ColorDeck {
Card c = sp12.get(this.r.nextInt(sp12.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) {
c = sp12.get(this.r.nextInt(sp12.size()));
lc++;
}
@@ -393,7 +393,7 @@ public class Generate2ColorDeck {
}
private class CCnt {
private String color;
private final String color;
private int count;
public CCnt(final String clr, final int cnt) {

View File

@@ -68,7 +68,7 @@ public class Generate3ColorDeck {
this.notColors.add("green");
if (Singletons.getModel().getPreferences().isDeckGenSingletons()) {
maxDuplicates = 1;
this.maxDuplicates = 1;
}
if (clr1.equals("AI")) {
@@ -252,7 +252,7 @@ public class Generate3ColorDeck {
Card c = cr123.get(this.r.nextInt(cr123.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) {
c = cr123.get(this.r.nextInt(cr123.size()));
lc++;
}
@@ -270,7 +270,7 @@ public class Generate3ColorDeck {
Card c = sp123.get(this.r.nextInt(sp123.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) {
c = sp123.get(this.r.nextInt(sp123.size()));
lc++;
}
@@ -420,7 +420,7 @@ public class Generate3ColorDeck {
}
private class CCnt {
private String color;
private final String color;
private int count;
public CCnt(final String clr, final int cnt) {

View File

@@ -94,7 +94,7 @@ public class Generate5ColorDeck {
this.notColors.remove(this.color5);
if (Singletons.getModel().getPreferences().isDeckGenSingletons()) {
maxDuplicates = 1;
this.maxDuplicates = 1;
}
this.dl = GenerateDeckUtil.getDualLandList("WUBRG");
@@ -278,7 +278,7 @@ public class Generate5ColorDeck {
Card c = cr12345.get(this.r.nextInt(cr12345.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) {
c = cr12345.get(this.r.nextInt(cr12345.size()));
lc++;
}
@@ -296,7 +296,7 @@ public class Generate5ColorDeck {
Card c = sp12345.get(this.r.nextInt(sp12345.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) {
c = sp12345.get(this.r.nextInt(sp12345.size()));
lc++;
}

View File

@@ -317,7 +317,7 @@ public class GenerateThemeDeck {
class CCnt {
/** The Color. */
private String color;
private final String color;
/** The Count. */
private int count;
@@ -344,7 +344,7 @@ public class GenerateThemeDeck {
class Grp {
/** The Cardnames. */
private ArrayList<String> cardnames = new ArrayList<String>();
private final ArrayList<String> cardnames = new ArrayList<String>();
/** The Max cnt. */
private int maxCnt;

View File

@@ -2,7 +2,6 @@ package forge.gui.deckeditor;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFileChooser;
@@ -38,13 +37,13 @@ public class CardPanelHeavy extends CardPanelBase {
// Controls to show card details
/** The detail. */
private CardDetailPanel detail = new CardDetailPanel(null);
private final CardDetailPanel detail = new CardDetailPanel(null);
/** The picture. */
private CardPanel picture = new CardPanel(null);
private final CardPanel picture = new CardPanel(null);
/** The picture view panel. */
private ViewPanel pictureViewPanel = new ViewPanel();
private final ViewPanel pictureViewPanel = new ViewPanel();
// fake card to allow picture changes
/** The c card hq. */
@@ -151,8 +150,7 @@ public class CardPanelHeavy extends CardPanelBase {
final Card cur = this.picture.getCard();
if (cur.isInAlternateState()) {
cur.setState("Original");
}
else {
} else {
if (cur.isFlip()) {
cur.setState("Flipped");
}
@@ -165,35 +163,6 @@ public class CardPanelHeavy extends CardPanelBase {
this.detail.setCard(cur);
}
/**
* <p>
* changePictureButton_actionPerformed. Removed Oct 25 2011 - Hellfish
* </p>
*
* @param e
* a {@link java.awt.event.ActionEvent} object.
*/
private void changePictureButtonActionPerformed(final ActionEvent e) {
if (this.cCardHQ != null) {
final File file = this.getImportFilename();
if (file != null) {
final String fileName = GuiDisplayUtil.cleanString(this.cCardHQ.getName()) + ".jpg";
final File base = ForgeProps.getFile(NewConstants.IMAGE_BASE);
final File f = new File(base, fileName);
f.delete();
try {
org.apache.commons.io.FileUtils.copyFile(file, f);
} catch (final IOException e1) {
// TODO Auto-generated catch block ignores the exception,
// but sends it to System.err and probably forge.log.
e1.printStackTrace();
}
this.setCard(this.cCardHQ);
}
}
}
/**
* <p>
* getImportFilename.
@@ -220,7 +189,7 @@ public class CardPanelHeavy extends CardPanelBase {
}
/** The dck filter. */
private FileFilter dckFilter = new FileFilter() {
private final FileFilter dckFilter = new FileFilter() {
@Override
public boolean accept(final File f) {

View File

@@ -23,7 +23,7 @@ public class CardPanelLite extends CardPanelBase {
// Controls to show card details
/** The detail. */
private CardDetailPanel detail = new CardDetailPanel(null);
private final CardDetailPanel detail = new CardDetailPanel(null);
private final CardPicturePanel picture = new CardPicturePanel(null);
private final JButton bChangeState = new JButton();
@@ -111,11 +111,9 @@ public class CardPanelLite extends CardPanelBase {
final Card cur = this.detail.getCard();
if (cur != null) {
if (cur.isDoubleFaced()) {
if(cur.getCurState().equals("Transformed"))
{
if (cur.getCurState().equals("Transformed")) {
cur.setState("Original");
}
else {
} else {
cur.setState("Transformed");
}
}

View File

@@ -282,8 +282,8 @@ public final class DeckEditorCommon extends DeckEditorBase {
*/
@Override
protected Predicate<InventoryItem> buildFilter() {
final Predicate<CardPrinted> cardFilter =
Predicate.and(this.getFilterBoxes().buildFilter(), this.filterNameTypeSet.buildFilter());
final Predicate<CardPrinted> cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(),
this.filterNameTypeSet.buildFilter());
return Predicate.instanceOf(cardFilter, CardPrinted.class);
}
@@ -400,17 +400,20 @@ public final class DeckEditorCommon extends DeckEditorBase {
}
/**
* Gets the custom menu.
*
* @return the customMenu
*/
public DeckEditorCommonMenu getCustomMenu() {
return customMenu;
return this.customMenu;
}
/**
* @param customMenu
* the customMenu to set
* Sets the custom menu.
*
* @param customMenu the customMenu to set
*/
public void setCustomMenu(DeckEditorCommonMenu customMenu) {
public void setCustomMenu(final DeckEditorCommonMenu customMenu) {
this.customMenu = customMenu; // TODO: Add 0 to parameter's name.
}

View File

@@ -110,7 +110,9 @@ public class InputPayManaCost extends Input {
AllZone.getStack().add(this.spell);
}
} else {
this.manaCost = manaCostToPay;//AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost));
this.manaCost = manaCostToPay; // AllZone.getGameAction().getSpellCostChange(sa,
// new
// ManaCost(this.originalManaCost));
}
} else {
this.manaCost = new ManaCost(sa.getManaCost());
@@ -212,20 +214,22 @@ public class InputPayManaCost extends Input {
AllZone.getInputControl().resetInput();
}
//If this is a spell with convoke, re-tap all creatures used for it.
// If this is a spell with convoke, re-tap all creatures used for
// it.
// This is done to make sure Taps triggers go off at the right time
//(i.e. AFTER cost payment, they are tapped previously as well so that
//any mana tapabilities can't be used in payment as well as being tapped for convoke)
// (i.e. AFTER cost payment, they are tapped previously as well so
// that
// any mana tapabilities can't be used in payment as well as being
// tapped for convoke)
if(spell.getTappedForConvoke() != null)
{
if (this.spell.getTappedForConvoke() != null) {
AllZone.getTriggerHandler().suppressMode("Untaps");
for(Card c : spell.getTappedForConvoke()) {
for (final Card c : this.spell.getTappedForConvoke()) {
c.untap();
c.tap();
}
AllZone.getTriggerHandler().clearSuppression("Untaps");
spell.clearTappedForConvoke();
this.spell.clearTappedForConvoke();
}
}
}
@@ -234,14 +238,13 @@ public class InputPayManaCost extends Input {
@Override
public final void selectButtonCancel() {
// If this is a spell with convoke, untap all creatures used for it.
if(spell.getTappedForConvoke() != null)
{
if (this.spell.getTappedForConvoke() != null) {
AllZone.getTriggerHandler().suppressMode("Untaps");
for(Card c : spell.getTappedForConvoke()) {
for (final Card c : this.spell.getTappedForConvoke()) {
c.untap();
}
AllZone.getTriggerHandler().clearSuppression("Untaps");
spell.clearTappedForConvoke();
this.spell.clearTappedForConvoke();
}
this.resetManaCost();

View File

@@ -79,15 +79,33 @@ public class FPanel extends JPanel {
}
}
public void setPreferredSize(int w, int h) {
setPreferredSize(new Dimension(w,h));
/**
* Sets the preferred size.
*
* @param w the w
* @param h the h
*/
public void setPreferredSize(final int w, final int h) {
this.setPreferredSize(new Dimension(w, h));
}
public void setMaximumSize(int w, int h) {
setMaximumSize(new Dimension(w,h));
/**
* Sets the maximum size.
*
* @param w the w
* @param h the h
*/
public void setMaximumSize(final int w, final int h) {
this.setMaximumSize(new Dimension(w, h));
}
public void setMinimumSize(int w, int h) {
setMinimumSize(new Dimension(w,h));
/**
* Sets the minimum size.
*
* @param w the w
* @param h the h
*/
public void setMinimumSize(final int w, final int h) {
this.setMinimumSize(new Dimension(w, h));
}
}

View File

@@ -415,7 +415,7 @@ public class FSkin {
/**
* Background of progress bar, "unfilled" state.
* @return {@link javax.awt.Color} clrProgress1
* @return {@link java.awt.Color} clrProgress1
*/
public Color getClrProgress1() {
return clrProgress1;
@@ -431,7 +431,7 @@ public class FSkin {
/**
* Text of progress bar, "unfilled" state.
* @return {@link javax.awt.Color} clrProgress1
* @return {@link java.awt.Color} clrProgress1
*/
public Color getClrProgress2() {
return clrProgress2;
@@ -447,7 +447,7 @@ public class FSkin {
/**
* Background of progress bar, "filled" state.
* @return {@link javax.awt.Color} clrProgress1
* @return {@link java.awt.Color} clrProgress1
*/
public Color getClrProgress3() {
return clrProgress3;
@@ -463,7 +463,7 @@ public class FSkin {
/**
* Text of progress bar, "filled" state.
* @return {@link javax.awt.Color} clrProgress1
* @return {@link java.awt.Color} clrProgress1
*/
public Color getClrProgress4() {
return clrProgress4;

View File

@@ -176,10 +176,6 @@ public final class CardPrinted implements Comparable<CardPrinted>, InventoryItem
* the rare
* @param index
* the index
* @param isAlt
* the is alt
* @param isDF
* the is df
* @return the card printed
*/
static CardPrinted build(final CardRules c, final String set, final CardRarity rare, final int index) {

View File

@@ -19,7 +19,7 @@ import java.util.List;
public class ForgePreferences extends Preferences {
/** The new gui. */
private boolean newGui;
private final boolean newGui;
/** The stack ai land. */
private boolean stackAiLand;
@@ -246,388 +246,515 @@ public class ForgePreferences extends Preferences {
}
/**
* Checks if is stack ai land.
*
* @return the stackAiLand
*/
public boolean isStackAiLand() {
return stackAiLand;
return this.stackAiLand;
}
/**
* Sets the stack ai land.
*
* @param stackAiLand the stackAiLand to set
*/
public void setStackAiLand(boolean stackAiLand) {
public void setStackAiLand(final boolean stackAiLand) {
this.stackAiLand = stackAiLand; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is milling loss condition.
*
* @return the millingLossCondition
*/
public boolean isMillingLossCondition() {
return millingLossCondition;
return this.millingLossCondition;
}
/**
* Sets the milling loss condition.
*
* @param millingLossCondition the millingLossCondition to set
*/
public void setMillingLossCondition(boolean millingLossCondition) {
this.millingLossCondition = millingLossCondition; // TODO: Add 0 to parameter's name.
public void setMillingLossCondition(final boolean millingLossCondition) {
this.millingLossCondition = millingLossCondition; // TODO: Add 0 to
// parameter's name.
}
/**
* Checks if is b ai begin combat.
*
* @return the bAIBeginCombat
*/
public boolean isbAIBeginCombat() {
return bAIBeginCombat;
return this.bAIBeginCombat;
}
/**
* Sets the b ai begin combat.
*
* @param bAIBeginCombat the bAIBeginCombat to set
*/
public void setbAIBeginCombat(boolean bAIBeginCombat) {
this.bAIBeginCombat = bAIBeginCombat; // TODO: Add 0 to parameter's name.
public void setbAIBeginCombat(final boolean bAIBeginCombat) {
this.bAIBeginCombat = bAIBeginCombat; // TODO: Add 0 to parameter's
// name.
}
/**
* Checks if is b ai end combat.
*
* @return the bAIEndCombat
*/
public boolean isbAIEndCombat() {
return bAIEndCombat;
return this.bAIEndCombat;
}
/**
* Sets the b ai end combat.
*
* @param bAIEndCombat the bAIEndCombat to set
*/
public void setbAIEndCombat(boolean bAIEndCombat) {
public void setbAIEndCombat(final boolean bAIEndCombat) {
this.bAIEndCombat = bAIEndCombat; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is b ai upkeep.
*
* @return the bAIUpkeep
*/
public boolean isbAIUpkeep() {
return bAIUpkeep;
return this.bAIUpkeep;
}
/**
* Sets the b ai upkeep.
*
* @param bAIUpkeep the bAIUpkeep to set
*/
public void setbAIUpkeep(boolean bAIUpkeep) {
public void setbAIUpkeep(final boolean bAIUpkeep) {
this.bAIUpkeep = bAIUpkeep; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is b ai draw.
*
* @return the bAIDraw
*/
public boolean isbAIDraw() {
return bAIDraw;
return this.bAIDraw;
}
/**
* Sets the b ai draw.
*
* @param bAIDraw the bAIDraw to set
*/
public void setbAIDraw(boolean bAIDraw) {
public void setbAIDraw(final boolean bAIDraw) {
this.bAIDraw = bAIDraw; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is b aieot.
*
* @return the bAIEOT
*/
public boolean isbAIEOT() {
return bAIEOT;
return this.bAIEOT;
}
/**
* Sets the b aieot.
*
* @param bAIEOT the bAIEOT to set
*/
public void setbAIEOT(boolean bAIEOT) {
public void setbAIEOT(final boolean bAIEOT) {
this.bAIEOT = bAIEOT; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is b human begin combat.
*
* @return the bHumanBeginCombat
*/
public boolean isbHumanBeginCombat() {
return bHumanBeginCombat;
return this.bHumanBeginCombat;
}
/**
* Sets the b human begin combat.
*
* @param bHumanBeginCombat the bHumanBeginCombat to set
*/
public void setbHumanBeginCombat(boolean bHumanBeginCombat) {
this.bHumanBeginCombat = bHumanBeginCombat; // TODO: Add 0 to parameter's name.
public void setbHumanBeginCombat(final boolean bHumanBeginCombat) {
this.bHumanBeginCombat = bHumanBeginCombat; // TODO: Add 0 to
// parameter's name.
}
/**
* Checks if is b human draw.
*
* @return the bHumanDraw
*/
public boolean isbHumanDraw() {
return bHumanDraw;
return this.bHumanDraw;
}
/**
* Sets the b human draw.
*
* @param bHumanDraw the bHumanDraw to set
*/
public void setbHumanDraw(boolean bHumanDraw) {
public void setbHumanDraw(final boolean bHumanDraw) {
this.bHumanDraw = bHumanDraw; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is upload draft ai.
*
* @return the uploadDraftAI
*/
public boolean isUploadDraftAI() {
return uploadDraftAI;
return this.uploadDraftAI;
}
/**
* Sets the upload draft ai.
*
* @param uploadDraftAI the uploadDraftAI to set
*/
public void setUploadDraftAI(boolean uploadDraftAI) {
public void setUploadDraftAI(final boolean uploadDraftAI) {
this.uploadDraftAI = uploadDraftAI; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is b human end combat.
*
* @return the bHumanEndCombat
*/
public boolean isbHumanEndCombat() {
return bHumanEndCombat;
return this.bHumanEndCombat;
}
/**
* Sets the b human end combat.
*
* @param bHumanEndCombat the bHumanEndCombat to set
*/
public void setbHumanEndCombat(boolean bHumanEndCombat) {
this.bHumanEndCombat = bHumanEndCombat; // TODO: Add 0 to parameter's name.
public void setbHumanEndCombat(final boolean bHumanEndCombat) {
this.bHumanEndCombat = bHumanEndCombat; // TODO: Add 0 to parameter's
// name.
}
/**
* Checks if is b human eot.
*
* @return the bHumanEOT
*/
public boolean isbHumanEOT() {
return bHumanEOT;
return this.bHumanEOT;
}
/**
* Sets the b human eot.
*
* @param bHumanEOT the bHumanEOT to set
*/
public void setbHumanEOT(boolean bHumanEOT) {
public void setbHumanEOT(final boolean bHumanEOT) {
this.bHumanEOT = bHumanEOT; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is b human upkeep.
*
* @return the bHumanUpkeep
*/
public boolean isbHumanUpkeep() {
return bHumanUpkeep;
return this.bHumanUpkeep;
}
/**
* Sets the b human upkeep.
*
* @param bHumanUpkeep the bHumanUpkeep to set
*/
public void setbHumanUpkeep(boolean bHumanUpkeep) {
public void setbHumanUpkeep(final boolean bHumanUpkeep) {
this.bHumanUpkeep = bHumanUpkeep; // TODO: Add 0 to parameter's name.
}
/**
* Gets the bugz name.
*
* @return the bugzName
*/
public String getBugzName() {
return bugzName;
return this.bugzName;
}
/**
* Sets the bugz name.
*
* @param bugzName the bugzName to set
*/
public void setBugzName(String bugzName) {
public void setBugzName(final String bugzName) {
this.bugzName = bugzName; // TODO: Add 0 to parameter's name.
}
/**
* Gets the bugz pwd.
*
* @return the bugzPwd
*/
public String getBugzPwd() {
return bugzPwd;
return this.bugzPwd;
}
/**
* Sets the bugz pwd.
*
* @param bugzPwd the bugzPwd to set
*/
public void setBugzPwd(String bugzPwd) {
public void setBugzPwd(final String bugzPwd) {
this.bugzPwd = bugzPwd; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is rand c foil.
*
* @return the randCFoil
*/
public boolean isRandCFoil() {
return randCFoil;
return this.randCFoil;
}
/**
* Sets the rand c foil.
*
* @param randCFoil the randCFoil to set
*/
public void setRandCFoil(boolean randCFoil) {
public void setRandCFoil(final boolean randCFoil) {
this.randCFoil = randCFoil; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is developer mode.
*
* @return the developerMode
*/
public boolean isDeveloperMode() {
return developerMode;
return this.developerMode;
}
/**
* Sets the developer mode.
*
* @param developerMode the developerMode to set
*/
public void setDeveloperMode(boolean developerMode) {
public void setDeveloperMode(final boolean developerMode) {
this.developerMode = developerMode; // TODO: Add 0 to parameter's name.
}
/**
* Gets the laf.
*
* @return the laf
*/
public String getLaf() {
return laf;
return this.laf;
}
/**
* Sets the laf.
*
* @param laf the laf to set
*/
public void setLaf(String laf) {
public void setLaf(final String laf) {
this.laf = laf; // TODO: Add 0 to parameter's name.
}
/**
* Gets the skin.
*
* @return the skin
*/
public String getSkin() {
return skin;
return this.skin;
}
/**
* Sets the skin.
*
* @param skin the skin to set
*/
public void setSkin(String skin) {
public void setSkin(final String skin) {
this.skin = skin; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is laf fonts.
*
* @return the lafFonts
*/
public boolean isLafFonts() {
return lafFonts;
return this.lafFonts;
}
/**
* Sets the laf fonts.
*
* @param lafFonts the lafFonts to set
*/
public void setLafFonts(boolean lafFonts) {
public void setLafFonts(final boolean lafFonts) {
this.lafFonts = lafFonts; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is scale larger than original.
*
* @return the scaleLargerThanOriginal
*/
public boolean isScaleLargerThanOriginal() {
return scaleLargerThanOriginal;
return this.scaleLargerThanOriginal;
}
/**
* Sets the scale larger than original.
*
* @param scaleLargerThanOriginal the scaleLargerThanOriginal to set
*/
public void setScaleLargerThanOriginal(boolean scaleLargerThanOriginal) {
this.scaleLargerThanOriginal = scaleLargerThanOriginal; // TODO: Add 0 to parameter's name.
public void setScaleLargerThanOriginal(final boolean scaleLargerThanOriginal) {
this.scaleLargerThanOriginal = scaleLargerThanOriginal; // TODO: Add 0
// to
// parameter's
// name.
}
/**
* Checks if is card overlay.
*
* @return the cardOverlay
*/
public boolean isCardOverlay() {
return cardOverlay;
return this.cardOverlay;
}
/**
* Sets the card overlay.
*
* @param cardOverlay the cardOverlay to set
*/
public void setCardOverlay(boolean cardOverlay) {
public void setCardOverlay(final boolean cardOverlay) {
this.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's name.
}
/**
* Checks if is deck gen singletons.
*
* @return true, if is deck gen singletons
*/
public boolean isDeckGenSingletons() {
return deckGenSingletons;
return this.deckGenSingletons;
}
public void setDeckGenSingletons(boolean deckSingletons) {
/**
* Sets the deck gen singletons.
*
* @param deckSingletons the new deck gen singletons
*/
public void setDeckGenSingletons(final boolean deckSingletons) {
this.deckGenSingletons = deckSingletons;
}
/**
* Checks if is deck gen rmv artifacts.
*
* @return the deckGenRmvArtifacts
*/
public boolean isDeckGenRmvArtifacts() {
return deckGenRmvArtifacts;
return this.deckGenRmvArtifacts;
}
/**
* Sets the deck gen rmv artifacts.
*
* @param deckGenRmvArtifacts the deckGenRmvArtifacts to set
*/
public void setDeckGenRmvArtifacts(boolean deckGenRmvArtifacts) {
this.deckGenRmvArtifacts = deckGenRmvArtifacts; // TODO: Add 0 to parameter's name.
public void setDeckGenRmvArtifacts(final boolean deckGenRmvArtifacts) {
this.deckGenRmvArtifacts = deckGenRmvArtifacts; // TODO: Add 0 to
// parameter's name.
}
/**
* Checks if is deck gen rmv small.
*
* @return the deckGenRmvSmall
*/
public boolean isDeckGenRmvSmall() {
return deckGenRmvSmall;
return this.deckGenRmvSmall;
}
/**
* Sets the deck gen rmv small.
*
* @param deckGenRmvSmall the deckGenRmvSmall to set
*/
public void setDeckGenRmvSmall(boolean deckGenRmvSmall) {
this.deckGenRmvSmall = deckGenRmvSmall; // TODO: Add 0 to parameter's name.
public void setDeckGenRmvSmall(final boolean deckGenRmvSmall) {
this.deckGenRmvSmall = deckGenRmvSmall; // TODO: Add 0 to parameter's
// name.
}
/**
* Gets the card size.
*
* @return the cardSize
*/
public CardSizeType getCardSize() {
return cardSize;
return this.cardSize;
}
/**
* Sets the card size.
*
* @param cardSize the cardSize to set
*/
public void setCardSize(CardSizeType cardSize) {
public void setCardSize(final CardSizeType cardSize) {
this.cardSize = cardSize; // TODO: Add 0 to parameter's name.
}
/**
* Gets the stack offset.
*
* @return the stackOffset
*/
public StackOffsetType getStackOffset() {
return stackOffset;
return this.stackOffset;
}
/**
* Sets the stack offset.
*
* @param stackOffset the stackOffset to set
*/
public void setStackOffset(StackOffsetType stackOffset) {
public void setStackOffset(final StackOffsetType stackOffset) {
this.stackOffset = stackOffset; // TODO: Add 0 to parameter's name.
}
/**
* Gets the max stack size.
*
* @return the maxStackSize
*/
public int getMaxStackSize() {
return maxStackSize;
return this.maxStackSize;
}
/**
* Sets the max stack size.
*
* @param maxStackSize the maxStackSize to set
*/
public void setMaxStackSize(int maxStackSize) {
public void setMaxStackSize(final int maxStackSize) {
this.maxStackSize = maxStackSize; // TODO: Add 0 to parameter's name.
}

View File

@@ -857,6 +857,7 @@ public final class NewConstants {
/** The TITLE. */
public static final String TITLE = "%s/NewGame/options/generate/title";
/** The Constant SINGLETONS. */
public static final String SINGLETONS = "%s/NewGame/options/generate/singletons";
/** The REMOV e_ small. */

View File

@@ -49,12 +49,12 @@ import forge.Command;
import forge.Constant;
import forge.ConstantStringArrayList;
import forge.FileUtil;
import forge.GuiImportPicture;
import forge.GuiDisplay;
import forge.GuiDownloadQuestImages;
import forge.GuiDownloadPicturesLQ;
import forge.GuiDownloadPrices;
import forge.GuiDownloadQuestImages;
import forge.GuiDownloadSetPicturesLQ;
import forge.GuiImportPicture;
import forge.ImageCache;
import forge.MyRandom;
import forge.PlayerType;
@@ -148,7 +148,8 @@ public class OldGuiNewGame extends JFrame {
private static JCheckBoxMenuItem removeArtifacts = new JCheckBoxMenuItem(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.REMOVE_ARTIFACTS));
/** Constant <code>useLAFFonts</code>. */
private static JCheckBoxMenuItem useLAFFonts = new JCheckBoxMenuItem(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.FONT));
private static JCheckBoxMenuItem useLAFFonts = new JCheckBoxMenuItem(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.FONT));
/** Constant <code>cardOverlay</code>. */
private static JCheckBoxMenuItem cardOverlay = new JCheckBoxMenuItem(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.CARD_OVERLAY));
@@ -245,8 +246,8 @@ public class OldGuiNewGame extends JFrame {
// CARD_SIZES_ACTION,
lookAndFeelAction, this.dnldPricesAction, this.downloadActionLQ, this.downloadActionSetLQ,
this.downloadActionQuest, this.importPicture, this.cardSizesAction, this.cardStackAction,
this.cardStackOffsetAction, this.bugzReporterAction, ErrorViewer.ALL_THREADS_ACTION,
this.aboutAction, this.exitAction };
this.cardStackOffsetAction, this.bugzReporterAction, ErrorViewer.ALL_THREADS_ACTION, this.aboutAction,
this.exitAction };
final JMenu menu = new JMenu(ForgeProps.getLocalized(Menu.TITLE));
for (final Action a : actions) {
menu.add(a);
@@ -259,15 +260,15 @@ public class OldGuiNewGame extends JFrame {
// useLAFFonts.setSelected(false);
// new stuff
final JMenu generatedDeck = new JMenu(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.TITLE));
final JMenu generatedDeck = new JMenu(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.TITLE));
generatedDeck.add(OldGuiNewGame.singletons);
OldGuiNewGame.singletons.setSelected(Singletons.getModel().getPreferences().isDeckGenSingletons());
OldGuiNewGame.singletons.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
Singletons.getModel().getPreferences()
.setDeckGenSingletons(OldGuiNewGame.singletons.isSelected());
Singletons.getModel().getPreferences().setDeckGenSingletons(OldGuiNewGame.singletons.isSelected());
}
});
@@ -416,7 +417,8 @@ public class OldGuiNewGame extends JFrame {
final String sDeckName = JOptionPane.showInputDialog(null,
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_MSG),
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL), JOptionPane.QUESTION_MESSAGE);
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL),
JOptionPane.QUESTION_MESSAGE);
deck.setName(sDeckName);
deck.setPlayerType(PlayerType.HUMAN);
@@ -501,10 +503,12 @@ public class OldGuiNewGame extends JFrame {
*/
/* jPanel2.setBorder(titledBorder1); */
this.setCustomBorder(this.jPanel2, ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.GAMETYPE));
this.setCustomBorder(this.jPanel2,
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.GAMETYPE));
this.jPanel2.setLayout(new MigLayout("align center"));
this.singleRadioButton.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.CONSTRUCTED_TEXT));
this.singleRadioButton.setText(ForgeProps
.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.CONSTRUCTED_TEXT));
this.singleRadioButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
@@ -513,7 +517,8 @@ public class OldGuiNewGame extends JFrame {
});
// sealedRadioButton.setToolTipText("");
this.sealedRadioButton.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SEALED_TEXT));
this.sealedRadioButton
.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SEALED_TEXT));
this.sealedRadioButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
@@ -522,7 +527,8 @@ public class OldGuiNewGame extends JFrame {
});
// draftRadioButton.setToolTipText("");
this.draftRadioButton.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.BOOSTER_TEXT));
this.draftRadioButton
.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.BOOSTER_TEXT));
this.draftRadioButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
@@ -546,13 +552,16 @@ public class OldGuiNewGame extends JFrame {
*/
/* jPanel3.setBorder(titledBorder3); */
this.setCustomBorder(this.jPanel3, ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SETTINGS));
this.setCustomBorder(this.jPanel3,
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SETTINGS));
this.jPanel3.setLayout(new MigLayout("align center"));
// newGuiCheckBox.setText(ForgeProps.getLocalized(NEW_GAME_TEXT.NEW_GUI));
OldGuiNewGame.getSmoothLandCheckBox().setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.AI_LAND));
OldGuiNewGame.getSmoothLandCheckBox().setText(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.AI_LAND));
OldGuiNewGame.getDevModeCheckBox().setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.DEV_MODE));
OldGuiNewGame.getDevModeCheckBox().setText(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.DEV_MODE));
OldGuiNewGame.getDevModeCheckBox().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
@@ -563,9 +572,8 @@ public class OldGuiNewGame extends JFrame {
OldGuiNewGame.getUpldDrftCheckBox().setText("Upload Draft Picks");
OldGuiNewGame.getUpldDrftCheckBox()
.setToolTipText("Your picks and all other participants' picks will help the Forge AI"
+ " make better draft picks.");
OldGuiNewGame.getUpldDrftCheckBox().setToolTipText(
"Your picks and all other participants' picks will help the Forge AI" + " make better draft picks.");
OldGuiNewGame.getUpldDrftCheckBox().addActionListener(new java.awt.event.ActionListener() {
@Override
@@ -576,8 +584,8 @@ public class OldGuiNewGame extends JFrame {
});
OldGuiNewGame.getFoilRandomCheckBox().setText("Random Foiling");
OldGuiNewGame.getFoilRandomCheckBox()
.setToolTipText("Approximately 1:20 cards will appear with foiling effects applied.");
OldGuiNewGame.getFoilRandomCheckBox().setToolTipText(
"Approximately 1:20 cards will appear with foiling effects applied.");
OldGuiNewGame.getFoilRandomCheckBox().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
@@ -1601,8 +1609,8 @@ public class OldGuiNewGame extends JFrame {
area.setEditable(false);
area.setOpaque(false);
JOptionPane.showMessageDialog(null, new JScrollPane(area), ForgeProps.getLocalized(NewConstants.Lang.HowTo.TITLE),
JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, new JScrollPane(area),
ForgeProps.getLocalized(NewConstants.Lang.HowTo.TITLE), JOptionPane.INFORMATION_MESSAGE);
}
}
@@ -1883,27 +1891,30 @@ public class OldGuiNewGame extends JFrame {
* @return the cardOverlay
*/
public static JCheckBoxMenuItem getCardOverlay() {
return cardOverlay;
return OldGuiNewGame.cardOverlay;
}
/**
* @param cardOverlay the cardOverlay to set
* @param cardOverlay
* the cardOverlay to set
*/
public static void setCardOverlay(JCheckBoxMenuItem cardOverlay) {
OldGuiNewGame.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's name.
public static void setCardOverlay(final JCheckBoxMenuItem cardOverlay) {
OldGuiNewGame.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's
// name.
}
/**
* @return the cardScale
*/
public static JCheckBoxMenuItem getCardScale() {
return cardScale;
return OldGuiNewGame.cardScale;
}
/**
* @param cardScale the cardScale to set
* @param cardScale
* the cardScale to set
*/
public static void setCardScale(JCheckBoxMenuItem cardScale) {
public static void setCardScale(final JCheckBoxMenuItem cardScale) {
OldGuiNewGame.cardScale = cardScale; // TODO: Add 0 to parameter's name.
}
@@ -1911,70 +1922,82 @@ public class OldGuiNewGame extends JFrame {
* @return the useLAFFonts
*/
public static JCheckBoxMenuItem getUseLAFFonts() {
return useLAFFonts;
return OldGuiNewGame.useLAFFonts;
}
/**
* @param useLAFFonts the useLAFFonts to set
* @param useLAFFonts
* the useLAFFonts to set
*/
public static void setUseLAFFonts(JCheckBoxMenuItem useLAFFonts) {
OldGuiNewGame.useLAFFonts = useLAFFonts; // TODO: Add 0 to parameter's name.
public static void setUseLAFFonts(final JCheckBoxMenuItem useLAFFonts) {
OldGuiNewGame.useLAFFonts = useLAFFonts; // TODO: Add 0 to parameter's
// name.
}
/**
* @return the smoothLandCheckBox
*/
static JCheckBox getSmoothLandCheckBox() {
return smoothLandCheckBox;
return OldGuiNewGame.smoothLandCheckBox;
}
/**
* @param smoothLandCheckBox the smoothLandCheckBox to set
* @param smoothLandCheckBox
* the smoothLandCheckBox to set
*/
static void setSmoothLandCheckBox(JCheckBox smoothLandCheckBox) {
OldGuiNewGame.smoothLandCheckBox = smoothLandCheckBox; // TODO: Add 0 to parameter's name.
static void setSmoothLandCheckBox(final JCheckBox smoothLandCheckBox) {
OldGuiNewGame.smoothLandCheckBox = smoothLandCheckBox; // TODO: Add 0 to
// parameter's
// name.
}
/**
* @return the devModeCheckBox
*/
public static JCheckBox getDevModeCheckBox() {
return devModeCheckBox;
return OldGuiNewGame.devModeCheckBox;
}
/**
* @param devModeCheckBox the devModeCheckBox to set
* @param devModeCheckBox
* the devModeCheckBox to set
*/
public static void setDevModeCheckBox(JCheckBox devModeCheckBox) {
OldGuiNewGame.devModeCheckBox = devModeCheckBox; // TODO: Add 0 to parameter's name.
public static void setDevModeCheckBox(final JCheckBox devModeCheckBox) {
OldGuiNewGame.devModeCheckBox = devModeCheckBox; // TODO: Add 0 to
// parameter's name.
}
/**
* @return the upldDrftCheckBox
*/
public static JCheckBox getUpldDrftCheckBox() {
return upldDrftCheckBox;
return OldGuiNewGame.upldDrftCheckBox;
}
/**
* @param upldDrftCheckBox the upldDrftCheckBox to set
* @param upldDrftCheckBox
* the upldDrftCheckBox to set
*/
public static void setUpldDrftCheckBox(JCheckBox upldDrftCheckBox) {
OldGuiNewGame.upldDrftCheckBox = upldDrftCheckBox; // TODO: Add 0 to parameter's name.
public static void setUpldDrftCheckBox(final JCheckBox upldDrftCheckBox) {
OldGuiNewGame.upldDrftCheckBox = upldDrftCheckBox; // TODO: Add 0 to
// parameter's name.
}
/**
* @return the foilRandomCheckBox
*/
public static JCheckBox getFoilRandomCheckBox() {
return foilRandomCheckBox;
return OldGuiNewGame.foilRandomCheckBox;
}
/**
* @param foilRandomCheckBox the foilRandomCheckBox to set
* @param foilRandomCheckBox
* the foilRandomCheckBox to set
*/
public static void setFoilRandomCheckBox(JCheckBox foilRandomCheckBox) {
OldGuiNewGame.foilRandomCheckBox = foilRandomCheckBox; // TODO: Add 0 to parameter's name.
public static void setFoilRandomCheckBox(final JCheckBox foilRandomCheckBox) {
OldGuiNewGame.foilRandomCheckBox = foilRandomCheckBox; // TODO: Add 0 to
// parameter's
// name.
}
}

View File

@@ -49,10 +49,10 @@ public class WinLoseFrame extends JFrame {
private FButton btnRestart;
/** The lbl title. */
private JLabel lblTitle;
private final JLabel lblTitle;
/** The lbl stats. */
private JLabel lblStats;
private final JLabel lblStats;
/** The pnl custom. */
private JPanel pnlCustom;
@@ -283,60 +283,62 @@ public class WinLoseFrame extends JFrame {
* @return {@link forge.gui.skin.FButton} btnContinue
*/
public FButton getBtnContinue() {
return btnContinue;
return this.btnContinue;
}
/**
* @param {@link forge.gui.skin.FButton} btnContinue
* @param btnContinue {@link forge.gui.skin.FButton}
*/
public void setBtnContinue(FButton btnContinue0) {
this.btnContinue = btnContinue0;
public void setBtnContinue(final FButton btnContinue) {
this.btnContinue = btnContinue;
}
/**
* @return {@link forge.gui.skin.FButton} btnRestart
*/
public FButton getBtnRestart() {
return btnRestart;
return this.btnRestart;
}
/**
* @param {@link forge.gui.skin.FButton} btnRestart
* @param btnRestart {@link forge.gui.skin.FButton}
*/
public void setBtnRestart(FButton btnRestart0) {
this.btnRestart = btnRestart0;
public void setBtnRestart(final FButton btnRestart) {
this.btnRestart = btnRestart;
}
/**
* @return {@link forge.gui.skin.FButton} btnQuit
*/
public FButton getBtnQuit() {
return btnQuit;
return this.btnQuit;
}
/**
* @param {@link forge.gui.skin.FButton} btnQuit
* @param btnQuit {@link forge.gui.skin.FButton}
*/
public void setBtnQuit(FButton btnQuit0) {
this.btnQuit = btnQuit0;
public void setBtnQuit(final FButton btnQuit) {
this.btnQuit = btnQuit;
}
/**
* The central panel in the win/lose screen, used for
* presenting customized messages and rewards.
* The central panel in the win/lose screen, used for presenting customized
* messages and rewards.
*
* @return {@link javax.swing.JPanel} pnlCustom
*/
public JPanel getPnlCustom() {
return pnlCustom;
return this.pnlCustom;
}
/**
* The central panel in the win/lose screen, used for
* presenting customized messages and rewards.
* @param {@link javax.swing.JPanel} pnlCustom
* The central panel in the win/lose screen, used for presenting customized
* messages and rewards.
*
* @param pnlCustom {@link javax.swing.JPanel}
*/
public void setPnlCustom(JPanel pnlCustom0) {
this.pnlCustom = pnlCustom0;
public void setPnlCustom(final JPanel pnlCustom) {
this.pnlCustom = pnlCustom;
}
private class WinLoseBorder extends AbstractBorder {