mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Merge branch 'master' into muse-vessel
This commit is contained in:
commit
a6311be836
645 changed files with 3060 additions and 1353 deletions
|
@ -1083,10 +1083,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
private void chooseMatching() {
|
||||
Collection<CardView> toMatch = dragCardList();
|
||||
|
||||
|
||||
for (DragCardGridListener l : listeners) {
|
||||
for (CardView card : allCards) {
|
||||
for (CardView aMatch : toMatch) {
|
||||
|
@ -1337,6 +1337,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
public void analyseDeck() {
|
||||
HashMap<String, Integer> qtys = new HashMap<>();
|
||||
HashMap<String, Integer> pips = new HashMap<>();
|
||||
HashMap<String, Integer> pips_at_cmcs = new HashMap<>();
|
||||
HashMap<String, Integer> sourcePips = new HashMap<>();
|
||||
HashMap<String, Integer> manaCounts = new HashMap<>();
|
||||
pips.put("#w}", 0);
|
||||
|
@ -1396,11 +1397,40 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
mc = mc.replaceAll("\\{([WUBRG]).([WUBRG])\\}", "{$1}{$2}");
|
||||
mc = mc.replaceAll("\\{", "#");
|
||||
mc = mc.replaceAll("#2\\/", "#");
|
||||
mc = mc.replaceAll("p}", "}");
|
||||
mc = mc.toLowerCase(Locale.ENGLISH);
|
||||
int cmc = card.getConvertedManaCost();
|
||||
|
||||
// Do colorless mana pips
|
||||
Pattern regex = Pattern.compile("#([0-9]+)}");
|
||||
Matcher regexMatcher = regex.matcher(mc);
|
||||
while (regexMatcher.find()) {
|
||||
String val = regexMatcher.group(1);
|
||||
int colorless_val = Integer.parseInt(val);
|
||||
|
||||
int total_c_pip = 0;
|
||||
if (pips.get("#c}") != null) {
|
||||
total_c_pip = pips.get("#c}");
|
||||
}
|
||||
pips.put("#c}", colorless_val + total_c_pip);
|
||||
|
||||
int cmc_pip_value = 0;
|
||||
if (pips_at_cmcs.get(cmc + "##c}") != null) {
|
||||
cmc_pip_value = pips_at_cmcs.get(cmc + "##c}");
|
||||
}
|
||||
pips_at_cmcs.put(cmc + "##c}", colorless_val + cmc_pip_value);
|
||||
}
|
||||
|
||||
for (String pip : pips.keySet()) {
|
||||
int value = pips.get(pip);
|
||||
while (mc.toLowerCase(Locale.ENGLISH).contains(pip)) {
|
||||
pips.put(pip, ++value);
|
||||
int pip_value = 0;
|
||||
if (pips_at_cmcs.get(cmc + "#" + pip) != null) {
|
||||
pip_value = pips_at_cmcs.get(cmc + "#" + pip);
|
||||
}
|
||||
pips_at_cmcs.put(cmc + "#" + pip, ++pip_value);
|
||||
mc = mc.replaceFirst(pip, "");
|
||||
}
|
||||
}
|
||||
|
@ -1448,9 +1478,17 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
panel4.add(new JLabel("Mana sources found:"));
|
||||
panel4.add(chart3);
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
panel5.setLayout(new BoxLayout(panel5, BoxLayout.Y_AXIS));
|
||||
ManaBarChart chart4 = new ManaBarChart(pips_at_cmcs);
|
||||
chart4.setMinimumSize(new Dimension(200, 200));
|
||||
panel5.add(new JLabel("Mana distribution:"));
|
||||
panel5.add(chart4);
|
||||
|
||||
panel.add(panel2);
|
||||
panel.add(panel3);
|
||||
panel.add(panel4);
|
||||
panel.add(panel5);
|
||||
|
||||
JFrame frame = new JFrame("JOptionPane showMessageDialog component example");
|
||||
JOptionPane.showMessageDialog(frame, panel, "This is the distribution of colors found", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
@ -1719,7 +1757,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
JMenuItem invertSelection = new JMenuItem("Invert Selection");
|
||||
invertSelection.addActionListener(e2 -> invertSelection());
|
||||
menu.add(invertSelection);
|
||||
|
||||
|
||||
JMenuItem chooseMatching = new JMenuItem("Choose Matching");
|
||||
chooseMatching.addActionListener(e2 -> chooseMatching());
|
||||
menu.add(chooseMatching);
|
||||
|
|
151
Mage.Client/src/main/java/mage/client/cards/ManaBarChart.java
Normal file
151
Mage.Client/src/main/java/mage/client/cards/ManaBarChart.java
Normal file
|
@ -0,0 +1,151 @@
|
|||
package mage.client.cards;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
public class ManaBarChart extends JComponent {
|
||||
|
||||
HashMap<String, Integer> pips_at_cmcs = new HashMap<String, Integer>();
|
||||
|
||||
ManaBarChart() {
|
||||
}
|
||||
|
||||
ManaBarChart(HashMap<String, Integer> pips_at_cmcs) {
|
||||
this.pips_at_cmcs = pips_at_cmcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension preferred = super.getPreferredSize();
|
||||
Dimension minimum = getMinimumSize();
|
||||
Dimension maximum = getMaximumSize();
|
||||
preferred.width = Math.min(Math.max(preferred.width, minimum.width), maximum.width);
|
||||
preferred.height = Math.min(Math.max(preferred.height, minimum.height), maximum.height);
|
||||
return preferred;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
drawBar((Graphics2D) g, getBounds());
|
||||
}
|
||||
|
||||
void drawBar(Graphics2D g, Rectangle area) {
|
||||
Pattern regex = Pattern.compile("^([0-9]+)##(.)}");
|
||||
HashMap<Integer, Integer> totals_at_cmcs = new HashMap<Integer, Integer>();
|
||||
int max_num_pips = 0;
|
||||
int max_cmc = 0;
|
||||
|
||||
for (String key : pips_at_cmcs.keySet()) {
|
||||
Matcher regexMatcher = regex.matcher(key);
|
||||
int num_pips = pips_at_cmcs.get(key);
|
||||
while (regexMatcher.find()) {
|
||||
String cmc = regexMatcher.group(1);
|
||||
int cmc_num = Integer.parseInt(cmc);
|
||||
if (max_cmc < cmc_num) {
|
||||
max_cmc = cmc_num;
|
||||
}
|
||||
|
||||
int total_at_cmc = 0;
|
||||
if (totals_at_cmcs.get(cmc_num) != null) {
|
||||
total_at_cmc = totals_at_cmcs.get(cmc_num);
|
||||
}
|
||||
totals_at_cmcs.put(cmc_num, total_at_cmc + num_pips);
|
||||
if (max_num_pips < total_at_cmc + num_pips) {
|
||||
max_num_pips = total_at_cmc + num_pips;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (max_num_pips <= 0) {
|
||||
max_num_pips = 1;
|
||||
}
|
||||
int height_factor = 200 / max_num_pips;
|
||||
int width_factor = 200 / (max_cmc + 2);
|
||||
if (width_factor > 20) {
|
||||
width_factor = 20;
|
||||
}
|
||||
if (width_factor < 11) {
|
||||
width_factor = 11;
|
||||
}
|
||||
|
||||
g.setColor(new Color(130, 130, 130));
|
||||
for (int i = 0; i < max_num_pips; i++) {
|
||||
if (max_num_pips > 10) {
|
||||
if (i % 10 == 0) {
|
||||
g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor);
|
||||
} else if (i % 10 == 5) {
|
||||
Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{5}, 0);
|
||||
Stroke oldstroke = g.getStroke();
|
||||
g.setStroke(dashed);
|
||||
g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor);
|
||||
g.setStroke(oldstroke);
|
||||
}
|
||||
} else if (i % 2 == 0) {
|
||||
g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor);
|
||||
} else if (i % 2 == 1) {
|
||||
Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{5}, 0);
|
||||
Stroke oldstroke = g.getStroke();
|
||||
g.setStroke(dashed);
|
||||
g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor);
|
||||
g.setStroke(oldstroke);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 17; i++) {
|
||||
if (i % 5 == 0) {
|
||||
g.drawLine(width_factor * i, 200, width_factor * i, 190);
|
||||
} else {
|
||||
g.drawLine(width_factor * i, 200, width_factor * i, 195);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HashMap<Integer, Integer> running_totals_at_cmcs = new HashMap<Integer, Integer>();
|
||||
for (String key : pips_at_cmcs.keySet()) {
|
||||
Matcher regexMatcher = regex.matcher(key);
|
||||
int num_pips = pips_at_cmcs.get(key);
|
||||
while (regexMatcher.find()) {
|
||||
String cmc = regexMatcher.group(1);
|
||||
int cmc_num = Integer.parseInt(cmc);
|
||||
String color = regexMatcher.group(2);
|
||||
|
||||
int total_at_cmc = 0;
|
||||
if (running_totals_at_cmcs.get(cmc_num) != null) {
|
||||
total_at_cmc = running_totals_at_cmcs.get(cmc_num);
|
||||
}
|
||||
|
||||
if (color.equalsIgnoreCase("w")) {
|
||||
g.setColor(Color.WHITE);
|
||||
}
|
||||
if (color.equalsIgnoreCase("u")) {
|
||||
g.setColor(Color.BLUE);
|
||||
}
|
||||
if (color.equalsIgnoreCase("b")) {
|
||||
g.setColor(Color.BLACK);
|
||||
}
|
||||
if (color.equalsIgnoreCase("r")) {
|
||||
g.setColor(Color.RED);
|
||||
}
|
||||
if (color.equalsIgnoreCase("g")) {
|
||||
g.setColor(Color.GREEN);
|
||||
}
|
||||
if (color.equalsIgnoreCase("c")) {
|
||||
g.setColor(Color.DARK_GRAY);
|
||||
}
|
||||
g.fill(new Rectangle2D.Double(cmc_num * width_factor, 200 - 1 - total_at_cmc - num_pips * height_factor, 10, num_pips * height_factor));
|
||||
running_totals_at_cmcs.put(cmc_num, total_at_cmc + num_pips * height_factor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -158,6 +158,7 @@ public class DownloadGui extends JPanel {
|
|||
b.addActionListener(e -> {
|
||||
switch(this.job.getState()) {
|
||||
case NEW:
|
||||
case PREPARING:
|
||||
case WORKING:
|
||||
this.job.setState(State.ABORTED);
|
||||
}
|
||||
|
|
|
@ -23,16 +23,16 @@ import org.mage.plugins.card.utils.CardImageUtils;
|
|||
* The class DownloadJob.
|
||||
*
|
||||
* @version V0.0 25.08.2010
|
||||
* @author Clemens Koza
|
||||
* @author Clemens Koza, JayDi85
|
||||
*/
|
||||
public class DownloadJob extends AbstractLaternaBean {
|
||||
|
||||
public enum State {
|
||||
NEW, WORKING, FINISHED, ABORTED
|
||||
NEW, PREPARING, WORKING, FINISHED, ABORTED
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final Source source;
|
||||
private Source source;
|
||||
private final Destination destination;
|
||||
private final Property<State> state = properties.property("state", State.NEW);
|
||||
private final Property<String> message = properties.property("message");
|
||||
|
@ -98,6 +98,36 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
this.message.setValue(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner prepare cycle from new to working
|
||||
*/
|
||||
public void doPrepareAndStartWork() {
|
||||
if (this.state.getValue() != State.NEW) {
|
||||
setError("Can't call prepare at this point.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.state.setValue(State.PREPARING);
|
||||
|
||||
try {
|
||||
onPreparing();
|
||||
} catch (Exception e) {
|
||||
setError("Prepare error: " + e.getMessage(), e);
|
||||
return;
|
||||
}
|
||||
|
||||
// change to working state on good prepare call
|
||||
this.state.setValue(State.WORKING);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare code to override in custom download tasks (it's calls before work start)
|
||||
*/
|
||||
public void onPreparing() throws Exception {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the job's message.
|
||||
*
|
||||
|
@ -131,6 +161,10 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
return source;
|
||||
}
|
||||
|
||||
public void setSource(Source source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public Destination getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
for (DownloadJob j : jobs) {
|
||||
switch (j.getState()) {
|
||||
case NEW:
|
||||
case PREPARING:
|
||||
case WORKING:
|
||||
j.setState(State.ABORTED);
|
||||
}
|
||||
|
@ -82,8 +83,11 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
}
|
||||
|
||||
public void add(DownloadJob job) {
|
||||
if (job.getState() == State.PREPARING) {
|
||||
throw new IllegalArgumentException("Job already preparing");
|
||||
}
|
||||
if (job.getState() == State.WORKING) {
|
||||
throw new IllegalArgumentException("Job already running");
|
||||
throw new IllegalArgumentException("Job already working");
|
||||
}
|
||||
if (job.getState() == State.FINISHED) {
|
||||
throw new IllegalArgumentException("Job already finished");
|
||||
|
@ -106,13 +110,22 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
|
||||
@Override
|
||||
public void onMessage(DownloadJob job) {
|
||||
//the job won't be processed by multiple threads
|
||||
|
||||
// start to work
|
||||
// the job won't be processed by multiple threads
|
||||
synchronized (job) {
|
||||
if (job.getState() != State.NEW) {
|
||||
return;
|
||||
}
|
||||
job.setState(State.WORKING);
|
||||
|
||||
job.doPrepareAndStartWork();
|
||||
|
||||
if (job.getState() != State.WORKING) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// download and save data
|
||||
try {
|
||||
Source src = job.getSource();
|
||||
Destination dst = job.getDestination();
|
||||
|
|
|
@ -9,8 +9,13 @@ import java.util.*;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import mage.MageException;
|
||||
import mage.util.StreamUtils;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.mage.plugins.card.dl.DownloadJob;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
|
||||
import javax.swing.text.Document;
|
||||
|
||||
import static org.mage.card.arcane.ManaSymbols.getSymbolFileNameAsSVG;
|
||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||
|
@ -18,14 +23,14 @@ import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
|||
// TODO: add force to download symbols (rewrite exist files)
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jaydi85@gmail.com
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
||||
|
||||
|
||||
static final String SOURCE_URL = "https://assets.scryfall.com/assets/scryfall.css"; // search css-file on https://scryfall.com/docs/api/colors
|
||||
//static final String SOURCE_URL = "https://assets.scryfall.com/assets/scryfall.css"; // old version with direct css-file on https://scryfall.com/docs/api/colors
|
||||
static final String CSS_SOURCE_URL = "https://scryfall.com/docs/api/colors";
|
||||
static final String CSS_SOURCE_SELECTOR = "link[rel=stylesheet]"; // <link rel="stylesheet" media="all" href="https://assets.scryfall.com/assets/scryfall-8cdaa786c4c86d5c49317e3e0fed72a0e409666753d3d3e8c906f33a188e19ed.css">
|
||||
static final String STATE_PROP_NAME = "state";
|
||||
static final String DOWNLOAD_TEMP_FILE = getImagesDir() + File.separator + "temp" + File.separator + "scryfall-symbols-source.txt";
|
||||
|
||||
|
@ -55,21 +60,21 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
|||
return jobs.iterator();
|
||||
}
|
||||
|
||||
private void parseData(String sourcePath){
|
||||
private void parseData(String sourcePath) {
|
||||
|
||||
String sourceData = "";
|
||||
try {
|
||||
sourceData = new String(Files.readAllBytes(Paths.get(sourcePath)));
|
||||
}catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Can't open file to parse data: " + sourcePath + " , reason: " + e.getMessage());
|
||||
}
|
||||
|
||||
// gen symbols list
|
||||
ArrayList<String> allMageSymbols = new ArrayList<>();
|
||||
for(int i = 0; i < SYMBOLS_LIST.length; i++){
|
||||
for (int i = 0; i < SYMBOLS_LIST.length; i++) {
|
||||
allMageSymbols.add(SYMBOLS_LIST[i]);
|
||||
}
|
||||
for(Integer i = SYMBOLS_NUMBER_START; i <= SYMBOLS_NUMBER_END; i++){
|
||||
for (Integer i = SYMBOLS_NUMBER_START; i <= SYMBOLS_NUMBER_END; i++) {
|
||||
allMageSymbols.add(String.valueOf(SYMBOLS_NUMBER_START + i));
|
||||
}
|
||||
|
||||
|
@ -88,23 +93,22 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
|||
|
||||
// dirs maker
|
||||
File dir = getSymbolFileNameAsSVG("W").getParentFile();
|
||||
if(!dir.exists()){
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
// decode and save data (only if not exist)
|
||||
for(String needCode: allMageSymbols){
|
||||
for (String needCode : allMageSymbols) {
|
||||
|
||||
String searchCode = needCode.replace("/", "");
|
||||
|
||||
if(!foundedData.containsKey(searchCode))
|
||||
{
|
||||
if (!foundedData.containsKey(searchCode)) {
|
||||
LOGGER.warn("Can't found symbol code from scryfall: " + searchCode);
|
||||
continue;
|
||||
}
|
||||
|
||||
File destFile = getSymbolFileNameAsSVG(searchCode);
|
||||
if (destFile.exists() && (destFile.length() > 0)){
|
||||
if (destFile.exists() && (destFile.length() > 0)) {
|
||||
continue;
|
||||
}
|
||||
FileOutputStream stream = null;
|
||||
|
@ -118,7 +122,7 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
|||
stream.write(fileData);
|
||||
|
||||
LOGGER.info("New svg symbol downloaded: " + needCode);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Can't decode svg icon and save to file: " + destFile.getPath() + ", reason: " + e.getMessage());
|
||||
} finally {
|
||||
StreamUtils.closeQuietly(stream);
|
||||
|
@ -127,23 +131,26 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
|||
}
|
||||
|
||||
|
||||
private class ScryfallSymbolsDownloadJob extends DownloadJob{
|
||||
private class ScryfallSymbolsDownloadJob extends DownloadJob {
|
||||
|
||||
private String cssUrl = ""; // need to find url from colors page https://scryfall.com/docs/api/colors
|
||||
|
||||
// listener for data parse after download complete
|
||||
private class ScryDownloadOnFinishedListener implements PropertyChangeListener {
|
||||
private class ScryfallDownloadOnFinishedListener implements PropertyChangeListener {
|
||||
private String downloadedFile;
|
||||
|
||||
public ScryDownloadOnFinishedListener(String ADestFile){
|
||||
public ScryfallDownloadOnFinishedListener(String ADestFile) {
|
||||
this.downloadedFile = ADestFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (!evt.getPropertyName().equals(STATE_PROP_NAME)){
|
||||
|
||||
if (!evt.getPropertyName().equals(STATE_PROP_NAME)) {
|
||||
throw new IllegalArgumentException("Unknown download property " + evt.getPropertyName());
|
||||
}
|
||||
|
||||
if (evt.getNewValue() != State.FINISHED){
|
||||
if (evt.getNewValue() != State.FINISHED) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -152,16 +159,34 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreparing() throws Exception {
|
||||
this.cssUrl = "";
|
||||
|
||||
org.jsoup.nodes.Document doc = CardImageUtils.downloadHtmlDocument(CSS_SOURCE_URL);
|
||||
org.jsoup.select.Elements cssList = doc.select(CSS_SOURCE_SELECTOR);
|
||||
if (cssList.size() == 1) {
|
||||
this.cssUrl = cssList.first().attr("href").toString();
|
||||
}
|
||||
|
||||
if (this.cssUrl.isEmpty()) {
|
||||
throw new IllegalStateException("Can't find stylesheet url from scryfall colors page.");
|
||||
} else {
|
||||
this.setSource(fromURL(this.cssUrl));
|
||||
}
|
||||
}
|
||||
|
||||
private String destFile = "";
|
||||
|
||||
public ScryfallSymbolsDownloadJob() {
|
||||
super("Scryfall symbols source", fromURL(SOURCE_URL), toFile(DOWNLOAD_TEMP_FILE));
|
||||
// download init
|
||||
super("Scryfall symbols source", fromURL(""), toFile(DOWNLOAD_TEMP_FILE)); // url setup on preparing stage
|
||||
this.destFile = DOWNLOAD_TEMP_FILE;
|
||||
this.addPropertyChangeListener(STATE_PROP_NAME, new ScryDownloadOnFinishedListener(this.destFile));
|
||||
this.addPropertyChangeListener(STATE_PROP_NAME, new ScryfallDownloadOnFinishedListener(this.destFile));
|
||||
|
||||
// clear dest file (always download new data)
|
||||
File file = new File(this.destFile);
|
||||
if (file.exists()){
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.jsoup.nodes.Document;
|
|||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
|
||||
/**
|
||||
* @author North
|
||||
|
@ -535,7 +536,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
|||
while (page < 999) {
|
||||
String searchUrl = "http://gatherer.wizards.com/Pages/Search/Default.aspx?sort=cn+&page=" + page + "&action=advanced&output=spoiler&method=visual&set=+%5B%22" + URLSetName + "%22%5D";
|
||||
logger.debug("URL: " + searchUrl);
|
||||
Document doc = getDocument(searchUrl);
|
||||
Document doc = CardImageUtils.downloadHtmlDocument(searchUrl);
|
||||
Elements cardsImages = doc.select("img[src^=../../Handlers/]");
|
||||
if (cardsImages.isEmpty()) {
|
||||
break;
|
||||
|
@ -587,33 +588,6 @@ public enum WizardCardsImageSource implements CardImageSource {
|
|||
return setLinks;
|
||||
}
|
||||
|
||||
private Document getDocument(String urlString) throws NumberFormatException, IOException {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
|
||||
Document doc;
|
||||
if (proxyType == ProxyType.NONE) {
|
||||
doc = Jsoup.connect(urlString).timeout(60 * 1000).get();
|
||||
} else {
|
||||
String proxyServer = prefs.get("proxyAddress", "");
|
||||
int proxyPort = Integer.parseInt(prefs.get("proxyPort", "0"));
|
||||
URL url = new URL(urlString);
|
||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, proxyPort));
|
||||
HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy);
|
||||
uc.setConnectTimeout(10000);
|
||||
uc.setReadTimeout(60000);
|
||||
uc.connect();
|
||||
|
||||
String line;
|
||||
StringBuffer tmp = new StringBuffer();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
|
||||
while ((line = in.readLine()) != null) {
|
||||
tmp.append(line);
|
||||
}
|
||||
doc = Jsoup.parse(String.valueOf(tmp));
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
private void getLandVariations(LinkedHashMap<String, String> setLinks, String cardSet, int multiverseId, String cardName) throws IOException, NumberFormatException {
|
||||
CardCriteria criteria = new CardCriteria();
|
||||
criteria.nameExact(cardName);
|
||||
|
@ -621,7 +595,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
|||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||
|
||||
String urlLandDocument = "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=" + multiverseId;
|
||||
Document landDoc = getDocument(urlLandDocument);
|
||||
Document landDoc = CardImageUtils.downloadHtmlDocument(urlLandDocument);
|
||||
Elements variations = landDoc.select("a.variationlink");
|
||||
if (!variations.isEmpty()) {
|
||||
if (variations.size() > cards.size()) {
|
||||
|
@ -668,7 +642,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
|||
|
||||
private HashMap<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException {
|
||||
String cardLanguagesUrl = "http://gatherer.wizards.com/Pages/Card/Languages.aspx?multiverseid=" + englishMultiverseId;
|
||||
Document cardLanguagesDoc = getDocument(cardLanguagesUrl);
|
||||
Document cardLanguagesDoc = CardImageUtils.downloadHtmlDocument(cardLanguagesUrl);
|
||||
Elements languageTableRows = cardLanguagesDoc.select("tr.cardItem");
|
||||
HashMap<String, Integer> localizedIds = new HashMap<>();
|
||||
if (!languageTableRows.isEmpty()) {
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package org.mage.plugins.card.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.constants.Constants;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
@ -13,6 +19,8 @@ import mage.remote.Connection;
|
|||
import mage.remote.Connection.ProxyType;
|
||||
import net.java.truevfs.access.TFile;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import org.mage.plugins.card.properties.SettingsManager;
|
||||
|
||||
|
@ -22,7 +30,6 @@ public final class CardImageUtils {
|
|||
private static final Logger log = Logger.getLogger(CardImageUtils.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param card
|
||||
* @return String if image exists, else null
|
||||
*/
|
||||
|
@ -54,7 +61,6 @@ public final class CardImageUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param card
|
||||
* @return String regardless of whether image exists
|
||||
*/
|
||||
|
@ -280,4 +286,31 @@ public final class CardImageUtils {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Document downloadHtmlDocument(String urlString) throws NumberFormatException, IOException {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
|
||||
Document doc;
|
||||
if (proxyType == ProxyType.NONE) {
|
||||
doc = Jsoup.connect(urlString).timeout(60 * 1000).get();
|
||||
} else {
|
||||
String proxyServer = prefs.get("proxyAddress", "");
|
||||
int proxyPort = Integer.parseInt(prefs.get("proxyPort", "0"));
|
||||
URL url = new URL(urlString);
|
||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, proxyPort));
|
||||
HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy);
|
||||
uc.setConnectTimeout(10000);
|
||||
uc.setReadTimeout(60000);
|
||||
uc.connect();
|
||||
|
||||
String line;
|
||||
StringBuffer tmp = new StringBuffer();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
|
||||
while ((line = in.readLine()) != null) {
|
||||
tmp.append(line);
|
||||
}
|
||||
doc = Jsoup.parse(String.valueOf(tmp));
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class CardsView extends LinkedHashMap<UUID, CardView> {
|
|||
case BATTLEFIELD:
|
||||
sourceObject = game.getPermanent(ability.getSourceId());
|
||||
if (sourceObject == null) {
|
||||
sourceObject = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
|
||||
sourceObject = game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
|
||||
}
|
||||
isPermanent = true;
|
||||
break;
|
||||
|
|
|
@ -3,11 +3,8 @@ package mage.deck;
|
|||
import java.util.*;
|
||||
import mage.abilities.common.CanBeYourCommanderAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.decks.Constructed;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.constants.SetType;
|
||||
import mage.filter.FilterMana;
|
||||
|
||||
/**
|
||||
|
@ -22,50 +19,11 @@ public class Brawl extends Constructed {
|
|||
super("Brawl");
|
||||
|
||||
// Copy of standard sets
|
||||
GregorianCalendar current = new GregorianCalendar();
|
||||
List<ExpansionSet> sets = new ArrayList(Sets.getInstance().values());
|
||||
Collections.sort(sets, new Comparator<ExpansionSet>() {
|
||||
@Override
|
||||
public int compare(final ExpansionSet lhs, ExpansionSet rhs) {
|
||||
return lhs.getReleaseDate().after(rhs.getReleaseDate()) ? -1 : 1;
|
||||
}
|
||||
});
|
||||
int fallSetsAdded = 0;
|
||||
Date earliestDate = null;
|
||||
// Get the second most recent fall set that's been released.
|
||||
for (ExpansionSet set : sets) {
|
||||
if (set.getReleaseDate().after(current.getTime())) {
|
||||
continue;
|
||||
}
|
||||
if (isFallSet(set)) {
|
||||
fallSetsAdded++;
|
||||
if (fallSetsAdded == 2) {
|
||||
earliestDate = set.getReleaseDate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get all sets released on or after the second most recent fall set's release
|
||||
for (ExpansionSet set : sets) {
|
||||
if ((set.getSetType() == SetType.CORE
|
||||
|| set.getSetType() == SetType.EXPANSION
|
||||
|| set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL)
|
||||
&& (!set.getReleaseDate().before(earliestDate)
|
||||
&& !set.getReleaseDate().after(current.getTime()))) {
|
||||
setCodes.add(set.getCode());
|
||||
}
|
||||
}
|
||||
setCodes.addAll(Standard.makeLegalSets());
|
||||
|
||||
banned.add("Baral, Chief of Compliance");
|
||||
banned.add("Smuggler's Copter");
|
||||
banned.add("Sorcerers' Spyglass");
|
||||
}
|
||||
|
||||
private static boolean isFallSet(ExpansionSet set) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(set.getReleaseDate());
|
||||
// Fall sets are normally released during or after September
|
||||
return set.getSetType() == SetType.EXPANSION
|
||||
&& (cal.get(Calendar.MONTH) > 7);
|
||||
banned.add("Sorcerous Spyglass");
|
||||
}
|
||||
|
||||
public Brawl(String name) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.deck;
|
||||
|
||||
import mage.cards.ExpansionSet;
|
||||
|
@ -32,6 +31,7 @@ public class Legacy extends Constructed {
|
|||
banned.add("Chaos Orb");
|
||||
banned.add("Contract from Below");
|
||||
banned.add("Darkpact");
|
||||
banned.add("Deathrite Shaman");
|
||||
banned.add("Demonic Attorney");
|
||||
banned.add("Demonic Consultation");
|
||||
banned.add("Demonic Tutor");
|
||||
|
@ -42,6 +42,7 @@ public class Legacy extends Constructed {
|
|||
banned.add("Fastbond");
|
||||
banned.add("Flash");
|
||||
banned.add("Frantic Search");
|
||||
banned.add("Gitaxian Probe");
|
||||
banned.add("Goblin Recruiter");
|
||||
banned.add("Gush");
|
||||
banned.add("Hermit Druid");
|
||||
|
|
|
@ -20,6 +20,28 @@ public class Standard extends Constructed {
|
|||
|
||||
public Standard() {
|
||||
super("Constructed - Standard");
|
||||
|
||||
setCodes.addAll(makeLegalSets());
|
||||
|
||||
banned.add("Attune with Aether"); // since 2018-01-15
|
||||
banned.add("Aetherworks Marvel");
|
||||
banned.add("Felidar Guardian");
|
||||
banned.add("Rampaging Ferocidon"); // since 2018-01-15
|
||||
banned.add("Ramunap Ruins"); // since 2018-01-15
|
||||
banned.add("Rogue Refiner"); // since 2018-01-15
|
||||
banned.add("Smuggler's Copter");
|
||||
}
|
||||
|
||||
private static boolean isFallSet(ExpansionSet set) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(set.getReleaseDate());
|
||||
// Fall sets are normally released during or after September
|
||||
return set.getSetType() == SetType.EXPANSION
|
||||
&& (cal.get(Calendar.MONTH) > 7);
|
||||
}
|
||||
|
||||
public static List<String> makeLegalSets() {
|
||||
List<String> codes = new ArrayList();
|
||||
GregorianCalendar current = new GregorianCalendar();
|
||||
List<ExpansionSet> sets = new ArrayList(Sets.getInstance().values());
|
||||
Collections.sort(sets, new Comparator<ExpansionSet>() {
|
||||
|
@ -50,23 +72,9 @@ public class Standard extends Constructed {
|
|||
|| set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL)
|
||||
&& !set.getReleaseDate().before(earliestDate)) {
|
||||
// && !set.getReleaseDate().after(current.getTime()))) {
|
||||
setCodes.add(set.getCode());
|
||||
codes.add(set.getCode());
|
||||
}
|
||||
}
|
||||
banned.add("Attune with Aether"); // since 2018-01-15
|
||||
banned.add("Aetherworks Marvel");
|
||||
banned.add("Felidar Guardian");
|
||||
banned.add("Rampaging Ferocidon"); // since 2018-01-15
|
||||
banned.add("Ramunap Ruins"); // since 2018-01-15
|
||||
banned.add("Rogue Refiner"); // since 2018-01-15
|
||||
banned.add("Smuggler's Copter");
|
||||
}
|
||||
|
||||
private static boolean isFallSet(ExpansionSet set) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(set.getReleaseDate());
|
||||
// Fall sets are normally released during or after September
|
||||
return set.getSetType() == SetType.EXPANSION
|
||||
&& (cal.get(Calendar.MONTH) > 7);
|
||||
return codes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class BrawlDuelMatch extends MatchImpl {
|
|||
|
||||
@Override
|
||||
public void startGame() throws GameException {
|
||||
int startLife = 20;
|
||||
int startLife = 25;
|
||||
boolean alsoHand = true;
|
||||
BrawlDuel game = new BrawlDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
||||
game.setCheckCommanderDamage(false);
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
|||
sb.setLength(0);
|
||||
sb.append("-> Permanents: [");
|
||||
for (Permanent permanent : game.getBattlefield().getAllPermanents()) {
|
||||
if (permanent.getOwnerId().equals(player.getId())) {
|
||||
if (permanent.isOwnedBy(player.getId())) {
|
||||
sb.append(permanent.getName());
|
||||
if (permanent.isTapped()) {
|
||||
sb.append("(tapped)");
|
||||
|
|
|
@ -341,8 +341,18 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
replacementEffectChoice.getChoices().clear();
|
||||
replacementEffectChoice.setKeyChoices(rEffects);
|
||||
|
||||
// Check if there are different ones
|
||||
int differentChoices = 0;
|
||||
String lastChoice = "";
|
||||
for (String value : replacementEffectChoice.getKeyChoices().values()) {
|
||||
if (!lastChoice.equalsIgnoreCase(value)) {
|
||||
lastChoice = value;
|
||||
differentChoices++;
|
||||
}
|
||||
}
|
||||
|
||||
while (!abort) {
|
||||
while (!abort && differentChoices > 1) {
|
||||
updateGameStatePriority("chooseEffect", game);
|
||||
prepareForResponse(game);
|
||||
if (!isExecutingMacro()) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.server.game;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -1149,7 +1148,7 @@ public class GameController implements GameCallback {
|
|||
sb.append(state.getTurnMods());
|
||||
sb.append("<br>getTurnNum: ");
|
||||
sb.append(state.getTurnNum());
|
||||
|
||||
|
||||
sb.append("<br>Using plane chase?:" + state.isPlaneChase());
|
||||
if (state.isPlaneChase()) {
|
||||
Plane currentPlane = state.getCurrentPlane();
|
||||
|
@ -1157,7 +1156,7 @@ public class GameController implements GameCallback {
|
|||
sb.append("<br>Current plane:" + currentPlane.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sb.append("<br>Future Timeout:");
|
||||
if (futureTimeout != null) {
|
||||
sb.append("Cancelled?=");
|
||||
|
@ -1188,8 +1187,13 @@ public class GameController implements GameCallback {
|
|||
|
||||
sb.append("<br>Active player is: ");
|
||||
sb.append(game.getPlayer(state.getActivePlayerId()).getName());
|
||||
|
||||
PassAbility pass = new PassAbility();
|
||||
if (game.getPlayer(state.getActivePlayerId()).hasLeft()) {
|
||||
Player p = game.getPlayer(state.getActivePlayerId());
|
||||
if (p != null) {
|
||||
p.concede(game);
|
||||
}
|
||||
Phase currentPhase = game.getPhase();
|
||||
if (currentPhase != null) {
|
||||
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
||||
|
@ -1204,6 +1208,10 @@ public class GameController implements GameCallback {
|
|||
sb.append("<br>getChoosingPlayerId: ");
|
||||
if (state.getChoosingPlayerId() != null) {
|
||||
if (game.getPlayer(state.getChoosingPlayerId()).hasLeft()) {
|
||||
Player p = game.getPlayer(state.getChoosingPlayerId());
|
||||
if (p != null) {
|
||||
p.concede(game);
|
||||
}
|
||||
Phase currentPhase = game.getPhase();
|
||||
if (currentPhase != null && !fixedAlready) {
|
||||
currentPhase.getStep().endStep(game, state.getActivePlayerId());
|
||||
|
@ -1218,7 +1226,11 @@ public class GameController implements GameCallback {
|
|||
|
||||
sb.append("<br><font color=orange>Player with Priority is: ");
|
||||
if (state.getPriorityPlayerId() != null) {
|
||||
if (game.getPlayer(state.getPriorityPlayerId()).hasLeft()) {
|
||||
if (game.getPlayer(state.getPriorityPlayerId()).hasLeft()) {
|
||||
Player p = game.getPlayer(state.getPriorityPlayerId());
|
||||
if (p != null) {
|
||||
p.concede(game);
|
||||
}
|
||||
Phase currentPhase = game.getPhase();
|
||||
if (currentPhase != null && !fixedAlready) {
|
||||
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
||||
|
@ -1228,7 +1240,7 @@ public class GameController implements GameCallback {
|
|||
}
|
||||
sb.append(game.getPlayer(state.getPriorityPlayerId()).getName());
|
||||
sb.append("</font>");
|
||||
}
|
||||
}
|
||||
|
||||
sb.append("<br>Future Timeout:");
|
||||
if (futureTimeout != null) {
|
||||
|
|
|
@ -155,7 +155,7 @@ class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl {
|
|||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null
|
||||
&& watcher != null
|
||||
&& card.getOwnerId().equals(controller.getId())) {
|
||||
&& card.isOwnedBy(controller.getId())) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof CyclingAbility) {
|
||||
cardHasCycling = true;
|
||||
|
@ -199,7 +199,7 @@ class AbandonedSarcophagusWatcher extends Watcher {
|
|||
Player controller = game.getPlayer(event.getPlayerId());
|
||||
if (card != null
|
||||
&& controller != null
|
||||
&& card.getOwnerId().equals(controller.getId())) {
|
||||
&& card.isOwnedBy(controller.getId())) {
|
||||
Cards c = getCardsCycledThisTurn(event.getPlayerId());
|
||||
c.add(card);
|
||||
cycledCardsThisTurn.put(event.getPlayerId(), c);
|
||||
|
|
|
@ -108,7 +108,7 @@ class AbbotOfKeralKeepCastFromExileEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.getControllerId().equals(affectedControllerId)
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class AcidicSoilEffect extends OneShotEffect {
|
|||
if (player != null) {
|
||||
int amount = 0;
|
||||
for (Permanent permanent : permanents) {
|
||||
if (permanent.getControllerId().equals(playerId)) {
|
||||
if (permanent.isControlledBy(playerId)) {
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class AerialCaravanCastFromExileEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.getControllerId().equals(affectedControllerId)
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class AetherChargeTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.isCreature() && permanent.hasSubtype(SubType.BEAST, game)
|
||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
||||
&& permanent.isControlledBy(this.controllerId)) {
|
||||
Effect effect = this.getEffects().get(0);
|
||||
effect.setValue("damageSource", event.getTargetId());
|
||||
return true;
|
||||
|
|
50
Mage.Sets/src/mage/cards/a/AetherflameWall.java
Normal file
50
Mage.Sets/src/mage/cards/a/AetherflameWall.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package mage.cards.a;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.CanBlockAsThoughtItHadShadowEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public final class AetherflameWall extends CardImpl {
|
||||
|
||||
public AetherflameWall(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
|
||||
|
||||
this.subtype.add(SubType.WALL);
|
||||
this.power = new MageInt(0);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// Defender
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
|
||||
// Aetherflame Wall can block creatures with shadow as though they didn’t have shadow.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockAsThoughtItHadShadowEffect(Duration.WhileOnBattlefield)));
|
||||
|
||||
// {R}: Aetherflame Wall gets +1/+0 until end of turn.
|
||||
this.addAbility(new SimpleActivatedAbility(new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{R}")));
|
||||
}
|
||||
|
||||
public AetherflameWall(final AetherflameWall card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AetherflameWall copy() {
|
||||
return new AetherflameWall(this);
|
||||
}
|
||||
}
|
98
Mage.Sets/src/mage/cards/a/Aetherplasm.java
Normal file
98
Mage.Sets/src/mage/cards/a/Aetherplasm.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BlocksTriggeredAbility;
|
||||
import mage.abilities.costs.common.ReturnToHandFromBattlefieldSourceCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DoIfCostPaid;
|
||||
import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public final class Aetherplasm extends CardImpl {
|
||||
|
||||
public Aetherplasm(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{U}");
|
||||
|
||||
this.subtype.add(SubType.ILLUSION);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever Aetherplasm blocks a creature, you may return Aetherplasm to its owner's hand. If you do, you may put a creature card from your hand onto the battlefield blocking that creature.
|
||||
this.addAbility(new BlocksTriggeredAbility
|
||||
(new DoIfCostPaid(new AetherplasmEffect(), new ReturnToHandFromBattlefieldSourceCost()), false, true));
|
||||
}
|
||||
|
||||
public Aetherplasm(final Aetherplasm card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Aetherplasm copy() {
|
||||
return new Aetherplasm(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AetherplasmEffect extends OneShotEffect {
|
||||
|
||||
public AetherplasmEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = "you may put a creature card from your hand onto the battlefield blocking that creature";
|
||||
}
|
||||
|
||||
public AetherplasmEffect(AetherplasmEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent blockedCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (player.chooseUse(Outcome.PutCardInPlay, "Put a creature card from your hand onto the battlefield?", source, game)) {
|
||||
TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE_A);
|
||||
if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
if(player.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null)
|
||||
&& game.getCombat() != null && blockedCreature != null){
|
||||
CombatGroup attacker = game.getCombat().findGroup(blockedCreature.getId());
|
||||
Permanent putIntoPlay = game.getPermanent(target.getFirstTarget());
|
||||
if (putIntoPlay != null && putIntoPlay.isCreature() &&attacker != null) {
|
||||
game.getCombat().findGroup(blockedCreature.getId()).addBlocker(putIntoPlay.getId(), source.getControllerId(), game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AetherplasmEffect copy() {
|
||||
return new AetherplasmEffect(this);
|
||||
}
|
||||
}
|
|
@ -81,7 +81,7 @@ class AetherspoutsEffect extends OneShotEffect {
|
|||
List<Permanent> permanentsToTop = new ArrayList<>();
|
||||
List<Permanent> permanentsToBottom = new ArrayList<>();
|
||||
for (Permanent permanent:game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source.getSourceId(), game)) {
|
||||
if (permanent.getOwnerId().equals(player.getId())) {
|
||||
if (permanent.isOwnedBy(player.getId())) {
|
||||
if (player.chooseUse(outcome, "Put " + permanent.getLogName() + " to the top? (else it goes to bottom)", source, game)) {
|
||||
permanentsToTop.add(permanent);
|
||||
game.informPlayers(permanent.getLogName() + " goes to the top of " + player.getLogName() + "'s library");
|
||||
|
|
|
@ -85,7 +85,7 @@ class AjanisLastStandTriggeredAbility extends TriggeredAbilityImpl {
|
|||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD
|
||||
&& zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.getTarget().getControllerId().equals(controllerId)
|
||||
if (zEvent.getTarget().isControlledBy(controllerId)
|
||||
&& (zEvent.getTarget().isCreature()
|
||||
|| zEvent.getTarget().isPlaneswalker())) {
|
||||
return true;
|
||||
|
|
|
@ -79,7 +79,7 @@ class AkoumFirebirdLandfallAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return permanent != null && permanent.isLand() && permanent.getControllerId().equals(this.controllerId);
|
||||
return permanent != null && permanent.isLand() && permanent.isControlledBy(this.controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,7 +82,7 @@ class AkoumHellkiteTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null
|
||||
&& permanent.isLand()
|
||||
&& permanent.getControllerId().equals(getControllerId())) {
|
||||
&& permanent.isControlledBy(getControllerId())) {
|
||||
Permanent sourcePermanent = game.getPermanent(getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
for (Effect effect : getEffects()) {
|
||||
|
|
|
@ -87,6 +87,6 @@ class AladdinsLampEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return source.getControllerId().equals(event.getPlayerId());
|
||||
return source.isControlledBy(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class AlhammarretsArchiveReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId())
|
||||
if (game.isActivePlayer(event.getPlayerId())
|
||||
&& game.getPhase().getStep().getType() == PhaseStep.DRAW) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
|
|
|
@ -75,7 +75,7 @@ class AmbuscadeShamanTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
UUID targetId = event.getTargetId();
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent.getControllerId().equals(this.controllerId)
|
||||
if (permanent.isControlledBy(this.controllerId)
|
||||
&& permanent.isCreature()) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
|
||||
return true;
|
||||
|
|
|
@ -58,7 +58,7 @@ class AmuletOfVigorTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent p = game.getPermanent(event.getTargetId());
|
||||
if (p != null && p.isTapped() && p.getControllerId().equals(this.controllerId)) {
|
||||
if (p != null && p.isTapped() && p.isControlledBy(this.controllerId)) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class AngelicArbiterCantAttackTargetEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (game.getActivePlayerId().equals(permanent.getControllerId()) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) {
|
||||
if (game.isActivePlayer(permanent.getControllerId()) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) {
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(permanent.getControllerId()) > 0) {
|
||||
return true;
|
||||
|
@ -113,7 +113,7 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
if (game.isActivePlayer(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getNumberOfAttackersCurrentTurn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
|
|
|
@ -62,7 +62,7 @@ class AngelicBenedictionTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (game.getActivePlayerId().equals(this.controllerId)) {
|
||||
if (game.isActivePlayer(this.controllerId)) {
|
||||
if (game.getCombat().attacksAlone()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class AngelicChorusTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.isCreature()
|
||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
||||
&& permanent.isControlledBy(this.controllerId)) {
|
||||
this.getEffects().get(0).setValue("lifeSource", event.getTargetId());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl {
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
return spell.isCreature();
|
||||
|
|
|
@ -84,7 +84,7 @@ class AnimationModuleTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(event.getTargetId());
|
||||
}
|
||||
return permanent != null && permanent.getControllerId().equals(this.getControllerId());
|
||||
return permanent != null && permanent.isControlledBy(this.getControllerId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class ApexOfPowerCastFromExileEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.getControllerId().equals(affectedControllerId)
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class ConspyEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
// in Library (e.g. for Mystical Teachings)
|
||||
for (Card card : controller.getLibrary().getCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
if (card.isOwnedBy(controller.getId()) && card.isCreature() && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class ConspyEffect extends ContinuousEffectImpl {
|
|||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||
StackObject stackObject = iterator.next();
|
||||
if (stackObject instanceof Spell
|
||||
&& stackObject.getControllerId().equals(source.getControllerId())
|
||||
&& stackObject.isControlledBy(source.getControllerId())
|
||||
&& stackObject.isCreature()
|
||||
&& !stackObject.hasSubtype(subType, game)) {
|
||||
Card card = ((Spell) stackObject).getCard();
|
||||
|
|
|
@ -66,7 +66,7 @@ class ArchonOfRedemptionTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.getControllerId().equals(getControllerId())
|
||||
if (permanent.isControlledBy(getControllerId())
|
||||
&& permanent.isCreature()
|
||||
&& (permanent.getId().equals(getSourceId())
|
||||
|| (permanent.getAbilities().contains(FlyingAbility.getInstance())))) {
|
||||
|
|
|
@ -133,7 +133,7 @@ class ArchonOfValorsReachChoice extends ChoiceImpl {
|
|||
return CardType.INSTANT;
|
||||
case "Sorcery":
|
||||
return CardType.SORCERY;
|
||||
case "Planewswalker":
|
||||
case "Planeswalker":
|
||||
return CardType.PLANESWALKER;
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -74,7 +74,7 @@ class AbilityActivatedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent aura = game.getPermanent(this.getSourceId());
|
||||
return aura != null && aura.getAttachedTo() != null && aura.getAttachedTo().equals(event.getSourceId());
|
||||
return aura != null && aura.isAttachedTo(event.getSourceId());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class AsLuckWouldHaveItTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (this.getControllerId().equals(event.getPlayerId()) && event.getFlag()) {
|
||||
if (this.isControlledBy(event.getPlayerId()) && event.getFlag()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("rolled", event.getAmount());
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ enum AshenGhoulCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (!game.getStep().getType().equals(PhaseStep.UPKEEP)
|
||||
|| !game.getActivePlayerId().equals(source.getControllerId())) {
|
||||
if (game.getStep().getType() != PhaseStep.UPKEEP
|
||||
|| !game.isActivePlayer(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
if (controller != null) {
|
||||
|
|
|
@ -78,7 +78,7 @@ class AsmiraHolyAvengerWatcher extends Watcher {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
MageObject card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (card != null && ((Card) card).getOwnerId().equals(this.controllerId) && card.isCreature()) {
|
||||
if (card != null && ((Card) card).isOwnedBy(this.controllerId) && card.isCreature()) {
|
||||
creaturesCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ public final class AssaultSuit extends CardImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
return equipment.getAttachedTo().equals(event.getTargetId());
|
||||
if (equipment != null) {
|
||||
return equipment.isAttachedTo(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -123,7 +123,7 @@ class AzorTheLawbringerCantCastEffect extends ContinuousRuleModifyingEffectImpl
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
UUID opponentId = getTargetPointer().getFirst(game, source);
|
||||
if (game.getActivePlayerId().equals(opponentId)) {
|
||||
if (game.isActivePlayer(opponentId)) {
|
||||
if (playersNextTurn == 0) {
|
||||
playersNextTurn = game.getTurnNum();
|
||||
}
|
||||
|
|
57
Mage.Sets/src/mage/cards/a/AzoriusPloy.java
Normal file
57
Mage.Sets/src/mage/cards/a/AzoriusPloy.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.AbilityImpl;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.PreventCombatDamageBySourceEffect;
|
||||
import mage.abilities.effects.common.PreventDamageByTargetEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.SecondTargetPointer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public final class AzoriusPloy extends CardImpl {
|
||||
|
||||
public AzoriusPloy(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}{W}{U}");
|
||||
|
||||
|
||||
// Prevent all combat damage target creature would deal this turn.
|
||||
Effect effect = new PreventDamageByTargetEffect( Duration.EndOfTurn, true);
|
||||
effect.setText("Prevent all combat damage target creature would deal this turn.");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
Target target = new TargetCreaturePermanent(new FilterCreaturePermanent("first creature"));
|
||||
this.getSpellAbility().addTarget(target);
|
||||
|
||||
// Prevent all combat damage that would be dealt to target creature this turn.
|
||||
Effect effect2 = new PreventDamageToTargetEffect(Duration.EndOfTurn, true);
|
||||
effect2.setText("<br></br>Prevent all combat damage that would be dealt to target creature this turn.");
|
||||
effect2.setTargetPointer(SecondTargetPointer.getInstance());
|
||||
this.getSpellAbility().addEffect(effect2);
|
||||
target = new TargetCreaturePermanent(new FilterCreaturePermanent("second creature (can be the same as the first)"));
|
||||
this.getSpellAbility().addTarget(target);
|
||||
|
||||
}
|
||||
|
||||
public AzoriusPloy(final AzoriusPloy card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AzoriusPloy copy() {
|
||||
return new AzoriusPloy(this);
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ class BattlefieldThaumaturgeSpellsCostReductionEffect extends CostModificationEf
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if ((abilityToModify instanceof SpellAbility)
|
||||
&& abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
&& abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
return spell != null && StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY.match(spell, game);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class BattlegraceAngelAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (game.getActivePlayerId().equals(this.controllerId) ) {
|
||||
if (game.isActivePlayer(this.controllerId) ) {
|
||||
if (game.getCombat().attacksAlone()) {
|
||||
for (Effect effect: this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0)));
|
||||
|
|
|
@ -74,7 +74,7 @@ class BidentOfThassaTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
Permanent creature = game.getPermanent(event.getSourceId());
|
||||
if (creature != null && creature.getControllerId().equals(controllerId)) {
|
||||
if (creature != null && creature.isControlledBy(controllerId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
|
|||
if (source.getTargets().size() > 1) {
|
||||
toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
}
|
||||
if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) {
|
||||
if (fromPermanent == null || toPermanent == null || !fromPermanent.isControlledBy(toPermanent.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1);
|
||||
|
@ -114,7 +114,7 @@ class SameControllerPredicate implements ObjectSourcePlayerPredicate<ObjectSourc
|
|||
source.getStackAbility().getTargets().get(0).getTargets().get(0));
|
||||
Permanent inputPermanent = game.getPermanent(input.getObject().getId());
|
||||
if (firstTarget != null && inputPermanent != null) {
|
||||
return firstTarget.getControllerId().equals(inputPermanent.getControllerId());
|
||||
return firstTarget.isControlledBy(inputPermanent.getControllerId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -89,7 +89,7 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (getControllerId().equals(game.getControllerId(event.getSourceId()))) {
|
||||
if (isControlledBy(game.getControllerId(event.getSourceId()))) {
|
||||
MageObject damageSource = game.getObject(event.getSourceId());
|
||||
if (damageSource != null) {
|
||||
if (damageSource.isInstant()|| damageSource.isSorcery()) {
|
||||
|
|
|
@ -118,7 +118,7 @@ class BlindingBeamEffect2 extends ContinuousRuleModifyingEffectImpl {
|
|||
public boolean isInactive(Ability source, Game game) {
|
||||
// the PRE step part is directly after the UNTAP events for permanents
|
||||
if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) {
|
||||
if (game.getActivePlayerId().equals(targetPlayerId) || game.getPlayer(source.getControllerId()).hasReachedNextTurnAfterLeaving()) {
|
||||
if (game.isActivePlayer(targetPlayerId) || game.getPlayer(source.getControllerId()).hasReachedNextTurnAfterLeaving()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ class BlindingBeamEffect2 extends ContinuousRuleModifyingEffectImpl {
|
|||
// prevent untap event of creatures of target player
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getControllerId().equals(targetPlayerId) && filter.match(permanent, game)) {
|
||||
if (permanent != null && permanent.isControlledBy(targetPlayerId) && filter.match(permanent, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class BloodOathEffect extends OneShotEffect {
|
|||
if (player != null && opponent != null && sourceObject != null) {
|
||||
Choice choiceImpl = new ChoiceImpl();
|
||||
choiceImpl.setChoices(choice);
|
||||
if (!player.choose(Outcome.Neutral, choiceImpl, game)) {
|
||||
if (player.choose(Outcome.Neutral, choiceImpl, game)) {
|
||||
CardType type = null;
|
||||
String choosenType = choiceImpl.getChoice();
|
||||
|
||||
|
|
|
@ -72,12 +72,7 @@ class BloodSunEffect extends ContinuousEffectImpl {
|
|||
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source.getSourceId(), game)) {
|
||||
switch (layer) {
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
for (Iterator<Ability> it = permanent.getAbilities().iterator(); it.hasNext();) {
|
||||
Ability ability = it.next();
|
||||
if (!ability.getAbilityType().equals(AbilityType.MANA)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
permanent.getAbilities().removeIf(ability -> ability.getAbilityType() != AbilityType.MANA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class BloodsporeThrinaxEntersBattlefieldEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
return creature != null && creature.getControllerId().equals(source.getControllerId())
|
||||
return creature != null && creature.isControlledBy(source.getControllerId())
|
||||
&& creature.isCreature()
|
||||
&& !event.getTargetId().equals(source.getSourceId());
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class BloodstoneGoblinTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.getControllerId().equals(controllerId)) {
|
||||
if (spell != null && spell.isControlledBy(controllerId)) {
|
||||
for (Ability ability : spell.getAbilities()) {
|
||||
if (ability instanceof KickerAbility && ((KickerAbility) ability).getKickedCounter(game, spell.getSpellAbility()) > 0) {
|
||||
return true;
|
||||
|
|
|
@ -92,7 +92,7 @@ class DiesWhileInGraveyardTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
for (Zone z : Zone.values()) {
|
||||
if (game.getShortLivingLKI(sourceId, z) && !z.equals(Zone.GRAVEYARD)) {
|
||||
if (game.getShortLivingLKI(sourceId, z) && z != Zone.GRAVEYARD) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class BosskTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.isLand() && permanent.getControllerId().equals(this.getControllerId())) {
|
||||
if (permanent != null && permanent.isLand() && permanent.isControlledBy(this.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -111,7 +111,7 @@ class BottledCloisterReturnEffect extends OneShotEffect {
|
|||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||
if (exileZone != null) {
|
||||
for (Card card: exileZone.getCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId())) {
|
||||
if (card.isOwnedBy(controller.getId())) {
|
||||
numberOfCards++;
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
||||
card.setFaceDown(false, game);
|
||||
|
|
|
@ -141,6 +141,6 @@ class DeterminedEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
return spell != null && !spell.getSourceId().equals(source.getSourceId()) && spell.getControllerId().equals(source.getControllerId());
|
||||
return spell != null && !spell.getSourceId().equals(source.getSourceId()) && spell.isControlledBy(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class BowerPassageEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker != null && attacker.getControllerId().equals(source.getControllerId()) && blocker.getAbilities().contains(FlyingAbility.getInstance())) {
|
||||
if (attacker != null && attacker.isControlledBy(source.getControllerId()) && blocker.getAbilities().contains(FlyingAbility.getInstance())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -79,7 +79,7 @@ class BramblewoodParagonReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
return creature != null && creature.getControllerId().equals(source.getControllerId())
|
||||
return creature != null && creature.isControlledBy(source.getControllerId())
|
||||
&& creature.isCreature()
|
||||
&& creature.hasSubtype(SubType.WARRIOR, game)
|
||||
&& !event.getTargetId().equals(source.getSourceId());
|
||||
|
|
|
@ -80,7 +80,7 @@ class BreathOfFuryAbility extends TriggeredAbilityImpl {
|
|||
Permanent enchantment = game.getPermanent(getSourceId());
|
||||
if (damageEvent.isCombatDamage()
|
||||
&& enchantment != null
|
||||
&& enchantment.getAttachedTo().equals(event.getSourceId())) {
|
||||
&& enchantment.isAttachedTo(event.getSourceId())) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
for (Effect effect : getEffects()) {
|
||||
|
|
|
@ -62,7 +62,7 @@ class BredForTheHuntTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((DamagedEvent) event).isCombatDamage()) {
|
||||
Permanent creature = game.getPermanent(event.getSourceId());
|
||||
if (creature != null && creature.getControllerId().equals(getControllerId()) && creature.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
||||
if (creature != null && creature.isControlledBy(getControllerId()) && creature.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import mage.constants.SubType;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.FilterSpell;
|
||||
import static mage.filter.StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT;
|
||||
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.target.TargetSpell;
|
||||
|
@ -30,7 +32,7 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public final class BrineShaman extends CardImpl {
|
||||
|
||||
private static final FilterSpell filter = new FilterSpell("noncreature spell");
|
||||
private static final FilterSpell filter = new FilterSpell("creature spell");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
|
||||
|
@ -54,7 +56,7 @@ public final class BrineShaman extends CardImpl {
|
|||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(),
|
||||
new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)));
|
||||
ability.addCost(new ManaCostsImpl("{1}{U}{U}"));
|
||||
ability.addTarget(new TargetSpell(filter));
|
||||
ability.addTarget(new TargetSpell(StaticFilters.FILTER_SPELL_CREATURE));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class BroodingSaurianControlEffect extends ContinuousEffectImpl {
|
|||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||
Permanent creature = it.next().getPermanent(game);
|
||||
if (creature != null) {
|
||||
if (!creature.getControllerId().equals(creature.getOwnerId())) {
|
||||
if (!creature.isControlledBy(creature.getOwnerId())) {
|
||||
creature.changeControllerId(creature.getOwnerId(), game);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -113,7 +113,7 @@ class BrutalHordechiefTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent source = game.getPermanent(event.getSourceId());
|
||||
if (source != null && source.getControllerId().equals(controllerId)) {
|
||||
if (source != null && source.isControlledBy(controllerId)) {
|
||||
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
|
||||
return true;
|
||||
|
|
|
@ -77,7 +77,7 @@ class BuildersBaneEffect extends OneShotEffect {
|
|||
if (permanent.destroy(source.getSourceId(), game, false)) {
|
||||
game.applyEffects();
|
||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
||||
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as grvayard
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -18,40 +18,41 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*
|
||||
* @author ayratn
|
||||
*/
|
||||
public final class BurntheImpure extends CardImpl {
|
||||
public final class BurnTheImpure extends CardImpl {
|
||||
|
||||
public BurntheImpure(UUID ownerId, CardSetInfo setInfo) {
|
||||
public BurnTheImpure(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{R}");
|
||||
|
||||
// Burn the Impure deals 3 damage to target creature. If that creature has infect, Burn the Impure deals 3 damage to that creature’s controller.
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().addEffect(new BurntheImpureEffect());
|
||||
this.getSpellAbility().addEffect(new BurnTheImpureEffect());
|
||||
}
|
||||
|
||||
public BurntheImpure(final BurntheImpure card) {
|
||||
public BurnTheImpure(final BurnTheImpure card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BurntheImpure copy() {
|
||||
return new BurntheImpure(this);
|
||||
public BurnTheImpure copy() {
|
||||
return new BurnTheImpure(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class BurntheImpureEffect extends OneShotEffect {
|
||||
class BurnTheImpureEffect extends OneShotEffect {
|
||||
|
||||
public BurntheImpureEffect() {
|
||||
public BurnTheImpureEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "{this} deals 3 damage to target creature. If that creature has infect, {this} deals 3 damage to that creature's controller.";
|
||||
}
|
||||
|
||||
public BurntheImpureEffect(final BurntheImpureEffect effect) {
|
||||
public BurnTheImpureEffect(final BurnTheImpureEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BurntheImpureEffect copy() {
|
||||
return new BurntheImpureEffect(this);
|
||||
public BurnTheImpureEffect copy() {
|
||||
return new BurnTheImpureEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -82,7 +82,7 @@ class CallerOfTheClawWatcher extends Watcher {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
Permanent card = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (card != null && card.getOwnerId().equals(this.controllerId) && card.isCreature() && !(card instanceof PermanentToken)) {
|
||||
if (card != null && card.isOwnedBy(this.controllerId) && card.isCreature() && !(card instanceof PermanentToken)) {
|
||||
creaturesCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class CampaignOfVengeanceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent source = game.getPermanent(event.getSourceId());
|
||||
if (source != null && source.getControllerId().equals(controllerId)) {
|
||||
if (source != null && source.isControlledBy(controllerId)) {
|
||||
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
|
||||
return true;
|
||||
|
|
|
@ -77,7 +77,7 @@ class GainReboundEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||
StackObject stackObject = iterator.next();
|
||||
if (stackObject instanceof Spell && stackObject.getControllerId().equals(source.getControllerId())) {
|
||||
if (stackObject instanceof Spell && stackObject.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
Card card = spell.getCard();
|
||||
if (card != null) {
|
||||
|
|
|
@ -89,7 +89,7 @@ class CatalystStoneCostReductionEffect extends CostModificationEffectImpl {
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
return SpellAbilityCastMode.FLASHBACK.equals(((SpellAbility) abilityToModify).getSpellAbilityCastMode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,13 +122,13 @@ class CelestialDawnToWhiteEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
// Stack
|
||||
for (MageObject object : game.getStack()) {
|
||||
if (object instanceof Spell && ((Spell) object).getControllerId().equals(controller.getId())) {
|
||||
if (object instanceof Spell && ((Spell) object).isControlledBy(controller.getId())) {
|
||||
setColor(object.getColor(game), game);
|
||||
}
|
||||
}
|
||||
// Exile
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId())) {
|
||||
if (card.isOwnedBy(controller.getId())) {
|
||||
setColor(card.getColor(game), game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class ChainsOfMephistophelesReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) {
|
||||
if (game.isActivePlayer(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
|
|
|
@ -79,7 +79,7 @@ class ChampionOfLambholtEffect extends RestrictionEffect {
|
|||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null && attacker.getControllerId().equals(sourcePermanent.getControllerId())) {
|
||||
if (sourcePermanent != null && attacker.isControlledBy(sourcePermanent.getControllerId())) {
|
||||
return blocker.getPower().getValue() >= sourcePermanent.getPower().getValue();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -68,7 +68,7 @@ class ChanceEncounterTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return this.getControllerId().equals(event.getPlayerId()) && event.getFlag();
|
||||
return this.isControlledBy(event.getPlayerId()) && event.getFlag();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,7 +67,7 @@ class ChancellorOfTheTangleDelayedTriggeredAbility extends DelayedTriggeredAbili
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return game.getActivePlayerId().equals(controllerId);
|
||||
return game.isActivePlayer(controllerId);
|
||||
}
|
||||
@Override
|
||||
public ChancellorOfTheTangleDelayedTriggeredAbility copy() {
|
||||
|
|
|
@ -115,7 +115,7 @@ class ChandraPyromasterTarget extends TargetPermanent {
|
|||
}
|
||||
UUID firstTarget = player.getId();
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (firstTarget != null && permanent != null && permanent.getControllerId().equals(firstTarget)) {
|
||||
if (firstTarget != null && permanent != null && permanent.isControlledBy(firstTarget)) {
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
return false;
|
||||
|
@ -142,7 +142,7 @@ class ChandraPyromasterTarget extends TargetPermanent {
|
|||
if (player != null) {
|
||||
for (UUID targetId : availablePossibleTargets) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null && permanent.getControllerId().equals(player.getId())) {
|
||||
if (permanent != null && permanent.isControlledBy(player.getId())) {
|
||||
possibleTargets.add(targetId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,14 +82,14 @@ class ChannelHarmEffect extends PreventionEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
||||
if ((targetPermanent != null && targetPermanent.getControllerId().equals(source.getControllerId()))
|
||||
if ((targetPermanent != null && targetPermanent.isControlledBy(source.getControllerId()))
|
||||
|| event.getTargetId().equals(source.getControllerId())) {
|
||||
MageObject damageSource = game.getObject(event.getSourceId());
|
||||
if (damageSource instanceof Controllable) {
|
||||
return !((Controllable) damageSource).getControllerId().equals(source.getControllerId());
|
||||
return !((Controllable) damageSource).isControlledBy(source.getControllerId());
|
||||
}
|
||||
else if (damageSource instanceof Card) {
|
||||
return !((Card) damageSource).getOwnerId().equals(source.getControllerId());
|
||||
return !((Card) damageSource).isOwnedBy(source.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,14 +82,16 @@ class ChaosWandEffect extends OneShotEffect {
|
|||
break;
|
||||
}
|
||||
opponent.moveCards(card, Zone.EXILED, source, game);
|
||||
controller.revealCards(source, new CardsImpl(card), game);
|
||||
if (card.isInstant() || card.isSorcery()) {
|
||||
if (!controller.chooseUse(outcome, "Cast " + card.getName() + " without paying its mana cost?", source, game)
|
||||
|| !controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) {
|
||||
cardsToShuffle.add(card);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
cardsToShuffle.add(card);
|
||||
}
|
||||
cardsToShuffle.add(card);
|
||||
}
|
||||
return opponent.putCardsOnBottomOfLibrary(cardsToShuffle, game, source, false);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class ChickenALaKingTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (this.getControllerId().equals(event.getPlayerId()) && event.getFlag()) {
|
||||
if (this.isControlledBy(event.getPlayerId()) && event.getFlag()) {
|
||||
// event.getData holds the num of sides of the die to roll
|
||||
String data = event.getData();
|
||||
if (data != null) {
|
||||
|
|
|
@ -57,7 +57,7 @@ class ChitteringDoomTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (this.getControllerId().equals(event.getPlayerId()) && event.getFlag()) {
|
||||
if (this.isControlledBy(event.getPlayerId()) && event.getFlag()) {
|
||||
if (event.getAmount() >= 4) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -72,10 +72,9 @@ class ChronicFloodingAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent source = game.getPermanent(this.sourceId);
|
||||
if (source != null && source.getAttachedTo().equals(event.getTargetId())) {
|
||||
if (source != null && source.isAttachedTo(event.getTargetId())) {
|
||||
Permanent attached = game.getPermanent(source.getAttachedTo());
|
||||
if (attached != null) {
|
||||
|
||||
for (Effect e : getEffects()) {
|
||||
e.setTargetPointer(new FixedTarget(attached.getControllerId()));
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class CinderCloudEffect extends OneShotEffect {
|
|||
if (permanent != null && permanent.destroy(source.getSourceId(), game, false) && permanent.getColor(game).equals(ObjectColor.WHITE)) {
|
||||
game.applyEffects();
|
||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
||||
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as grvayard
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class CircleOfFlameTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
youOrYourPlaneswalker = permanent != null
|
||||
&& permanent.isPlaneswalker()
|
||||
&& permanent.getControllerId().equals(this.getControllerId());
|
||||
&& permanent.isControlledBy(this.getControllerId());
|
||||
}
|
||||
if (youOrYourPlaneswalker) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
|
|
|
@ -67,7 +67,7 @@ class CityOfSolitudeEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return !game.getActivePlayerId().equals(event.getPlayerId());
|
||||
return !game.isActivePlayer(event.getPlayerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,7 +62,7 @@ class CityOfTraitorsTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent land = game.getPermanent(event.getTargetId());
|
||||
return land.isLand()
|
||||
&& land.getControllerId().equals(this.controllerId)
|
||||
&& land.isControlledBy(this.controllerId)
|
||||
&& !Objects.equals(event.getTargetId(), this.getSourceId());
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class CleansingMeditationEffect extends OneShotEffect {
|
|||
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_ENCHANTMENT_PERMANENT, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (permanent != null && permanent.destroy(source.getSourceId(), game, false)) {
|
||||
if (threshold && controller != null && permanent.getOwnerId().equals(controller.getId())) {
|
||||
if (threshold && controller != null && permanent.isOwnedBy(controller.getId())) {
|
||||
cardsToBattlefield.add(permanent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class CloudCoverAbility extends TriggeredAbilityImpl {
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
Player controller = game.getPlayer(this.getControllerId());
|
||||
if (permanent != null
|
||||
&& permanent.getControllerId().equals(getControllerId())
|
||||
&& permanent.isControlledBy(getControllerId())
|
||||
&& !permanent.getId().equals(this.getSourceId())
|
||||
&& controller != null
|
||||
&& controller.hasOpponent(event.getPlayerId(), game)) {
|
||||
|
|
|
@ -119,7 +119,7 @@ class CloudKeyCostModificationEffect extends CostModificationEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility && abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
if (abilityToModify instanceof SpellAbility && abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(abilityToModify.getSourceId());
|
||||
if (spell != null && spell.getCardType().toString().contains((String) game.getState().getValue(source.getSourceId().toString() + "_CloudKey"))) {
|
||||
return true;
|
||||
|
|
|
@ -63,7 +63,7 @@ class CoastalPiracyTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (((DamagedPlayerEvent) event).isCombatDamage()
|
||||
&& game.getOpponents(this.controllerId).contains(((DamagedPlayerEvent) event).getPlayerId())) {
|
||||
Permanent creature = game.getPermanent(event.getSourceId());
|
||||
if (creature != null && creature.getControllerId().equals(controllerId)) {
|
||||
if (creature != null && creature.isControlledBy(controllerId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class ComeuppanceEffect extends PreventionEffectImpl {
|
|||
MageObject damageDealingObject = game.getObject(event.getSourceId());
|
||||
UUID objectControllerId = null;
|
||||
if (damageDealingObject instanceof Permanent) {
|
||||
if (((Permanent) damageDealingObject).isCreature()) {
|
||||
if (damageDealingObject.isCreature()) {
|
||||
((Permanent) damageDealingObject).damage(preventionData.getPreventedDamage(), source.getSourceId(), game, false, true);
|
||||
} else {
|
||||
objectControllerId = ((Permanent) damageDealingObject).getControllerId();
|
||||
|
@ -102,7 +102,7 @@ class ComeuppanceEffect extends PreventionEffectImpl {
|
|||
} else {
|
||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
||||
if (targetPermanent != null &&
|
||||
targetPermanent.getControllerId().equals(source.getControllerId()) &&
|
||||
targetPermanent.isControlledBy(source.getControllerId()) &&
|
||||
targetPermanent.isPlaneswalker()) {
|
||||
catched = true;
|
||||
}
|
||||
|
@ -110,11 +110,11 @@ class ComeuppanceEffect extends PreventionEffectImpl {
|
|||
if (catched) {
|
||||
MageObject damageSource = game.getObject(event.getSourceId());
|
||||
if (damageSource instanceof StackObject) {
|
||||
return !((StackObject) damageSource).getControllerId().equals(source.getControllerId());
|
||||
return !((StackObject) damageSource).isControlledBy(source.getControllerId());
|
||||
} else if (damageSource instanceof Permanent) {
|
||||
return !((Permanent) damageSource).getControllerId().equals(source.getControllerId());
|
||||
return !((Permanent) damageSource).isControlledBy(source.getControllerId());
|
||||
} else if (damageSource instanceof Card) {
|
||||
return !((Card) damageSource).getOwnerId().equals(source.getControllerId());
|
||||
return !((Card) damageSource).isOwnedBy(source.getControllerId());
|
||||
}
|
||||
Logger.getLogger(Comeuppance.class).error("Comeuppance: could not define source objects controller - " + (damageSource != null ? damageSource.getName(): "null"));
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ class CommuneWithLavaMayPlayEffect extends AsThoughEffectImpl {
|
|||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
if (castOnTurn != game.getTurnNum() && game.getPhase().getStep().getType() == PhaseStep.END_TURN) {
|
||||
if (game.getActivePlayerId().equals(source.getControllerId())) {
|
||||
if (game.isActivePlayer(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class CommuneWithLavaMayPlayEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.getControllerId().equals(affectedControllerId)
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& getTargetPointer().getTargets(game, source).contains(sourceId);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ class ConcussiveBoltRestrictionEffect extends RestrictionEffect {
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (metalcraft && permanent.getControllerId().equals(player.getId())) {
|
||||
if (metalcraft && permanent.isControlledBy(player.getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
85
Mage.Sets/src/mage/cards/c/ConjurersBan.java
Normal file
85
Mage.Sets/src/mage/cards/c/ConjurersBan.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public final class ConjurersBan extends CardImpl {
|
||||
|
||||
public ConjurersBan(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}{B}");
|
||||
|
||||
|
||||
// Choose a card name. Until your next turn, spells with the chosen name can’t be cast and lands with the chosen name can’t be played.
|
||||
this.getSpellAbility().addEffect(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL));
|
||||
this.getSpellAbility().addEffect(new ConjurersBanEffect());
|
||||
|
||||
// Draw a card.
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
||||
}
|
||||
|
||||
public ConjurersBan(final ConjurersBan card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConjurersBan copy() {
|
||||
return new ConjurersBan(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ConjurersBanEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
public ConjurersBanEffect() {
|
||||
super(Duration.UntilYourNextTurn, Outcome.Detriment, true, false);
|
||||
this.staticText = "spells with the chosen name can't be cast and lands with the chosen name can't be played";
|
||||
}
|
||||
|
||||
public ConjurersBanEffect(final ConjurersBanEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConjurersBanEffect copy() {
|
||||
return new ConjurersBanEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL || event.getType() == GameEvent.EventType.PLAY_LAND) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
return object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessage(Ability source, GameEvent event, Game game) {
|
||||
String namedCard = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
|
||||
String playerName = game.getPlayer(source.getControllerId()).getName();
|
||||
if (namedCard == null || playerName == null || source.getSourceObject(game) == null){
|
||||
return super.getInfoMessage(source, event, game);
|
||||
}
|
||||
return "Until "+playerName+"'s next turn, spells named "+namedCard+" can't be cast and lands named "+namedCard+" can't be played ("+source.getSourceObject(game).getIdName()+").";
|
||||
}
|
||||
}
|
|
@ -149,7 +149,7 @@ class ConquerorsFlailEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
}
|
||||
}
|
||||
|
||||
if (isAttached && game.getActivePlayerId().equals(source.getControllerId())
|
||||
if (isAttached && game.isActivePlayer(source.getControllerId())
|
||||
&& game.getPlayer(source.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -85,13 +85,13 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
// in Exile
|
||||
for (Card card : game.getState().getExile().getAllCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature()) {
|
||||
if (card.isOwnedBy(controller.getId()) && card.isCreature()) {
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
// in Library (e.g. for Mystical Teachings)
|
||||
for (Card card : controller.getLibrary().getCards(game)) {
|
||||
if (card.getOwnerId().equals(controller.getId()) && card.isCreature()) {
|
||||
if (card.isOwnedBy(controller.getId()) && card.isCreature()) {
|
||||
setCreatureSubtype(card, subType, game);
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
|||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||
StackObject stackObject = iterator.next();
|
||||
if (stackObject instanceof Spell
|
||||
&& stackObject.getControllerId().equals(source.getControllerId())
|
||||
&& stackObject.isControlledBy(source.getControllerId())
|
||||
&& stackObject.isCreature()) {
|
||||
Card card = ((Spell) stackObject).getCard();
|
||||
setCreatureSubtype(card, subType, game);
|
||||
|
|
|
@ -83,7 +83,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
|
|||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(event.getTargetId());
|
||||
}
|
||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())
|
||||
if (permanent != null && permanent.isControlledBy(source.getControllerId())
|
||||
&& permanent.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue