remove trailing space from java code

master
melvinzhang 2015-12-31 18:54:52 +08:00
parent 8e0c790d3f
commit c8f1262b45
336 changed files with 1196 additions and 1196 deletions

View File

@ -132,8 +132,8 @@ public class DeckStrCal {
// Set difficulty.
final MagicDuel testDuel=new MagicDuel(config);
testDuel.initialize();
// Create players
// Create players
final DuelPlayerConfig[] players = new DuelPlayerConfig[2];
for (int i = 0; i < 2; i++) {
players[i] = new DuelPlayerConfig(
@ -195,7 +195,7 @@ public class DeckStrCal {
while (testDuel.getGamesPlayed() < testDuel.getGamesTotal()) {
final MagicGame game=testDuel.nextGame();
game.setArtificial(true);
//maximum duration of a game is 60 minutes
final HeadlessGameController controller = new HeadlessGameController(game, 3600000);

View File

@ -29,7 +29,7 @@ public class MagicMain {
Thread.setDefaultUncaughtExceptionHandler(new UiExceptionHandler());
setSplashScreen();
System.out.println(MagicSystem.getRuntimeParameters());
parseCommandline(args);
@ -44,7 +44,7 @@ public class MagicMain {
final double duration = (double)(System.currentTimeMillis() - start_time) / 1000;
System.err.println("Initalization of engine took " + duration + "s");
}
// try to set the look and feel
setLookAndFeel("Nimbus");
reporter.setMessage("Starting UI...");
@ -54,7 +54,7 @@ public class MagicMain {
}
});
}
private static void setLookAndFeel(final String laf) {
try {
for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
@ -112,7 +112,7 @@ public class MagicMain {
if (MagicSystem.isAiVersusAi()) {
final DuelConfig config = DuelConfig.getInstance();
config.load();
// set both player profile to AI for AI vs AI mode
config.setPlayerProfile(0, config.getPlayerProfile(1));
@ -122,7 +122,7 @@ public class MagicMain {
// normal UI startup.
ScreenController.showStartScreen();
}
private static void parseCommandline(final String[] args) {

View File

@ -69,7 +69,7 @@ public class MCTSAI implements MagicAI {
static double UCB1_C = 0.4;
static double RATIO_K = 1.0;
private int sims = 0;
private static final int THREADS = Runtime.getRuntime().availableProcessors();
static {
@ -126,14 +126,14 @@ public class MCTSAI implements MagicAI {
if (size == 1) {
return startGame.map(RCHOICES.get(0));
}
//root represents the start state
final MCTSGameTree root = MCTSGameTree.getNode(CACHE, aiGame, RCHOICES);
log("MCTS cached=" + root.getNumSim());
sims = 0;
final ExecutorService executor = Executors.newFixedThreadPool(THREADS);
final ExecutorService executor = Executors.newFixedThreadPool(THREADS);
final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
// ensure tree update runs at least once
@ -146,9 +146,9 @@ public class MCTSAI implements MagicAI {
TreeUpdate(this, root, aiGame, executor, queue, END_TIME, RCHOICES);
}
};
updateTask.run();
try {
// wait for artificialLevel + 1 seconds for jobs to finish
executor.awaitTermination(aiLevel + 1, TimeUnit.SECONDS);
@ -210,10 +210,10 @@ public class MCTSAI implements MagicAI {
public void TreeUpdate(
final Runnable updateTask,
final MCTSGameTree root,
final MagicGame aiGame,
final ExecutorService executor,
final BlockingQueue<Runnable> queue,
final MCTSGameTree root,
final MagicGame aiGame,
final ExecutorService executor,
final BlockingQueue<Runnable> queue,
final long END_TIME,
final List<Object[]> RCHOICES
) {
@ -232,14 +232,14 @@ public class MCTSAI implements MagicAI {
//clone the MagicGame object for simulation
final MagicGame rootGame = new MagicGame(aiGame, aiGame.getScorePlayer());
//pass in a clone of the state,
//genNewTreeNode grows the tree by one node
//and returns the path from the root to the new node
final LinkedList<MCTSGameTree> path = growTree(root, rootGame, RCHOICES);
assert path.size() >= 2 : "ERROR! length of MCTS path is " + path.size();
// play a simulated game to get score
// update all nodes along the path from root to new node
@ -254,7 +254,7 @@ public class MCTSAI implements MagicAI {
return;
}
}
// virtual loss + game theoretic value propagation
final Iterator<MCTSGameTree> iter = path.descendingIterator();
MCTSGameTree child = null;
@ -278,7 +278,7 @@ public class MCTSAI implements MagicAI {
}
}
}
// end simulations once root is AI win or time is up
if (running && root.isAIWin() == false) {
try {
@ -450,7 +450,7 @@ public class MCTSAI implements MagicAI {
return 1.0 - counts[0] / (2.0 * MAX_CHOICES);
}
}
private int[] runSimulation(final MagicGame game) {
int aiChoices = 0;
@ -465,7 +465,7 @@ public class MCTSAI implements MagicAI {
!Thread.currentThread().isInterrupted() &&
game.advanceToNextEventWithChoice()) {
final MagicEvent event = game.getNextEvent();
if (event.getPlayer() == game.getScorePlayer()) {
aiChoices++;
} else {
@ -713,11 +713,11 @@ class MCTSGameTree implements Iterable<MCTSGameTree> {
boolean isSolved() {
return evalScore == Integer.MAX_VALUE || evalScore == Integer.MIN_VALUE;
}
void recordVirtualLoss() {
numSim++;
}
void removeVirtualLoss() {
numSim--;
}

View File

@ -62,11 +62,11 @@ public class MMAB implements MagicAI {
final int artificialLevel = scorePlayer.getAiProfile().getAiLevel();
final int rounds = (size + THREADS - 1) / THREADS;
final long slice = artificialLevel * SEC_TO_NANO / rounds;
for (final Object[] choice : choices) {
final ArtificialChoiceResults achoice=new ArtificialChoiceResults(choice);
achoices.add(achoice);
final MagicGame workerGame=new MagicGame(sourceGame,scorePlayer);
if (!CHEAT) {
workerGame.hideHiddenCards();
@ -77,7 +77,7 @@ public class MMAB implements MagicAI {
workerGame.setFastMana(true);
workerGame.setFastTarget(true);
workerGame.setFastBlocker(true);
executor.execute(new Runnable() {
@Override
public void run() {
@ -148,7 +148,7 @@ class MMABWorker {
this.scoreBoard=scoreBoard;
this.CHEAT=CHEAT;
}
/** Determines if game score should be cached for this game state. */
public boolean shouldCache() {
switch (game.getPhase().getType()) {

View File

@ -29,16 +29,16 @@ public class MTDF implements MagicAI {
public Object[] findNextEventChoiceResults(final MagicGame sourceGame, final MagicPlayer scorePlayer) {
final int artificialLevel = scorePlayer.getAiProfile().getAiLevel();
final long startTime = System.currentTimeMillis();
END = startTime + artificialLevel * 1000;
final MagicGame root = new MagicGame(sourceGame, scorePlayer);
//root.setMainPhases(artificialLevel);
if (!CHEAT) {
root.hideHiddenCards();
}
final MagicEvent event = root.getNextEvent();
final List<Object[]> choices = event.getArtificialChoiceResults(root);
if (choices.size() == 1) {
@ -47,7 +47,7 @@ public class MTDF implements MagicAI {
root.setFastChoices(true);
final TTEntry result = iterative_deepening(root, choices);
// Logging.
final long timeTaken = System.currentTimeMillis() - startTime;
log("MTDF" +
@ -70,7 +70,7 @@ public class MTDF implements MagicAI {
}
private boolean hasTime() {
return System.currentTimeMillis() < END;
return System.currentTimeMillis() < END;
}
private TTEntry iterative_deepening(final MagicGame root, final List<Object[]> choices) {
@ -129,18 +129,18 @@ public class MTDF implements MagicAI {
final boolean isMax = game.getScorePlayer() == game.getNextEvent().getPlayer();
final boolean isMin = !isMax;
int g = isMax ? Integer.MIN_VALUE : Integer.MAX_VALUE;
int a = alpha; /* save original alpha value */
int b = beta; /* save original beta value */
int idx = -1;
for (final Object[] choice : choices) {
if ((isMax && g >= beta) ||
(isMin && g <= alpha)) {
break;
}
game.snapshot();
game.executeNextEvent(choice);
final List<Object[]> choices_child = d == 1 ?
@ -148,7 +148,7 @@ public class MTDF implements MagicAI {
game.advanceToNextEventWithChoices();
final int g_child = AlphaBetaWithMemory(game, choices_child, a, b, d - 1);
game.restore();
idx++;
if ((isMax && g_child > g) ||
(isMin && g_child < g)) {
@ -168,11 +168,11 @@ public class MTDF implements MagicAI {
table.put(id_check, entry);
table.remove(id);
}
entry.update(g, alpha, beta);
return g;
}
private void log(final String message) {
MagicGameLog.log(message);
}
@ -182,21 +182,21 @@ class TTEntry {
int lowerbound = Integer.MIN_VALUE;
int upperbound = Integer.MAX_VALUE;
int chosen = -1;
void update(int g, int alpha, int beta) {
/* Traditional transposition table storing of bounds */
/* Fail low result implies an upper bound */
/* Traditional transposition table storing of bounds */
/* Fail low result implies an upper bound */
if (g <= alpha) {
upperbound = g;
}
/* Found an accurate minimax value - will not occur if called with zero window */
if (g > alpha && g < beta) {
lowerbound = g;
upperbound = g;
}
/* Fail high result implies a lower bound */
/* Found an accurate minimax value - will not occur if called with zero window */
if (g > alpha && g < beta) {
lowerbound = g;
upperbound = g;
}
/* Fail high result implies a lower bound */
if (g >= beta) {
lowerbound = g;
lowerbound = g;
}
}
}

View File

@ -98,11 +98,11 @@ public class CardDefinitions {
assert cardDef.getIndex() == -1 : "cardDefinition has been assigned index";
cardDef.setIndex(cdefIndex.getAndIncrement());
if (cardDef.isPlayable()) {
cardDef.add(new MagicHandCastActivation(cardDef));
}
allPlayableCardDefs.put(cardDef.getAsciiName(), cardDef);
}
@ -125,7 +125,7 @@ public class CardDefinitions {
}
}
}
try {
cardDefinition.validate();
} catch (Exception e) {
@ -175,7 +175,7 @@ public class CardDefinitions {
throw new RuntimeException("Error loading " + file, cause);
}
}
public static void loadCardDefinition(final String cardName) {
final File cardFile = new File(SCRIPTS_DIRECTORY, getCanonicalName(cardName) + ".txt");
if (cardFile.isFile() == false) {
@ -215,7 +215,7 @@ public class CardDefinitions {
printStatistics();
updateNewCardsLog(CardDefinitions.loadCardsSnapshotFile());
}
private static boolean isZero(double value, double delta){
return value >= -delta && value <= delta;
}
@ -242,7 +242,7 @@ public class CardDefinitions {
throw new RuntimeException(ex);
}
}
public static MagicCardDefinition getToken(final String original) {
final MagicCardDefinition token = getCard(original);
if (token.isToken()) {

View File

@ -8,7 +8,7 @@ public enum CardLegality {
Banned(CardLegalityStrings._S3),
Restricted(CardLegalityStrings._S4),
TooManyCopies(CardLegalityStrings._S5);
private final String description;
private CardLegality(String aString) {

View File

@ -58,7 +58,7 @@ public class CardStatistics {
MagicIcon.ARTIFACT
)
);
private final Collection<MagicCardDefinition> cards;
public int totalCards;

View File

@ -32,7 +32,7 @@ public class DuelConfig {
// CTR
public DuelConfig() {
// Ensure DuelConfig has valid PlayerProfile references.
// If missing then creates default profiles.
PlayerProfiles.refreshMap();

View File

@ -34,27 +34,27 @@ public class GeneralConfig {
private static final String LEFT="left";
private int left = -1;
private static final String TOP="top";
private int top = 0;
private static final String TEXT_MODE_OPTION = "TextViewOption";
private boolean showTextModeOption = false;
private static final String WIDTH="width";
public static final int DEFAULT_WIDTH=1024;
private int width = DEFAULT_WIDTH;
private static final String HEIGHT="height";
public static final int DEFAULT_HEIGHT=600;
private int height = DEFAULT_HEIGHT;
private static final String MAXIMIZED="maximized";
private boolean maximized=false;
private static final String THEME="theme";
private String theme="felt";
private static final String AVATAR="avatar";
private String avatar="legend";
@ -66,121 +66,121 @@ public class GeneralConfig {
private static final String ALWAYS_PASS="pass";
private boolean alwaysPass = true;
private static final String SMART_TARGET="target";
private boolean smartTarget = false;
private static final String POPUP_DELAY="popup";
private int popupDelay = 300;
private static final String MESSAGE_DELAY = "message";
private int messageDelay = 2000;
private static final String HIGH_QUALITY="hq";
private boolean highQuality = false;
private static final String SOUND="sound";
private boolean sound = true;
private static final String TOUCHSCREEN = "touchscreen";
private boolean touchscreen = false;
private static final String MOUSEWHEEL_POPUP = "mousewheel";
private boolean mouseWheelPopup = false;
private static final String FULLSCREEN = "fullScreen";
private boolean fullScreen = false;
private static final String PREVIEW_CARD_ON_SELECT = "previewCardOnSelect";
private boolean previewCardOnSelect = true;
private static final String SHOW_LOG_MESSAGES = "showLogMessages";
private boolean showLogMessages = true;
private static final String MULLIGAN_SCREEN = "mulliganScreen";
private boolean isMulliganScreenActive = true;
private static final String RECENT_DECK = "MostRecentDeckFilename";
private String mostRecentDeckFilename = "";
private static final String CUSTOM_BACKGROUND = "customBackground";
private boolean isCustomBackground = false;
private static final String SHOW_MISSING_CARD_DATA = "showMissingCardData";
private boolean showMissingCardData = true;
private static final String CARD_IMAGES_PATH = "cardImagesPath";
private String cardImagesPath = "";
private static final String ANIMATE_GAMEPLAY = "animateGameplay";
private boolean animateGameplay = true;
private static final String ANIMATION_FLAGS = "animationFlags";
private static final String DECK_FILE_MAX_LINES = "deckFileMaxLines";
private int deckFileMaxLines = 500;
private static final String PROXY_SETTINGS = "proxySettings";
private String proxySettings = "";
private static final String FIREMIND_ACCESS_TOKEN = "firemindAccessToken";
private String firemindAccessToken = "";
private static final String NEWTURN_ALERT_DURATION = "newTurnAlertDuration";
private int newTurnAlertDuration = 3000; // msecs
private static final String LAND_PREVIEW_DURATION = "landPreviewDuration";
private int landPreviewDuration = 5000; // msecs
private static final String NONLAND_PREVIEW_DURATION = "nonLandPreviewDuration";
private int nonLandPreviewDuration = 10000; // msecs
private static final String SPLITVIEW_DECKEDITOR = "splitViewDeckEditor";
private boolean isSplitViewDeckEditor = false;
private static final String OVERLAY_PERMANENT_MIN_HEIGHT = "overlayPermanentMinHeight";
private int overlayPermanentMinHeight = 30; // pixels
private static final String IGNORED_VERSION_ALERT = "ignoredVersionAlert";
private String ignoredVersionAlert = "";
private static final String UI_SOUND = "uiSound";
private boolean isUiSound = true;
private static final String PAUSE_GAME_POPUP = "pauseGamePopup";
private boolean isGamePausedOnPopup = false;
private static final String MISSING_DOWNLOAD_DATE = "missingImagesDownloadDate";
private String missingImagesDownloadDate = "1970-01-01";
private static final String PLAYABLE_DOWNLOAD_DATE = "imageDownloaderRunDate";
private String playableImagesDownloadDate = "1970-01-01";
private static final String DUEL_SIDEBAR_LAYOUT ="duelSidebarLayout";
private String duelSidebarLayout = "LOGSTACK,PLAYER2,TURNINFO,PLAYER1";
private static final String HIDE_AI_ACTION_PROMPT ="hideAiActionPrompt";
private boolean hideAiActionPrompt = false;
private static final String ROLLOVER_COLOR ="rolloverColor";
private Color rolloverColor = Color.YELLOW;
private static final String UI_SOUND_VOLUME = "uiSoundVolume";
private int uiSoundVolume = 50;
private static final String TRANSLATION = "translation";
public static final String DEFAULT_TRANSLATION = "";
private String translation = DEFAULT_TRANSLATION;
private static final String LOG_MESSAGE_STYLE = "logMessageStyle";
private MessageStyle logMessageStyle = MessageStyle.PLAIN;
private static final String PREF_IMAGE_SIZE = "prefImageSize";
private ImageSizePresets preferredImageSize = ImageSizePresets.SIZE_ORIGINAL;
private static final String CARD_TEXT_LANG = "cardTextLanguage";
private CardTextLanguage cardTextLanguage = CardTextLanguage.ENGLISH;
private GeneralConfig() { }
public Proxy getProxy() {
@ -206,7 +206,7 @@ public class GeneralConfig {
proxySettings = sb.toString();
} else {
proxySettings = "";
}
}
}
public int getDeckFileMaxLines() {
@ -336,7 +336,7 @@ public class GeneralConfig {
public void setHighlight(final String highlight) {
this.highlight = highlight;
}
public String getFiremindAccessToken() {
return firemindAccessToken;
}

View File

@ -25,7 +25,7 @@ public class ImagesDownloadList extends ArrayList<DownloadableFile> {
}
private void sortListByFilename() {
Collections.sort(this, (o1, o2) ->
Collections.sort(this, (o1, o2) ->
o1.getFilename().compareTo(o2.getFilename())
);
}

View File

@ -16,11 +16,11 @@ import magic.utility.MagicFileSystem.DataPath;
import magic.model.MagicCardDefinition;
public class MagicCustomFormat extends MagicFormat {
private final Set<String> legal = new HashSet<>();
private final String name;
private final File file;
public MagicCustomFormat(final String aName) {
this(aName, null);
}
@ -46,7 +46,7 @@ public class MagicCustomFormat extends MagicFormat {
public String getName() {
return name;
}
@Override
public int getMinimumDeckSize() {
return 40;
@ -56,7 +56,7 @@ public class MagicCustomFormat extends MagicFormat {
public String getLabel() {
return name;
}
private void load() {
List<String> content = Collections.emptyList();
try { //load cube
@ -78,7 +78,7 @@ public class MagicCustomFormat extends MagicFormat {
//
// static members
//
private static final String CUBE_FILE_EXTENSION = "_cube.txt";
private static final FileFilter CUBE_FILE_FILTER = new FileFilter() {
@Override
@ -88,7 +88,7 @@ public class MagicCustomFormat extends MagicFormat {
};
private static List<MagicFormat> customFormats;
public static void loadCustomFormats() {
final List<MagicFormat> fmts = new ArrayList<>();
final File[] cubeFiles = MagicFileSystem.getDataPath(DataPath.MODS).toFile().listFiles(CUBE_FILE_FILTER);
@ -105,7 +105,7 @@ public class MagicCustomFormat extends MagicFormat {
static List<MagicFormat> values() {
return customFormats;
}
private static String getNameWithoutSize(final String cube) {
final int toIndex = cube.indexOf("(");
if (toIndex == -1) {
@ -114,20 +114,20 @@ public class MagicCustomFormat extends MagicFormat {
return cube.substring(0, toIndex).trim();
}
}
public static MagicFormat get(final String cubeLabel) {
// prior to 1.62 the cube label including card count was saved to the duel
// config file so for backwards compatibility during import need to check
// for and remove card count if it exists to isolate just the cube name.
final String cubeName = getNameWithoutSize(cubeLabel);
for (final MagicFormat cube : MagicFormat.getDuelFormats()) {
if (cube.getName().equals(cubeName)) {
return cube;
}
}
return MagicFormat.ALL;
}

View File

@ -8,25 +8,25 @@ import magic.model.MagicDeck;
import magic.utility.DeckUtils;
public abstract class MagicFormat {
public abstract String getName();
public abstract CardLegality getCardLegality(MagicCardDefinition card, int cardCount);
public abstract int getMinimumDeckSize();
public boolean isCardLegal(MagicCardDefinition card, int cardCount) {
return getCardLegality(card, cardCount) == CardLegality.Legal;
}
public boolean isCardLegal(MagicCardDefinition card) {
return isCardLegal(card, 1);
}
public String getLabel() {
return getName();
}
public boolean isDeckLegal(final MagicDeck aDeck) {
if (aDeck.size() < getMinimumDeckSize()) {
return false;
@ -49,12 +49,12 @@ public abstract class MagicFormat {
public String getName() {
return "All";
}
@Override
public CardLegality getCardLegality(MagicCardDefinition card, int cardCount) {
return CardLegality.Legal;
}
@Override
public int getMinimumDeckSize() {
return 40;
@ -81,11 +81,11 @@ public abstract class MagicFormat {
public static List<MagicFormat> getCubeFilterFormats() {
return MagicCustomFormat.values();
}
public static MagicFormat[] getDuelFormatsArray() {
return getDuelFormats().toArray(new MagicFormat[0]);
}
public static String[] getDuelLabels() {
return getFormatLabels(getDuelFormats()).toArray(new String[0]);
}

View File

@ -31,14 +31,14 @@ public class SoundEffects {
private static Clip clip;
private SoundEffects() {}
public static void playGameSound(final MagicGame game, final String name) {
if (game.isReal() && GeneralConfig.getInstance().isSound()) {
playSound(name);
}
}
public static void playUISound(final String name) {
public static void playUISound(final String name) {
if (GeneralConfig.getInstance().isUiSound()) {
playSound(name);
}

View File

@ -110,7 +110,7 @@ public class UnimplementedParser {
System.err.println("Failed to save " + LOG_FILE + " - " + ex);
}
}
private static void exportParseResults() {
parsedCards.removeAll(errorCards);
Collections.sort(errorList);

View File

@ -55,17 +55,17 @@ public final class NewVersionJsonParser {
//source: https://stackoverflow.com/questions/6701948/efficient-way-to-compare-version-strings-in-java
/**
* Compares two version strings.
*
* Use this instead of String.compareTo() for a non-lexicographical
* Compares two version strings.
*
* Use this instead of String.compareTo() for a non-lexicographical
* comparison that works for version strings. e.g. "1.10".compareTo("1.6").
*
*
* @note It does not work if "1.10" is supposed to be equal to "1.10.0".
*
* @param str1 a string of ordinal numbers separated by decimal points.
*
* @param str1 a string of ordinal numbers separated by decimal points.
* @param str2 a string of ordinal numbers separated by decimal points.
* @return The result is a negative integer if str1 is _numerically_ less than str2.
* The result is a positive integer if str1 is _numerically_ greater than str2.
* @return The result is a negative integer if str1 is _numerically_ less than str2.
* The result is a positive integer if str1 is _numerically_ greater than str2.
* The result is zero if the strings are _numerically_ equal.
*/
public static int versionCompare(String str1, String str2) {

View File

@ -19,6 +19,6 @@ public class InvalidDeckException extends RuntimeException {
public InvalidDeckException(final String message) {
super(message);
}
}
}

View File

@ -7,7 +7,7 @@ public abstract class ExceptionHandler implements Thread.UncaughtExceptionHandle
// first case is actually handled. This is mainly to prevent multiple
// error notification dialogs being created in UiExceptionReporter.
private volatile boolean isRunning = false;
@Override
public void uncaughtException(final Thread th, final Throwable ex) {
if (!isRunning) {

View File

@ -20,7 +20,7 @@ import magic.exception.GameException;
public class ExceptionReport {
private final StringBuilder sb = new StringBuilder();
public ExceptionReport(final Thread th, final Throwable ex) {
sb.append("CRASH REPORT FOR MAGARENA THREAD ").append(th);
@ -160,5 +160,5 @@ public class ExceptionReport {
}
report.append("\n");
}
}

View File

@ -1,6 +1,6 @@
package magic.firemind;
public class Duel {
public Integer games_to_play;
public Integer id;
public Integer seed;
@ -11,5 +11,5 @@ public class Duel {
public Integer strAi1;
public Integer strAi2;
public Integer life;
}

View File

@ -64,13 +64,13 @@ public class FiremindClient {
for (int i = 0; i < scripts.length(); i++) {
JSONObject script = scripts.getJSONObject(i);
String name = script.getString("name");
saveScriptFile(name, "txt", script.getString("config"));
String groovyScript = script.getString("script");
if(groovyScript != null && !groovyScript.equals("")){
saveScriptFile(name, "groovy", groovyScript);
}
System.out.println(name);
}
}
@ -102,7 +102,7 @@ public class FiremindClient {
addedScripts.add(f.getAbsolutePath());
}
try {
f.createNewFile();
f.createNewFile();
}catch (IOException e){
System.err.println("Couldn't save script file");
}
@ -117,7 +117,7 @@ public class FiremindClient {
System.err.println("Couldn't save script file");
}
}
public static void resetChangedScripts(){
File scriptsDirectory = MagicFileSystem.getDataPath(DataPath.SCRIPTS_ORIG).toFile();
MagicFileSystem.getDataPath(DataPath.SCRIPTS_ORIG).toFile().mkdirs();
@ -130,14 +130,14 @@ public class FiremindClient {
(new File(path)).delete();
}
}
public static boolean postGame(
Integer duel_id,
Integer duel_id,
Integer game_number,
Date play_time,
boolean win_deck1,
Date play_time,
boolean win_deck1,
Integer magarena_version_major,
Integer magarena_version_minor,
Integer magarena_version_minor,
String logFile
) {
CONFIG.load();
@ -252,8 +252,8 @@ public class FiremindClient {
e.printStackTrace();
}
return true;
}
}
public static JSONObject readJsonFromUrl(String url) throws IOException,
JSONException {
HttpURLConnection con = (HttpURLConnection) (new URL(url))
@ -283,9 +283,9 @@ public class FiremindClient {
}
public static void setFiremindHost(String host) {
firemindHost = host;
firemindHost = host;
}
public static boolean checkMagarenaVersion(String magarenaVersion) {
String url = firemindHost + "/api/v1/status/client_info";
@ -308,7 +308,7 @@ public class FiremindClient {
JSONObject json = new JSONObject(jsonText);
String[] remoteVersion = json.getString("current_magarena_version").split("\\.");
String[] localVersion = magarenaVersion.split("\\.");
return Integer.valueOf(localVersion[0]) >= Integer.valueOf(remoteVersion[0]) && Integer.valueOf(localVersion[1]) >= Integer.valueOf(remoteVersion[1]);
return Integer.valueOf(localVersion[0]) >= Integer.valueOf(remoteVersion[0]) && Integer.valueOf(localVersion[1]) >= Integer.valueOf(remoteVersion[1]);
} catch (IOException e) {
e.printStackTrace();
return false;

View File

@ -104,17 +104,17 @@ public class FiremindDuelRunner {
final MagicDuel testDuel = new MagicDuel(config);
final MagicDeckProfile profile = new MagicDeckProfile("bgruw");
final DuelPlayerConfig player1 = new DuelPlayerConfig(
AiProfile.create("Player1", ai1, str1),
AiProfile.create("Player1", ai1, str1),
profile
);
final DuelPlayerConfig player2 = new DuelPlayerConfig(
AiProfile.create("Player2", ai2, str2),
profile
);
testDuel.setPlayers(new DuelPlayerConfig[] { player1, player2 });
// Set the deck.

View File

@ -161,7 +161,7 @@ public class FiremindGameReport implements Thread.UncaughtExceptionHandler {
ex.printStackTrace(printWriter);
sb.append(result.toString());
sb.append('\n');
FiremindClient.postFailure(currentDuelId, sb.toString());
// print a copy to stderr

View File

@ -37,7 +37,7 @@ public final class FiremindJsonReader {
if (jsonFile.exists()) {
if (!isJsonFileUpToDate(jsonFile)) {
// only attempt download once per day even if download fails.
final Calendar cal = Calendar.getInstance();
final Calendar cal = Calendar.getInstance();
jsonFile.setLastModified(cal.getTimeInMillis());
}
} else {

View File

@ -26,7 +26,7 @@ public final class JsonOrgParser {
final String[] deckNamesArray = JSONObject.getNames(jsonFormat);
if (deckNamesArray == null)
continue; // no decks specified for given format.
final List<String> deckNames = new ArrayList<>(Arrays.asList(deckNamesArray));
for (String deckName : deckNames) {
@ -41,7 +41,7 @@ public final class JsonOrgParser {
return decks;
}
private static void addCardsToDeck(final MagicDeck deck, final JSONArray jsonCards) {
for (int i = 0; i < jsonCards.length(); i++) {
final JSONObject jsonCard = jsonCards.getJSONObject(i);

View File

@ -9,7 +9,7 @@ public class GameCardState {
GameCardState(String cardName, int quantity, boolean tapped) {
this.cardName = cardName;
this.quantity = quantity;
this.isTapped = tapped;
this.isTapped = tapped;
}
GameCardState(String cardName, int quantity) {
this(cardName, quantity, false);

View File

@ -39,7 +39,7 @@ public final class GameLoader {
for (int i = 0; i < playerDefs.length; i++) {
final PlayerProfile pp = gameState.getPlayer(i).isAi() ?
AiProfile.create(
gameState.getPlayer(i).getName(),
gameState.getPlayer(i).getName(),
MagicAIImpl.valueOf(gameState.getPlayer(i).getAiType()),
gameState.getDifficulty()
) :
@ -49,7 +49,7 @@ public final class GameLoader {
final MagicDeckProfile deckProfile = new MagicDeckProfile(gameState.getPlayer(i).getDeckProfileColors());
playerDefs[i] = new DuelPlayerConfig(pp, deckProfile);
}
duel.setPlayers(playerDefs);
duel.setStartPlayer(gameState.getStartPlayerIndex());
return duel;
@ -88,7 +88,7 @@ public final class GameLoader {
for (GameCardState card : exiled) {
TestGameBuilder.addToExile(player, card.getCardName(), card.getQuantity());
}
}
}

View File

@ -40,7 +40,7 @@ public class GamePlayerState {
}
public List<GameCardState> getPermanents() {
return permanents;
return permanents;
}
public void addToHand(String cardName, int quantity) {
@ -65,7 +65,7 @@ public class GamePlayerState {
public List<GameCardState> getExiled() {
return exiled;
}
}
public void setLife(int i) {
this.life = i;

View File

@ -78,5 +78,5 @@ public final class GameStateFileReader {
prop.remove(usedKey);
}
}
}

View File

@ -38,7 +38,7 @@ public final class GameStateFileWriter {
throw new RuntimeException(ex);
}
}
private static void setGameProperties(final Properties properties, final GameState gameState) {
properties.setProperty(PROP_Version, GeneralConfig.VERSION);
properties.setProperty(PROP_PlayerCount, Integer.toString(gameState.getPlayers().size()));

View File

@ -95,7 +95,7 @@ public final class GameStateSnapshot {
}
return cardDefs;
}
private static void updateCardCount(final MagicCardDefinition cardDef, final Map<MagicCardDefinition, Integer> cardDefs) {
if (cardDefs.containsKey(cardDef)) {
int count = cardDefs.get(cardDef);

View File

@ -92,7 +92,7 @@ public class RandomDeckGenerator {
}
public void generateDeck(final DeckGenerator deckGenerator) {
final MagicDeckProfile profile = deckGenerator.getDeckProfile();
final MagicDeck deck = deckGenerator.getDeck();
final int spells = deckGenerator.getSpellsCount();
@ -104,9 +104,9 @@ public class RandomDeckGenerator {
genSpells();
genLands();
final int lands = profile.getNrOfNonBasicLands(deckGenerator.getLandsCount());
final int maxNonlandNoncreature = spells - maxCreatures;
final int maxColorless = spells/6;
final int maxHigh = spells/6;
@ -138,7 +138,7 @@ public class RandomDeckGenerator {
// Add spells to deck.
boolean isGenSpellsCalled = false;
while (condensedDeck.getNumCards() < spells && !spellCards.isEmpty()) {
final int index = MagicRandom.nextRNGInt(spellCards.size());
final MagicCardDefinition cardDefinition=spellCards.get(index);
@ -188,7 +188,7 @@ public class RandomDeckGenerator {
}
}
// Add nonbasic lands to deck.
addRequiredLands(condensedDeck);

View File

@ -11,7 +11,7 @@ public class HeadlessGameController implements IGameController {
private final long maxDuration;
private final MagicGame game;
private boolean running;
/** Fully artificial test game. */
public HeadlessGameController(final MagicGame aGame, final long duration) {
game = aGame;
@ -22,18 +22,18 @@ public class HeadlessGameController implements IGameController {
public void haltGame() {
running = false;
}
@Override
public void runGame() {
final long startTime = System.currentTimeMillis();
running = true;
while (running && game.advanceToNextEventWithChoice() && System.currentTimeMillis() - startTime <= maxDuration) {
final MagicEvent event = game.getNextEvent();
final Object[] result = getAIChoiceResults(event);
game.executeNextEvent(result);
}
if (game.isFinished()) {
game.advanceDuel();
}

View File

@ -23,7 +23,7 @@ public class ARG {
public static final String GRAVEYARD = "(?<choice>[^\\.]* card [^\\.]+? graveyard)";
public static final String THING = "(permanent|creature|artifact|land|player|opponent|spell or ability|spell|ability)";
public static final String EVENQUOTES = "(?=([^\"]*'[^\"]*')*[^\"]*$)";
public static final String NUMBER = "(?<number>[0-9]+)";
public static int number(final Matcher m) {
return Integer.parseInt(m.group("number"));
@ -36,7 +36,7 @@ public class ARG {
public static MagicAmount amountObj(final Matcher m) {
return MagicAmountParser.build(m.group("amount"));
}
public static final String AMOUNT2 = "(?<amount2>[^ ]+?)";
public static int amount2(final Matcher m) {
return EnglishToInt.convert(m.group("amount2"));
@ -144,7 +144,7 @@ public class ARG {
return event.getPlayer();
}
}
private static final String TNC = "(that [^ ]+'s|its) controller( or that player)?";
public static final String PLAYERS = "((?<rnc>rn's controller)|(?<tnc>" + TNC + ")|(?<rn>rn)|(?<pn>(pn||you))|" + CHOICE + "|(?<group>[^\\.]+?))";
public static List<MagicPlayer> players(final MagicEvent event, final Matcher m, final MagicTargetFilter<MagicPlayer> filter) {
@ -183,7 +183,7 @@ public class ARG {
return filter.filter(event);
}
}
public static MagicTargetFilter<MagicPermanent> permanentsParse(final Matcher m) {
if (m.group("group") != null) {
return MagicTargetFilterFactory.Permanent(m.group("group"));
@ -191,7 +191,7 @@ public class ARG {
return MagicTargetFilterFactory.ANY;
}
}
public static final String TARGETS = "((?<rnc1>rn's controller)|(?<tnc1>" + TNC + ")|(?<rn1>rn)|(?<sn1>sn)|(?<pn1>(pn||you))|" + CHOICE + "|(?<group1>[^\\.]+?))";
public static List<? extends MagicTarget> targets(final MagicEvent event, final Matcher m, final MagicTargetFilter<MagicTarget> filter) {
if (m.group("rnc1") != null) {
@ -218,7 +218,7 @@ public class ARG {
return MagicTargetFilterFactory.ONE;
}
}
public static final String TARGETS2 = "((?<tnc2>" + TNC + ")|(?<rn2>rn)|(?<sn2>sn)|(?<pn2>(pn||you))|(?<group2>[^\\.]+?))";
public static List<? extends MagicTarget> targets2(final MagicEvent event, final Matcher m, final MagicTargetFilter<MagicTarget> filter) {
if (m.group("tnc2") != null) {
@ -241,7 +241,7 @@ public class ARG {
return MagicTargetFilterFactory.ONE;
}
}
public static final String CARDS = "((?<choice>[^\\.]* card [^\\.]+?)|(?<group>[^\\.]* cards [^\\.]+?))";
public static List<MagicCard> cards(final MagicEvent event, final Matcher m, final MagicTargetFilter<MagicCard> filter) {
if (m.group("choice") != null) {
@ -250,7 +250,7 @@ public class ARG {
return filter.filter(event);
}
}
public static MagicTargetFilter<MagicCard> cardsParse(final Matcher m) {
if (m.group("group") != null) {
return MagicTargetFilterFactory.Card(m.group("group"));
@ -271,7 +271,7 @@ public class ARG {
return filter.filter(event);
}
}
public static MagicTargetFilter<MagicItemOnStack> itemsParse(final Matcher m) {
if (m.group("group") != null) {
return MagicTargetFilterFactory.ItemOnStack(m.group("group"));

View File

@ -71,7 +71,7 @@ public class DuelPlayerConfig {
final String cardName = properties.getProperty(deckPrefix);
deck.add(getCard(cardName));
}
}
}
}
public void save(final Properties properties, final String prefix) {

View File

@ -1,6 +1,6 @@
package magic.model;
public interface IGameController {
void haltGame();
void haltGame();
void runGame();
}

View File

@ -6,7 +6,7 @@ import magic.exception.UndoClickedException;
import magic.model.choice.MagicPlayChoiceResult;
public interface IUIGameController extends IGameController {
<T> T getChoiceClicked();
boolean isActionClicked();
void clearCards();
@ -22,7 +22,7 @@ public interface IUIGameController extends IGameController {
void updateGameView();
void waitForInput() throws UndoClickedException;
void refreshSidebarLayout();
// Choices
MagicSubType getLandSubTypeChoice(final MagicSource source) throws UndoClickedException;
boolean getPayBuyBackCostChoice(final MagicSource source, final String costText) throws UndoClickedException;

View File

@ -10,10 +10,10 @@ import java.util.List;
import java.util.Set;
public class MagicAbilityList implements MagicAbilityStore {
private List<MagicAbility> abilities =
private List<MagicAbility> abilities =
new LinkedList<MagicAbility>();
private List<MagicTrigger<?>> triggers =
private List<MagicTrigger<?>> triggers =
new LinkedList<MagicTrigger<?>>();
private List<MagicActivation<MagicPermanent>> permActivations =
@ -37,7 +37,7 @@ public class MagicAbilityList implements MagicAbilityStore {
public MagicAbility getFirst() {
return abilities.get(0);
}
public void addAbility(final MagicAbility ability) {
abilities.add(ability);
}
@ -55,7 +55,7 @@ public class MagicAbilityList implements MagicAbilityStore {
permanent.addAbility(trigger);
}
}
public void loseAbility(final MagicPermanent permanent, final Set<MagicAbility> flags) {
flags.removeAll(abilities);
}

View File

@ -5,7 +5,7 @@ import magic.model.event.MagicEvent;
public abstract class MagicAmount {
public abstract int getAmount(final MagicSource source, final MagicPlayer player);
public int getAmount(final MagicEvent event) {
return getAmount(event.getSource(), event.getPlayer());
}

View File

@ -15,7 +15,7 @@ public class MagicAmountFactory {
}
};
}
public static MagicAmount CounterOnSource(final MagicCounterType type) {
return new MagicAmount() {
@Override
@ -25,7 +25,7 @@ public class MagicAmountFactory {
}
};
}
public static MagicAmount AllCountersOnSource =
new MagicAmount() {
@Override
@ -39,7 +39,7 @@ public class MagicAmountFactory {
}
};
public static MagicAmount One =
public static MagicAmount One =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
@ -50,8 +50,8 @@ public class MagicAmountFactory {
return true;
}
};
public static MagicAmount Constant(final int n) {
public static MagicAmount Constant(final int n) {
return new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
@ -63,8 +63,8 @@ public class MagicAmountFactory {
}
};
}
public static MagicAmount Equipment =
public static MagicAmount Equipment =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
@ -72,8 +72,8 @@ public class MagicAmountFactory {
return perm.getEquipmentPermanents().size();
}
};
public static MagicAmount Aura =
public static MagicAmount Aura =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
@ -81,16 +81,16 @@ public class MagicAmountFactory {
return perm.getAuraPermanents().size();
}
};
public static MagicAmount Domain =
public static MagicAmount Domain =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
return player.getDomain();
}
};
public static MagicAmount SN_Power =
public static MagicAmount SN_Power =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
@ -99,15 +99,15 @@ public class MagicAmountFactory {
}
};
public static MagicAmount LifeTotal =
public static MagicAmount LifeTotal =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
return player.getLife();
}
};
public static MagicAmount ColorsOnPerms =
public static MagicAmount ColorsOnPerms =
new MagicAmount() {
@Override
public int getAmount(final MagicSource source, final MagicPlayer player) {
@ -120,8 +120,8 @@ public class MagicAmountFactory {
return amount;
}
};
public static MagicAmount XCost =
public static MagicAmount XCost =
new MagicAmount() {
@Override
public int getAmount(final MagicEvent event) {
@ -132,8 +132,8 @@ public class MagicAmountFactory {
throw new RuntimeException("getAmount(source, player) called on XCost");
}
};
public static MagicAmount NegXCost =
public static MagicAmount NegXCost =
new MagicAmount() {
@Override
public int getAmount(final MagicEvent event) {

View File

@ -10,7 +10,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public enum MagicAmountParser {
YourLife("your life total") {
public MagicAmount toAmount(final Matcher arg) {
return MagicAmountFactory.LifeTotal;
@ -75,19 +75,19 @@ public enum MagicAmountParser {
);
}
};
private final Pattern pattern;
private MagicAmountParser(final String regex) {
pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
}
public Matcher matcher(final String rule) {
return pattern.matcher(rule);
}
public abstract MagicAmount toAmount(final Matcher arg);
public static final MagicAmount build(final String text) {
if (text == null || text.isEmpty()) {
return MagicAmountFactory.One;
@ -101,4 +101,4 @@ public enum MagicAmountParser {
}
throw new RuntimeException("unknown amount \"" + text + "\"");
}
}
}

View File

@ -663,7 +663,7 @@ public class MagicCardDefinition implements MagicAbilityStore, IRenderableCard {
public List<MagicEvent> getCostEvent(final MagicCard source) {
final List<MagicEvent> costEvent = new ArrayList<MagicEvent>();
final MagicManaCost modCost = source.getGame().modCost(source, cost);
if (modCost != MagicManaCost.ZERO) {
costEvent.add(new MagicPayManaCostEvent(
source,

View File

@ -18,7 +18,7 @@ public class MagicCardList extends ArrayList<MagicCard> implements MagicCopyable
add(copyMap.copy(card));
}
}
@Override
public MagicCardList copy(final MagicCopyMap copyMap) {
return new MagicCardList(copyMap, this);
@ -61,7 +61,7 @@ public class MagicCardList extends ArrayList<MagicCard> implements MagicCopyable
final int size = size();
return size > 0 ? get(size-1) : MagicCard.NONE;
}
public MagicCardList getRandomCards(final int amount) {
final MagicRandom rng = new MagicRandom(getStateId());
final MagicCardList copy = new MagicCardList(this);
@ -73,7 +73,7 @@ public class MagicCardList extends ArrayList<MagicCard> implements MagicCopyable
}
return choiceList;
}
public MagicCardList getCardsFromTop(final int amount) {
final int size = size();
final MagicCardList choiceList = new MagicCardList();
@ -90,7 +90,7 @@ public class MagicCardList extends ArrayList<MagicCard> implements MagicCopyable
remove(index);
return card;
}
public MagicCard removeCardAtBottom() {
final MagicCard card=get(0);
remove(0);

View File

@ -33,11 +33,11 @@ public class MagicDamage {
public MagicSource getSource() {
return source;
}
public boolean isSource(final MagicSource other) {
return source == other;
}
public boolean isSourcePermanent() {
return source.isPermanent();
}
@ -49,15 +49,15 @@ public class MagicDamage {
public MagicTarget getTarget() {
return target;
}
public boolean isTarget(final MagicTarget other) {
return target == other;
}
public boolean isTargetPlayer() {
return target.isPlayer();
}
public boolean isTargetCreature() {
return target.isCreature();
}
@ -65,7 +65,7 @@ public class MagicDamage {
public MagicPlayer getTargetPlayer() {
return (MagicPlayer)target;
}
public MagicPermanent getTargetPermanent() {
return (MagicPermanent)target;
}
@ -77,13 +77,13 @@ public class MagicDamage {
public void setAmount(final int amt) {
amount = amt;
}
public int replace() {
final int oldAmount = amount;
amount = 0;
return oldAmount;
}
public int prevent() {
return prevent(amount);
}
@ -115,7 +115,7 @@ public class MagicDamage {
public void setUnpreventable() {
unpreventable=true;
}
public boolean isPreventable() {
return !unpreventable;
}

View File

@ -91,7 +91,7 @@ public class MagicDuel {
void advance(final boolean won, final MagicGame game) {
gameNr++;
gamesPlayed++;
if (won) {
gamesWon++;
startPlayer = opponentIndex;
@ -167,7 +167,7 @@ public class MagicDuel {
break;
case Firemind:
setDeckFromFile(player, DeckUtils.getFiremindDecksFolder());
break;
break;
default:
break;
}

View File

@ -545,7 +545,7 @@ public class MagicGame {
public void addDelayedAction(final MagicAction action) {
delayedActions.add(action);
}
public void doValidAction(final MagicPermanent perm, final MagicAction action) {
if (perm.isValid()) {
doAction(action);

View File

@ -12,9 +12,9 @@ public class MagicGameLog {
private MagicGameLog() {}
public static final String LOG_FILE = "game.log";
private static final String gameLog = (System.getProperty("game.log") != null) ?
System.getProperty("game.log") :
System.getProperty("game.log") :
MagicFileSystem.getDataPath(DataPath.LOGS).resolve(LOG_FILE).toString();
private static PrintWriter writer;
@ -22,7 +22,7 @@ public class MagicGameLog {
public static String getLogFileName(){
return gameLog;
}
public static void initialize() {
try {
writer = new PrintWriter(gameLog);

View File

@ -34,7 +34,7 @@ public class MagicLogger {
public void log(final String message) {
sb.append(message).append("\n");
}
public void writeLog() {
sb.append("WRITTEN ON ").append(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
sb.append('\n');

View File

@ -80,7 +80,7 @@ public class MagicMessage {
for (int idx = 0; result.indexOf('$') >= 0; idx++) {
final String choice = (idx < choices.length && choices[idx] != null)
final String choice = (idx < choices.length && choices[idx] != null)
? getCardToken(choices[idx])
: "";
@ -91,7 +91,7 @@ public class MagicMessage {
}
private static final String CARD_TOKEN = "<%s" + CARD_ID_DELIMITER + "%d>";
public static String getXCost(final Object obj) {
if (obj != null && obj instanceof MagicPayedCost) {
return "X (" + ((MagicPayedCost)obj).getX() + ")";

View File

@ -10,45 +10,45 @@ public abstract class MagicObjectImpl implements MagicObject {
public boolean isEnemy(final MagicObject other) {
return getOpponent() == other.getController();
}
@Override
public MagicPlayer getOpponent() {
return getController().getOpponent();
}
@Override
public boolean isCreature() {
return isPermanent() && hasType(MagicType.Creature);
}
@Override
public boolean isPlaneswalker() {
return isPermanent() && hasType(MagicType.Planeswalker);
}
@Override
public boolean isInstantOrSorcerySpell() {
return isSpell(MagicType.Instant) || isSpell(MagicType.Sorcery);
}
@Override
public boolean isSpell(MagicType type) {
return isSpell() && hasType(type);
}
@Override
public boolean isSpell(MagicSubType subType) {
return isSpell() && hasSubType(subType);
}
@Override
public boolean isToken() {
return isPermanent() && ((MagicPermanent)this).isToken();
}
@Override
public boolean hasCounters(final MagicCounterType counterType) {
return getCounters(counterType) > 0;
return getCounters(counterType) > 0;
}
public static long getStateId(final Object obj) {

View File

@ -27,7 +27,7 @@ public class MagicPermanentList extends ArrayList<MagicPermanent> implements Mag
public MagicPermanentList copy(final MagicCopyMap copyMap) {
return new MagicPermanentList(copyMap, this);
}
public long getStateId() {
final long[] keys = new long[size()];
int idx = 0;

View File

@ -4,12 +4,12 @@ import magic.data.MagicIcon;
import magic.translate.UiString;
public enum MagicPlayerZone {
HAND(MagicPlayerZoneStrings._S1, MagicIcon.HAND_ZONE),
LIBRARY(MagicPlayerZoneStrings._S2, MagicIcon.LIBRARY_ZONE),
GRAVEYARD(MagicPlayerZoneStrings._S3, MagicIcon.GRAVEYARD_ZONE),
EXILE(MagicPlayerZoneStrings._S4, MagicIcon.EXILE_ZONE);
private final String zoneName;
private final MagicIcon zoneIcon;

View File

@ -17,7 +17,7 @@ public class MagicRandom extends Random {
}
System.err.println("Using random seed " + RNG.getState());
}
private MagicRandom() {
this(System.nanoTime());
}
@ -41,7 +41,7 @@ public class MagicRandom extends Random {
x &= ((1L << nbits) - 1);
return (int) x;
}
public long getState() {
return state;
}
@ -49,11 +49,11 @@ public class MagicRandom extends Random {
public static void setRNGState(final long state) {
RNG.setState(state);
}
public static int nextRNGInt(final int n) {
return RNG.nextInt(n);
}
public static int nextRNGInt() {
return RNG.nextInt(Integer.MAX_VALUE);
}

View File

@ -8,15 +8,15 @@ import java.util.List;
import java.util.Arrays;
public class AIRevealAction extends MagicAction {
private final List<MagicCard> cards = new ArrayList<MagicCard>();
private final List<Boolean> known = new ArrayList<Boolean>();
private boolean newValue;
public AIRevealAction(final MagicCard... aCards) {
this(Arrays.asList(aCards), true);
}
public AIRevealAction(final Collection<MagicCard> aCards) {
this(aCards, true);
}

View File

@ -29,7 +29,7 @@ public class AddTriggerAction extends MagicAction {
public void undoAction(final MagicGame game) {
game.removeTrigger(permanentTrigger);
}
@Override
public String toString() {
return getClass().getSimpleName()+" ("+permanent+','+trigger+')';

View File

@ -15,7 +15,7 @@ public class AddTurnTriggerAction extends MagicAction {
this.permanent=permanent;
this.trigger=trigger;
}
public AddTurnTriggerAction(final MagicTrigger<?> trigger) {
this(MagicPermanent.NONE, trigger);
}

View File

@ -26,7 +26,7 @@ public class AttachAction extends MagicAction {
attachable = aAttachable;
creature = aCreature;
}
private MagicPermanent getAttached() {
return attachable.isEquipment() ?
attachable.getEquippedCreature() :
@ -40,7 +40,7 @@ public class AttachAction extends MagicAction {
old.removeAura(attachable);
}
}
private void attach(final MagicPermanent perm) {
if (attachable.isEquipment()) {
perm.addEquipment(attachable);

View File

@ -26,13 +26,13 @@ public class BecomesAction extends MagicAction {
private final boolean additionTo;
public BecomesAction(
final MagicPermanent aPermanent,
final int[] aPt,
final Set<MagicColor> aColor,
final Set<MagicSubType> aSubType,
final Set<MagicType> aType,
final MagicAbilityList aAbility,
final boolean aDuration,
final MagicPermanent aPermanent,
final int[] aPt,
final Set<MagicColor> aColor,
final Set<MagicSubType> aSubType,
final Set<MagicType> aType,
final MagicAbilityList aAbility,
final boolean aDuration,
final boolean aAdditionTo
) {
permanent = aPermanent;
@ -44,7 +44,7 @@ public class BecomesAction extends MagicAction {
duration=aDuration;
additionTo=aAdditionTo;
}
public BecomesAction(final MagicPermanent aPermanent, final Set<MagicColor> aColor, final boolean aDuration, final boolean aAdditionTo) {
this(aPermanent, null, aColor, Collections.<MagicSubType>emptySet(), Collections.<MagicType>emptySet(), null, aDuration, aAdditionTo);
}
@ -86,7 +86,7 @@ public class BecomesAction extends MagicAction {
return flags | mask;
// if color change replaces original color, return changes
} else {
return mask;
return mask;
}
}
};
@ -102,7 +102,7 @@ public class BecomesAction extends MagicAction {
@Override
public int getTypeFlags(final MagicPermanent permanent,final int flags) {
// turning into an artifact creature retains previous types
if (additionTo || (type.contains(MagicType.Creature) && type.contains(MagicType.Artifact))) {
if (additionTo || (type.contains(MagicType.Creature) && type.contains(MagicType.Artifact))) {
return flags | mask;
} else {
return mask;
@ -116,7 +116,7 @@ public class BecomesAction extends MagicAction {
@Override
public void modSubTypeFlags(final MagicPermanent permanent, final Set<MagicSubType> flags) {
// turning into an artifact creature retains previous subtypes
if (additionTo || (type.contains(MagicType.Creature) && type.contains(MagicType.Artifact))) {
if (additionTo || (type.contains(MagicType.Creature) && type.contains(MagicType.Artifact))) {
flags.addAll(subType);
} else {
flags.clear();

View File

@ -34,7 +34,7 @@ public class CastCardAction extends MagicAction {
from = aFrom;
to = aTo;
}
@Override
public void doAction(final MagicGame game) {
for (final MagicEvent event : card.getAdditionalCostEvent()) {

View File

@ -21,7 +21,7 @@ public class ChangeTurnPTAction extends MagicAction {
@Override
public void doAction(final MagicGame game) {
game.doAction(new AddStaticAction(
permanent,
permanent,
new MagicStatic(MagicLayer.ModPT, MagicStatic.UntilEOT) {
@Override
public void modPowerToughness(final MagicPermanent source, final MagicPermanent permanent, final MagicPowerToughness pt) {

View File

@ -24,16 +24,16 @@ public class CleanupPlayerAction extends MagicAction {
oldDrawnCards=player.getDrawnCards();
player.setDrawnCards(0);
oldLifeLost=player.getLifeLossThisTurn();
player.setLifeLossThisTurn(0);
oldLifeGained=player.getLifeGainThisTurn();
player.setLifeGainThisTurn(0);
oldCreaturesAttacked=player.getCreaturesAttackedThisTurn();
player.setCreaturesAttackedThisTurn(0);
for (final MagicPermanent permanent : player.getPermanents()) {
game.doAction(new CleanupPermanentAction(permanent));

View File

@ -56,7 +56,7 @@ public class CombatDamageAction extends MagicAction {
combatDamage.add(MagicDamage.Combat(blocker,attacker,power));
}
if (first) {
game.doAction(ChangeStateAction.Set(blocker, MagicPermanentState.DealtFirstStrike));
game.doAction(ChangeStateAction.Set(blocker, MagicPermanentState.DealtFirstStrike));
}
}
}
@ -102,7 +102,7 @@ public class CombatDamageAction extends MagicAction {
}
}
if (first) {
game.doAction(ChangeStateAction.Set(attacker, MagicPermanentState.DealtFirstStrike));
game.doAction(ChangeStateAction.Set(attacker, MagicPermanentState.DealtFirstStrike));
}
}
}

View File

@ -25,10 +25,10 @@ public class CounterItemOnStackAction extends MagicAction {
game.doAction(new RemoveItemFromStackAction(itemOnStack));
if (itemOnStack.isSpell()) {
final MagicCardOnStack cardOnStack = (MagicCardOnStack)itemOnStack;
final MagicLocationType destination = (toLocation == MagicLocationType.Stack) ?
final MagicLocationType destination = (toLocation == MagicLocationType.Stack) ?
cardOnStack.getMoveLocation() :
toLocation;
game.doAction(new MoveCardAction(
cardOnStack.getCard(),
MagicLocationType.Stack,

View File

@ -21,7 +21,7 @@ public class DealDamageAction extends MagicAction {
private final MagicDamage damage;
private MagicTarget target;
private int oldDamage = UNINIT;
public DealDamageAction(final MagicSource source, MagicTarget target, final int amt) {
this(new MagicDamage(source, target, amt), null);
}
@ -42,7 +42,7 @@ public class DealDamageAction extends MagicAction {
@Override
public void doAction(final MagicGame game) {
game.executeTrigger(MagicTriggerType.IfDamageWouldBeDealt,damage);
/*
306.7. If damage would be dealt to a player by a source
controlled by an opponent, that opponent may have that source deal that

View File

@ -12,7 +12,7 @@ public class DiscardCardAction extends MagicAction {
private final MagicCard card;
private final MagicLocationType toLocation;
private int index;
public DiscardCardAction(final MagicPlayer aPlayer,final MagicCard aCard) {
this(aPlayer, aCard, MagicLocationType.Graveyard);
}

View File

@ -22,7 +22,7 @@ public class FlipAction extends MagicAction {
public void doAction(final MagicGame game) {
if (permanent.isFlipCard() && permanent.isFlipped() == false) {
oldStatics = permanent.getStatics();
game.doAction(ChangeStateAction.Set(permanent, MagicPermanentState.Flipped));
newStatics = permanent.getStatics();

View File

@ -17,7 +17,7 @@ public class GainAbilityAction extends MagicAction {
private final MagicPermanent permanent;
private final MagicAbilityList abilityList;
private final boolean duration;
public GainAbilityAction(final MagicPermanent permanent,final MagicAbilityList abilityList, final boolean duration) {
this.permanent=permanent;
this.abilityList=abilityList;
@ -27,7 +27,7 @@ public class GainAbilityAction extends MagicAction {
public GainAbilityAction(final MagicPermanent permanent,final Set<MagicAbility> abilities, final boolean duration) {
this(permanent,MagicAbility.getAbilityList(abilities), duration);
}
public GainAbilityAction(final MagicPermanent permanent,final MagicAbilityList abilityList) {
this(permanent,abilityList,MagicStatic.UntilEOT);
}

View File

@ -26,7 +26,7 @@ public class GainControlAction extends MagicAction {
public void doAction(final MagicGame game) {
//insert continuous effect
game.doAction(new AddStaticAction(
permanent,
permanent,
new MagicStatic(MagicLayer.Control, duration) {
@Override
public MagicPlayer getController(final MagicPermanent source, final MagicPermanent permanent, final MagicPlayer controller) {

View File

@ -13,7 +13,7 @@ import java.util.Collection;
import java.util.List;
public class LookAction extends MagicAction {
private final List<MagicCard> cards = new ArrayList<MagicCard>();
private final MagicPlayer player;
private final String desc;

View File

@ -17,7 +17,7 @@ public class LoseAbilityAction extends MagicAction {
private final MagicPermanent permanent;
private final MagicAbilityList abilityList;
private final boolean duration;
public LoseAbilityAction(final MagicPermanent permanent,final MagicAbilityList abilityList, final boolean duration) {
this.permanent=permanent;
this.abilityList=abilityList;
@ -27,7 +27,7 @@ public class LoseAbilityAction extends MagicAction {
public LoseAbilityAction(final MagicPermanent permanent,final Set<MagicAbility> abilities, final boolean duration) {
this(permanent,MagicAbility.getAbilityList(abilities), duration);
}
public LoseAbilityAction(final MagicPermanent permanent,final MagicAbilityList abilityList) {
this(permanent,abilityList,MagicStatic.UntilEOT);
}

View File

@ -30,6 +30,6 @@ public class ManifestAction extends MagicAction {
@Override
public void undoAction(final MagicGame game) {
}
}

View File

@ -13,7 +13,7 @@ public class ManifestCardAction extends PlayCardAction {
public ManifestCardAction(final MagicCard card, final MagicPlayer player) {
super(card, player, MagicPlayMod.MANIFEST);
}
@Override
public void doAction(final MagicGame game) {
final MagicCardOnStack cardOnStack = new MagicCardOnStack(

View File

@ -22,19 +22,19 @@ public class PlayCardAction extends MagicAction {
controller = aController;
modifications = aModifications;
}
public PlayCardAction(final MagicCard aCard, final MagicPlayer aController,final MagicPermanentAction... aModifications) {
this(aCard, aController, Arrays.asList(aModifications));
}
public PlayCardAction(final MagicCard card, final MagicPlayer player) {
this(card, player, Collections.<MagicPermanentAction>emptyList());
}
public PlayCardAction(final MagicCard card, final List<? extends MagicPermanentAction> modifications) {
this(card, card.getController(), modifications);
}
public PlayCardAction(final MagicCard card) {
this(card, card.getController(), Collections.<MagicPermanentAction>emptyList());
}

View File

@ -17,7 +17,7 @@ public class PlayTokenAction extends MagicAction {
private final MagicCard card;
private final List<? extends MagicPermanentAction> modifications;
public PlayTokenAction(final MagicPlayer player,final MagicCardDefinition cardDefinition, final List<? extends MagicPermanentAction> aModifications) {
card = MagicCard.createTokenCard(cardDefinition,player);
modifications = aModifications;
@ -27,23 +27,23 @@ public class PlayTokenAction extends MagicAction {
card = aCard;
modifications = Collections.<MagicPermanentAction>emptyList();
}
public PlayTokenAction(final MagicPlayer player,final MagicCardDefinition cardDefinition) {
this(player, cardDefinition, Collections.<MagicPermanentAction>emptyList());
}
public PlayTokenAction(final MagicPlayer player,final MagicCardDefinition cardDefinition,final MagicPermanentAction... aModifications) {
this(player, cardDefinition, Arrays.asList(aModifications));
}
public PlayTokenAction(final MagicPlayer player,final MagicObject obj) {
this(player, obj.getCardDefinition(), Collections.<MagicPermanentAction>emptyList());
}
public PlayTokenAction(final MagicPlayer player,final MagicObject obj, final List<? extends MagicPermanentAction> aModifications) {
this(player, obj.getCardDefinition(), aModifications);
}
public PlayTokenAction(final MagicPlayer player,final MagicObject obj, final MagicPermanentAction... aModifications) {
this(player, obj.getCardDefinition(), Arrays.asList(aModifications));
}
@ -53,7 +53,7 @@ public class PlayTokenAction extends MagicAction {
final MagicCardOnStack cardOnStack = new MagicCardOnStack(card, card.getController(), MagicPayedCost.NOT_SPELL, modifications);
game.addEvent(cardOnStack.getEvent());
}
@Override
public void undoAction(final MagicGame game) {}
}

View File

@ -15,7 +15,7 @@ public class PlayTokensAction extends MagicAction {
card = MagicCard.createTokenCard(cardDefinition,player);
count = aCount;
}
public PlayTokensAction(final MagicPlayer player, final MagicObject obj, final int aCount) {
this(player, obj.getCardDefinition(), aCount);
}

View File

@ -19,11 +19,11 @@ public class ReanimateAction extends MagicAction {
controller = aController;
modifications = aModifications;
}
public ReanimateAction(final MagicCard aCard, final MagicPlayer aController, final MagicPermanentAction... aModifications) {
this(aCard, aController, Arrays.asList(aModifications));
}
@Override
public void doAction(final MagicGame game) {
if (card.isInGraveyard() && card.isPermanentCard()) {
@ -31,7 +31,7 @@ public class ReanimateAction extends MagicAction {
game.doAction(new PlayCardAction(card,controller,modifications));
}
}
@Override
public void undoAction(final MagicGame game) {}
}

View File

@ -13,12 +13,12 @@ public class ReclaimExiledCardAction extends MagicAction {
this.source = source;
this.card = card;
}
public void doAction(final MagicGame game) {
game.doAction(new ShiftCardAction(card, MagicLocationType.Exile, MagicLocationType.OwnersHand));
source.removeExiledCard(card);
}
public void undoAction(final MagicGame game) {
source.addExiledCard(card);
}

View File

@ -9,15 +9,15 @@ import java.util.Collection;
import java.util.ArrayList;
public class RemoveAllFromPlayAction extends MagicAction {
private final Collection<MagicPermanent> perms = new ArrayList<MagicPermanent>();
private final MagicLocationType toLocation;
public RemoveAllFromPlayAction(final Collection<MagicPermanent> aPerms, final MagicLocationType aToLocation) {
perms.addAll(aPerms);
toLocation = aToLocation;
}
@Override
public void doAction(final MagicGame game) {
final boolean isLibrary = toLocation == MagicLocationType.OwnersLibrary;
@ -42,7 +42,7 @@ public class RemoveAllFromPlayAction extends MagicAction {
game.update();
}
}
@Override
public void undoAction(final MagicGame game) {}
}

View File

@ -18,7 +18,7 @@ public class RemoveFromPlayAction extends MagicAction {
toLocation = aToLocation;
update = aUpdate;
}
// default to update after remove
public RemoveFromPlayAction(final MagicPermanent aPermanent, final MagicLocationType aToLocation) {
this(aPermanent, aToLocation, true);
@ -32,11 +32,11 @@ public class RemoveFromPlayAction extends MagicAction {
public boolean isValid() {
return valid;
}
public boolean isPermanent(final MagicPermanent aPermanent) {
return permanent == aPermanent;
}
public MagicPermanent getPermanent() {
return permanent;
}

View File

@ -22,11 +22,11 @@ public class ReturnCardAction extends MagicAction {
from = aFrom;
modifications = aModifications;
}
public ReturnCardAction(final MagicLocationType aFrom, final MagicCard aCard, final MagicPlayer aController, final MagicPermanentAction... aModifications) {
this(aFrom, aCard, aController, Arrays.asList(aModifications));
}
@Override
public void doAction(final MagicGame game) {
if (card.isIn(from) && card.isPermanentCard()) {
@ -34,7 +34,7 @@ public class ReturnCardAction extends MagicAction {
game.doAction(new PlayCardAction(card,controller,modifications));
}
}
@Override
public void undoAction(final MagicGame game) {}
}

View File

@ -13,7 +13,7 @@ import magic.model.event.MagicEvent;
import magic.model.event.MagicEventAction;
public class RevealAction extends MagicAction {
private final List<MagicCard> cards = new ArrayList<>();
public RevealAction(final MagicCard aCard) {

View File

@ -15,7 +15,7 @@ public class ScryComplAction extends MagicAction {
public ScryComplAction(final MagicPlayer aPlayer, final MagicCard aCard, final boolean aDown) {
player = aPlayer;
card = aCard;
down = aDown;
down = aDown;
}
@Override

View File

@ -8,13 +8,13 @@ public class ShiftCardAction extends MagicAction {
public final MagicCard card;
public final MagicLocationType from;
public final MagicLocationType to;
public ShiftCardAction(final MagicCard aCard, final MagicLocationType fromLocation, final MagicLocationType toLocation) {
card = aCard;
from = fromLocation;
to = toLocation;
}
@Override
public void doAction(final MagicGame game) {
if (card.isIn(from)) {
@ -22,7 +22,7 @@ public class ShiftCardAction extends MagicAction {
game.doAction(new MoveCardAction(card, from, to));
}
}
@Override
public void undoAction(final MagicGame game) {}
}

View File

@ -37,7 +37,7 @@ public class SoulbondAction extends MagicAction {
if (!valid) {
return;
}
if (set) {
permanent.setPairedCreature(MagicPermanent.NONE);
pairedCreature.setPairedCreature(MagicPermanent.NONE);

View File

@ -12,7 +12,7 @@ public class TapAction extends MagicAction {
private final MagicPermanent permanent;
private boolean isUntapped;
private final boolean hasScore;
public TapAction(final MagicPermanent permanent) {
this(permanent, true);
}

View File

@ -22,13 +22,13 @@ public class TransformAction extends MagicAction {
public void doAction(final MagicGame game) {
if (permanent.isValid() && permanent.isDoubleFaced()) {
oldStatics = permanent.getStatics();
if (permanent.isTransformed()) {
game.doAction(ChangeStateAction.Clear(permanent, MagicPermanentState.Transformed));
} else {
game.doAction(ChangeStateAction.Set(permanent, MagicPermanentState.Transformed));
}
newStatics = permanent.getStatics();
game.removeStatics(permanent, oldStatics);
game.addStatics(permanent, newStatics);

View File

@ -22,9 +22,9 @@ public class TurnFaceDownAction extends MagicAction {
public void doAction(final MagicGame game) {
if (permanent.isFaceDown() == false && permanent.isDoubleFaced() == false) {
oldStatics = permanent.getStatics();
game.doAction(ChangeStateAction.Set(permanent, MagicPermanentState.FaceDown));
newStatics = permanent.getStatics();
game.removeStatics(permanent, oldStatics);
game.addStatics(permanent, newStatics);

View File

@ -23,14 +23,14 @@ public class TurnFaceUpAction extends MagicAction {
public void doAction(final MagicGame game) {
if (permanent.isFaceDown() && permanent.getRealCardDefinition().isPermanent()) {
oldStatics = permanent.getStatics();
game.doAction(ChangeStateAction.Clear(permanent, MagicPermanentState.FaceDown));
game.doAction(ChangeStateAction.Clear(permanent, MagicPermanentState.Manifest));
newStatics = permanent.getStatics();
game.removeStatics(permanent, oldStatics);
game.addStatics(permanent, newStatics);
// force an update so that triggers are registered
game.update();

View File

@ -113,5 +113,5 @@ public class MagicBasicLandChoice extends MagicChoice {
controller.disableActionButton(false);
return new Object[]{controller.getLandSubTypeChoice(source)};
}
}

View File

@ -48,7 +48,7 @@ public class MagicBuilderPayManaCostResult implements MagicPayManaCostResult, Co
x = source.x;
hashCode = source.hashCode;
}
@Override
public MagicBuilderPayManaCostResult copy(final MagicCopyMap copyMap) {
return new MagicBuilderPayManaCostResult(copyMap, this);

View File

@ -22,13 +22,13 @@ public class MagicCardChoiceResult extends ArrayList<MagicCard> implements Magic
}
MagicCardChoiceResult() {}
private MagicCardChoiceResult(final MagicCopyMap copyMap, final List<MagicCard> cardList) {
for (final MagicCard card : cardList) {
add(copyMap.copy(card));
}
}
@Override
public MagicCardChoiceResult copy(final MagicCopyMap copyMap) {
return new MagicCardChoiceResult(copyMap, this);
@ -43,7 +43,7 @@ public class MagicCardChoiceResult extends ArrayList<MagicCard> implements Magic
}
return result;
}
@Override
public String toString() {
final StringBuilder buffer=new StringBuilder();

View File

@ -52,7 +52,7 @@ public abstract class MagicChoice {
public MagicTargetChoice getTargetChoice() {
return MagicTargetChoice.NONE;
}
public MagicTargetChoice getTargetChoice(final Object[] chosen) {
return getTargetChoice();
}

View File

@ -43,7 +43,7 @@ public class MagicDelayedPayManaCostResult implements MagicPayManaCostResult {
public void doAction(final MagicGame game,final MagicPlayer player) {
game.doAction(new PayDelayedCostAction(player,this));
}
@Override
public MagicDelayedPayManaCostResult copy(final MagicCopyMap copyMap) {
return this;
@ -53,7 +53,7 @@ public class MagicDelayedPayManaCostResult implements MagicPayManaCostResult {
public MagicDelayedPayManaCostResult map(final MagicGame game) {
return this;
}
@Override
public long getId() {
return hashCode();

View File

@ -23,7 +23,7 @@ public class MagicFromCardFilterChoice extends MagicChoice {
private final String displayMessage;
private final int amount;
private final boolean upTo;
public MagicFromCardFilterChoice(final MagicTargetFilter<MagicCard> aFilter, final int aAmount, final boolean aUpTo, final String description) {
super(genDescription(aAmount, description, aUpTo));
filter = aFilter;
@ -54,7 +54,7 @@ public class MagicFromCardFilterChoice extends MagicChoice {
final int limit,
final int index
) {
if (count == limit) {
options.add(new MagicCardChoiceResult(cards));
return;
@ -69,7 +69,7 @@ public class MagicFromCardFilterChoice extends MagicChoice {
createOptions(options,cList,cards,count+1,limit,index+1);
createOptions(options,cList,cards,count,limit,index+1);
}
private void createOptionsUpTo(
final Collection<Object> options,
final List<MagicCard> cList,
@ -78,7 +78,7 @@ public class MagicFromCardFilterChoice extends MagicChoice {
final int limit,
final int index
) {
if (index >= cList.size() || count >= limit) {
final MagicCardChoiceResult result = new MagicCardChoiceResult(cards);
//System.out.println("add " + result);
@ -95,12 +95,12 @@ public class MagicFromCardFilterChoice extends MagicChoice {
cards[count + i] = cList.get(index + i);
createOptionsUpTo(options,cList,cards,count + i + 1,limit,index + cnt);
}
// use 0 copies of first
for (int i = 0; i < cnt && count + i + 1 <= limit; i++) {
cards[count + i] = null;
}
createOptionsUpTo(options,cList,cards,count,limit,index + cnt);
}
}
@ -132,12 +132,12 @@ public class MagicFromCardFilterChoice extends MagicChoice {
} else {
createOptions(options,cList,new MagicCard[actualAmount],0,actualAmount,0);
}
//hide the cards
for (int i = 0; i < oList.size(); i++) {
oList.get(i).setGameKnown(known.get(i));
}
return options;
}

View File

@ -31,31 +31,31 @@ public class MagicFromCardListChoice extends MagicChoice {
public MagicFromCardListChoice(final List<MagicCard> choiceList,final int amount) {
this(choiceList, choiceList, amount, false);
}
public MagicFromCardListChoice(final List<MagicCard> choiceList,final int amount, final String description) {
this(choiceList, choiceList, amount, false, description);
}
public MagicFromCardListChoice(final List<MagicCard> choiceList,final int amount, final boolean upTo) {
this(choiceList, choiceList, amount, upTo);
}
public MagicFromCardListChoice(final List<MagicCard> choiceList,final int amount, final boolean upTo, final String description) {
this(choiceList, choiceList, amount, upTo, description);
}
public MagicFromCardListChoice(final List<MagicCard> choiceList,final List<MagicCard> showList,final int amount) {
this(choiceList, showList, amount, false);
}
public MagicFromCardListChoice(final List<MagicCard> choiceList,final List<MagicCard> showList,final int amount, final String description) {
this(choiceList, showList, amount, false, description);
}
public MagicFromCardListChoice(final List<MagicCard> choiceList,final List<MagicCard> showList,final int amount, final boolean upTo) {
this(choiceList, showList, amount, upTo, "");
}
public MagicFromCardListChoice(final List<MagicCard> aChoiceList,final List<MagicCard> aShowList,final int aAmount, final boolean aUpTo, final String description) {
super(genDescription(aAmount, description, aUpTo));
choiceList = aChoiceList;
@ -89,7 +89,7 @@ public class MagicFromCardListChoice extends MagicChoice {
final int limit,
final int index
) {
if (count == limit) {
options.add(new MagicCardChoiceResult(cards));
return;
@ -104,7 +104,7 @@ public class MagicFromCardListChoice extends MagicChoice {
createOptions(options,cList,cards,count+1,limit,index+1);
createOptions(options,cList,cards,count,limit,index+1);
}
private void createOptionsUpTo(
final Collection<Object> options,
final List<MagicCard> cList,
@ -113,7 +113,7 @@ public class MagicFromCardListChoice extends MagicChoice {
final int limit,
final int index
) {
if (index >= cList.size() || count >= limit) {
final MagicCardChoiceResult result = new MagicCardChoiceResult(cards);
//System.out.println("add " + result);
@ -130,12 +130,12 @@ public class MagicFromCardListChoice extends MagicChoice {
cards[count + i] = cList.get(index + i);
createOptionsUpTo(options,cList,cards,count + i + 1,limit,index + cnt);
}
// use 0 copies of first
for (int i = 0; i < cnt && count + i + 1 <= limit; i++) {
cards[count + i] = null;
}
createOptionsUpTo(options,cList,cards,count,limit,index + cnt);
}
}
@ -149,7 +149,7 @@ public class MagicFromCardListChoice extends MagicChoice {
final List<Object> options = new ArrayList<Object>();
final List<MagicCard> oList = new ArrayList<MagicCard>();
final List<Boolean> known = new ArrayList<Boolean>(oList.size());
//map the cards to the current game
for (final MagicCard card : choiceList) {
oList.add(card.map(game));
@ -172,12 +172,12 @@ public class MagicFromCardListChoice extends MagicChoice {
} else {
createOptions(options,cList,new MagicCard[actualAmount],0,actualAmount,0);
}
//hide the cards
for (int i = 0; i < oList.size(); i++) {
oList.get(i).setGameKnown(known.get(i));
}
return options;
}

View File

@ -23,7 +23,7 @@ public class MagicMayChoice extends MagicChoice {
new Object[]{YES_CHOICE},
new Object[]{NO_CHOICE}
);
private final MagicChoice[] choices;
private final MagicTargetChoice targetChoice;
private final int manaChoiceResultIndex;
@ -45,7 +45,7 @@ public class MagicMayChoice extends MagicChoice {
}
};
}
public MagicMayChoice(final String description,final MagicMatchedCostEvent cost) {
this(description, satisfied(cost));
}

View File

@ -51,7 +51,7 @@ public class MagicMulliganChoice extends MagicChoice {
costSum += card.getConvertedCost();
//System.err.println("MULLIGAN: card=" + card);
}
// There is more fine tuning to be done here
int minLands = 2;
int maxLands = 3;
@ -64,7 +64,7 @@ public class MagicMulliganChoice extends MagicChoice {
}
final int hand = player.getHandSize();
if (hand <= 4) {
return NO_CHOICE_LIST;
}
@ -83,16 +83,16 @@ public class MagicMulliganChoice extends MagicChoice {
int playable = 0;
for (final MagicCard card : assumedPlayer.getHand()) {
if (card.hasType(MagicType.Land) == false &&
if (card.hasType(MagicType.Land) == false &&
card.getCost().getCondition().accept(card)) {
playable++;
}
}
//System.err.println("MULLIGAN: hand=" + hand + " lands=" + numLands + " playable=" + playable);
if ((hand > 6 && playable > 1) ||
(hand <= 6 && playable > 0)) {
(hand <= 6 && playable > 0)) {
return NO_CHOICE_LIST;
} else if (numLands < minLands || numLands > maxLands) {
return YES_CHOICE_LIST;

View File

@ -23,7 +23,7 @@ public class MagicOrChoice extends MagicChoice {
public MagicOrChoice(final MagicChoice... choices) {
this("Choose the mode.", choices);
}
@Override
public MagicTargetChoice getTargetChoice(final Object[] chosen) {
final int idx = (Integer)chosen[0] - 1;
@ -66,7 +66,7 @@ public class MagicOrChoice extends MagicChoice {
}
}
}
if (choiceResultsList.isEmpty()) {
choiceResultsList.add(new Object[]{0});
}
@ -78,7 +78,7 @@ public class MagicOrChoice extends MagicChoice {
public Object[] getPlayerChoiceResults(final IUIGameController controller, final MagicGame game, final MagicEvent event) throws UndoClickedException {
final MagicPlayer player = event.getPlayer();
final MagicSource source = event.getSource();
final boolean hints = GeneralConfig.getInstance().getSmartTarget();
final List<Integer> availableModes = new ArrayList<>();
for (int i = 0; i < choices.length; i++) {

View File

@ -28,7 +28,7 @@ public class MagicPlayChoice extends MagicChoice {
private static final String _S_CONTINUE_MESSAGE = "Click {f} or Space to pass.";
@StringContext(eg = "| represents a new line. Position to fit text in user prompt.")
private static final String _S_SKIP_MESSAGE = "Right click {f} or Shift+Space to|skip till end of turn.";
private static final String MESSAGE = String.format("%s|%s|[%s]",
UiString.get(_S_PLAY_MESSAGE),
UiString.get(_S_CONTINUE_MESSAGE),
@ -91,11 +91,11 @@ public class MagicPlayChoice extends MagicChoice {
public Object[] getPlayerChoiceResults(final IUIGameController controller, final MagicGame game, final MagicEvent event) throws UndoClickedException {
final MagicPlayer player = event.getPlayer();
final MagicSource source = event.getSource();
controller.focusViewers(0);
//always pass draw and begin combat if
// option is true and
// option is true and
// stack is empty
if (game.canAlwaysPass() && game.getStack().isEmpty()) {
return PASS_CHOICE_RESULTS;
@ -147,7 +147,7 @@ public class MagicPlayChoice extends MagicChoice {
if (game.shouldSkip()) {
if (game.getStack().isEmpty() == false) {
game.clearSkipTurnTill();
} else if (game.isPhase(MagicPhaseType.DeclareAttackers) && game.getNrOfPermanents(MagicPermanentState.Attacking) > 0) {
} else if (game.isPhase(MagicPhaseType.DeclareAttackers) && game.getNrOfPermanents(MagicPermanentState.Attacking) > 0) {
game.clearSkipTurnTill();
} else {
return PASS_CHOICE_RESULTS;
@ -173,7 +173,7 @@ public class MagicPlayChoice extends MagicChoice {
return PASS_CHOICE_RESULTS;
}
final MagicSource activationSource = controller.getChoiceClicked();
final MagicSource activationSource = controller.getChoiceClicked();
final List<MagicPlayChoiceResult> results=new ArrayList<>();
for (final MagicSourceActivation<? extends MagicSource> sourceActivation : activationSource.getSourceActivations()) {
if (sourceActivation.canPlay(game,player,false)) {

View File

@ -33,7 +33,7 @@ public class MagicPlayerPayManaCostResult implements MagicPayManaCostResult {
public String toString() {
return x>0?"X="+x:"";
}
@Override
public MagicPlayerPayManaCostResult copy(final MagicCopyMap copyMap) {
return this;
@ -43,7 +43,7 @@ public class MagicPlayerPayManaCostResult implements MagicPayManaCostResult {
public MagicPlayerPayManaCostResult map(final MagicGame game) {
return this;
}
@Override
public long getId() {
return hashCode();

Some files were not shown because too many files have changed in this diff Show More