mirror of
https://github.com/correl/mage.git
synced 2025-03-16 09:16:26 -09: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();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseMatching() {
|
private void chooseMatching() {
|
||||||
Collection<CardView> toMatch = dragCardList();
|
Collection<CardView> toMatch = dragCardList();
|
||||||
|
|
||||||
for (DragCardGridListener l : listeners) {
|
for (DragCardGridListener l : listeners) {
|
||||||
for (CardView card : allCards) {
|
for (CardView card : allCards) {
|
||||||
for (CardView aMatch : toMatch) {
|
for (CardView aMatch : toMatch) {
|
||||||
|
@ -1337,6 +1337,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
public void analyseDeck() {
|
public void analyseDeck() {
|
||||||
HashMap<String, Integer> qtys = new HashMap<>();
|
HashMap<String, Integer> qtys = new HashMap<>();
|
||||||
HashMap<String, Integer> pips = 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> sourcePips = new HashMap<>();
|
||||||
HashMap<String, Integer> manaCounts = new HashMap<>();
|
HashMap<String, Integer> manaCounts = new HashMap<>();
|
||||||
pips.put("#w}", 0);
|
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("\\{([WUBRG]).([WUBRG])\\}", "{$1}{$2}");
|
||||||
mc = mc.replaceAll("\\{", "#");
|
mc = mc.replaceAll("\\{", "#");
|
||||||
|
mc = mc.replaceAll("#2\\/", "#");
|
||||||
|
mc = mc.replaceAll("p}", "}");
|
||||||
mc = mc.toLowerCase(Locale.ENGLISH);
|
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()) {
|
for (String pip : pips.keySet()) {
|
||||||
int value = pips.get(pip);
|
int value = pips.get(pip);
|
||||||
while (mc.toLowerCase(Locale.ENGLISH).contains(pip)) {
|
while (mc.toLowerCase(Locale.ENGLISH).contains(pip)) {
|
||||||
pips.put(pip, ++value);
|
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, "");
|
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(new JLabel("Mana sources found:"));
|
||||||
panel4.add(chart3);
|
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(panel2);
|
||||||
panel.add(panel3);
|
panel.add(panel3);
|
||||||
panel.add(panel4);
|
panel.add(panel4);
|
||||||
|
panel.add(panel5);
|
||||||
|
|
||||||
JFrame frame = new JFrame("JOptionPane showMessageDialog component example");
|
JFrame frame = new JFrame("JOptionPane showMessageDialog component example");
|
||||||
JOptionPane.showMessageDialog(frame, panel, "This is the distribution of colors found", JOptionPane.INFORMATION_MESSAGE);
|
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");
|
JMenuItem invertSelection = new JMenuItem("Invert Selection");
|
||||||
invertSelection.addActionListener(e2 -> invertSelection());
|
invertSelection.addActionListener(e2 -> invertSelection());
|
||||||
menu.add(invertSelection);
|
menu.add(invertSelection);
|
||||||
|
|
||||||
JMenuItem chooseMatching = new JMenuItem("Choose Matching");
|
JMenuItem chooseMatching = new JMenuItem("Choose Matching");
|
||||||
chooseMatching.addActionListener(e2 -> chooseMatching());
|
chooseMatching.addActionListener(e2 -> chooseMatching());
|
||||||
menu.add(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 -> {
|
b.addActionListener(e -> {
|
||||||
switch(this.job.getState()) {
|
switch(this.job.getState()) {
|
||||||
case NEW:
|
case NEW:
|
||||||
|
case PREPARING:
|
||||||
case WORKING:
|
case WORKING:
|
||||||
this.job.setState(State.ABORTED);
|
this.job.setState(State.ABORTED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,16 +23,16 @@ import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
* The class DownloadJob.
|
* The class DownloadJob.
|
||||||
*
|
*
|
||||||
* @version V0.0 25.08.2010
|
* @version V0.0 25.08.2010
|
||||||
* @author Clemens Koza
|
* @author Clemens Koza, JayDi85
|
||||||
*/
|
*/
|
||||||
public class DownloadJob extends AbstractLaternaBean {
|
public class DownloadJob extends AbstractLaternaBean {
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
NEW, WORKING, FINISHED, ABORTED
|
NEW, PREPARING, WORKING, FINISHED, ABORTED
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Source source;
|
private Source source;
|
||||||
private final Destination destination;
|
private final Destination destination;
|
||||||
private final Property<State> state = properties.property("state", State.NEW);
|
private final Property<State> state = properties.property("state", State.NEW);
|
||||||
private final Property<String> message = properties.property("message");
|
private final Property<String> message = properties.property("message");
|
||||||
|
@ -98,6 +98,36 @@ public class DownloadJob extends AbstractLaternaBean {
|
||||||
this.message.setValue(message);
|
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.
|
* Sets the job's message.
|
||||||
*
|
*
|
||||||
|
@ -131,6 +161,10 @@ public class DownloadJob extends AbstractLaternaBean {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSource(Source source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
public Destination getDestination() {
|
public Destination getDestination() {
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
||||||
for (DownloadJob j : jobs) {
|
for (DownloadJob j : jobs) {
|
||||||
switch (j.getState()) {
|
switch (j.getState()) {
|
||||||
case NEW:
|
case NEW:
|
||||||
|
case PREPARING:
|
||||||
case WORKING:
|
case WORKING:
|
||||||
j.setState(State.ABORTED);
|
j.setState(State.ABORTED);
|
||||||
}
|
}
|
||||||
|
@ -82,8 +83,11 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(DownloadJob job) {
|
public void add(DownloadJob job) {
|
||||||
|
if (job.getState() == State.PREPARING) {
|
||||||
|
throw new IllegalArgumentException("Job already preparing");
|
||||||
|
}
|
||||||
if (job.getState() == State.WORKING) {
|
if (job.getState() == State.WORKING) {
|
||||||
throw new IllegalArgumentException("Job already running");
|
throw new IllegalArgumentException("Job already working");
|
||||||
}
|
}
|
||||||
if (job.getState() == State.FINISHED) {
|
if (job.getState() == State.FINISHED) {
|
||||||
throw new IllegalArgumentException("Job already finished");
|
throw new IllegalArgumentException("Job already finished");
|
||||||
|
@ -106,13 +110,22 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(DownloadJob job) {
|
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) {
|
synchronized (job) {
|
||||||
if (job.getState() != State.NEW) {
|
if (job.getState() != State.NEW) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
job.setState(State.WORKING);
|
|
||||||
|
job.doPrepareAndStartWork();
|
||||||
|
|
||||||
|
if (job.getState() != State.WORKING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// download and save data
|
||||||
try {
|
try {
|
||||||
Source src = job.getSource();
|
Source src = job.getSource();
|
||||||
Destination dst = job.getDestination();
|
Destination dst = job.getDestination();
|
||||||
|
|
|
@ -9,8 +9,13 @@ import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import mage.MageException;
|
||||||
import mage.util.StreamUtils;
|
import mage.util.StreamUtils;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
import org.mage.plugins.card.dl.DownloadJob;
|
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.card.arcane.ManaSymbols.getSymbolFileNameAsSVG;
|
||||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
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)
|
// TODO: add force to download symbols (rewrite exist files)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author JayDi85
|
||||||
* @author jaydi85@gmail.com
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
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 STATE_PROP_NAME = "state";
|
||||||
static final String DOWNLOAD_TEMP_FILE = getImagesDir() + File.separator + "temp" + File.separator + "scryfall-symbols-source.txt";
|
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();
|
return jobs.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseData(String sourcePath){
|
private void parseData(String sourcePath) {
|
||||||
|
|
||||||
String sourceData = "";
|
String sourceData = "";
|
||||||
try {
|
try {
|
||||||
sourceData = new String(Files.readAllBytes(Paths.get(sourcePath)));
|
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());
|
LOGGER.error("Can't open file to parse data: " + sourcePath + " , reason: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen symbols list
|
// gen symbols list
|
||||||
ArrayList<String> allMageSymbols = new ArrayList<>();
|
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]);
|
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));
|
allMageSymbols.add(String.valueOf(SYMBOLS_NUMBER_START + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,23 +93,22 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
||||||
|
|
||||||
// dirs maker
|
// dirs maker
|
||||||
File dir = getSymbolFileNameAsSVG("W").getParentFile();
|
File dir = getSymbolFileNameAsSVG("W").getParentFile();
|
||||||
if(!dir.exists()){
|
if (!dir.exists()) {
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode and save data (only if not exist)
|
// decode and save data (only if not exist)
|
||||||
for(String needCode: allMageSymbols){
|
for (String needCode : allMageSymbols) {
|
||||||
|
|
||||||
String searchCode = needCode.replace("/", "");
|
String searchCode = needCode.replace("/", "");
|
||||||
|
|
||||||
if(!foundedData.containsKey(searchCode))
|
if (!foundedData.containsKey(searchCode)) {
|
||||||
{
|
|
||||||
LOGGER.warn("Can't found symbol code from scryfall: " + searchCode);
|
LOGGER.warn("Can't found symbol code from scryfall: " + searchCode);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
File destFile = getSymbolFileNameAsSVG(searchCode);
|
File destFile = getSymbolFileNameAsSVG(searchCode);
|
||||||
if (destFile.exists() && (destFile.length() > 0)){
|
if (destFile.exists() && (destFile.length() > 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FileOutputStream stream = null;
|
FileOutputStream stream = null;
|
||||||
|
@ -118,7 +122,7 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
|
||||||
stream.write(fileData);
|
stream.write(fileData);
|
||||||
|
|
||||||
LOGGER.info("New svg symbol downloaded: " + needCode);
|
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());
|
LOGGER.error("Can't decode svg icon and save to file: " + destFile.getPath() + ", reason: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
StreamUtils.closeQuietly(stream);
|
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
|
// listener for data parse after download complete
|
||||||
private class ScryDownloadOnFinishedListener implements PropertyChangeListener {
|
private class ScryfallDownloadOnFinishedListener implements PropertyChangeListener {
|
||||||
private String downloadedFile;
|
private String downloadedFile;
|
||||||
|
|
||||||
public ScryDownloadOnFinishedListener(String ADestFile){
|
public ScryfallDownloadOnFinishedListener(String ADestFile) {
|
||||||
this.downloadedFile = ADestFile;
|
this.downloadedFile = ADestFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
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());
|
throw new IllegalArgumentException("Unknown download property " + evt.getPropertyName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.getNewValue() != State.FINISHED){
|
if (evt.getNewValue() != State.FINISHED) {
|
||||||
return;
|
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 = "";
|
private String destFile = "";
|
||||||
|
|
||||||
public ScryfallSymbolsDownloadJob() {
|
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.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)
|
// clear dest file (always download new data)
|
||||||
File file = new File(this.destFile);
|
File file = new File(this.destFile);
|
||||||
if (file.exists()){
|
if (file.exists()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
import org.mage.plugins.card.images.CardDownloadData;
|
import org.mage.plugins.card.images.CardDownloadData;
|
||||||
|
import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author North
|
* @author North
|
||||||
|
@ -535,7 +536,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
||||||
while (page < 999) {
|
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";
|
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);
|
logger.debug("URL: " + searchUrl);
|
||||||
Document doc = getDocument(searchUrl);
|
Document doc = CardImageUtils.downloadHtmlDocument(searchUrl);
|
||||||
Elements cardsImages = doc.select("img[src^=../../Handlers/]");
|
Elements cardsImages = doc.select("img[src^=../../Handlers/]");
|
||||||
if (cardsImages.isEmpty()) {
|
if (cardsImages.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
|
@ -587,33 +588,6 @@ public enum WizardCardsImageSource implements CardImageSource {
|
||||||
return setLinks;
|
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 {
|
private void getLandVariations(LinkedHashMap<String, String> setLinks, String cardSet, int multiverseId, String cardName) throws IOException, NumberFormatException {
|
||||||
CardCriteria criteria = new CardCriteria();
|
CardCriteria criteria = new CardCriteria();
|
||||||
criteria.nameExact(cardName);
|
criteria.nameExact(cardName);
|
||||||
|
@ -621,7 +595,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
||||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||||
|
|
||||||
String urlLandDocument = "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=" + multiverseId;
|
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");
|
Elements variations = landDoc.select("a.variationlink");
|
||||||
if (!variations.isEmpty()) {
|
if (!variations.isEmpty()) {
|
||||||
if (variations.size() > cards.size()) {
|
if (variations.size() > cards.size()) {
|
||||||
|
@ -668,7 +642,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
||||||
|
|
||||||
private HashMap<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException {
|
private HashMap<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException {
|
||||||
String cardLanguagesUrl = "http://gatherer.wizards.com/Pages/Card/Languages.aspx?multiverseid=" + englishMultiverseId;
|
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");
|
Elements languageTableRows = cardLanguagesDoc.select("tr.cardItem");
|
||||||
HashMap<String, Integer> localizedIds = new HashMap<>();
|
HashMap<String, Integer> localizedIds = new HashMap<>();
|
||||||
if (!languageTableRows.isEmpty()) {
|
if (!languageTableRows.isEmpty()) {
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package org.mage.plugins.card.utils;
|
package org.mage.plugins.card.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.constants.Constants;
|
import mage.client.constants.Constants;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
@ -13,6 +19,8 @@ import mage.remote.Connection;
|
||||||
import mage.remote.Connection.ProxyType;
|
import mage.remote.Connection.ProxyType;
|
||||||
import net.java.truevfs.access.TFile;
|
import net.java.truevfs.access.TFile;
|
||||||
import org.apache.log4j.Logger;
|
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.images.CardDownloadData;
|
||||||
import org.mage.plugins.card.properties.SettingsManager;
|
import org.mage.plugins.card.properties.SettingsManager;
|
||||||
|
|
||||||
|
@ -22,7 +30,6 @@ public final class CardImageUtils {
|
||||||
private static final Logger log = Logger.getLogger(CardImageUtils.class);
|
private static final Logger log = Logger.getLogger(CardImageUtils.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param card
|
* @param card
|
||||||
* @return String if image exists, else null
|
* @return String if image exists, else null
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +61,6 @@ public final class CardImageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param card
|
* @param card
|
||||||
* @return String regardless of whether image exists
|
* @return String regardless of whether image exists
|
||||||
*/
|
*/
|
||||||
|
@ -280,4 +286,31 @@ public final class CardImageUtils {
|
||||||
}
|
}
|
||||||
return null;
|
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:
|
case BATTLEFIELD:
|
||||||
sourceObject = game.getPermanent(ability.getSourceId());
|
sourceObject = game.getPermanent(ability.getSourceId());
|
||||||
if (sourceObject == null) {
|
if (sourceObject == null) {
|
||||||
sourceObject = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
|
sourceObject = game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
|
||||||
}
|
}
|
||||||
isPermanent = true;
|
isPermanent = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,11 +3,8 @@ package mage.deck;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import mage.abilities.common.CanBeYourCommanderAbility;
|
import mage.abilities.common.CanBeYourCommanderAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.ExpansionSet;
|
|
||||||
import mage.cards.Sets;
|
|
||||||
import mage.cards.decks.Constructed;
|
import mage.cards.decks.Constructed;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.SetType;
|
|
||||||
import mage.filter.FilterMana;
|
import mage.filter.FilterMana;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,50 +19,11 @@ public class Brawl extends Constructed {
|
||||||
super("Brawl");
|
super("Brawl");
|
||||||
|
|
||||||
// Copy of standard sets
|
// Copy of standard sets
|
||||||
GregorianCalendar current = new GregorianCalendar();
|
setCodes.addAll(Standard.makeLegalSets());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
banned.add("Baral, Chief of Compliance");
|
banned.add("Baral, Chief of Compliance");
|
||||||
banned.add("Smuggler's Copter");
|
banned.add("Smuggler's Copter");
|
||||||
banned.add("Sorcerers' Spyglass");
|
banned.add("Sorcerous 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Brawl(String name) {
|
public Brawl(String name) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.deck;
|
package mage.deck;
|
||||||
|
|
||||||
import mage.cards.ExpansionSet;
|
import mage.cards.ExpansionSet;
|
||||||
|
@ -32,6 +31,7 @@ public class Legacy extends Constructed {
|
||||||
banned.add("Chaos Orb");
|
banned.add("Chaos Orb");
|
||||||
banned.add("Contract from Below");
|
banned.add("Contract from Below");
|
||||||
banned.add("Darkpact");
|
banned.add("Darkpact");
|
||||||
|
banned.add("Deathrite Shaman");
|
||||||
banned.add("Demonic Attorney");
|
banned.add("Demonic Attorney");
|
||||||
banned.add("Demonic Consultation");
|
banned.add("Demonic Consultation");
|
||||||
banned.add("Demonic Tutor");
|
banned.add("Demonic Tutor");
|
||||||
|
@ -42,6 +42,7 @@ public class Legacy extends Constructed {
|
||||||
banned.add("Fastbond");
|
banned.add("Fastbond");
|
||||||
banned.add("Flash");
|
banned.add("Flash");
|
||||||
banned.add("Frantic Search");
|
banned.add("Frantic Search");
|
||||||
|
banned.add("Gitaxian Probe");
|
||||||
banned.add("Goblin Recruiter");
|
banned.add("Goblin Recruiter");
|
||||||
banned.add("Gush");
|
banned.add("Gush");
|
||||||
banned.add("Hermit Druid");
|
banned.add("Hermit Druid");
|
||||||
|
|
|
@ -20,6 +20,28 @@ public class Standard extends Constructed {
|
||||||
|
|
||||||
public Standard() {
|
public Standard() {
|
||||||
super("Constructed - 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();
|
GregorianCalendar current = new GregorianCalendar();
|
||||||
List<ExpansionSet> sets = new ArrayList(Sets.getInstance().values());
|
List<ExpansionSet> sets = new ArrayList(Sets.getInstance().values());
|
||||||
Collections.sort(sets, new Comparator<ExpansionSet>() {
|
Collections.sort(sets, new Comparator<ExpansionSet>() {
|
||||||
|
@ -50,23 +72,9 @@ public class Standard extends Constructed {
|
||||||
|| set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL)
|
|| set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL)
|
||||||
&& !set.getReleaseDate().before(earliestDate)) {
|
&& !set.getReleaseDate().before(earliestDate)) {
|
||||||
// && !set.getReleaseDate().after(current.getTime()))) {
|
// && !set.getReleaseDate().after(current.getTime()))) {
|
||||||
setCodes.add(set.getCode());
|
codes.add(set.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
banned.add("Attune with Aether"); // since 2018-01-15
|
return codes;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class BrawlDuelMatch extends MatchImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startGame() throws GameException {
|
public void startGame() throws GameException {
|
||||||
int startLife = 20;
|
int startLife = 25;
|
||||||
boolean alsoHand = true;
|
boolean alsoHand = true;
|
||||||
BrawlDuel game = new BrawlDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
BrawlDuel game = new BrawlDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
||||||
game.setCheckCommanderDamage(false);
|
game.setCheckCommanderDamage(false);
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
||||||
sb.setLength(0);
|
sb.setLength(0);
|
||||||
sb.append("-> Permanents: [");
|
sb.append("-> Permanents: [");
|
||||||
for (Permanent permanent : game.getBattlefield().getAllPermanents()) {
|
for (Permanent permanent : game.getBattlefield().getAllPermanents()) {
|
||||||
if (permanent.getOwnerId().equals(player.getId())) {
|
if (permanent.isOwnedBy(player.getId())) {
|
||||||
sb.append(permanent.getName());
|
sb.append(permanent.getName());
|
||||||
if (permanent.isTapped()) {
|
if (permanent.isTapped()) {
|
||||||
sb.append("(tapped)");
|
sb.append("(tapped)");
|
||||||
|
|
|
@ -341,8 +341,18 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
|
|
||||||
replacementEffectChoice.getChoices().clear();
|
replacementEffectChoice.getChoices().clear();
|
||||||
replacementEffectChoice.setKeyChoices(rEffects);
|
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);
|
updateGameStatePriority("chooseEffect", game);
|
||||||
prepareForResponse(game);
|
prepareForResponse(game);
|
||||||
if (!isExecutingMacro()) {
|
if (!isExecutingMacro()) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -1149,7 +1148,7 @@ public class GameController implements GameCallback {
|
||||||
sb.append(state.getTurnMods());
|
sb.append(state.getTurnMods());
|
||||||
sb.append("<br>getTurnNum: ");
|
sb.append("<br>getTurnNum: ");
|
||||||
sb.append(state.getTurnNum());
|
sb.append(state.getTurnNum());
|
||||||
|
|
||||||
sb.append("<br>Using plane chase?:" + state.isPlaneChase());
|
sb.append("<br>Using plane chase?:" + state.isPlaneChase());
|
||||||
if (state.isPlaneChase()) {
|
if (state.isPlaneChase()) {
|
||||||
Plane currentPlane = state.getCurrentPlane();
|
Plane currentPlane = state.getCurrentPlane();
|
||||||
|
@ -1157,7 +1156,7 @@ public class GameController implements GameCallback {
|
||||||
sb.append("<br>Current plane:" + currentPlane.getName());
|
sb.append("<br>Current plane:" + currentPlane.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("<br>Future Timeout:");
|
sb.append("<br>Future Timeout:");
|
||||||
if (futureTimeout != null) {
|
if (futureTimeout != null) {
|
||||||
sb.append("Cancelled?=");
|
sb.append("Cancelled?=");
|
||||||
|
@ -1188,8 +1187,13 @@ public class GameController implements GameCallback {
|
||||||
|
|
||||||
sb.append("<br>Active player is: ");
|
sb.append("<br>Active player is: ");
|
||||||
sb.append(game.getPlayer(state.getActivePlayerId()).getName());
|
sb.append(game.getPlayer(state.getActivePlayerId()).getName());
|
||||||
|
|
||||||
PassAbility pass = new PassAbility();
|
PassAbility pass = new PassAbility();
|
||||||
if (game.getPlayer(state.getActivePlayerId()).hasLeft()) {
|
if (game.getPlayer(state.getActivePlayerId()).hasLeft()) {
|
||||||
|
Player p = game.getPlayer(state.getActivePlayerId());
|
||||||
|
if (p != null) {
|
||||||
|
p.concede(game);
|
||||||
|
}
|
||||||
Phase currentPhase = game.getPhase();
|
Phase currentPhase = game.getPhase();
|
||||||
if (currentPhase != null) {
|
if (currentPhase != null) {
|
||||||
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
||||||
|
@ -1204,6 +1208,10 @@ public class GameController implements GameCallback {
|
||||||
sb.append("<br>getChoosingPlayerId: ");
|
sb.append("<br>getChoosingPlayerId: ");
|
||||||
if (state.getChoosingPlayerId() != null) {
|
if (state.getChoosingPlayerId() != null) {
|
||||||
if (game.getPlayer(state.getChoosingPlayerId()).hasLeft()) {
|
if (game.getPlayer(state.getChoosingPlayerId()).hasLeft()) {
|
||||||
|
Player p = game.getPlayer(state.getChoosingPlayerId());
|
||||||
|
if (p != null) {
|
||||||
|
p.concede(game);
|
||||||
|
}
|
||||||
Phase currentPhase = game.getPhase();
|
Phase currentPhase = game.getPhase();
|
||||||
if (currentPhase != null && !fixedAlready) {
|
if (currentPhase != null && !fixedAlready) {
|
||||||
currentPhase.getStep().endStep(game, state.getActivePlayerId());
|
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: ");
|
sb.append("<br><font color=orange>Player with Priority is: ");
|
||||||
if (state.getPriorityPlayerId() != null) {
|
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();
|
Phase currentPhase = game.getPhase();
|
||||||
if (currentPhase != null && !fixedAlready) {
|
if (currentPhase != null && !fixedAlready) {
|
||||||
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
||||||
|
@ -1228,7 +1240,7 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
sb.append(game.getPlayer(state.getPriorityPlayerId()).getName());
|
sb.append(game.getPlayer(state.getPriorityPlayerId()).getName());
|
||||||
sb.append("</font>");
|
sb.append("</font>");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("<br>Future Timeout:");
|
sb.append("<br>Future Timeout:");
|
||||||
if (futureTimeout != null) {
|
if (futureTimeout != null) {
|
||||||
|
|
|
@ -155,7 +155,7 @@ class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl {
|
||||||
Card card = game.getCard(event.getTargetId());
|
Card card = game.getCard(event.getTargetId());
|
||||||
if (card != null
|
if (card != null
|
||||||
&& watcher != null
|
&& watcher != null
|
||||||
&& card.getOwnerId().equals(controller.getId())) {
|
&& card.isOwnedBy(controller.getId())) {
|
||||||
for (Ability ability : card.getAbilities()) {
|
for (Ability ability : card.getAbilities()) {
|
||||||
if (ability instanceof CyclingAbility) {
|
if (ability instanceof CyclingAbility) {
|
||||||
cardHasCycling = true;
|
cardHasCycling = true;
|
||||||
|
@ -199,7 +199,7 @@ class AbandonedSarcophagusWatcher extends Watcher {
|
||||||
Player controller = game.getPlayer(event.getPlayerId());
|
Player controller = game.getPlayer(event.getPlayerId());
|
||||||
if (card != null
|
if (card != null
|
||||||
&& controller != null
|
&& controller != null
|
||||||
&& card.getOwnerId().equals(controller.getId())) {
|
&& card.isOwnedBy(controller.getId())) {
|
||||||
Cards c = getCardsCycledThisTurn(event.getPlayerId());
|
Cards c = getCardsCycledThisTurn(event.getPlayerId());
|
||||||
c.add(card);
|
c.add(card);
|
||||||
cycledCardsThisTurn.put(event.getPlayerId(), c);
|
cycledCardsThisTurn.put(event.getPlayerId(), c);
|
||||||
|
|
|
@ -108,7 +108,7 @@ class AbbotOfKeralKeepCastFromExileEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
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));
|
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class AcidicSoilEffect extends OneShotEffect {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
for (Permanent permanent : permanents) {
|
for (Permanent permanent : permanents) {
|
||||||
if (permanent.getControllerId().equals(playerId)) {
|
if (permanent.isControlledBy(playerId)) {
|
||||||
amount++;
|
amount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ class AerialCaravanCastFromExileEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
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));
|
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class AetherChargeTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent.isCreature() && permanent.hasSubtype(SubType.BEAST, game)
|
if (permanent.isCreature() && permanent.hasSubtype(SubType.BEAST, game)
|
||||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
&& permanent.isControlledBy(this.controllerId)) {
|
||||||
Effect effect = this.getEffects().get(0);
|
Effect effect = this.getEffects().get(0);
|
||||||
effect.setValue("damageSource", event.getTargetId());
|
effect.setValue("damageSource", event.getTargetId());
|
||||||
return true;
|
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> permanentsToTop = new ArrayList<>();
|
||||||
List<Permanent> permanentsToBottom = new ArrayList<>();
|
List<Permanent> permanentsToBottom = new ArrayList<>();
|
||||||
for (Permanent permanent:game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source.getSourceId(), game)) {
|
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)) {
|
if (player.chooseUse(outcome, "Put " + permanent.getLogName() + " to the top? (else it goes to bottom)", source, game)) {
|
||||||
permanentsToTop.add(permanent);
|
permanentsToTop.add(permanent);
|
||||||
game.informPlayers(permanent.getLogName() + " goes to the top of " + player.getLogName() + "'s library");
|
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;
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD
|
if (zEvent.getFromZone() == Zone.BATTLEFIELD
|
||||||
&& zEvent.getToZone() == Zone.GRAVEYARD) {
|
&& zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||||
if (zEvent.getTarget().getControllerId().equals(controllerId)
|
if (zEvent.getTarget().isControlledBy(controllerId)
|
||||||
&& (zEvent.getTarget().isCreature()
|
&& (zEvent.getTarget().isCreature()
|
||||||
|| zEvent.getTarget().isPlaneswalker())) {
|
|| zEvent.getTarget().isPlaneswalker())) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,7 +79,7 @@ class AkoumFirebirdLandfallAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
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
|
@Override
|
||||||
|
|
|
@ -82,7 +82,7 @@ class AkoumHellkiteTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null
|
if (permanent != null
|
||||||
&& permanent.isLand()
|
&& permanent.isLand()
|
||||||
&& permanent.getControllerId().equals(getControllerId())) {
|
&& permanent.isControlledBy(getControllerId())) {
|
||||||
Permanent sourcePermanent = game.getPermanent(getSourceId());
|
Permanent sourcePermanent = game.getPermanent(getSourceId());
|
||||||
if (sourcePermanent != null) {
|
if (sourcePermanent != null) {
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
|
|
|
@ -87,6 +87,6 @@ class AladdinsLampEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
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
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||||
if (game.getActivePlayerId().equals(event.getPlayerId())
|
if (game.isActivePlayer(event.getPlayerId())
|
||||||
&& game.getPhase().getStep().getType() == PhaseStep.DRAW) {
|
&& game.getPhase().getStep().getType() == PhaseStep.DRAW) {
|
||||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName());
|
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ class AmbuscadeShamanTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
UUID targetId = event.getTargetId();
|
UUID targetId = event.getTargetId();
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
if (permanent.getControllerId().equals(this.controllerId)
|
if (permanent.isControlledBy(this.controllerId)
|
||||||
&& permanent.isCreature()) {
|
&& permanent.isCreature()) {
|
||||||
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
|
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -58,7 +58,7 @@ class AmuletOfVigorTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent p = game.getPermanent(event.getTargetId());
|
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()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ class AngelicArbiterCantAttackTargetEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
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());
|
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(permanent.getControllerId()) > 0) {
|
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(permanent.getControllerId()) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,7 +113,7 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
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());
|
PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher.getNumberOfAttackersCurrentTurn(event.getPlayerId()) > 0) {
|
if (watcher != null && watcher.getNumberOfAttackersCurrentTurn(event.getPlayerId()) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -62,7 +62,7 @@ class AngelicBenedictionTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (game.getActivePlayerId().equals(this.controllerId)) {
|
if (game.isActivePlayer(this.controllerId)) {
|
||||||
if (game.getCombat().attacksAlone()) {
|
if (game.getCombat().attacksAlone()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class AngelicChorusTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent.isCreature()
|
if (permanent.isCreature()
|
||||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
&& permanent.isControlledBy(this.controllerId)) {
|
||||||
this.getEffects().get(0).setValue("lifeSource", event.getTargetId());
|
this.getEffects().get(0).setValue("lifeSource", event.getTargetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility) {
|
||||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
return spell.isCreature();
|
return spell.isCreature();
|
||||||
|
|
|
@ -84,7 +84,7 @@ class AnimationModuleTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
permanent = game.getPermanentEntering(event.getTargetId());
|
permanent = game.getPermanentEntering(event.getTargetId());
|
||||||
}
|
}
|
||||||
return permanent != null && permanent.getControllerId().equals(this.getControllerId());
|
return permanent != null && permanent.isControlledBy(this.getControllerId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class ApexOfPowerCastFromExileEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
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));
|
&& objectId.equals(getTargetPointer().getFirst(game, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ConspyEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
// in Library (e.g. for Mystical Teachings)
|
// in Library (e.g. for Mystical Teachings)
|
||||||
for (Card card : controller.getLibrary().getCards(game)) {
|
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);
|
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();) {
|
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||||
StackObject stackObject = iterator.next();
|
StackObject stackObject = iterator.next();
|
||||||
if (stackObject instanceof Spell
|
if (stackObject instanceof Spell
|
||||||
&& stackObject.getControllerId().equals(source.getControllerId())
|
&& stackObject.isControlledBy(source.getControllerId())
|
||||||
&& stackObject.isCreature()
|
&& stackObject.isCreature()
|
||||||
&& !stackObject.hasSubtype(subType, game)) {
|
&& !stackObject.hasSubtype(subType, game)) {
|
||||||
Card card = ((Spell) stackObject).getCard();
|
Card card = ((Spell) stackObject).getCard();
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ArchonOfRedemptionTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent.getControllerId().equals(getControllerId())
|
if (permanent.isControlledBy(getControllerId())
|
||||||
&& permanent.isCreature()
|
&& permanent.isCreature()
|
||||||
&& (permanent.getId().equals(getSourceId())
|
&& (permanent.getId().equals(getSourceId())
|
||||||
|| (permanent.getAbilities().contains(FlyingAbility.getInstance())))) {
|
|| (permanent.getAbilities().contains(FlyingAbility.getInstance())))) {
|
||||||
|
|
|
@ -133,7 +133,7 @@ class ArchonOfValorsReachChoice extends ChoiceImpl {
|
||||||
return CardType.INSTANT;
|
return CardType.INSTANT;
|
||||||
case "Sorcery":
|
case "Sorcery":
|
||||||
return CardType.SORCERY;
|
return CardType.SORCERY;
|
||||||
case "Planewswalker":
|
case "Planeswalker":
|
||||||
return CardType.PLANESWALKER;
|
return CardType.PLANESWALKER;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -74,7 +74,7 @@ class AbilityActivatedTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent aura = game.getPermanent(this.getSourceId());
|
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
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setValue("rolled", event.getAmount());
|
effect.setValue("rolled", event.getAmount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ enum AshenGhoulCondition implements Condition {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (!game.getStep().getType().equals(PhaseStep.UPKEEP)
|
if (game.getStep().getType() != PhaseStep.UPKEEP
|
||||||
|| !game.getActivePlayerId().equals(source.getControllerId())) {
|
|| !game.isActivePlayer(source.getControllerId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ class AsmiraHolyAvengerWatcher extends Watcher {
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||||
MageObject card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
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++;
|
creaturesCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,8 @@ public final class AssaultSuit extends CardImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT) {
|
if (event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT) {
|
||||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null) {
|
||||||
return equipment.getAttachedTo().equals(event.getTargetId());
|
return equipment.isAttachedTo(event.getTargetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -123,7 +123,7 @@ class AzorTheLawbringerCantCastEffect extends ContinuousRuleModifyingEffectImpl
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
UUID opponentId = getTargetPointer().getFirst(game, source);
|
UUID opponentId = getTargetPointer().getFirst(game, source);
|
||||||
if (game.getActivePlayerId().equals(opponentId)) {
|
if (game.isActivePlayer(opponentId)) {
|
||||||
if (playersNextTurn == 0) {
|
if (playersNextTurn == 0) {
|
||||||
playersNextTurn = game.getTurnNum();
|
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
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if ((abilityToModify instanceof SpellAbility)
|
if ((abilityToModify instanceof SpellAbility)
|
||||||
&& abilityToModify.getControllerId().equals(source.getControllerId())) {
|
&& abilityToModify.isControlledBy(source.getControllerId())) {
|
||||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||||
return spell != null && StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY.match(spell, game);
|
return spell != null && StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY.match(spell, game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class BattlegraceAngelAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (game.getActivePlayerId().equals(this.controllerId) ) {
|
if (game.isActivePlayer(this.controllerId) ) {
|
||||||
if (game.getCombat().attacksAlone()) {
|
if (game.getCombat().attacksAlone()) {
|
||||||
for (Effect effect: this.getEffects()) {
|
for (Effect effect: this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0)));
|
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0)));
|
||||||
|
|
|
@ -74,7 +74,7 @@ class BidentOfThassaTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (((DamagedPlayerEvent) event).isCombatDamage()) {
|
if (((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||||
Permanent creature = game.getPermanent(event.getSourceId());
|
Permanent creature = game.getPermanent(event.getSourceId());
|
||||||
if (creature != null && creature.getControllerId().equals(controllerId)) {
|
if (creature != null && creature.isControlledBy(controllerId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
|
||||||
if (source.getTargets().size() > 1) {
|
if (source.getTargets().size() > 1) {
|
||||||
toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1);
|
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));
|
source.getStackAbility().getTargets().get(0).getTargets().get(0));
|
||||||
Permanent inputPermanent = game.getPermanent(input.getObject().getId());
|
Permanent inputPermanent = game.getPermanent(input.getObject().getId());
|
||||||
if (firstTarget != null && inputPermanent != null) {
|
if (firstTarget != null && inputPermanent != null) {
|
||||||
return firstTarget.getControllerId().equals(inputPermanent.getControllerId());
|
return firstTarget.isControlledBy(inputPermanent.getControllerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -89,7 +89,7 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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());
|
MageObject damageSource = game.getObject(event.getSourceId());
|
||||||
if (damageSource != null) {
|
if (damageSource != null) {
|
||||||
if (damageSource.isInstant()|| damageSource.isSorcery()) {
|
if (damageSource.isInstant()|| damageSource.isSorcery()) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ class BlindingBeamEffect2 extends ContinuousRuleModifyingEffectImpl {
|
||||||
public boolean isInactive(Ability source, Game game) {
|
public boolean isInactive(Ability source, Game game) {
|
||||||
// the PRE step part is directly after the UNTAP events for permanents
|
// 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.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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class BlindingBeamEffect2 extends ContinuousRuleModifyingEffectImpl {
|
||||||
// prevent untap event of creatures of target player
|
// prevent untap event of creatures of target player
|
||||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class BloodOathEffect extends OneShotEffect {
|
||||||
if (player != null && opponent != null && sourceObject != null) {
|
if (player != null && opponent != null && sourceObject != null) {
|
||||||
Choice choiceImpl = new ChoiceImpl();
|
Choice choiceImpl = new ChoiceImpl();
|
||||||
choiceImpl.setChoices(choice);
|
choiceImpl.setChoices(choice);
|
||||||
if (!player.choose(Outcome.Neutral, choiceImpl, game)) {
|
if (player.choose(Outcome.Neutral, choiceImpl, game)) {
|
||||||
CardType type = null;
|
CardType type = null;
|
||||||
String choosenType = choiceImpl.getChoice();
|
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)) {
|
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source.getSourceId(), game)) {
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
case AbilityAddingRemovingEffects_6:
|
case AbilityAddingRemovingEffects_6:
|
||||||
for (Iterator<Ability> it = permanent.getAbilities().iterator(); it.hasNext();) {
|
permanent.getAbilities().removeIf(ability -> ability.getAbilityType() != AbilityType.MANA);
|
||||||
Ability ability = it.next();
|
|
||||||
if (!ability.getAbilityType().equals(AbilityType.MANA)) {
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ class BloodsporeThrinaxEntersBattlefieldEffect extends ReplacementEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||||
return creature != null && creature.getControllerId().equals(source.getControllerId())
|
return creature != null && creature.isControlledBy(source.getControllerId())
|
||||||
&& creature.isCreature()
|
&& creature.isCreature()
|
||||||
&& !event.getTargetId().equals(source.getSourceId());
|
&& !event.getTargetId().equals(source.getSourceId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class BloodstoneGoblinTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
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()) {
|
for (Ability ability : spell.getAbilities()) {
|
||||||
if (ability instanceof KickerAbility && ((KickerAbility) ability).getKickedCounter(game, spell.getSpellAbility()) > 0) {
|
if (ability instanceof KickerAbility && ((KickerAbility) ability).getKickedCounter(game, spell.getSpellAbility()) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -92,7 +92,7 @@ class DiesWhileInGraveyardTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
for (Zone z : Zone.values()) {
|
for (Zone z : Zone.values()) {
|
||||||
if (game.getShortLivingLKI(sourceId, z) && !z.equals(Zone.GRAVEYARD)) {
|
if (game.getShortLivingLKI(sourceId, z) && z != Zone.GRAVEYARD) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class BosskTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -111,7 +111,7 @@ class BottledCloisterReturnEffect extends OneShotEffect {
|
||||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||||
if (exileZone != null) {
|
if (exileZone != null) {
|
||||||
for (Card card: exileZone.getCards(game)) {
|
for (Card card: exileZone.getCards(game)) {
|
||||||
if (card.getOwnerId().equals(controller.getId())) {
|
if (card.isOwnedBy(controller.getId())) {
|
||||||
numberOfCards++;
|
numberOfCards++;
|
||||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
||||||
card.setFaceDown(false, game);
|
card.setFaceDown(false, game);
|
||||||
|
|
|
@ -141,6 +141,6 @@ class DeterminedEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
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
|
@Override
|
||||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,7 +79,7 @@ class BramblewoodParagonReplacementEffect extends ReplacementEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||||
return creature != null && creature.getControllerId().equals(source.getControllerId())
|
return creature != null && creature.isControlledBy(source.getControllerId())
|
||||||
&& creature.isCreature()
|
&& creature.isCreature()
|
||||||
&& creature.hasSubtype(SubType.WARRIOR, game)
|
&& creature.hasSubtype(SubType.WARRIOR, game)
|
||||||
&& !event.getTargetId().equals(source.getSourceId());
|
&& !event.getTargetId().equals(source.getSourceId());
|
||||||
|
|
|
@ -80,7 +80,7 @@ class BreathOfFuryAbility extends TriggeredAbilityImpl {
|
||||||
Permanent enchantment = game.getPermanent(getSourceId());
|
Permanent enchantment = game.getPermanent(getSourceId());
|
||||||
if (damageEvent.isCombatDamage()
|
if (damageEvent.isCombatDamage()
|
||||||
&& enchantment != null
|
&& enchantment != null
|
||||||
&& enchantment.getAttachedTo().equals(event.getSourceId())) {
|
&& enchantment.isAttachedTo(event.getSourceId())) {
|
||||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||||
if (creature != null) {
|
if (creature != null) {
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ class BredForTheHuntTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (((DamagedEvent) event).isCombatDamage()) {
|
if (((DamagedEvent) event).isCombatDamage()) {
|
||||||
Permanent creature = game.getPermanent(event.getSourceId());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterSpell;
|
import mage.filter.FilterSpell;
|
||||||
import static mage.filter.StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT;
|
import static mage.filter.StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT;
|
||||||
|
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||||
import mage.target.TargetSpell;
|
import mage.target.TargetSpell;
|
||||||
|
@ -30,7 +32,7 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
*/
|
*/
|
||||||
public final class BrineShaman extends CardImpl {
|
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 {
|
static {
|
||||||
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
|
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(),
|
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(),
|
||||||
new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)));
|
new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)));
|
||||||
ability.addCost(new ManaCostsImpl("{1}{U}{U}"));
|
ability.addCost(new ManaCostsImpl("{1}{U}{U}"));
|
||||||
ability.addTarget(new TargetSpell(filter));
|
ability.addTarget(new TargetSpell(StaticFilters.FILTER_SPELL_CREATURE));
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ class BroodingSaurianControlEffect extends ContinuousEffectImpl {
|
||||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
|
||||||
Permanent creature = it.next().getPermanent(game);
|
Permanent creature = it.next().getPermanent(game);
|
||||||
if (creature != null) {
|
if (creature != null) {
|
||||||
if (!creature.getControllerId().equals(creature.getOwnerId())) {
|
if (!creature.isControlledBy(creature.getOwnerId())) {
|
||||||
creature.changeControllerId(creature.getOwnerId(), game);
|
creature.changeControllerId(creature.getOwnerId(), game);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -113,7 +113,7 @@ class BrutalHordechiefTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent source = game.getPermanent(event.getSourceId());
|
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);
|
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
|
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -77,7 +77,7 @@ class BuildersBaneEffect extends OneShotEffect {
|
||||||
if (permanent.destroy(source.getSourceId(), game, false)) {
|
if (permanent.destroy(source.getSourceId(), game, false)) {
|
||||||
game.applyEffects();
|
game.applyEffects();
|
||||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
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
|
// A replacement effect has moved the card to another zone as grvayard
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,40 +18,41 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
*
|
*
|
||||||
* @author ayratn
|
* @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}");
|
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().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);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BurntheImpure copy() {
|
public BurnTheImpure copy() {
|
||||||
return new BurntheImpure(this);
|
return new BurnTheImpure(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BurntheImpureEffect extends OneShotEffect {
|
class BurnTheImpureEffect extends OneShotEffect {
|
||||||
|
|
||||||
public BurntheImpureEffect() {
|
public BurnTheImpureEffect() {
|
||||||
super(Outcome.Damage);
|
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.";
|
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);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BurntheImpureEffect copy() {
|
public BurnTheImpureEffect copy() {
|
||||||
return new BurntheImpureEffect(this);
|
return new BurnTheImpureEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -82,7 +82,7 @@ class CallerOfTheClawWatcher extends Watcher {
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||||
Permanent card = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
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++;
|
creaturesCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class CampaignOfVengeanceTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent source = game.getPermanent(event.getSourceId());
|
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);
|
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
|
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -77,7 +77,7 @@ class GainReboundEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||||
StackObject stackObject = iterator.next();
|
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;
|
Spell spell = (Spell) stackObject;
|
||||||
Card card = spell.getCard();
|
Card card = spell.getCard();
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class CatalystStoneCostReductionEffect extends CostModificationEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility) {
|
||||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||||
return SpellAbilityCastMode.FLASHBACK.equals(((SpellAbility) abilityToModify).getSpellAbilityCastMode());
|
return SpellAbilityCastMode.FLASHBACK.equals(((SpellAbility) abilityToModify).getSpellAbilityCastMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,13 +122,13 @@ class CelestialDawnToWhiteEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
// Stack
|
// Stack
|
||||||
for (MageObject object : game.getStack()) {
|
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);
|
setColor(object.getColor(game), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Exile
|
// Exile
|
||||||
for (Card card : game.getExile().getAllCards(game)) {
|
for (Card card : game.getExile().getAllCards(game)) {
|
||||||
if (card.getOwnerId().equals(controller.getId())) {
|
if (card.isOwnedBy(controller.getId())) {
|
||||||
setColor(card.getColor(game), game);
|
setColor(card.getColor(game), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class ChainsOfMephistophelesReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
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());
|
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName());
|
||||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,7 +79,7 @@ class ChampionOfLambholtEffect extends RestrictionEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
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 blocker.getPower().getValue() >= sourcePermanent.getPower().getValue();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ChanceEncounterTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
return this.getControllerId().equals(event.getPlayerId()) && event.getFlag();
|
return this.isControlledBy(event.getPlayerId()) && event.getFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -67,7 +67,7 @@ class ChancellorOfTheTangleDelayedTriggeredAbility extends DelayedTriggeredAbili
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
return game.getActivePlayerId().equals(controllerId);
|
return game.isActivePlayer(controllerId);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ChancellorOfTheTangleDelayedTriggeredAbility copy() {
|
public ChancellorOfTheTangleDelayedTriggeredAbility copy() {
|
||||||
|
|
|
@ -115,7 +115,7 @@ class ChandraPyromasterTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
UUID firstTarget = player.getId();
|
UUID firstTarget = player.getId();
|
||||||
Permanent permanent = game.getPermanent(id);
|
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 super.canTarget(id, source, game);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,7 +142,7 @@ class ChandraPyromasterTarget extends TargetPermanent {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
for (UUID targetId : availablePossibleTargets) {
|
for (UUID targetId : availablePossibleTargets) {
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
if (permanent != null && permanent.getControllerId().equals(player.getId())) {
|
if (permanent != null && permanent.isControlledBy(player.getId())) {
|
||||||
possibleTargets.add(targetId);
|
possibleTargets.add(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,14 +82,14 @@ class ChannelHarmEffect extends PreventionEffectImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game)) {
|
if (super.applies(event, source, game)) {
|
||||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
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())) {
|
|| event.getTargetId().equals(source.getControllerId())) {
|
||||||
MageObject damageSource = game.getObject(event.getSourceId());
|
MageObject damageSource = game.getObject(event.getSourceId());
|
||||||
if (damageSource instanceof Controllable) {
|
if (damageSource instanceof Controllable) {
|
||||||
return !((Controllable) damageSource).getControllerId().equals(source.getControllerId());
|
return !((Controllable) damageSource).isControlledBy(source.getControllerId());
|
||||||
}
|
}
|
||||||
else if (damageSource instanceof Card) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
opponent.moveCards(card, Zone.EXILED, source, game);
|
opponent.moveCards(card, Zone.EXILED, source, game);
|
||||||
|
controller.revealCards(source, new CardsImpl(card), game);
|
||||||
if (card.isInstant() || card.isSorcery()) {
|
if (card.isInstant() || card.isSorcery()) {
|
||||||
if (!controller.chooseUse(outcome, "Cast " + card.getName() + " without paying its mana cost?", source, game)
|
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))) {
|
|| !controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) {
|
||||||
cardsToShuffle.add(card);
|
cardsToShuffle.add(card);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
cardsToShuffle.add(card);
|
||||||
}
|
}
|
||||||
cardsToShuffle.add(card);
|
|
||||||
}
|
}
|
||||||
return opponent.putCardsOnBottomOfLibrary(cardsToShuffle, game, source, false);
|
return opponent.putCardsOnBottomOfLibrary(cardsToShuffle, game, source, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ChickenALaKingTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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
|
// event.getData holds the num of sides of the die to roll
|
||||||
String data = event.getData();
|
String data = event.getData();
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ChitteringDoomTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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) {
|
if (event.getAmount() >= 4) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,9 @@ class ChronicFloodingAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent source = game.getPermanent(this.sourceId);
|
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());
|
Permanent attached = game.getPermanent(source.getAttachedTo());
|
||||||
if (attached != null) {
|
if (attached != null) {
|
||||||
|
|
||||||
for (Effect e : getEffects()) {
|
for (Effect e : getEffects()) {
|
||||||
e.setTargetPointer(new FixedTarget(attached.getControllerId()));
|
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)) {
|
if (permanent != null && permanent.destroy(source.getSourceId(), game, false) && permanent.getColor(game).equals(ObjectColor.WHITE)) {
|
||||||
game.applyEffects();
|
game.applyEffects();
|
||||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
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
|
// A replacement effect has moved the card to another zone as grvayard
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class CircleOfFlameTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
youOrYourPlaneswalker = permanent != null
|
youOrYourPlaneswalker = permanent != null
|
||||||
&& permanent.isPlaneswalker()
|
&& permanent.isPlaneswalker()
|
||||||
&& permanent.getControllerId().equals(this.getControllerId());
|
&& permanent.isControlledBy(this.getControllerId());
|
||||||
}
|
}
|
||||||
if (youOrYourPlaneswalker) {
|
if (youOrYourPlaneswalker) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CityOfSolitudeEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
return !game.getActivePlayerId().equals(event.getPlayerId());
|
return !game.isActivePlayer(event.getPlayerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -62,7 +62,7 @@ class CityOfTraitorsTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Permanent land = game.getPermanent(event.getTargetId());
|
Permanent land = game.getPermanent(event.getTargetId());
|
||||||
return land.isLand()
|
return land.isLand()
|
||||||
&& land.getControllerId().equals(this.controllerId)
|
&& land.isControlledBy(this.controllerId)
|
||||||
&& !Objects.equals(event.getTargetId(), this.getSourceId());
|
&& !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)) {
|
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 (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);
|
cardsToBattlefield.add(permanent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CloudCoverAbility extends TriggeredAbilityImpl {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
Player controller = game.getPlayer(this.getControllerId());
|
Player controller = game.getPlayer(this.getControllerId());
|
||||||
if (permanent != null
|
if (permanent != null
|
||||||
&& permanent.getControllerId().equals(getControllerId())
|
&& permanent.isControlledBy(getControllerId())
|
||||||
&& !permanent.getId().equals(this.getSourceId())
|
&& !permanent.getId().equals(this.getSourceId())
|
||||||
&& controller != null
|
&& controller != null
|
||||||
&& controller.hasOpponent(event.getPlayerId(), game)) {
|
&& controller.hasOpponent(event.getPlayerId(), game)) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ class CloudKeyCostModificationEffect extends CostModificationEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
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());
|
Spell spell = game.getStack().getSpell(abilityToModify.getSourceId());
|
||||||
if (spell != null && spell.getCardType().toString().contains((String) game.getState().getValue(source.getSourceId().toString() + "_CloudKey"))) {
|
if (spell != null && spell.getCardType().toString().contains((String) game.getState().getValue(source.getSourceId().toString() + "_CloudKey"))) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CoastalPiracyTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
if (((DamagedPlayerEvent) event).isCombatDamage()
|
if (((DamagedPlayerEvent) event).isCombatDamage()
|
||||||
&& game.getOpponents(this.controllerId).contains(((DamagedPlayerEvent) event).getPlayerId())) {
|
&& game.getOpponents(this.controllerId).contains(((DamagedPlayerEvent) event).getPlayerId())) {
|
||||||
Permanent creature = game.getPermanent(event.getSourceId());
|
Permanent creature = game.getPermanent(event.getSourceId());
|
||||||
if (creature != null && creature.getControllerId().equals(controllerId)) {
|
if (creature != null && creature.isControlledBy(controllerId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class ComeuppanceEffect extends PreventionEffectImpl {
|
||||||
MageObject damageDealingObject = game.getObject(event.getSourceId());
|
MageObject damageDealingObject = game.getObject(event.getSourceId());
|
||||||
UUID objectControllerId = null;
|
UUID objectControllerId = null;
|
||||||
if (damageDealingObject instanceof Permanent) {
|
if (damageDealingObject instanceof Permanent) {
|
||||||
if (((Permanent) damageDealingObject).isCreature()) {
|
if (damageDealingObject.isCreature()) {
|
||||||
((Permanent) damageDealingObject).damage(preventionData.getPreventedDamage(), source.getSourceId(), game, false, true);
|
((Permanent) damageDealingObject).damage(preventionData.getPreventedDamage(), source.getSourceId(), game, false, true);
|
||||||
} else {
|
} else {
|
||||||
objectControllerId = ((Permanent) damageDealingObject).getControllerId();
|
objectControllerId = ((Permanent) damageDealingObject).getControllerId();
|
||||||
|
@ -102,7 +102,7 @@ class ComeuppanceEffect extends PreventionEffectImpl {
|
||||||
} else {
|
} else {
|
||||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
||||||
if (targetPermanent != null &&
|
if (targetPermanent != null &&
|
||||||
targetPermanent.getControllerId().equals(source.getControllerId()) &&
|
targetPermanent.isControlledBy(source.getControllerId()) &&
|
||||||
targetPermanent.isPlaneswalker()) {
|
targetPermanent.isPlaneswalker()) {
|
||||||
catched = true;
|
catched = true;
|
||||||
}
|
}
|
||||||
|
@ -110,11 +110,11 @@ class ComeuppanceEffect extends PreventionEffectImpl {
|
||||||
if (catched) {
|
if (catched) {
|
||||||
MageObject damageSource = game.getObject(event.getSourceId());
|
MageObject damageSource = game.getObject(event.getSourceId());
|
||||||
if (damageSource instanceof StackObject) {
|
if (damageSource instanceof StackObject) {
|
||||||
return !((StackObject) damageSource).getControllerId().equals(source.getControllerId());
|
return !((StackObject) damageSource).isControlledBy(source.getControllerId());
|
||||||
} else if (damageSource instanceof Permanent) {
|
} else if (damageSource instanceof Permanent) {
|
||||||
return !((Permanent) damageSource).getControllerId().equals(source.getControllerId());
|
return !((Permanent) damageSource).isControlledBy(source.getControllerId());
|
||||||
} else if (damageSource instanceof Card) {
|
} 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"));
|
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
|
@Override
|
||||||
public boolean isInactive(Ability source, Game game) {
|
public boolean isInactive(Ability source, Game game) {
|
||||||
if (castOnTurn != game.getTurnNum() && game.getPhase().getStep().getType() == PhaseStep.END_TURN) {
|
if (castOnTurn != game.getTurnNum() && game.getPhase().getStep().getType() == PhaseStep.END_TURN) {
|
||||||
if (game.getActivePlayerId().equals(source.getControllerId())) {
|
if (game.isActivePlayer(source.getControllerId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class CommuneWithLavaMayPlayEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
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);
|
&& getTargetPointer().getTargets(game, source).contains(sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ConcussiveBoltRestrictionEffect extends RestrictionEffect {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (metalcraft && permanent.getControllerId().equals(player.getId())) {
|
if (metalcraft && permanent.isControlledBy(player.getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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)) {
|
&& game.getPlayer(source.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,13 +85,13 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
// in Exile
|
// in Exile
|
||||||
for (Card card : game.getState().getExile().getAllCards(game)) {
|
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);
|
setCreatureSubtype(card, subType, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// in Library (e.g. for Mystical Teachings)
|
// in Library (e.g. for Mystical Teachings)
|
||||||
for (Card card : controller.getLibrary().getCards(game)) {
|
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);
|
setCreatureSubtype(card, subType, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class ConspiracyEffect extends ContinuousEffectImpl {
|
||||||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||||
StackObject stackObject = iterator.next();
|
StackObject stackObject = iterator.next();
|
||||||
if (stackObject instanceof Spell
|
if (stackObject instanceof Spell
|
||||||
&& stackObject.getControllerId().equals(source.getControllerId())
|
&& stackObject.isControlledBy(source.getControllerId())
|
||||||
&& stackObject.isCreature()) {
|
&& stackObject.isCreature()) {
|
||||||
Card card = ((Spell) stackObject).getCard();
|
Card card = ((Spell) stackObject).getCard();
|
||||||
setCreatureSubtype(card, subType, game);
|
setCreatureSubtype(card, subType, game);
|
||||||
|
|
|
@ -83,7 +83,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
permanent = game.getPermanentEntering(event.getTargetId());
|
permanent = game.getPermanentEntering(event.getTargetId());
|
||||||
}
|
}
|
||||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())
|
if (permanent != null && permanent.isControlledBy(source.getControllerId())
|
||||||
&& permanent.isCreature()) {
|
&& permanent.isCreature()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue