mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Chesckstyle fixes in several files
This commit is contained in:
@@ -14,14 +14,14 @@ public class HandSizeOp {
|
||||
/**
|
||||
* <p>Constructor for HandSizeOp.</p>
|
||||
*
|
||||
* @param M a {@link java.lang.String} object.
|
||||
* @param A a int.
|
||||
* @param TS a int.
|
||||
* @param m a {@link java.lang.String} object.
|
||||
* @param a a int.
|
||||
* @param ts a int.
|
||||
*/
|
||||
public HandSizeOp(String M, int A, int TS) {
|
||||
Mode = M;
|
||||
Amount = A;
|
||||
hsTimeStamp = TS;
|
||||
public HandSizeOp(final String m, final int a, final int ts) {
|
||||
Mode = m;
|
||||
Amount = a;
|
||||
hsTimeStamp = ts;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ public class HandSizeOp {
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
return "Mode(" + Mode + ") Amount(" + Amount + ") Timestamp(" + hsTimeStamp + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.net.URL;
|
||||
* @version $Id$
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public class HttpUtil {
|
||||
public class HttpUtil {
|
||||
|
||||
private static final String Boundary = "--7d021a37605f0";
|
||||
|
||||
@@ -27,15 +27,14 @@ public class HttpUtil {
|
||||
* @param sURL a {@link java.lang.String} object.
|
||||
* @param file a {@link java.lang.String} object.
|
||||
*/
|
||||
public void upload(String sURL, String file)
|
||||
{
|
||||
public final void upload(final String sURL, final String file) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(sURL);
|
||||
} catch (MalformedURLException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HttpURLConnection theUrlConnection = null;
|
||||
try {
|
||||
theUrlConnection = (HttpURLConnection) url.openConnection();
|
||||
@@ -44,7 +43,7 @@ public class HttpUtil {
|
||||
}
|
||||
theUrlConnection.setDoOutput(true);
|
||||
theUrlConnection.setDoInput(true);
|
||||
theUrlConnection.setUseCaches(false);
|
||||
theUrlConnection.setUseCaches(false);
|
||||
theUrlConnection.setChunkedStreamingMode(1024);
|
||||
|
||||
theUrlConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + Boundary);
|
||||
@@ -53,7 +52,7 @@ public class HttpUtil {
|
||||
try {
|
||||
httpOut = new DataOutputStream(theUrlConnection.getOutputStream());
|
||||
} catch (IOException e1) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
File f = new File(file);
|
||||
@@ -124,17 +123,18 @@ public class HttpUtil {
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
if (Constant.Runtime.DevMode[0])
|
||||
System.out.println(response.toString());
|
||||
}
|
||||
|
||||
if (Constant.Runtime.DevMode[0]) {
|
||||
System.out.println(response.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getURL.</p>
|
||||
*
|
||||
* @param sURL a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getURL(String sURL) {
|
||||
public final String getURL(final String sURL) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(sURL);
|
||||
@@ -151,12 +151,12 @@ public class HttpUtil {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
try {
|
||||
while ((ptr = is.read()) != -1) {
|
||||
buffer.append((char)ptr);
|
||||
buffer.append((char) ptr);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return "error 3";
|
||||
}
|
||||
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,28 +12,28 @@ interface IPlayerZone {
|
||||
*
|
||||
* @param b a boolean.
|
||||
*/
|
||||
public void setUpdate(boolean b);
|
||||
void setUpdate(boolean b);
|
||||
|
||||
/**
|
||||
* <p>getUpdate.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean getUpdate();
|
||||
boolean getUpdate();
|
||||
|
||||
/**
|
||||
* <p>size.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int size();
|
||||
int size();
|
||||
|
||||
/**
|
||||
* <p>add.</p>
|
||||
*
|
||||
* @param o a {@link java.lang.Object} object.
|
||||
*/
|
||||
public void add(Object o);
|
||||
void add(Object o);
|
||||
|
||||
/**
|
||||
* <p>add.</p>
|
||||
@@ -41,14 +41,14 @@ interface IPlayerZone {
|
||||
* @param c a {@link forge.Card} object.
|
||||
* @param index a int.
|
||||
*/
|
||||
public void add(Card c, int index);
|
||||
void add(Card c, int index);
|
||||
|
||||
/**
|
||||
* <p>addOnce.</p>
|
||||
*
|
||||
* @param o a {@link java.lang.Object} object.
|
||||
*/
|
||||
public void addOnce(Object o);
|
||||
void addOnce(Object o);
|
||||
|
||||
/**
|
||||
* <p>get.</p>
|
||||
@@ -56,34 +56,34 @@ interface IPlayerZone {
|
||||
* @param index a int.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public Card get(int index);
|
||||
Card get(int index);
|
||||
|
||||
/**
|
||||
* <p>remove.</p>
|
||||
*
|
||||
* @param o a {@link java.lang.Object} object.
|
||||
*/
|
||||
public void remove(Object o);
|
||||
void remove(Object o);
|
||||
|
||||
/**
|
||||
* <p>setCards.</p>
|
||||
*
|
||||
* @param c an array of {@link forge.Card} objects.
|
||||
*/
|
||||
public void setCards(Card c[]);
|
||||
void setCards(Card[] c);
|
||||
|
||||
/**
|
||||
* <p>getCards.</p>
|
||||
*
|
||||
* @return an array of {@link forge.Card} objects.
|
||||
*/
|
||||
public Card[] getCards();
|
||||
Card[] getCards();
|
||||
|
||||
//removes all cards
|
||||
/**
|
||||
* <p>reset.</p>
|
||||
*/
|
||||
public void reset();
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* <p>is.</p>
|
||||
@@ -91,7 +91,7 @@ interface IPlayerZone {
|
||||
* @param zone a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean is(String zone);
|
||||
boolean is(String zone);
|
||||
|
||||
/**
|
||||
* <p>is.</p>
|
||||
@@ -100,27 +100,27 @@ interface IPlayerZone {
|
||||
* @param player a {@link forge.Player} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean is(String zone, Player player);
|
||||
boolean is(String zone, Player player);
|
||||
|
||||
/**
|
||||
* <p>getPlayer.</p>
|
||||
*
|
||||
* @return a {@link forge.Player} object.
|
||||
*/
|
||||
public Player getPlayer();//the Player that owns this zone
|
||||
Player getPlayer(); //the Player that owns this zone
|
||||
|
||||
/**
|
||||
* <p>getZoneName.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getZoneName();//returns the Zone's name like Graveyard
|
||||
String getZoneName(); //returns the Zone's name like Graveyard
|
||||
|
||||
/**
|
||||
* <p>toString.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String toString();
|
||||
String toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ import java.io.File;
|
||||
public class ImagePreviewPanel extends JPanel implements PropertyChangeListener {
|
||||
|
||||
|
||||
/** Constant <code>serialVersionUID=2163809931940286240L</code> */
|
||||
/** Constant <code>serialVersionUID=2163809931940286240L</code>. */
|
||||
private static final long serialVersionUID = 2163809931940286240L;
|
||||
private int width, height;
|
||||
private ImageIcon icon;
|
||||
private Image image;
|
||||
/** Constant <code>ACCSIZE=155</code> */
|
||||
/** Constant <code>ACCSIZE=155</code>. */
|
||||
private static final int ACCSIZE = 155;
|
||||
private Color bg;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ImagePreviewPanel extends JPanel implements PropertyChangeListener
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
public final void propertyChange(final PropertyChangeEvent e) {
|
||||
String propertyName = e.getPropertyName();
|
||||
|
||||
// Make sure we are responding to the right event.
|
||||
@@ -44,8 +44,11 @@ public class ImagePreviewPanel extends JPanel implements PropertyChangeListener
|
||||
File selection = (File) e.getNewValue();
|
||||
String name;
|
||||
|
||||
if (selection == null) return;
|
||||
else name = selection.getAbsolutePath();
|
||||
if (selection == null) {
|
||||
return;
|
||||
} else {
|
||||
name = selection.getAbsolutePath();
|
||||
}
|
||||
|
||||
/*
|
||||
* Make reasonably sure we have an image format that AWT can
|
||||
@@ -53,7 +56,8 @@ public class ImagePreviewPanel extends JPanel implements PropertyChangeListener
|
||||
*/
|
||||
if ((name != null)
|
||||
&& (name.toLowerCase().endsWith(".jpg") || name.toLowerCase().endsWith(".jpeg")
|
||||
|| name.toLowerCase().endsWith(".gif") || name.toLowerCase().endsWith(".png"))) {
|
||||
|| name.toLowerCase().endsWith(".gif") || name.toLowerCase().endsWith(".png")))
|
||||
{
|
||||
icon = new ImageIcon(name);
|
||||
image = icon.getImage();
|
||||
scaleImage();
|
||||
@@ -96,7 +100,7 @@ public class ImagePreviewPanel extends JPanel implements PropertyChangeListener
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
public final void paintComponent(final Graphics g) {
|
||||
g.setColor(bg);
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Random;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MyRandom {
|
||||
/** Constant <code>random</code> */
|
||||
/** Constant <code>random</code>. */
|
||||
public static Random random = new Random();
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ public class MyRandom {
|
||||
* @param percent a int.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean percentTrue(int percent) {
|
||||
public static boolean percentTrue(final int percent) {
|
||||
return percent > random.nextInt(100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class NameChanger implements NewConstants {
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean shouldChangeCardName() {
|
||||
public final boolean shouldChangeCardName() {
|
||||
return changeCardName;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class NameChanger implements NewConstants {
|
||||
*
|
||||
* @param b a boolean.
|
||||
*/
|
||||
public void setShouldChangeCardName(boolean b) {
|
||||
public final void setShouldChangeCardName(final boolean b) {
|
||||
changeCardName = b;
|
||||
}
|
||||
|
||||
@@ -62,23 +62,23 @@ public class NameChanger implements NewConstants {
|
||||
* This change's the inputGenerator's Card instances in place,
|
||||
* and returns a generator of those same changed instances.
|
||||
*
|
||||
* TODO: Should this method return void, because it side effects
|
||||
* TODO Should this method return void, because it side effects
|
||||
* the contents of its inputGenerator?
|
||||
*
|
||||
* @param inputGenerator a Generator of Card objects
|
||||
* @return a Generator of side-effected Card objects
|
||||
*/
|
||||
public Generator<Card> changeCard(Generator<Card> inputGenerator) {
|
||||
|
||||
public final Generator<Card> changeCard(final Generator<Card> inputGenerator) {
|
||||
|
||||
// Create a new Generator by applying a transform to the
|
||||
// inputGenerator.
|
||||
|
||||
Lambda1<Card,Card> transform = new Lambda1<Card,Card>() {
|
||||
public Card apply(Card toChange) {
|
||||
|
||||
Lambda1<Card, Card> transform = new Lambda1<Card, Card>() {
|
||||
public Card apply(final Card toChange) {
|
||||
return changeCard(toChange);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
return GeneratorFunctions.transformGenerator(transform, inputGenerator);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class NameChanger implements NewConstants {
|
||||
* @param c a {@link forge.Card} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public Card changeCard(Card c) {
|
||||
public final Card changeCard(final Card c) {
|
||||
//change name
|
||||
String newName = changeName(c.getName());
|
||||
c.setName(newName);
|
||||
@@ -110,7 +110,7 @@ public class NameChanger implements NewConstants {
|
||||
}
|
||||
|
||||
return c;
|
||||
}//getMutatedCard()
|
||||
} //getMutatedCard()
|
||||
|
||||
/**
|
||||
* <p>changeString.</p>
|
||||
@@ -119,9 +119,9 @@ public class NameChanger implements NewConstants {
|
||||
* @param in a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String changeString(Card c, String in) {
|
||||
public final String changeString(final Card c, final String in) {
|
||||
//String name = getOriginalName(c.getName()); // unused
|
||||
// in = in.replaceAll(name, changeName(name));
|
||||
// in = in.replaceAll(name, changeName(name));
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class NameChanger implements NewConstants {
|
||||
*
|
||||
* If not, we just return list.
|
||||
*
|
||||
* TODO: Should this method return void, because it side effects the
|
||||
* TODO Should this method return void, because it side effects the
|
||||
* contents of its input list?
|
||||
*
|
||||
* @param list
|
||||
@@ -141,7 +141,7 @@ public class NameChanger implements NewConstants {
|
||||
* @return either list itself or a new list (possibly wasteful) containing
|
||||
* the side effected cards
|
||||
*/
|
||||
public CardList changeCardsIfNeeded(CardList list) {
|
||||
public final CardList changeCardsIfNeeded(CardList list) {
|
||||
if (shouldChangeCardName()) {
|
||||
list = new CardList(changeCard(YieldUtils.toGenerator(list)));
|
||||
}
|
||||
@@ -156,13 +156,15 @@ public class NameChanger implements NewConstants {
|
||||
* @param originalName a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String changeName(String originalName) {
|
||||
public final String changeName(final String originalName) {
|
||||
Object o = mutatedMap.get(originalName);
|
||||
|
||||
if (o == null) return originalName;
|
||||
if (o == null) {
|
||||
return originalName;
|
||||
}
|
||||
|
||||
return o.toString();
|
||||
}//getMutatedName()
|
||||
} //getMutatedName()
|
||||
|
||||
//always returns the original cardname
|
||||
//if argument is a original name, it returns the same original name
|
||||
@@ -172,13 +174,15 @@ public class NameChanger implements NewConstants {
|
||||
* @param mutatedName a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getOriginalName(String mutatedName) {
|
||||
public final String getOriginalName(final String mutatedName) {
|
||||
Object o = originalMap.get(mutatedName);
|
||||
|
||||
if (o == null) return mutatedName;
|
||||
if (o == null) {
|
||||
return mutatedName;
|
||||
}
|
||||
|
||||
return o.toString();
|
||||
}//getOriginalName()
|
||||
} //getOriginalName()
|
||||
|
||||
/**
|
||||
* <p>readFile.</p>
|
||||
@@ -195,8 +199,8 @@ public class NameChanger implements NewConstants {
|
||||
processLine(line.trim());
|
||||
|
||||
line = in.readLine();
|
||||
}//while
|
||||
}//try
|
||||
} //while
|
||||
} //try
|
||||
catch (Exception ex) {
|
||||
//~ throw new RuntimeException("NameMutator : readFile() error, " +ex);
|
||||
|
||||
@@ -210,7 +214,7 @@ public class NameChanger implements NewConstants {
|
||||
//stop reading if end of file or blank line is read
|
||||
while ((line = in.readLine()) != null && (line.trim().length() != 0)) {
|
||||
processLine(line.trim());
|
||||
}//while
|
||||
} //while
|
||||
} catch (Exception ex2) {
|
||||
// Show orig exception
|
||||
ErrorViewer.showError(ex2);
|
||||
@@ -218,7 +222,7 @@ public class NameChanger implements NewConstants {
|
||||
}
|
||||
//~
|
||||
}
|
||||
}//readFile()
|
||||
} //readFile()
|
||||
|
||||
//line is formated "original card name : alias card name"
|
||||
/**
|
||||
@@ -226,12 +230,13 @@ public class NameChanger implements NewConstants {
|
||||
*
|
||||
* @param line a {@link java.lang.String} object.
|
||||
*/
|
||||
private void processLine(String line) {
|
||||
private void processLine(final String line) {
|
||||
StringTokenizer tok = new StringTokenizer(line, ":");
|
||||
|
||||
if (tok.countTokens() != 2)
|
||||
if (tok.countTokens() != 2) {
|
||||
throw new RuntimeException(
|
||||
"NameMutator : processLine() error, invalid line in file name-mutator.txt - " + line);
|
||||
}
|
||||
|
||||
String original = tok.nextToken().trim();
|
||||
String mutated = tok.nextToken().trim();
|
||||
@@ -247,7 +252,7 @@ public class NameChanger implements NewConstants {
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
// printMap
|
||||
private void printMap(Map<String, String> map) {
|
||||
private void printMap(final Map<String, String> map) {
|
||||
for (Entry<String, String> e : map.entrySet()) {
|
||||
System.out.println(e.getKey() + " : " + e.getValue());
|
||||
}
|
||||
|
||||
@@ -10,26 +10,31 @@ import forge.gui.input.Input;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PlayerUtil {
|
||||
public final class PlayerUtil {
|
||||
|
||||
private PlayerUtil() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>worshipFlag.</p>
|
||||
*
|
||||
* @param player a {@link forge.Player} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean worshipFlag(Player player) {
|
||||
public static boolean worshipFlag(final Player player) {
|
||||
// Instead of hardcoded Ali from Cairo like cards, it is now a Keyword
|
||||
CardList list = AllZoneUtil.getPlayerCardsInPlay(player);
|
||||
list = list.getKeyword("Damage that would reduce your life total to less than 1 reduces it to 1 instead.");
|
||||
list = list.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
return !c.isFaceDown();
|
||||
}
|
||||
});
|
||||
|
||||
return list.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>input_discardNumUnless.</p>
|
||||
*
|
||||
@@ -39,7 +44,7 @@ public class PlayerUtil {
|
||||
* @return a {@link forge.gui.input.Input} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static Input input_discardNumUnless(final int nCards, final String uType, SpellAbility sa) {
|
||||
public static Input input_discardNumUnless(final int nCards, final String uType, final SpellAbility sa) {
|
||||
final SpellAbility sp = sa;
|
||||
Input target = new Input() {
|
||||
private static final long serialVersionUID = 8822292413831640944L;
|
||||
@@ -48,7 +53,9 @@ public class PlayerUtil {
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
if (AllZone.getHumanHand().size() == 0) stop();
|
||||
if (AllZone.getHumanHand().size() == 0) {
|
||||
stop();
|
||||
}
|
||||
AllZone.getDisplay().showMessage("Select " + (nCards - n) + " cards to discard, unless you discard a "
|
||||
+ uType + ".");
|
||||
ButtonUtil.disableAll();
|
||||
@@ -60,25 +67,27 @@ public class PlayerUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(Card card, PlayerZone zone) {
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Hand)) {
|
||||
card.getController().discard(card, sp);
|
||||
n++;
|
||||
|
||||
if (card.isType(uType.toString())) stop();
|
||||
|
||||
else {
|
||||
if (n == nCards || AllZone.getHumanHand().size() == 0) stop();
|
||||
else
|
||||
if (card.isType(uType.toString())) {
|
||||
stop();
|
||||
} else {
|
||||
if (n == nCards || AllZone.getHumanHand().size() == 0) {
|
||||
stop();
|
||||
} else {
|
||||
showMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return target;
|
||||
}//input_discardNumUnless
|
||||
|
||||
} //input_discardNumUnless
|
||||
|
||||
/**
|
||||
* <p>input_discard.</p>
|
||||
*
|
||||
@@ -87,7 +96,7 @@ public class PlayerUtil {
|
||||
* @return a {@link forge.gui.input.Input} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static Input input_discard(final int nCards, SpellAbility sa) {
|
||||
public static Input input_discard(final int nCards, final SpellAbility sa) {
|
||||
final SpellAbility sp = sa;
|
||||
Input target = new Input() {
|
||||
private static final long serialVersionUID = -329993322080934435L;
|
||||
@@ -96,55 +105,62 @@ public class PlayerUtil {
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
if (AllZone.getHumanHand().size() == 0) stop();
|
||||
if (nCards == 0) stop();
|
||||
if (AllZone.getHumanHand().size() == 0) {
|
||||
stop();
|
||||
}
|
||||
if (nCards == 0) {
|
||||
stop();
|
||||
}
|
||||
|
||||
AllZone.getDisplay().showMessage("Select a card to discard");
|
||||
ButtonUtil.disableAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(Card card, PlayerZone zone) {
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Hand)) {
|
||||
card.getController().discard(card, sp);
|
||||
n++;
|
||||
|
||||
//in case no more cards in hand
|
||||
if (n == nCards || AllZone.getHumanHand().size() == 0) stop();
|
||||
else
|
||||
if (n == nCards || AllZone.getHumanHand().size() == 0) {
|
||||
stop();
|
||||
} else {
|
||||
showMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return target;
|
||||
}//input_discard()
|
||||
|
||||
} //input_discard()
|
||||
|
||||
/**
|
||||
* <p>input_chainsDiscard.</p>
|
||||
*
|
||||
* @return a {@link forge.gui.input.Input} object.
|
||||
* @since
|
||||
*/
|
||||
public static Input input_chainsDiscard() {
|
||||
Input target = new Input() {
|
||||
private static final long serialVersionUID = 2856894846224546303L;
|
||||
private static final long serialVersionUID = 2856894846224546303L;
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
if (AllZone.getHumanHand().size() == 0) stop();
|
||||
if (AllZone.getHumanHand().size() == 0) {
|
||||
stop();
|
||||
}
|
||||
|
||||
AllZone.getDisplay().showMessage("Chains of Mephistopheles:\n"+"Select a card to discard");
|
||||
AllZone.getDisplay().showMessage("Chains of Mephistopheles:\n" + "Select a card to discard");
|
||||
ButtonUtil.disableAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(Card card, PlayerZone zone) {
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Hand)) {
|
||||
card.getController().discard(card, null);
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void done() {
|
||||
stop();
|
||||
//hack to not trigger Chains of Mephistopheles recursively
|
||||
@@ -152,8 +168,8 @@ public class PlayerUtil {
|
||||
}
|
||||
};
|
||||
return target;
|
||||
}//input_chainsDiscard()
|
||||
|
||||
} //input_chainsDiscard()
|
||||
|
||||
/**
|
||||
* <p>input_sacrificePermanent.</p>
|
||||
*
|
||||
@@ -164,7 +180,7 @@ public class PlayerUtil {
|
||||
*/
|
||||
public static Input input_sacrificePermanent(final CardList choices, final String message) {
|
||||
return input_sacrificePermanentsFromList(1, choices, message);
|
||||
}//input_sacrifice()
|
||||
} //input_sacrifice()
|
||||
|
||||
/**
|
||||
* <p>input_sacrificePermanents.</p>
|
||||
@@ -177,7 +193,7 @@ public class PlayerUtil {
|
||||
CardList list = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer());
|
||||
list.remove("Mana Pool"); // is this needed?
|
||||
return input_sacrificePermanentsFromList(nCards, list, "Select a permanent to sacrifice");
|
||||
}//input_sacrificePermanents()
|
||||
} //input_sacrificePermanents()
|
||||
|
||||
/**
|
||||
* <p>input_sacrificePermanents.</p>
|
||||
@@ -193,7 +209,7 @@ public class PlayerUtil {
|
||||
|
||||
list = list.getType(type);
|
||||
return input_sacrificePermanentsFromList(nCards, list, "Select a " + type + " to sacrifice");
|
||||
}//input_sacrificePermanents()
|
||||
} //input_sacrificePermanents()
|
||||
|
||||
/**
|
||||
* <p>input_sacrificePermanentsFromList.</p>
|
||||
@@ -222,7 +238,7 @@ public class PlayerUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(Card card, PlayerZone zone) {
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (zone.equals(AllZone.getHumanBattlefield()) && list.contains(card)) {
|
||||
AllZone.getGameAction().sacrifice(card);
|
||||
n++;
|
||||
@@ -232,14 +248,15 @@ public class PlayerUtil {
|
||||
if (n == nCards || list.size() == 0) {
|
||||
stop();
|
||||
return;
|
||||
} else
|
||||
} else {
|
||||
showMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return target;
|
||||
}//input_sacrificePermanents()
|
||||
|
||||
} //input_sacrificePermanents()
|
||||
|
||||
/**
|
||||
* <p>input_putFromHandToLibrary.</p>
|
||||
*
|
||||
@@ -258,7 +275,9 @@ public class PlayerUtil {
|
||||
AllZone.getDisplay().showMessage("Select a card to put on the " + TopOrBottom + " of your library.");
|
||||
ButtonUtil.disableAll();
|
||||
|
||||
if (n == num || AllZone.getHumanHand().size() == 0) stop();
|
||||
if (n == num || AllZone.getHumanHand().size() == 0) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,16 +286,19 @@ public class PlayerUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(Card card, PlayerZone zone) {
|
||||
public void selectCard(final Card card, final PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Hand)) {
|
||||
int position = 0;
|
||||
if (TopOrBottom.equalsIgnoreCase("bottom"))
|
||||
if (TopOrBottom.equalsIgnoreCase("bottom")) {
|
||||
position = -1;
|
||||
}
|
||||
|
||||
AllZone.getGameAction().moveToLibrary(card, position);
|
||||
|
||||
n++;
|
||||
if (n == num) stop();
|
||||
if (n == num) {
|
||||
stop();
|
||||
}
|
||||
|
||||
showMessage();
|
||||
}
|
||||
@@ -285,5 +307,4 @@ public class PlayerUtil {
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
}//end class PlayerUtil
|
||||
} //end class PlayerUtil
|
||||
|
||||
@@ -9,6 +9,6 @@ import java.util.Observer;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
abstract public class PlayerZone extends MyObservable implements IPlayerZone, Observer {
|
||||
public abstract class PlayerZone extends MyObservable implements IPlayerZone, Observer {
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.card.spellability.SpellAbility;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
/** Constant <code>serialVersionUID=5750837078903423978L</code> */
|
||||
/** Constant <code>serialVersionUID=5750837078903423978L</code>. */
|
||||
private static final long serialVersionUID = 5750837078903423978L;
|
||||
|
||||
private boolean trigger = true;
|
||||
@@ -23,24 +23,30 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
* @param zone a {@link java.lang.String} object.
|
||||
* @param player a {@link forge.Player} object.
|
||||
*/
|
||||
public PlayerZone_ComesIntoPlay(String zone, Player player) {
|
||||
public PlayerZone_ComesIntoPlay(final String zone, final Player player) {
|
||||
super(zone, player);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void add(Object o) {
|
||||
if (o == null) throw new RuntimeException("PlayerZone_ComesInto Play : add() object is null");
|
||||
public final void add(final Object o) {
|
||||
if (o == null) {
|
||||
throw new RuntimeException("PlayerZone_ComesInto Play : add() object is null");
|
||||
}
|
||||
|
||||
super.add(o);
|
||||
|
||||
final Card c = (Card) o;
|
||||
final Player player = c.getController();
|
||||
|
||||
if (trigger && ((CardFactoryUtil.oppHasKismet(c.getController()) && (c.isLand() || c.isCreature() || c.isArtifact()))
|
||||
if (trigger && ((CardFactoryUtil.oppHasKismet(c.getController())
|
||||
&& (c.isLand() || c.isCreature() || c.isArtifact()))
|
||||
|| (AllZoneUtil.isCardInPlay("Urabrask the Hidden", c.getController().getOpponent()) && c.isCreature())
|
||||
|| (AllZoneUtil.isCardInPlay("Root Maze") && (c.isLand() || c.isArtifact()))
|
||||
|| (AllZoneUtil.isCardInPlay("Orb of Dreams") && c.isPermanent()))) c.tap();
|
||||
|| (AllZoneUtil.isCardInPlay("Orb of Dreams") && c.isPermanent())))
|
||||
{
|
||||
c.tap();
|
||||
}
|
||||
|
||||
//cannot use addComesIntoPlayCommand - trigger might be set to false;
|
||||
// Keep track of max lands can play per turn
|
||||
@@ -67,12 +73,13 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
if (eachPlayer) {
|
||||
AllZone.getHumanPlayer().addMaxLandsToPlay(addMax);
|
||||
AllZone.getComputerPlayer().addMaxLandsToPlay(addMax);
|
||||
} else
|
||||
} else {
|
||||
c.getController().addMaxLandsToPlay(addMax);
|
||||
}
|
||||
}
|
||||
|
||||
if (trigger) {
|
||||
c.setSickness(true);// summoning sickness
|
||||
c.setSickness(true); // summoning sickness
|
||||
c.comesIntoPlay();
|
||||
|
||||
if (c.isLand()) {
|
||||
@@ -85,7 +92,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
});*/
|
||||
|
||||
list = list.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
public boolean addCard(final Card c) {
|
||||
return c.hasKeyword("Landfall")
|
||||
|| c.hasKeyword("Landfall - Whenever a land enters the battlefield under your control, CARDNAME gets +2/+2 until end of turn.");
|
||||
}
|
||||
@@ -97,8 +104,8 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
/*
|
||||
// Check for a mountain
|
||||
if (!listValakut.isEmpty() && c.isType("Mountain") ) {
|
||||
for (int i = 0; i < listValakut.size(); i++) {
|
||||
boolean b = GameActionUtil.executeValakutEffect(listValakut.get(i),c);
|
||||
for (int i = 0; i < listValakut.size(); i++) {
|
||||
boolean b = GameActionUtil.executeValakutEffect(listValakut.get(i),c);
|
||||
if (!b) {
|
||||
// Not enough mountains to activate Valakut -- stop the loop
|
||||
break;
|
||||
@@ -116,7 +123,9 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
public void resolve() {
|
||||
CardList lands = AllZoneUtil.getPlayerCardsInPlay(tisLand.getController());
|
||||
lands = lands.filter(AllZoneUtil.lands);
|
||||
for (Card land : lands) land.tap();
|
||||
for (Card land : lands) {
|
||||
land.tap();
|
||||
}
|
||||
}
|
||||
};
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -136,7 +145,8 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
@Override
|
||||
public void resolve() {
|
||||
CardList lands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner());
|
||||
lesLand.getOwner().sacrificePermanent(source.getName() + " - Select a land to sacrifice", lands);
|
||||
lesLand.getOwner().sacrificePermanent(
|
||||
source.getName() + " - Select a land to sacrifice", lands);
|
||||
}
|
||||
};
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -152,7 +162,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
}
|
||||
}
|
||||
|
||||
}//isLand()
|
||||
} //isLand()
|
||||
}
|
||||
|
||||
if (AllZone.getStaticEffects().getCardToEffectsList().containsKey(c.getName())) {
|
||||
@@ -175,18 +185,19 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
if (GameActionUtil.showYesNoDialog(crd, "Attach " + crd + " to " + c + "?")) {
|
||||
if (AllZoneUtil.isCardInPlayerGraveyard(player, crd)
|
||||
&& AllZoneUtil.isCardInPlay(c) && c.isCreature()
|
||||
&& c.getNetAttack() == 1 && c.getNetDefense() == 1) {
|
||||
&& c.getNetAttack() == 1 && c.getNetDefense() == 1)
|
||||
{
|
||||
AllZone.getGameAction().moveToPlay(crd);
|
||||
|
||||
crd.equipCard(c);
|
||||
}
|
||||
}
|
||||
|
||||
} else //computer
|
||||
{
|
||||
} else {
|
||||
if (AllZoneUtil.isCardInPlayerGraveyard(player, crd)
|
||||
&& AllZoneUtil.isCardInPlay(c) && c.isCreature()
|
||||
&& c.getNetAttack() == 1 && c.getNetDefense() == 1) {
|
||||
&& c.getNetAttack() == 1 && c.getNetDefense() == 1)
|
||||
{
|
||||
AllZone.getGameAction().moveToPlay(crd);
|
||||
|
||||
crd.equipCard(c);
|
||||
@@ -196,8 +207,10 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
};
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Sword of the Meek - Whenever a 1/1 creature enters the battlefield under your control, you may ");
|
||||
sb.append("return Sword of the Meek from your graveyard to the battlefield, then attach it to that creature.");
|
||||
sb.append(crd);
|
||||
sb.append(" - Whenever a 1/1 creature enters the battlefield under your control, you may ");
|
||||
sb.append("return Sword of the Meek from your graveyard to the battlefield, ");
|
||||
sb.append("then attach it to that creature.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
AllZone.getStack().addSimultaneousStackEntry(ability);
|
||||
@@ -205,11 +218,11 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
}
|
||||
}
|
||||
|
||||
}// end add()
|
||||
} // end add()
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void remove(Object o) {
|
||||
public final void remove(final Object o) {
|
||||
|
||||
super.remove(o);
|
||||
|
||||
@@ -239,8 +252,9 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
if (eachPlayer) {
|
||||
AllZone.getHumanPlayer().addMaxLandsToPlay(addMax);
|
||||
AllZone.getComputerPlayer().addMaxLandsToPlay(addMax);
|
||||
} else
|
||||
} else {
|
||||
c.getController().addMaxLandsToPlay(addMax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +287,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
*
|
||||
* @param b a boolean.
|
||||
*/
|
||||
public void setTrigger(boolean b) {
|
||||
public final void setTrigger(final boolean b) {
|
||||
trigger = b;
|
||||
}
|
||||
|
||||
@@ -282,7 +296,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
*
|
||||
* @param b a boolean.
|
||||
*/
|
||||
public void setLeavesTrigger(boolean b) {
|
||||
public final void setLeavesTrigger(final boolean b) {
|
||||
leavesTrigger = b;
|
||||
}
|
||||
|
||||
@@ -291,7 +305,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
*
|
||||
* @param b a boolean.
|
||||
*/
|
||||
public void setTriggers(boolean b) {
|
||||
public final void setTriggers(final boolean b) {
|
||||
trigger = b;
|
||||
leavesTrigger = b;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user