Merge pull request #5 from magefree/master

pulling upstream changes
This commit is contained in:
brodee 2018-12-15 12:55:54 -08:00 committed by GitHub
commit 34b044e733
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
189 changed files with 7524 additions and 4155 deletions

View file

@ -1,3 +0,0 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
SplashScreen-Image: splash.jpg

View file

@ -194,11 +194,13 @@
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${manifest.file}</manifestFile>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>mage.client.MageFrame</mainClass>
</manifest>
<manifestEntries>
<SplashScreen-Image>splash.jpg</SplashScreen-Image>
</manifestEntries>
</archive>
</configuration>
</plugin>

View file

@ -1,21 +1,5 @@
package mage.client;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import mage.cards.action.ActionCallback;
import mage.cards.decks.Deck;
import mage.cards.repository.CardRepository;
@ -67,6 +51,22 @@ import org.mage.plugins.card.images.DownloadPictures;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -93,7 +93,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static final Preferences PREFS = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title;
private Rectangle titleRectangle;
private static final MageVersion VERSION = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final MageVersion VERSION = new MageVersion(MageFrame.class);
private Connection currentConnection;
private static MagePane activeFrame;
private static boolean liteMode = false;
@ -760,7 +760,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
prepareAndShowTablesPane();
return true;
} else {
showMessage("Unable to connect to server");
showMessage("Unable connect to server");
}
} finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
@ -934,16 +934,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 769, Short.MAX_VALUE)
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 769, Short.MAX_VALUE)
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
);
pack();
@ -1184,20 +1184,20 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (arg.startsWith(SKIP_DONE_SYMBOLS)) {
skipSmallSymbolGenerationForExisting = true;
}
if (arg.startsWith(USER_ARG)){
startUser = args[i+1];
if (arg.startsWith(USER_ARG)) {
startUser = args[i + 1];
i++;
}
if (arg.startsWith(PASSWORD_ARG)){
startPassword = args[i+1];
if (arg.startsWith(PASSWORD_ARG)) {
startPassword = args[i + 1];
i++;
}
if (arg.startsWith(SERVER_ARG)){
startServer = args[i+1];
if (arg.startsWith(SERVER_ARG)) {
startServer = args[i + 1];
i++;
}
if (arg.startsWith(PORT_ARG)){
startPort = Integer.valueOf(args[i+1]);
if (arg.startsWith(PORT_ARG)) {
startPort = Integer.valueOf(args[i + 1]);
i++;
}
}
@ -1213,13 +1213,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
instance = new MageFrame();
if( startUser != null){
if (startUser != null) {
instance.currentConnection = new Connection();
instance.currentConnection.setUsername(startUser);
instance.currentConnection.setHost(startServer);
if (startPort > 0){
if (startPort > 0) {
instance.currentConnection.setPort(startPort);
}else {
} else {
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
}
PreferencesDialog.setProxyInformation(instance.currentConnection);
@ -1339,18 +1339,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} else {
LOGGER.info("DISCONNECTED (NO Event Dispatch Thread)");
SwingUtilities.invokeLater(() -> {
setConnectButtonText(NOT_CONNECTED_TEXT);
disableButtons();
hideGames();
hideTables();
SessionHandler.disconnect(false);
if (errorCall) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message);
}
}
setConnectButtonText(NOT_CONNECTED_TEXT);
disableButtons();
hideGames();
hideTables();
SessionHandler.disconnect(false);
if (errorCall) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message);
}
}
);
}
}

View file

@ -1,192 +1,187 @@
/*
* TablesPanel.java
*
* Created on 15-Dec-2009, 10:54:01 PM
*/
package mage.client.table;
package mage.client.table;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.chat.ChatPanelBasic;
import mage.client.components.MageComponents;
import mage.client.dialog.*;
import mage.client.util.*;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.TableUtil;
import mage.constants.*;
import mage.game.match.MatchOptions;
import mage.players.PlayerType;
import mage.remote.MageRemoteException;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRendererUtils;
import org.ocpsoft.prettytime.Duration;
import org.ocpsoft.prettytime.PrettyTime;
import org.ocpsoft.prettytime.units.JustNow;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.chat.ChatPanelBasic;
import mage.client.components.MageComponents;
import mage.client.dialog.*;
import mage.client.util.*;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.TableUtil;
import mage.constants.*;
import mage.game.match.MatchOptions;
import mage.players.PlayerType;
import mage.remote.MageRemoteException;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRendererUtils;
import org.ocpsoft.prettytime.Duration;
import org.ocpsoft.prettytime.PrettyTime;
import org.ocpsoft.prettytime.units.JustNow;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static mage.client.dialog.PreferencesDialog.*;
import static mage.client.dialog.PreferencesDialog.*;
/**
* @author BetaSteward_at_googlemail.com
*/
public class TablesPanel extends javax.swing.JPanel {
/**
* @author BetaSteward_at_googlemail.com
*/
public class TablesPanel extends javax.swing.JPanel {
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
private final TableTableModel tableModel;
private final MatchesTableModel matchesModel;
private UUID roomId;
private UpdateTablesTask updateTablesTask;
private UpdatePlayersTask updatePlayersTask;
private UpdateMatchesTask updateMatchesTask;
private JoinTableDialog joinTableDialog;
private NewTableDialog newTableDialog;
private NewTournamentDialog newTournamentDialog;
private final GameChooser gameChooser;
private java.util.List<String> messages;
private int currentMessage;
private final MageTableRowSorter activeTablesSorter;
private final MageTableRowSorter completedTablesSorter;
private final TableTableModel tableModel;
private final MatchesTableModel matchesModel;
private UUID roomId;
private UpdateTablesTask updateTablesTask;
private UpdatePlayersTask updatePlayersTask;
private UpdateMatchesTask updateMatchesTask;
private JoinTableDialog joinTableDialog;
private NewTableDialog newTableDialog;
private NewTournamentDialog newTournamentDialog;
private final GameChooser gameChooser;
private java.util.List<String> messages;
private int currentMessage;
private final MageTableRowSorter activeTablesSorter;
private final MageTableRowSorter completedTablesSorter;
private final ButtonColumn actionButton1;
private final ButtonColumn actionButton2;
private final ButtonColumn actionButton1;
private final ButtonColumn actionButton2;
final JToggleButton[] filterButtons;
final JToggleButton[] filterButtons;
// time formater
private PrettyTime timeFormater = new PrettyTime();
// time formater
private PrettyTime timeFormater = new PrettyTime();
// time ago renderer
TableCellRenderer timeAgoCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Date d = (Date) value;
label.setText(timeFormater.format(d));
return label;
}
};
// time ago renderer
TableCellRenderer timeAgoCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Date d = (Date) value;
label.setText(timeFormater.format(d));
return label;
}
};
// duration renderer
TableCellRenderer durationCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Long ms = (Long) value;
// duration renderer
TableCellRenderer durationCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Long ms = (Long) value;
if (ms != 0) {
Duration dur = timeFormater.approximateDuration(new Date(ms));
label.setText((timeFormater.formatDuration(dur)));
} else {
label.setText("");
}
return label;
}
};
if (ms != 0) {
Duration dur = timeFormater.approximateDuration(new Date(ms));
label.setText((timeFormater.formatDuration(dur)));
} else {
label.setText("");
}
return label;
}
};
// datetime render
TableCellRenderer datetimeCellRenderer = new DefaultTableCellRenderer() {
DateFormat datetimeFormater = new SimpleDateFormat("HH:mm:ss");
// datetime render
TableCellRenderer datetimeCellRenderer = new DefaultTableCellRenderer() {
DateFormat datetimeFormater = new SimpleDateFormat("HH:mm:ss");
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Date d = (Date) value;
if (d != null) {
label.setText(datetimeFormater.format(d));
} else {
label.setText("");
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Date d = (Date) value;
if (d != null) {
label.setText(datetimeFormater.format(d));
} else {
label.setText("");
}
return label;
}
};
return label;
}
};
// skill renderer
TableCellRenderer skillCellRenderer = new DefaultTableCellRenderer() {
// skill renderer
TableCellRenderer skillCellRenderer = new DefaultTableCellRenderer() {
// base panel to render
private JPanel renderPanel = new JPanel();
private ImageIcon skillIcon = new ImageIcon(this.getClass().getResource("/info/yellow_star_16.png"));
// base panel to render
private JPanel renderPanel = new JPanel();
private ImageIcon skillIcon = new ImageIcon(this.getClass().getResource("/info/yellow_star_16.png"));
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// get table text cell settings
DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String skillCode = baseComp.getText();
// get table text cell settings
DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String skillCode = baseComp.getText();
// apply settings to render panel from parent
renderPanel.setOpaque(baseComp.isOpaque());
renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground()));
renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground()));
renderPanel.setBorder(baseComp.getBorder());
// apply settings to render panel from parent
renderPanel.setOpaque(baseComp.isOpaque());
renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground()));
renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground()));
renderPanel.setBorder(baseComp.getBorder());
// create each skill symbol as child label
renderPanel.removeAll();
renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS));
for (char skillSymbol : skillCode.toCharArray()) {
JLabel symbolLabel = new JLabel();
symbolLabel.setBorder(new EmptyBorder(0, 3, 0, 0));
symbolLabel.setIcon(skillIcon);
renderPanel.add(symbolLabel);
}
// create each skill symbol as child label
renderPanel.removeAll();
renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS));
for (char skillSymbol : skillCode.toCharArray()) {
JLabel symbolLabel = new JLabel();
symbolLabel.setBorder(new EmptyBorder(0, 3, 0, 0));
symbolLabel.setIcon(skillIcon);
renderPanel.add(symbolLabel);
}
return renderPanel;
}
};
return renderPanel;
}
};
/**
* Creates new form TablesPanel
*/
public TablesPanel() {
/**
* Creates new form TablesPanel
*/
public TablesPanel() {
tableModel = new TableTableModel();
matchesModel = new MatchesTableModel();
gameChooser = new GameChooser();
tableModel = new TableTableModel();
matchesModel = new MatchesTableModel();
gameChooser = new GameChooser();
initComponents();
// tableModel.setSession(session);
initComponents();
// tableModel.setSession(session);
// formater
timeFormater.setLocale(Locale.ENGLISH);
JustNow jn = timeFormater.getUnit(JustNow.class);
jn.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
// formater
timeFormater.setLocale(Locale.ENGLISH);
JustNow jn = timeFormater.getUnit(JustNow.class);
jn.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
// 1. TABLE CURRENT
tableTables.createDefaultColumnsFromModel();
activeTablesSorter = new MageTableRowSorter(tableModel);
tableTables.setRowSorter(activeTablesSorter);
// 1. TABLE CURRENT
tableTables.createDefaultColumnsFromModel();
activeTablesSorter = new MageTableRowSorter(tableModel);
tableTables.setRowSorter(activeTablesSorter);
// time ago
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_CREATED).setCellRenderer(timeAgoCellRenderer);
// skill level
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_SKILL).setCellRenderer(skillCellRenderer);
// time ago
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_CREATED).setCellRenderer(timeAgoCellRenderer);
// skill level
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_SKILL).setCellRenderer(skillCellRenderer);
/* date sorter (not need, default is good - see getColumnClass)
activeTablesSorter.setComparator(TableTableModel.COLUMN_CREATED, new Comparator<Date>() {
@ -225,9 +220,9 @@
// 4. BUTTONS
filterButtons = new JToggleButton[]{btnStateWaiting, btnStateActive, btnStateFinished,
btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited,
btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther,
btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated, btnOpen, btnPassword};
btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited,
btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther,
btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated, btnOpen, btnPassword};
JComponent[] components = new JComponent[]{chatPanelMain, jSplitPane1, jScrollPaneTablesActive, jScrollPaneTablesFinished, jPanelTop, jPanelTables};
for (JComponent component : components) {
@ -244,7 +239,12 @@
openTableAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int modelRow = Integer.valueOf(e.getActionCommand());
// tableUUID;gameUUID
String searchID = e.getActionCommand();
int modelRow = tableModel.findRowByTableAndGameInfo(searchID);
if (modelRow == -1) {
return;
}
UUID tableId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3);
UUID gameId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
String action = (String) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
@ -321,7 +321,12 @@
closedTableAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int modelRow = Integer.valueOf(e.getActionCommand());
// tableUUID;gameUUID
String searchID = e.getActionCommand();
int modelRow = tableModel.findRowByTableAndGameInfo(searchID);
if (modelRow == -1) {
return;
}
String action = (String) matchesModel.getValueAt(modelRow, MatchesTableModel.COLUMN_ACTION);
switch (action) {
case "Replay":
@ -353,22 +358,17 @@
addTableDoubleClickListener(tableCompleted, closedTableAction);
}
private void addTableDoubleClickListener(JTable table, Action action) {
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int selRow = table.getSelectedRow();
if (selRow != -1) {
int dataRow = table.convertRowIndexToModel(selRow);
if (dataRow != -1) {
action.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "" + dataRow));
}
}
}
}
});
}
private void addTableDoubleClickListener(JTable table, Action action) {
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (e.getClickCount() == 2 && row != -1) {
action.actionPerformed(new ActionEvent(table, ActionEvent.ACTION_PERFORMED, tableModel.findTableAndGameInfoByRow(row)));
}
}
});
}
public void cleanUp() {
saveGuiSettings();
@ -661,7 +661,7 @@
if (btnSkillBeginner.isSelected()) {
skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.BEGINNER, true), TableTableModel.COLUMN_SKILL));
}
if (btnSkillCasual.isSelected()) {
if (btnSkillCasual.isSelected()) {
skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.CASUAL, true), TableTableModel.COLUMN_SKILL));
}
if (btnSkillSerious.isSelected()) {
@ -1121,35 +1121,35 @@
javax.swing.GroupLayout jPanelTopLayout = new javax.swing.GroupLayout(jPanelTop);
jPanelTop.setLayout(jPanelTopLayout);
jPanelTopLayout.setHorizontalGroup(
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createSequentialGroup()
.addContainerGap()
.addComponent(btnNewTable)
.addGap(6, 6, 6)
.addComponent(btnNewTournament)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnQuickStart)
.addContainerGap(835, Short.MAX_VALUE))
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createSequentialGroup()
.addContainerGap()
.addComponent(btnNewTable)
.addGap(6, 6, 6)
.addComponent(btnNewTournament)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnQuickStart)
.addContainerGap(835, Short.MAX_VALUE))
);
jPanelTopLayout.setVerticalGroup(
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnNewTable)
.addComponent(btnNewTournament))
.addGroup(jPanelTopLayout.createSequentialGroup()
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnQuickStart))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnNewTable)
.addComponent(btnNewTournament))
.addGroup(jPanelTopLayout.createSequentialGroup()
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnQuickStart))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
gridBagConstraints = new java.awt.GridBagConstraints();
@ -1186,12 +1186,12 @@
javax.swing.GroupLayout jPanelTablesLayout = new javax.swing.GroupLayout(jPanelTables);
jPanelTables.setLayout(jPanelTablesLayout);
jPanelTablesLayout.setHorizontalGroup(
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.PREFERRED_SIZE, 23, Short.MAX_VALUE)
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.PREFERRED_SIZE, 23, Short.MAX_VALUE)
);
jPanelTablesLayout.setVerticalGroup(
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.DEFAULT_SIZE, 672, Short.MAX_VALUE)
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.DEFAULT_SIZE, 672, Short.MAX_VALUE)
);
jSplitPane1.setLeftComponent(jPanelTables);
@ -1233,11 +1233,11 @@
add(jPanelBottom, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
private void btnNewTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTournamentActionPerformed
private void btnNewTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTournamentActionPerformed
newTournamentDialog.showDialog(roomId);
}//GEN-LAST:event_btnNewTournamentActionPerformed
}//GEN-LAST:event_btnNewTournamentActionPerformed
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
TableView table;
try {
File f = new File("test.dck");
@ -1269,7 +1269,7 @@
} catch (HeadlessException ex) {
handleError(ex);
}
}//GEN-LAST:event_btnQuickStartActionPerformed
}//GEN-LAST:event_btnQuickStartActionPerformed
private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed
newTableDialog.showDialog(roomId);
@ -1393,6 +1393,28 @@ class TableTableModel extends AbstractTableModel {
this.fireTableDataChanged();
}
public String getTableAndGameInfo(int row) {
return this.tables[row].getTableId().toString() + ";" + (!tables[row].getGames().isEmpty() ? tables[row].getGames().get(0) : null).toString();
}
public String findTableAndGameInfoByRow(int row) {
if (row >= 0 && this.tables.length < row) {
return getTableAndGameInfo(row);
} else {
return null;
}
}
public int findRowByTableAndGameInfo(String tableAndGame) {
for (int i = 0; i < this.tables.length; i++) {
String rowID = this.tables[i].getTableId().toString() + ";" + (!tables[i].getGames().isEmpty() ? tables[i].getGames().get(0) : null).toString();
if (tableAndGame.equals(rowID)) {
return i;
}
}
return -1;
}
public String getSkillLevelAsCode(SkillLevel skill, boolean asRegExp) {
String res;
switch (skill) {
@ -1448,7 +1470,7 @@ class TableTableModel extends AbstractTableModel {
case 7:
return tables[arg0].getCreateTime(); // use cell render, not format here
case 8:
return this.getSkillLevelAsCode(tables[arg0].getSkillLevel(), false);
return this.getSkillLevelAsCode(tables[arg0].getSkillLevel(), false);
case 9:
return tables[arg0].isRated() ? RATED_VALUE_YES : RATED_VALUE_NO;
case 10:

View file

@ -1,3 +0,0 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
SplashScreen-Image: splash.jpg

View file

@ -1,8 +1,5 @@
package mage.client.game;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import mage.client.components.MageUI;
import mage.interfaces.MageClient;
import mage.interfaces.callback.ClientCallback;
@ -13,6 +10,10 @@ import mage.utils.MageVersion;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import javax.swing.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/**
* Test for emulating the connection from multi mage clients.
*
@ -30,7 +31,7 @@ public class MultiConnectTest {
private static final CountDownLatch latch = new CountDownLatch(USER_CONNECT_COUNT);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final MageVersion version = new MageVersion(MultiConnectTest.class);
private static volatile int connected;

View file

@ -1,15 +1,5 @@
package mage.remote;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardInfo;
@ -38,6 +28,12 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
import org.jboss.remoting.transport.socket.SocketWrapper;
import org.jboss.remoting.transporter.TransporterClient;
import java.io.*;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -94,37 +90,38 @@ public class SessionImpl implements Session {
return remoting.run();
} catch (MalformedURLException ex) {
logger.fatal("", ex);
client.showMessage("Unable to connect to server. " + ex.getMessage());
client.showMessage("Unable connect to server. " + ex.getMessage());
} catch (UndeclaredThrowableException ex) {
String addMessage = "";
Throwable cause = ex.getCause();
if (cause instanceof InvocationFailureException) {
InvocationFailureException exep = (InvocationFailureException) cause;
if (exep.getCause() instanceof IOException) {
if (exep.getCause().getMessage().startsWith("Field hash null is not available on current")) {
addMessage = "Probabaly the server version is not compatible to the client. ";
if (exep.getCause().getMessage().startsWith("Field hash null is not available on current")
|| exep.getCause().getMessage().endsWith("end of file")) {
addMessage = "Probably the server version is not compatible with the client. ";
}
}
} else if (cause instanceof NoSuchMethodException) {
// NoSuchMethodException is thrown on an invocation of an unknow JBoss remoting
// method, so it's likely to be because of a version incompatibility.
addMessage = "The following method is not available in the server, probably the "
+ "server version is not compatible to the client: " + cause.getMessage();
+ "server version is not compatible with the client: " + cause.getMessage();
}
if (addMessage.isEmpty()) {
logger.fatal("", ex);
}
client.showMessage("Unable to connect to server. " + addMessage + (ex.getMessage() != null ? ex.getMessage() : ""));
client.showMessage("Unable connect to server. " + addMessage + (ex.getMessage() != null ? ex.getMessage() : ""));
} catch (IOException ex) {
logger.fatal("", ex);
String addMessage = "";
if (ex.getMessage() != null && ex.getMessage().startsWith("Unable to perform invocation")) {
addMessage = "Maybe the server version is not compatible. ";
}
client.showMessage("Unable to connect to server. " + addMessage + ex.getMessage() != null ? ex.getMessage() : "");
client.showMessage("Unable connect to server. " + addMessage + ex.getMessage() != null ? ex.getMessage() : "");
} catch (MageVersionException ex) {
if (!canceled) {
client.showMessage("Unable to connect to server. " + ex.getMessage());
client.showMessage("Unable connect to server. " + ex.getMessage());
}
disconnect(false);
} catch (CannotConnectException ex) {
@ -132,11 +129,11 @@ public class SessionImpl implements Session {
handleCannotConnectException(ex);
}
} catch (Throwable t) {
logger.fatal("Unable to connect to server - ", t);
logger.fatal("Unable connect to server - ", t);
if (!canceled) {
disconnect(false);
StringBuilder sb = new StringBuilder();
sb.append("Unable to connect to server.\n");
sb.append("Unable connect to server.\n");
for (StackTraceElement element : t.getStackTrace()) {
sb.append(element.toString()).append('\n');
}
@ -196,32 +193,32 @@ public class SessionImpl implements Session {
public synchronized boolean connect(final Connection connection) {
return establishJBossRemotingConnection(connection)
&& handleRemotingTaskExceptions(new RemotingTask() {
@Override
public boolean run() throws Throwable {
logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ':' + connection.getPort());
boolean registerResult;
if (connection.getAdminPassword() == null) {
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion(), connection.getUserIdStr());
if (registerResult) {
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
}
} else {
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
}
if (registerResult) {
serverState = server.getServerState();
if (!connection.getUsername().equals("Admin")) {
updateDatabase(connection.isForceDBComparison(), serverState);
}
logger.info("Logged-in as " + getUserName() + " to MAGE server at " + connection.getHost() + ':' + connection.getPort());
client.connected(getUserName() + '@' + connection.getHost() + ':' + connection.getPort() + ' ');
return true;
}
disconnect(false);
return false;
@Override
public boolean run() throws Throwable {
logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ':' + connection.getPort());
boolean registerResult;
if (connection.getAdminPassword() == null) {
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion(), connection.getUserIdStr());
if (registerResult) {
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
}
});
} else {
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
}
if (registerResult) {
serverState = server.getServerState();
if (!connection.getUsername().equals("Admin")) {
updateDatabase(connection.isForceDBComparison(), serverState);
}
logger.info("Logged-in as " + getUserName() + " to MAGE server at " + connection.getHost() + ':' + connection.getPort());
client.connected(getUserName() + '@' + connection.getHost() + ':' + connection.getPort() + ' ');
return true;
}
disconnect(false);
return false;
}
});
}
@Override
@ -442,7 +439,7 @@ public class SessionImpl implements Session {
t = t.getCause();
}
client.showMessage("Unable to connect to server. " + message);
client.showMessage("Unable connect to server. " + message);
if (logger.isTraceEnabled()) {
logger.trace("StackTrace", t);
}
@ -450,7 +447,7 @@ public class SessionImpl implements Session {
/**
* @param askForReconnect - true = connection was lost because of error and
* ask the user if he want to try to reconnect
* ask the user if he want to try to reconnect
*/
@Override
public synchronized void disconnect(boolean askForReconnect) {

View file

@ -0,0 +1,50 @@
package mage.utils;
import org.apache.log4j.Logger;
import java.net.URL;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
/**
* @author JayDi85
*/
public class JarVersion {
private static final Logger logger = Logger.getLogger(JarVersion.class);
private static final String JAR_BUILD_TIME_FROM_CLASSES = "runtime";
private static final String JAR_BUILD_TIME_ERROR = "n/a";
public static String getBuildTime(Class clazz) {
// build time info inserted by maven on jar build phase (see root pom.xml)
String className = clazz.getSimpleName() + ".class";
String classPath = clazz.getResource(className).toString();
// https://stackoverflow.com/a/1273432/1276632
String manifestPath;
if (classPath.startsWith("jar")) {
// jar source
manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
} else {
// dir source (e.g. IDE's debug)
// it's can be generated by runtime, but need extra code and performance: https://stackoverflow.com/questions/34674073/how-to-generate-manifest-mf-file-during-compile-phase
// manifestPath = classPath.substring(0, classPath.lastIndexOf("/" + className)) + "/META-INF/MANIFEST.MF";
return JAR_BUILD_TIME_FROM_CLASSES;
}
try {
Manifest manifest = new Manifest(new URL(manifestPath).openStream());
Attributes attr = manifest.getMainAttributes();
String buildTime = attr.getValue("Build-Time");
Instant instant = Instant.parse(buildTime);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").withZone(ZoneOffset.UTC);
return formatter.format(instant);
} catch (Throwable e) {
logger.error("Can't read build time in jar manifest for class " + clazz.getName() + " and path " + manifestPath, e);
return JAR_BUILD_TIME_ERROR;
}
}
}

View file

@ -3,7 +3,6 @@ package mage.utils;
import java.io.Serializable;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class MageVersion implements Serializable, Comparable<MageVersion> {
@ -14,22 +13,30 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 32;
public final static String MAGE_EDITION_INFO = ""; // set "-beta" for 1.4.32-betaV0
public final static String MAGE_VERSION_MINOR_PATCH = "V0";
public final static String MAGE_VERSION_INFO = "";
private final int major;
private final int minor;
private final int patch;
private final String minorPatch; // doesn't matter for compatibility
private final String buildTime;
private String editionInfo;
private final boolean showBuildTime = true;
private String info = "";
public MageVersion(Class sourceClass) {
this(MAGE_VERSION_MAJOR, MAGE_VERSION_MINOR, MAGE_VERSION_PATCH, MAGE_VERSION_MINOR_PATCH, MAGE_EDITION_INFO, sourceClass);
}
public MageVersion(int major, int minor, int patch, String minorPatch, String info) {
public MageVersion(int major, int minor, int patch, String minorPatch, String editionInfo, Class sourceClass) {
this.major = major;
this.minor = minor;
this.patch = patch;
this.minorPatch = minorPatch;
this.info = info;
this.editionInfo = editionInfo;
// build time
this.buildTime = showBuildTime ? JarVersion.getBuildTime(sourceClass) : "";
}
public int getMajor() {
@ -50,7 +57,8 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
@Override
public String toString() {
return major + "." + minor + '.' + patch + info + minorPatch;
// 1.4.32-betaV0 (build: time)
return major + "." + minor + '.' + patch + editionInfo + minorPatch + (!this.buildTime.isEmpty() ? " (build: " + this.buildTime + ")" : "");
}
@Override
@ -64,7 +72,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
if (patch != o.patch) {
return patch - o.patch;
}
return info.compareTo(o.info);
return editionInfo.compareTo(o.editionInfo);
}
}

View file

@ -53,7 +53,6 @@
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${manifest.file}</manifestFile>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>mage.server.console.ConsoleFrame</mainClass>

View file

@ -1,11 +1,3 @@
/*
* ConsoleFrame.java
*
* Created on May 13, 2011, 2:39:10 PM
*/
package mage.server.console;
import mage.interfaces.MageClient;
@ -25,7 +17,6 @@ import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
@ -35,9 +26,10 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
private static Session session;
private ConnectDialog connectDialog;
private static final Preferences prefs = Preferences.userNodeForPackage(ConsoleFrame.class);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final MageVersion version = new MageVersion(ConsoleFrame.class);
private static final ScheduledExecutorService pingTaskExecutor = Executors.newSingleThreadScheduledExecutor();
/**
* @return the session
*/
@ -54,7 +46,9 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
return version;
}
/** Creates new form ConsoleFrame */
/**
* Creates new form ConsoleFrame
*/
public ConsoleFrame() {
addWindowListener(new WindowAdapter() {
@ -76,7 +70,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
pingTaskExecutor.scheduleAtFixedRate(() -> session.ping(), 60, 60, TimeUnit.SECONDS);
}
public boolean connect(Connection connection) {
public boolean connect(Connection connection) {
if (session.connect(connection)) {
this.consolePanel1.start();
return true;
@ -100,7 +94,8 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
btnSendMessage.setEnabled(false);
}
/** This method is called from within the constructor to
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@ -143,16 +138,16 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 933, Short.MAX_VALUE)
.addComponent(consolePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 933, Short.MAX_VALUE)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 933, Short.MAX_VALUE)
.addComponent(consolePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 933, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(consolePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE))
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(consolePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE))
);
pack();
@ -177,8 +172,8 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
}//GEN-LAST:event_btnSendMessageActionPerformed
/**
* @param args the command line arguments
*/
* @param args the command line arguments
*/
public static void main(String args[]) {
logger.info("Starting MAGE server console version " + version);
logger.info("Logging level: " + logger.getEffectiveLevel());
@ -206,8 +201,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
if (SwingUtilities.isEventDispatchThread()) {
setStatusText(message);
enableButtons();
}
else {
} else {
SwingUtilities.invokeLater(() -> {
setStatusText(message);
enableButtons();
@ -221,8 +215,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
consolePanel1.stop();
setStatusText("Not connected");
disableButtons();
}
else {
} else {
SwingUtilities.invokeLater(() -> {
consolePanel1.stop();
setStatusText("Not connected");
@ -235,8 +228,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
public void showMessage(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
JOptionPane.showMessageDialog(this, message);
}
else {
} else {
SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message));
}
}
@ -245,8 +237,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
public void showError(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
}
else {
} else {
SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE));
}
}

View file

@ -1,3 +0,0 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

View file

@ -258,7 +258,6 @@
<configuration>
<generatePackage>mage.server.util.config</generatePackage>
<schemaDirectory>./src/main/xml-resources/jaxb/Config/</schemaDirectory>
<arguments>-Xcommons-lang</arguments>
</configuration>
<executions>
<execution>

View file

@ -1,10 +1,5 @@
package mage.server;
import java.security.SecureRandom;
import java.util.*;
import java.util.concurrent.ExecutorService;
import javax.management.timer.Timer;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardInfo;
@ -43,6 +38,11 @@ import mage.view.ChatMessage.MessageColor;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.log4j.Logger;
import javax.management.timer.Timer;
import java.security.SecureRandom;
import java.util.*;
import java.util.concurrent.ExecutorService;
/**
* @author BetaSteward_at_googlemail.com, noxx
*/
@ -827,27 +827,27 @@ public class MageServerImpl implements MageServer {
public void quitDraft(final UUID draftId, final String sessionId) throws MageException {
execute("quitDraft", sessionId, () -> {
try {
callExecutor.execute(
() -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
Table table = TableManager.instance.getTable(tableId);
if (table.isTournament()) {
UUID tournamentId = table.getTournament().getId();
TournamentManager.instance.quit(tournamentId, userId);
try {
callExecutor.execute(
() -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
Table table = TableManager.instance.getTable(tableId);
if (table.isTournament()) {
UUID tournamentId = table.getTournament().getId();
TournamentManager.instance.quit(tournamentId, userId);
}
}
}
}
}
);
} catch (Exception ex) {
handleException(ex);
}
}
);
} catch (Exception ex) {
handleException(ex);
}
}
);
}
@ -1141,12 +1141,12 @@ public class MageServerImpl implements MageServer {
public void toggleActivation(final String sessionId, final String userName) throws MageException {
execute("toggleActivation", sessionId, ()
-> UserManager.instance.getUserByName(userName).ifPresent(user
-> {
user.setActive(!user.isActive());
if (!user.isActive() && user.isConnected()) {
SessionManager.instance.disconnectUser(sessionId, user.getSessionId());
}
}));
-> {
user.setActive(!user.isActive());
if (!user.isActive() && user.isConnected()) {
SessionManager.instance.disconnectUser(sessionId, user.getSessionId());
}
}));
}
@Override
@ -1181,8 +1181,8 @@ public class MageServerImpl implements MageServer {
if (title != null && message != null) {
execute("sendFeedbackMessage", sessionId, ()
-> SessionManager.instance.getSession(sessionId).ifPresent(
session -> FeedbackServiceImpl.instance.feedback(username, title, type, message, email, session.getHost())
));
session -> FeedbackServiceImpl.instance.feedback(username, title, type, message, email, session.getHost())
));
}
}
@ -1307,8 +1307,8 @@ public class MageServerImpl implements MageServer {
logger.error("Session not found : " + sessionId);
return null;
} else {
UUID userId = session.get().getUserId();
return GameManager.instance.getGameView(gameId, userId, playerId);
//UUID userId = session.get().getUserId();
return GameManager.instance.getGameView(gameId, playerId);
}
}
}

View file

@ -1,12 +1,5 @@
package mage.server;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.util.*;
import javax.management.MBeanServer;
import mage.cards.ExpansionSet;
import mage.cards.Sets;
import mage.cards.repository.CardScanner;
@ -39,13 +32,20 @@ import org.jboss.remoting.transporter.TransporterClient;
import org.jboss.remoting.transporter.TransporterServer;
import org.w3c.dom.Element;
import javax.management.MBeanServer;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
public final class Main {
private static final Logger logger = Logger.getLogger(Main.class);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final MageVersion version = new MageVersion(Main.class);
private static final String testModeArg = "-testMode=";
private static final String fastDBModeArg = "-fastDbMode=";

View file

@ -1,4 +1,3 @@
package mage.server;
import java.util.Locale;
@ -240,6 +239,7 @@ public class TableController {
public synchronized boolean joinTable(UUID userId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException {
Optional<User> _user = UserManager.instance.getUser(userId);
if (!_user.isPresent()) {
logger.error("Join Table: can't find user to join " + name + " Id = " + userId);
return false;
}
User user = _user.get();

View file

@ -1,6 +1,12 @@
package mage.server.game;
import mage.cards.decks.DeckCardLists;
import mage.constants.ManaType;
import mage.constants.PlayerAction;
import mage.game.Game;
import mage.game.GameOptions;
import mage.view.GameView;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@ -9,15 +15,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import mage.cards.decks.DeckCardLists;
import mage.constants.ManaType;
import mage.constants.PlayerAction;
import mage.game.Game;
import mage.game.GameOptions;
import mage.view.GameView;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public enum GameManager {
@ -38,15 +37,25 @@ public enum GameManager {
return gameController.getSessionId();
}
private GameController getGameControllerSafe(UUID gameId) {
final Lock r = gameControllersLock.readLock();
r.lock();
try {
return gameControllers.get(gameId);
} finally {
r.unlock();
}
}
public void joinGame(UUID gameId, UUID userId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.join(userId);
}
}
public Optional<UUID> getChatId(UUID gameId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
return Optional.of(gameController.getChatId());
}
@ -54,56 +63,56 @@ public enum GameManager {
}
public void sendPlayerUUID(UUID gameId, UUID userId, UUID data) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.sendPlayerUUID(userId, data);
}
}
public void sendPlayerString(UUID gameId, UUID userId, String data) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.sendPlayerString(userId, data);
}
}
public void sendPlayerManaType(UUID gameId, UUID playerId, UUID userId, ManaType data) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.sendPlayerManaType(userId, playerId, data);
}
}
public void sendPlayerBoolean(UUID gameId, UUID userId, Boolean data) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.sendPlayerBoolean(userId, data);
}
}
public void sendPlayerInteger(UUID gameId, UUID userId, Integer data) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.sendPlayerInteger(userId, data);
}
}
public void quitMatch(UUID gameId, UUID userId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.quitMatch(userId);
}
}
public void sendPlayerAction(PlayerAction playerAction, UUID gameId, UUID userId, Object data) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.sendPlayerAction(playerAction, userId, data);
}
}
public boolean watchGame(UUID gameId, UUID userId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
return gameController.watch(userId);
}
@ -111,21 +120,21 @@ public enum GameManager {
}
public void stopWatching(UUID gameId, UUID userId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.stopWatching(userId);
}
}
public void cheat(UUID gameId, UUID userId, UUID playerId, DeckCardLists deckList) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.cheat(userId, playerId, deckList);
}
}
public boolean cheat(UUID gameId, UUID userId, UUID playerId, String cardName) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
return gameController.cheat(userId, playerId, cardName);
}
@ -133,7 +142,7 @@ public enum GameManager {
}
public void removeGame(UUID gameId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
gameController.cleanUp();
final Lock w = gameControllersLock.writeLock();
@ -147,15 +156,15 @@ public enum GameManager {
}
public boolean saveGame(UUID gameId) {
GameController gameController = gameControllers.get(gameId);
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
return gameController.saveGame();
}
return false;
}
public GameView getGameView(UUID gameId, UUID userId, UUID playerId) {
GameController gameController = gameControllers.get(gameId);
public GameView getGameView(UUID gameId, UUID playerId) {
GameController gameController = getGameControllerSafe(gameId);
if (gameController != null) {
return gameController.getGameView(playerId);
}
@ -163,7 +172,7 @@ public enum GameManager {
}
public int getNumberActiveGames() {
return gameControllers.size();
return getGameController().size();
}
public Map<UUID, GameController> getGameController() {

View file

@ -0,0 +1,144 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.VariableCostImpl;
import mage.abilities.costs.common.DiscardTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetCardInHand;
/**
*
* @author jeffwadsworth
*/
public final class AetherTide extends CardImpl {
public AetherTide(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}");
// As an additional cost to cast Aether Tide, discard X creature cards.
this.getSpellAbility().addCost(new AetherTideCost());
// Return X target creatures to their owners' hands.
this.getSpellAbility().addEffect(new ReturnToHandTargetPermanentEffect());
}
public AetherTide(final AetherTide card) {
super(card);
}
@Override
public AetherTide copy() {
return new AetherTide(this);
}
}
class AetherTideCost extends VariableCostImpl {
public AetherTideCost() {
super("discard X creature cards");
text = "As an additional cost to cast {this}, discard X creature cards";
}
public AetherTideCost(AetherTideCost cost) {
super(cost);
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
return (game.getPlayer(controllerId).getHand().count(new FilterCreatureCard(), game) > 0);
}
@Override
public int getMaxValue(Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return controller.getHand().count(new FilterCreatureCard(), game);
}
return 0;
}
@Override
public int getMinValue(Ability source, Game game) {
return 0;
}
@Override
public Cost getFixedCostsFromAnnouncedValue(int xValue) {
TargetCardInHand target = new TargetCardInHand(xValue, new FilterCreatureCard());
return new DiscardTargetCost(target);
}
@Override
public int announceXValue(Ability source, Game game) {
int xValue = 0;
Player controller = game.getPlayer(source.getControllerId());
StackObject stackObject = game.getStack().getStackObject(source.getId());
if (controller != null
&& stackObject != null) {
xValue = controller.announceXCost(getMinValue(source, game), getMaxValue(source, game),
"Announce the number of creature cards to discard", game, source, this);
}
return xValue;
}
@Override
public AetherTideCost copy() {
return new AetherTideCost(this);
}
}
class ReturnToHandTargetPermanentEffect extends OneShotEffect {
public ReturnToHandTargetPermanentEffect() {
super(Outcome.ReturnToHand);
setText("Return X target creatures to their owners' hands");
}
public ReturnToHandTargetPermanentEffect(final ReturnToHandTargetPermanentEffect effect) {
super(effect);
}
@Override
public ReturnToHandTargetPermanentEffect copy() {
return new ReturnToHandTargetPermanentEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
int xPaid = source.getCosts().getVariableCosts().get(0).getAmount();
if (controller != null
&& xPaid > 0) {
int available = game.getBattlefield().count(new FilterCreaturePermanent(),
source.getSourceId(),
source.getControllerId(), game);
if (available > 0) {
TargetPermanent target = new TargetPermanent(Math.min(xPaid, available),
xPaid,
new FilterCreaturePermanent("creatures to return to their owner's hands"),
true);
if (controller.chooseTarget(outcome.Detriment, target, source, game)) {
controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
}
return true;
}
}
return false;
}
}

View file

@ -1,6 +1,5 @@
package mage.cards.a;
import java.util.*;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -16,6 +15,10 @@ import mage.game.stack.Spell;
import mage.players.Player;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author stravant
*/
@ -64,7 +67,7 @@ class ApproachOfTheSecondSunEffect extends OneShotEffect {
ApproachOfTheSecondSunWatcher watcher
= (ApproachOfTheSecondSunWatcher) game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getSimpleName());
if (watcher != null
&& !spell.isCopiedSpell()
&& !spell.isCopy()
&& watcher.getApproachesCast(controller.getId()) > 1
&& spell.getFromZone() == Zone.HAND) {
// Win the game
@ -74,7 +77,7 @@ class ApproachOfTheSecondSunEffect extends OneShotEffect {
controller.gainLife(7, game, source);
// Put this into the library as the 7th from the top
if (spell.isCopiedSpell()) {
if (spell.isCopy()) {
return true;
}
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();

View file

@ -1,7 +1,5 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.common.continuous.BoostAllEffect;
@ -12,15 +10,17 @@ import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Quercitron
*/
public final class BileBlight extends CardImpl {
public BileBlight(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}{B}");
// Target creature and all creatures with the same name as that creature get -3/-3 until end of turn.
@ -56,12 +56,12 @@ class BileBlightEffect extends BoostAllEffect {
if (this.affectedObjectsSet) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
if (target.getName().isEmpty()) { // face down creature
if (CardUtil.haveEmptyName(target)) { // face down creature
affectedObjectList.add(new MageObjectReference(target, game));
} else {
String name = target.getName();
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (perm.getName().equals(name)) {
if (CardUtil.haveSameNames(perm.getName(), name)) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -14,15 +12,17 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class BrainPry extends CardImpl {
public BrainPry(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
//Name a nonland card. Target player reveals their hand. That player discards a card with that name. If he or she can't, you draw a card.
this.getSpellAbility().addEffect((new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.NON_LAND_NAME)));
@ -60,7 +60,7 @@ class BrainPryEffect extends OneShotEffect {
if (targetPlayer != null && controller != null && sourceObject != null && cardName != null) {
boolean hasDiscarded = false;
for (Card card : targetPlayer.getHand().getCards(game)) {
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
targetPlayer.discard(card, source, game);
hasDiscarded = true;
break;

View file

@ -15,11 +15,11 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author jonubuu
*/
public final class CabalTherapy extends CardImpl {
@ -71,13 +71,13 @@ class CabalTherapyEffect extends OneShotEffect {
for (Card card : hand.getCards(game)) {
if (card.isSplitCard()) {
SplitCard splitCard = (SplitCard) card;
if (splitCard.getLeftHalfCard().getName().equals(cardName)) {
if (CardUtil.haveSameNames(splitCard.getLeftHalfCard().getName(), cardName)) {
targetPlayer.discard(card, source, game);
} else if (splitCard.getRightHalfCard().getName().equals(cardName)) {
} else if (CardUtil.haveSameNames(splitCard.getRightHalfCard().getName(), cardName)) {
targetPlayer.discard(card, source, game);
}
}
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
targetPlayer.discard(card, source, game);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -17,9 +15,11 @@ import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class CandlesOfLeng extends CardImpl {
@ -73,7 +73,7 @@ class CandlesOfLengEffect extends OneShotEffect {
controller.revealCards(sourceObject.getName(), cards, game);
boolean hasTheSameName = false;
for (UUID uuid : controller.getGraveyard()) {
if (card.getName().equals(game.getCard(uuid).getName())) {
if (CardUtil.haveSameNames(card, game.getCard(uuid))) {
hasTheSameName = true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.c;
import mage.MageInt;
@ -136,7 +135,7 @@ class CircuDimirLobotomistRuleModifyingEffect extends ContinuousRuleModifyingEff
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
if ((exileZone != null)) {
for (Card card : exileZone.getCards(game)) {
if ((card.getName().equals(object.getName()))) {
if (CardUtil.haveSameNames(card, object)) {
return true;
}
}

View file

@ -0,0 +1,191 @@
package mage.cards.c;
import java.util.UUID;
import mage.constants.SubType;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
*/
public final class CloakOfConfusion extends CardImpl {
public CloakOfConfusion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
this.subtype.add(SubType.AURA);
// Enchant creature you control
TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Whenever enchanted creature attacks and isn't blocked, you may have it assign no combat damage this turn.
// If you do, defending player discards a card at random.
this.addAbility(new CloakOfConfusionTriggeredAbility());
}
public CloakOfConfusion(final CloakOfConfusion card) {
super(card);
}
@Override
public CloakOfConfusion copy() {
return new CloakOfConfusion(this);
}
}
class CloakOfConfusionTriggeredAbility extends TriggeredAbilityImpl {
public CloakOfConfusionTriggeredAbility() {
super(Zone.BATTLEFIELD, new CloakOfConfusionEffect(), true);
}
public CloakOfConfusionTriggeredAbility(final CloakOfConfusionTriggeredAbility ability) {
super(ability);
}
@Override
public CloakOfConfusionTriggeredAbility copy() {
return new CloakOfConfusionTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARE_BLOCKERS_STEP;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent aura = game.getPermanentOrLKIBattlefield(getSourceId());
if (aura != null) {
Permanent enchantedCreature = game.getPermanent(aura.getAttachedTo());
if (enchantedCreature != null
&& enchantedCreature.isAttacking()) {
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (combatGroup.getBlockers().isEmpty()
&& combatGroup.getAttackers().contains(enchantedCreature.getId())) {
this.getEffects().setTargetPointer(
new FixedTarget(game.getCombat().getDefendingPlayerId(
enchantedCreature.getId(), game)));
return true;
}
}
}
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted creature attacks and isn't blocked, " + super.getRule();
}
}
class CloakOfConfusionEffect extends OneShotEffect {
public CloakOfConfusionEffect() {
super(Outcome.Neutral);
this.staticText = "you may have it assign no combat damage this turn. "
+ "If you do, defending player discards a card at random";
}
public CloakOfConfusionEffect(final CloakOfConfusionEffect effect) {
super(effect);
}
@Override
public CloakOfConfusionEffect copy() {
return new CloakOfConfusionEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantedCreature = game.getPermanent(game.getPermanent(source.getSourceId()).getAttachedTo());
if (controller != null) {
if (controller.chooseUse(outcome, "Do you wish to not assign combat damage from "
+ enchantedCreature.getName() + " and have the defending player discard a card at random?", source, game)) {
ContinuousEffect effect = new AssignNoCombatDamageTargetEffect();
effect.setTargetPointer(new FixedTarget(enchantedCreature.getId()));
game.addEffect(effect, source);
Player defendingPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (defendingPlayer != null) {
defendingPlayer.discard(1, true, source, game);
}
}
return true;
}
return false;
}
}
class AssignNoCombatDamageTargetEffect extends ReplacementEffectImpl {
public AssignNoCombatDamageTargetEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
}
public AssignNoCombatDamageTargetEffect(final AssignNoCombatDamageTargetEffect effect) {
super(effect);
}
@Override
public AssignNoCombatDamageTargetEffect copy() {
return new AssignNoCombatDamageTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch (event.getType()) {
case DAMAGE_CREATURE:
case DAMAGE_PLAYER:
case DAMAGE_PLANESWALKER:
return true;
default:
return false;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
return event.getSourceId().equals(targetPointer.getFirst(game, source))
&& damageEvent.isCombatDamage();
}
}

View file

@ -82,7 +82,7 @@ class CommitEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
return controller.putCardOnTopXOfLibrary(permanent, game, source, 2);
}

View file

@ -1,7 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -18,9 +16,11 @@ import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public final class ConundrumSphinx extends CardImpl {
@ -85,7 +85,7 @@ class ConundrumSphinxEffect extends OneShotEffect {
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards(source, player.getName(), cards, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
player.moveCards(cards, Zone.HAND, source, game);
} else {
player.putCardsOnBottomOfLibrary(cards, game, source, false);

View file

@ -2,6 +2,8 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility;
@ -17,6 +19,7 @@ import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.players.Player;
import mage.target.Target;
import mage.util.functions.EmptyApplyToPermanent;

View file

@ -1,13 +1,5 @@
package mage.cards.c;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -18,12 +10,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TurnPhase;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.EquippedPredicate;
import mage.game.Game;
@ -31,10 +18,12 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import mage.watchers.Watcher;
import java.util.*;
/**
*
* @author rscoates
*/
public final class CorrosiveOoze extends CardImpl {
@ -156,7 +145,7 @@ class CorrosiveOozeCombatWatcher extends Watcher {
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
Permanent attacker = game.getPermanent(event.getTargetId());
Permanent blocker = game.getPermanent(event.getSourceId());
if (attacker != null && attacker.getName().equals("Corrosive Ooze")) { // To check for name is not working if Ooze is copied but name changed
if (attacker != null && CardUtil.haveSameNames(attacker.getName(), "Corrosive Ooze")) { // To check for name is not working if Ooze is copied but name changed
if (blocker != null && hasAttachedEquipment(game, blocker)) {
MageObjectReference oozeMor = new MageObjectReference(attacker, game);
HashSet<MageObjectReference> relatedCreatures = oozeBlocksOrBlocked.getOrDefault(oozeMor, new HashSet<>());
@ -164,7 +153,7 @@ class CorrosiveOozeCombatWatcher extends Watcher {
oozeBlocksOrBlocked.put(oozeMor, relatedCreatures);
}
}
if (blocker != null && blocker.getName().equals("Corrosive Ooze")) {
if (blocker != null && CardUtil.haveSameNames(blocker.getName(), "Corrosive Ooze")) {
if (attacker != null && hasAttachedEquipment(game, attacker)) {
MageObjectReference oozeMor = new MageObjectReference(blocker, game);
HashSet<MageObjectReference> relatedCreatures = oozeBlocksOrBlocked.getOrDefault(oozeMor, new HashSet<>());

View file

@ -1,6 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -19,8 +18,9 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class CouncilOfTheAbsolute extends CardImpl {
@ -92,7 +92,8 @@ class CouncilOfTheAbsoluteReplacementEffect extends ContinuousRuleModifyingEffec
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY))) {
String needName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (object != null && CardUtil.haveSameNames(object.getName(), needName)) {
return true;
}
}
@ -122,7 +123,8 @@ class CouncilOfTheAbsoluteCostReductionEffect extends CostModificationEffectImpl
if ((abilityToModify instanceof SpellAbility)
&& abilityToModify.isControlledBy(source.getControllerId())) {
Card card = game.getCard(abilityToModify.getSourceId());
return card.getName().equals(game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY));
String needName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
return CardUtil.haveSameNames(card.getName(), needName);
}
return false;
}

View file

@ -1,7 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.SimpleActivatedAbility;
@ -17,6 +15,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author nantuko
@ -24,7 +25,7 @@ import mage.target.targetpointer.FixedTarget;
public final class CrownOfEmpires extends CardImpl {
public CrownOfEmpires(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// {3}, {tap}: Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CrownOfEmpiresEffect(), new GenericManaCost(3));
@ -60,9 +61,9 @@ class CrownOfEmpiresEffect extends OneShotEffect {
boolean scepter = false;
boolean throne = false;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent.getName().equals("Scepter of Empires")) {
if (CardUtil.haveSameNames(permanent.getName(), "Scepter of Empires")) {
scepter = true;
} else if (permanent.getName().equals("Throne of Empires")) {
} else if (CardUtil.haveSameNames(permanent.getName(), "Throne of Empires")) {
throne = true;
}
if (scepter && throne) break;

View file

@ -0,0 +1,89 @@
package mage.cards.c;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author jeffwadsworth
*/
public final class Cunning extends CardImpl {
public Cunning(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Enchanted creature gets +3/+3.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3)));
// When enchanted creature attacks or blocks, sacrifice Cunning at the beginning of the next cleanup step.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD,
new SacrificeSourceBeginningCleanupStepEffect()));
}
public Cunning(final Cunning card) {
super(card);
}
@Override
public Cunning copy() {
return new Cunning(this);
}
}
class SacrificeSourceBeginningCleanupStepEffect extends OneShotEffect {
public SacrificeSourceBeginningCleanupStepEffect() {
super(Outcome.Sacrifice);
this.staticText = "sacrifice {this} at the beginning of the next cleanup step";
}
public SacrificeSourceBeginningCleanupStepEffect(final SacrificeSourceBeginningCleanupStepEffect effect) {
super(effect);
}
@Override
public SacrificeSourceBeginningCleanupStepEffect copy() {
return new SacrificeSourceBeginningCleanupStepEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent cunning = game.getPermanent(source.getSourceId());
if (cunning != null) {
DelayedTriggeredAbility delayedAbility
= new AtTheBeginOfNextCleanupDelayedTriggeredAbility(
new SacrificeSourceEffect());
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
}

View file

@ -1,6 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -16,11 +15,12 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*
*/
public final class CursedScroll extends CardImpl {
@ -70,7 +70,7 @@ class CursedScrollEffect extends OneShotEffect {
}
revealed.add(card);
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
creature.damage(2, source.getSourceId(), game, false, true);

View file

@ -1,9 +1,5 @@
package mage.cards.d;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -20,9 +16,13 @@ import mage.game.permanent.PermanentToken;
import mage.game.permanent.token.ClueArtifactToken;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public final class DeclarationInStone extends CardImpl {
@ -66,7 +66,7 @@ class DeclarationInStoneEffect extends OneShotEffect {
if (targetPermanent != null) {
Set<Card> cardsToExile = new HashSet<>();
int nonTokenCount = 0;
if (targetPermanent.getName().isEmpty()) { // face down creature
if (CardUtil.haveEmptyName(targetPermanent)) { // face down creature
cardsToExile.add(targetPermanent);
if (!(targetPermanent instanceof PermanentToken)) {
nonTokenCount++;
@ -78,7 +78,7 @@ class DeclarationInStoneEffect extends OneShotEffect {
}
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, targetPermanent.getControllerId(), game)) {
if (!permanent.getId().equals(targetPermanent.getId())
&& permanent.getName().equals(targetPermanent.getName())) {
&& CardUtil.haveSameNames(permanent, targetPermanent)) {
cardsToExile.add(permanent);
// exiled count only matters for non-tokens
if (!(permanent instanceof PermanentToken)) {

View file

@ -1,6 +1,5 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -18,9 +17,11 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class DementiaSliver extends CardImpl {
@ -44,9 +45,9 @@ public final class DementiaSliver extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAllEffect(gainedAbility, Duration.WhileOnBattlefield, filter,
"All Slivers have \"{T}: Choose a card name. "
+ "Target opponent reveals a card at random from their hand."
+ " If that card has the chosen name, that player discards it."
+ " Activate this ability only during your turn.\""
+ "Target opponent reveals a card at random from their hand."
+ " If that card has the chosen name, that player discards it."
+ " Activate this ability only during your turn.\""
)
));
}
@ -84,7 +85,7 @@ class DementiaSliverEffect extends OneShotEffect {
if (card != null) {
revealed.add(card);
opponent.revealCards(sourceObject.getName(), revealed, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
opponent.discard(card, source, game);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
@ -11,18 +9,20 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetSpell;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author L_J
*/
public final class Denied extends CardImpl {
public Denied(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}");
// Choose a card name, then target spell's controller reveals their hand. If a card with the chosen name is revealed this way, counter that spell.
this.getSpellAbility().addEffect(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL));
@ -63,7 +63,7 @@ class DeniedEffect extends OneShotEffect {
player.revealCards("Denied!", player.getHand(), game, true);
String namedCard = (String) object;
for (Card card : player.getHand().getCards(game)) {
if (card != null && card.getName().equals(namedCard)) {
if (card != null && CardUtil.haveSameNames(card.getName(), namedCard)) {
game.getStack().counter(targetSpell.getId(), source.getSourceId(), game);
break;
}

View file

@ -1,7 +1,5 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -25,8 +23,9 @@ import mage.target.TargetPermanent;
import mage.util.CardUtil;
import org.apache.log4j.Logger;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class DetentionSphere extends CardImpl {
@ -81,12 +80,12 @@ class DetentionSphereEntersEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && exileId != null && targetPermanent != null && controller != null) {
if (targetPermanent.getName().isEmpty()) { // face down creature
if (CardUtil.haveEmptyName(targetPermanent)) { // face down creature
controller.moveCardToExileWithInfo(targetPermanent, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
} else {
String name = targetPermanent.getName();
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (permanent != null && permanent.getName().equals(name)) {
if (permanent != null && CardUtil.haveSameNames(permanent.getName(), name)) {
controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -21,9 +19,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author maxlebedev
*/
public final class DiviningWitch extends CardImpl {
@ -92,7 +92,7 @@ public final class DiviningWitch extends CardImpl {
if (card != null) {
cardsToReaveal.add(card);
// Put that card into your hand
if (card.getName().equals(name)) {
if (CardUtil.haveSameNames(card.getName(), name)) {
cardToHand = card;
break;
}

View file

@ -0,0 +1,71 @@
package mage.cards.d;
import java.util.UUID;
import mage.constants.SubType;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.constants.Outcome;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author jeffwadsworth
*/
public final class DizzyingGaze extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("with flying");
static {
filter.add(new AbilityPredicate(FlyingAbility.class));
}
public DizzyingGaze(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{R}");
this.subtype.add(SubType.AURA);
// Enchant creature you control
TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// {R}: Enchanted creature deals 1 damage to target creature with flying.
Ability ability2 = new SimpleActivatedAbility(new DamageTargetEffect(1), new ManaCostsImpl("{R}"));
ability2.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new GainAbilityAttachedEffect(
ability2,
AttachmentType.AURA,
Duration.WhileOnBattlefield)));
}
public DizzyingGaze(final DizzyingGaze card) {
super(card);
}
@Override
public DizzyingGaze copy() {
return new DizzyingGaze(this);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
@ -13,20 +11,18 @@ import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class DragonlordKolaghan extends CardImpl {
@ -95,7 +91,7 @@ class DragonlordKolaghanTriggeredAbility extends TriggeredAbilityImpl {
Player opponent = game.getPlayer(event.getPlayerId());
boolean sameName = false;
for (Card graveCard : opponent.getGraveyard().getCards(game)) {
if (graveCard.getName().equals(spell.getName())) {
if (CardUtil.haveSameNames(graveCard, spell)) {
sameName = true;
break;
}

View file

@ -0,0 +1,237 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
*/
public final class DreadWight extends CardImpl {
public DreadWight(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{B}");
this.subtype.add(SubType.ZOMBIE);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// At end of combat, put a paralyzation counter on each creature blocking or blocked by Dread Wight and tap those creatures. Each of those creatures doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it. Each of those creatures gains "{4}: Remove a paralyzation counter from this creature."
this.addAbility(new DreadWightTriggeredAbility(
new CreateDelayedTriggeredAbilityEffect(
new AtTheEndOfCombatDelayedTriggeredAbility(
new DreadWightEffect()))));
}
public DreadWight(final DreadWight card) {
super(card);
}
@Override
public DreadWight copy() {
return new DreadWight(this);
}
}
class DreadWightTriggeredAbility extends TriggeredAbilityImpl {
DreadWightTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect);
this.usesStack = false;
}
DreadWightTriggeredAbility(final DreadWightTriggeredAbility ability) {
super(ability);
}
@Override
public DreadWightTriggeredAbility copy() {
return new DreadWightTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return (event.getType() == EventType.BLOCKER_DECLARED);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(getSourceId())) { // Dread Wight is the blocker
getAllEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
return true;
}
if (event.getTargetId().equals(getSourceId())) { // Dread Wight is the attacker
getAllEffects().setTargetPointer(new FixedTarget(event.getSourceId()));
return true;
}
return false;
}
@Override
public String getRule() {
return super.getRule();
}
}
class DreadWightEffect extends OneShotEffect {
String rule = "doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it.";
public DreadWightEffect() {
super(Outcome.Detriment);
this.staticText = "put a paralyzation counter on each creature blocking or blocked by {this} and tap those creatures. "
+ "Each of those creatures doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it. "
+ "Each of those creatures gains \"{4}: Remove a paralyzation counter from this creature.\"";
}
public DreadWightEffect(final DreadWightEffect effect) {
super(effect);
}
@Override
public DreadWightEffect copy() {
return new DreadWightEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
// add paralyzation counter
Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
effect.setTargetPointer(new FixedTarget(permanent.getId()));
effect.apply(game, source);
// tap permanent
permanent.tap(game);
// does not untap while paralyzation counter is on it
ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(
Duration.WhileOnBattlefield,
permanent.getId());
effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
Condition condition = new DreadWightCounterCondition(permanent.getId());
ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(
effect2,
condition);
Ability ability = new SimpleStaticAbility(
Zone.BATTLEFIELD,
conditionalEffect);
ContinuousEffect effect3 = new GainAbilityTargetEffect(
ability,
Duration.WhileOnBattlefield);
ability.setRuleVisible(true);
effect3.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect3, source);
// each gains 4: remove paralyzation counter
Ability activatedAbility = new SimpleActivatedAbility(
Zone.BATTLEFIELD,
new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()),
new ManaCostsImpl("{4}"));
ContinuousEffect effect4 = new GainAbilityTargetEffect(
activatedAbility,
Duration.WhileOnBattlefield);
effect4.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect4, source);
return true;
}
return false;
}
}
class DreadWightDoNotUntapEffect extends ContinuousRuleModifyingEffectImpl {
UUID permanentId;
public DreadWightDoNotUntapEffect(Duration duration, UUID permanentId) {
super(duration, Outcome.Detriment);
this.permanentId = permanentId;
}
public DreadWightDoNotUntapEffect(final DreadWightDoNotUntapEffect effect) {
super(effect);
this.permanentId = effect.permanentId;
}
@Override
public DreadWightDoNotUntapEffect copy() {
return new DreadWightDoNotUntapEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
Permanent permanentToUntap = game.getPermanent((event.getTargetId()));
if (permanentToUntap != null) {
return permanentToUntap.getLogName() + " doesn't untap.";
}
return null;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId() == permanentId
&& game.isActivePlayer(game.getPermanent(permanentId).getControllerId());
}
}
class DreadWightCounterCondition implements Condition {
UUID permanentId;
public DreadWightCounterCondition(UUID permanentId) {
this.permanentId = permanentId;
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
return permanent.getCounters(game).getCount(CounterType.PARALYZATION) > 0;
}
return false;
}
@Override
public String toString() {
return "has counter on it";
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -12,6 +10,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetEnchantmentPermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author Loki
@ -19,7 +20,7 @@ import mage.target.common.TargetEnchantmentPermanent;
public final class EchoingCalm extends CardImpl {
public EchoingCalm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
// Destroy target enchantment and all other enchantments with the same name as that enchantment.
@ -58,9 +59,9 @@ class EchoingCalmEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller != null && permanent != null) {
permanent.destroy(source.getSourceId(), game, false);
if (!permanent.getName().isEmpty()) { // in case of face down enchantment creature
if (!CardUtil.haveEmptyName(permanent)) { // in case of face down enchantment creature
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (!perm.getId().equals(permanent.getId()) && perm.getName().equals(permanent.getName()) && perm.isEnchantment()) {
if (!perm.getId().equals(permanent.getId()) && CardUtil.haveSameNames(perm, permanent) && perm.isEnchantment()) {
perm.destroy(source.getSourceId(), game, false);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
@ -17,15 +15,17 @@ import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class EchoingCourage extends CardImpl {
public EchoingCourage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
// Target creature and all other creatures with the same name as that creature get +2/+2 until end of turn.
@ -64,12 +64,12 @@ class EchoingCourageEffect extends OneShotEffect {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (targetPermanent.getName().isEmpty()) {
if (CardUtil.haveEmptyName(targetPermanent)) {
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(targetPermanent.getName()));
}
ContinuousEffect effect = new BoostAllEffect(2,2, Duration.EndOfTurn, filter, false);
ContinuousEffect effect = new BoostAllEffect(2, 2, Duration.EndOfTurn, filter, false);
game.addEffect(effect, source);
return true;
}

View file

@ -1,7 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
@ -17,15 +15,17 @@ import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class EchoingDecay extends CardImpl {
public EchoingDecay(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}");
// Target creature and all other creatures with the same name as that creature get -2/-2 until end of turn.
this.getSpellAbility().addEffect(new EchoingDecayEffect());
@ -63,12 +63,12 @@ class EchoingDecayEffect extends OneShotEffect {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (targetPermanent.getName().isEmpty()) {
if (CardUtil.haveEmptyName(targetPermanent)) {
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(targetPermanent.getName()));
}
ContinuousEffect effect = new BoostAllEffect(-2,-2, Duration.EndOfTurn, filter, false);
ContinuousEffect effect = new BoostAllEffect(-2, -2, Duration.EndOfTurn, filter, false);
game.addEffect(effect, source);
return true;
}

View file

@ -1,7 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -14,13 +12,15 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class EchoingRuin extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("artifact");
private static final FilterPermanent filter = new FilterPermanent("artifact");
static {
@ -28,7 +28,7 @@ public final class EchoingRuin extends CardImpl {
}
public EchoingRuin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{R}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}");
// Destroy target artifact and all other artifacts with the same name as that artifact.
this.getSpellAbility().addTarget(new TargetPermanent(filter));
@ -66,9 +66,9 @@ class EchoingRuinEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller != null && permanent != null) {
permanent.destroy(source.getSourceId(), game, false);
if (!permanent.getName().isEmpty()) { // in case of face down artifact creature
if (!CardUtil.haveEmptyName(permanent)) { // in case of face down artifact creature
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (!perm.getId().equals(permanent.getId()) && perm.getName().equals(permanent.getName()) && perm.isArtifact()) {
if (!perm.getId().equals(permanent.getId()) && CardUtil.haveSameNames(perm, permanent) && perm.isArtifact()) {
perm.destroy(source.getSourceId(), game, false);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
@ -20,15 +18,17 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetNonlandPermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class EchoingTruth extends CardImpl {
public EchoingTruth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Return target nonland permanent and all other permanents with the same name as that permanent to their owners' hands.
Target target = new TargetNonlandPermanent();
@ -67,7 +67,7 @@ class ReturnToHandAllNamedPermanentsEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (controller != null && permanent != null) {
FilterPermanent filter = new FilterPermanent();
if (permanent.getName().isEmpty()) {
if (CardUtil.haveEmptyName(permanent)) {
filter.add(new PermanentIdPredicate(permanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(permanent.getName()));

View file

@ -1,7 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -24,10 +22,12 @@ import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import mage.util.functions.ApplyToPermanent;
import java.util.UUID;
/**
*
* @author BetaSteward
*/
public final class EvilTwin extends CardImpl {
@ -90,7 +90,7 @@ class EvilTwinPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlaye
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
Permanent permanent = input.getObject();
Permanent twin = game.getPermanent(input.getSourceId());
return permanent != null && twin != null && !twin.getName().isEmpty() && permanent.getName().equals(twin.getName());
return CardUtil.haveSameNames(permanent, twin);
}
@Override

View file

@ -1,13 +1,11 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -17,15 +15,17 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Quercitron & L_J
*/
public final class Foreshadow extends CardImpl {
public Foreshadow(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Choose a card name, then target opponent puts the top card of their library into their graveyard. If that card has the chosen name, you draw a card.
this.getSpellAbility().addEffect(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL));
@ -72,7 +72,7 @@ class ForeshadowEffect extends OneShotEffect {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
controller.drawCards(1, game);
}
}

View file

@ -0,0 +1,73 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author jeffwadsworth
*/
public final class Grollub extends CardImpl {
public Grollub(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
this.subtype.add(SubType.BEAST);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Whenever Grollub is dealt damage, each opponent gains that much life.
this.addAbility(new DealtDamageToSourceTriggeredAbility(
Zone.BATTLEFIELD,
new EachOpponentGainsLifeEffect(), false, false, true));
}
public Grollub(final Grollub card) {
super(card);
}
@Override
public Grollub copy() {
return new Grollub(this);
}
}
class EachOpponentGainsLifeEffect extends OneShotEffect {
public EachOpponentGainsLifeEffect() {
super(Outcome.Neutral);
this.staticText = "each opponent gains that much life";
}
public EachOpponentGainsLifeEffect(final EachOpponentGainsLifeEffect effect) {
super(effect);
}
@Override
public EachOpponentGainsLifeEffect copy() {
return new EachOpponentGainsLifeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getOpponents(source.getControllerId()).stream().map((opponentId) -> game.getPlayer(opponentId)).filter((opponent) -> (opponent != null)).forEachOrdered((opponent) -> {
int amount = (Integer) getValue("damage");
if (amount > 0) {
opponent.gainLife(amount, game, source);
}
});
return true;
}
}

View file

@ -13,10 +13,11 @@ import mage.abilities.effects.common.cost.SpellsCostReductionAllOfChosenSubtypeE
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
@ -79,15 +80,18 @@ class HeraldsHornEffect extends OneShotEffect {
// If it's a creature card of the chosen type, you may reveal it and put it into your hand.
FilterCreatureCard filter = new FilterCreatureCard("creature card of the chosen type");
filter.add(new ChosenSubtypePredicate());
SubType subtype = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
filter.add(new SubtypePredicate(subtype));
String message = "Reveal the top card of your library and put that card into your hand?";
if (card != null) {
if (filter.match(card, game) && controller.chooseUse(Outcome.Benefit, message, source, game)) {
if (filter.match(card, game)
&& controller.chooseUse(Outcome.Benefit, message, source, game)) {
controller.moveCards(card, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName() + " put into hand", cards, game);
return true;
}
}
}
return true;
return false;
}
}

View file

@ -0,0 +1,76 @@
package mage.cards.h;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.PutCardFromHandOnTopOfLibraryCost;
import mage.abilities.effects.PreventionEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
import mage.filter.StaticFilters;
import mage.game.events.DamageEvent;
import mage.target.TargetSpell;
/**
*
* @author bunchOfDevs
*/
public class HiddenRetreat extends CardImpl {
public HiddenRetreat(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
//Put a card from your hand on top of your library: Prevent all damage that would be dealt by target instant or sorcery spell this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HiddenRetreatEffect(), new PutCardFromHandOnTopOfLibraryCost());
ability.addTarget(new TargetSpell(StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY));
this.addAbility(ability);
}
public HiddenRetreat(final HiddenRetreat hiddenRetreat) {
super(hiddenRetreat);
}
@Override
public HiddenRetreat copy() {
return new HiddenRetreat(this);
}
}
class HiddenRetreatEffect extends PreventionEffectImpl {
public HiddenRetreatEffect() {
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
this.staticText = "Prevent all damage that would be dealt by target instant or sorcery spell this turn.";
}
public HiddenRetreatEffect(final HiddenRetreatEffect effect) {
super(effect);
}
@Override
public HiddenRetreatEffect copy() {
return new HiddenRetreatEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return (super.applies(event, source, game)
&& event instanceof DamageEvent
&& event.getAmount() > 0
&& game.getObject(source.getFirstTarget()) != null
&& game.getObject(event.getSourceId()) != null
&& game.getObject(source.getFirstTarget()).equals(game.getObject(event.getSourceId()))
&& game.getObject(source.getFirstTarget()).isInstantOrSorcery());
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.h;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -14,15 +12,17 @@ import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class HomingLightning extends CardImpl {
public HomingLightning(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{R}{R}");
// Homing Lightning deals 4 damage to target creature and each other creature with the same name as that creature.
@ -58,7 +58,7 @@ class HomingLightningEffect extends OneShotEffect {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (targetPermanent.getName().isEmpty()) {
if (CardUtil.haveEmptyName(targetPermanent)) {
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(targetPermanent.getName()));

View file

@ -1,7 +1,5 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -12,8 +10,8 @@ import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.NamePredicate;
@ -21,15 +19,17 @@ import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class IzzetStaticaster extends CardImpl {
public IzzetStaticaster(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
@ -79,7 +79,7 @@ class IzzetStaticasterDamageEffect extends OneShotEffect {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (targetPermanent.getName().isEmpty()) {
if (CardUtil.haveEmptyName(targetPermanent)) {
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(targetPermanent.getName()));

View file

@ -1,4 +1,3 @@
package mage.cards.j;
import java.util.HashMap;
@ -92,7 +91,6 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
//
player.moveCardsToExile(player.getLibrary().getTopCards(game, xValue), source, game, true, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName());
}
}
@ -130,7 +128,7 @@ class JelevaNephaliasCastEffect extends OneShotEffect {
if (controller.choose(Outcome.PlayForFree, exileZone, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
return controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
return controller.playCard(card, game, true, false, new MageObjectReference(source.getSourceId(), game));
}
}
}

View file

@ -0,0 +1,79 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterOpponent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
*
* @author jeffwadsworth
*/
public final class KeeperOfTheFlame extends CardImpl {
private static final FilterOpponent filter = new FilterOpponent();
static {
filter.add(new KeeperOfTheFlamePredicate());
}
public KeeperOfTheFlame(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(1);
this.toughness = new MageInt(2);
// {R}, {tap}: Choose target opponent who had more life than you did as you activated this ability. Keeper of the Flame deals 2 damage to him or her.
Ability ability = new SimpleActivatedAbility(
new DamageTargetEffect(2).setText("Choose target opponent who had more life than you did as you activated this ability. {this} deals 2 damage to him or her"),
new ManaCostsImpl("{R}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPlayer(1, 1, false, filter));
this.addAbility(ability);
}
public KeeperOfTheFlame(final KeeperOfTheFlame card) {
super(card);
}
@Override
public KeeperOfTheFlame copy() {
return new KeeperOfTheFlame(this);
}
}
class KeeperOfTheFlamePredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
Player targetOpponent = input.getObject();
Player controller = game.getPlayer(input.getPlayerId());
if (targetOpponent == null
|| controller == null
|| !controller.hasOpponent(targetOpponent.getId(), game)) {
return false;
}
return targetOpponent.getLife() > controller.getLife();
}
@Override
public String toString() {
return "opponent who had more life than you did as you activated this ability";
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -14,13 +12,7 @@ import mage.abilities.keyword.MorphAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.ZoneDetail;
import mage.constants.*;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
@ -28,14 +20,15 @@ import mage.players.Player;
import mage.target.TargetSpell;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class KheruSpellsnatcher extends CardImpl {
public KheruSpellsnatcher(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.subtype.add(SubType.NAGA);
this.subtype.add(SubType.WIZARD);
@ -85,7 +78,7 @@ class KheruSpellsnatcherEffect extends OneShotEffect {
StackObject stackObject = game.getStack().getStackObject(objectId);
if (stackObject != null
&& game.getStack().counter(targetPointer.getFirst(game, source), source.getSourceId(), game, Zone.EXILED, false, ZoneDetail.NONE)) {
if (!((Spell) stackObject).isCopiedSpell()) {
if (!((Spell) stackObject).isCopy()) {
MageObject card = game.getObject(stackObject.getSourceId());
if (card instanceof Card) {
((Card) card).moveToZone(Zone.EXILED, sourceId, game, true);

View file

@ -1,10 +1,9 @@
package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -14,9 +13,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class LammastideWeave extends CardImpl {
@ -70,7 +71,7 @@ class LammastideWeaveEffect extends OneShotEffect {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
controller.gainLife(card.getConvertedManaCost(), game, source);
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
@ -20,9 +18,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author L_J
*/
public final class LiarsPendulum extends CardImpl {
@ -93,7 +93,7 @@ class LiarsPendulumEffect extends OneShotEffect {
rightGuess = opponentGuess;
}
}
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
rightGuess = opponentGuess;
}
}

View file

@ -0,0 +1,124 @@
package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.common.TargetLandPermanent;
/**
*
* @author jeffwadsworth
*/
public final class LimitedResources extends CardImpl {
public LimitedResources(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
// When Limited Resources enters the battlefield, each player chooses five lands he or she controls and sacrifices the rest.
this.addAbility(new EntersBattlefieldTriggeredAbility(new LimitedResourcesEffect(), false));
// Players can't play lands as long as ten or more lands are on the battlefield.
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new ConditionalContinuousRuleModifyingEffect(
new CantPlayLandEffect(),
new PermanentsOnTheBattlefieldCondition(
new FilterLandPermanent(),
ComparisonType.MORE_THAN, 9))));
}
public LimitedResources(final LimitedResources card) {
super(card);
}
@Override
public LimitedResources copy() {
return new LimitedResources(this);
}
}
class LimitedResourcesEffect extends OneShotEffect {
public LimitedResourcesEffect() {
super(Outcome.Benefit);
this.staticText = "each player chooses five lands he or she controls and sacrifices the rest";
}
public LimitedResourcesEffect(final LimitedResourcesEffect effect) {
super(effect);
}
@Override
public LimitedResourcesEffect copy() {
return new LimitedResourcesEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getPlayersInRange(source.getControllerId(), game).forEach((playerId) -> {
Player player = game.getPlayer(playerId);
if (player != null) {
int lands = game.getBattlefield().countAll(new FilterControlledLandPermanent(), playerId, game);
TargetLandPermanent target = new TargetLandPermanent(Integer.min(5, lands));
target.setNotTarget(true);
target.setRequired(true);
player.chooseTarget(outcome.Benefit, target, source, game);
game.getBattlefield().getAllActivePermanents(new FilterControlledLandPermanent(), playerId, game).stream().filter((land) -> (!target.getTargets().contains(land.getId()))).forEachOrdered((land) -> {
land.sacrifice(source.getSourceId(), game);
});
}
});
return true;
}
}
class CantPlayLandEffect extends ContinuousRuleModifyingEffectImpl {
public CantPlayLandEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
this.staticText = "Players can't play lands as long as ten or more lands are on the battlefield";
}
public CantPlayLandEffect(final CantPlayLandEffect effect) {
super(effect);
}
@Override
public CantPlayLandEffect copy() {
return new CantPlayLandEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.PLAY_LAND;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return true;
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -10,11 +8,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
@ -23,9 +17,11 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class MagusOfTheScroll extends CardImpl {
@ -80,7 +76,7 @@ class MagusOfTheScrollEffect extends OneShotEffect {
}
revealed.add(card);
you.revealCards(sourceObject.getName(), revealed, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null) {
creature.damage(2, source.getSourceId(), game, false, true);

View file

@ -0,0 +1,88 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
/**
*
* @author jeffwadsworth
*/
public final class MindMaggots extends CardImpl {
public MindMaggots(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add(SubType.INSECT);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// When Mind Maggots enters the battlefield, discard any number of creature cards.
// For each card discarded this way, put two +1/+1 counters on Mind Maggots.
this.addAbility(new EntersBattlefieldTriggeredAbility(new MindMaggotsEffect()));
}
public MindMaggots(final MindMaggots card) {
super(card);
}
@Override
public MindMaggots copy() {
return new MindMaggots(this);
}
}
class MindMaggotsEffect extends OneShotEffect {
MindMaggotsEffect() {
super(Outcome.BoostCreature);
this.staticText = "discard any number of creature cards. For each card discarded this way, put two +1/+1 counters on {this}";
}
MindMaggotsEffect(final MindMaggotsEffect effect) {
super(effect);
}
@Override
public MindMaggotsEffect copy() {
return new MindMaggotsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int numToDiscard = controller.getAmount(0,
controller.getHand().getCards(new FilterCreatureCard(), game).size(),
"Discard how many creature cards?",
game);
TargetCardInHand target = new TargetCardInHand(numToDiscard, new FilterCreatureCard());
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Card card = game.getCard(targetId);
if (card != null
&& controller.discard(card, source, game)) {
new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)).apply(game, source);
}
}
}
return true;
}
return false;
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
@ -19,17 +17,17 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.target.TargetSpell;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class Mirari extends CardImpl {
public Mirari(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}");
addSuperType(SuperType.LEGENDARY);
// Whenever you cast an instant or sorcery spell, you may pay {3}. If you do, copy that spell. You may choose new targets for the copy.
@ -58,8 +56,9 @@ class MirariTriggeredAbility extends TriggeredAbilityImpl {
}
MirariTriggeredAbility() {
super(Zone.BATTLEFIELD, new DoIfCostPaid(new CopyTargetSpellEffect(true), new GenericManaCost(3)), false);
this.addTarget(new TargetSpell(filter));
super(Zone.BATTLEFIELD, new DoIfCostPaid(
new CopyTargetSpellEffect(true),
new GenericManaCost(3)), false);
}
MirariTriggeredAbility(final MirariTriggeredAbility ability) {
@ -82,7 +81,11 @@ class MirariTriggeredAbility extends TriggeredAbilityImpl {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (isControlledInstantOrSorcery(spell)) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(spell.getId()));
if (effect instanceof DoIfCostPaid) {
for (Effect execEffect : ((DoIfCostPaid) effect).getExecutingEffects()) {
execEffect.setTargetPointer(new FixedTarget(spell.getId()));
}
}
}
return true;
}

View file

@ -0,0 +1,131 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author jeffwadsworth
*/
public final class MonstrousHound extends CardImpl {
public MonstrousHound(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");
this.subtype.add(SubType.HOUND);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Monstrous Hound can't attack unless you control more lands than defending player.
Effect effect = new CantAttackUnlessControllerControlsMoreLandsEffect();
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
effect.setText("{this} can't attack unless you control more lands than defending player")));
// Monstrous Hound can't block unless you control more lands than attacking player.
Effect effect2 = new CantBlockUnlessControllerControlsMoreLandsEffect();
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
effect2.setText("{this} can't block unless you control more lands than attacking player")));
}
public MonstrousHound(final MonstrousHound card) {
super(card);
}
@Override
public MonstrousHound copy() {
return new MonstrousHound(this);
}
}
class CantAttackUnlessControllerControlsMoreLandsEffect extends RestrictionEffect {
CantAttackUnlessControllerControlsMoreLandsEffect() {
super(Duration.WhileOnBattlefield);
}
CantAttackUnlessControllerControlsMoreLandsEffect(final CantAttackUnlessControllerControlsMoreLandsEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getId().equals(source.getSourceId());
}
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
UUID defendingPlayerId;
Player defender = game.getPlayer(defenderId);
if (defender == null) {
Permanent permanent = game.getPermanent(defenderId);
if (permanent != null) {
defendingPlayerId = permanent.getControllerId();
} else {
return false;
}
} else {
defendingPlayerId = defenderId;
}
if (defendingPlayerId != null) {
return game.getBattlefield().countAll(new FilterControlledLandPermanent(),
source.getControllerId(), game) > game.getBattlefield().countAll(new FilterControlledLandPermanent(),
defendingPlayerId, game);
} else {
return true;
}
}
@Override
public CantAttackUnlessControllerControlsMoreLandsEffect copy() {
return new CantAttackUnlessControllerControlsMoreLandsEffect(this);
}
}
class CantBlockUnlessControllerControlsMoreLandsEffect extends RestrictionEffect {
CantBlockUnlessControllerControlsMoreLandsEffect() {
super(Duration.WhileOnBattlefield);
}
CantBlockUnlessControllerControlsMoreLandsEffect(final CantBlockUnlessControllerControlsMoreLandsEffect effect) {
super(effect);
}
@Override
public CantBlockUnlessControllerControlsMoreLandsEffect copy() {
return new CantBlockUnlessControllerControlsMoreLandsEffect(this);
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
UUID attackingPlayerId = attacker.getControllerId();
if (attackingPlayerId != null) {
return game.getBattlefield().countAll(new FilterControlledLandPermanent(),
source.getControllerId(), game) > game.getBattlefield().countAll(new FilterControlledLandPermanent(),
attackingPlayerId, game);
}
return true;
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getId().equals(source.getSourceId());
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.o;
import mage.abilities.Ability;
@ -18,6 +17,7 @@ import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
import mage.target.targetpointer.FixedTarget;
@ -25,12 +25,10 @@ import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class OathOfLieges extends CardImpl {
private final UUID originalId;
private static final FilterPlayer FILTER = new FilterPlayer("player who controls more lands than you do and is your opponent");
static {
@ -43,26 +41,19 @@ public final class OathOfLieges extends CardImpl {
// At the beginning of each player's upkeep, that player chooses target player who controls more lands than he or she does and is their opponent. The first player may search their library for a basic land card, put that card onto the battlefield, then shuffle their library.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfLiegesEffect(), TargetController.ANY, false);
ability.addTarget(new TargetPlayer(1, 1, false, FILTER));
originalId = ability.getOriginalId();
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
ability.getTargets().clear();
TargetPlayer target = new TargetPlayer(1, 1, false, FILTER);
target.setTargetController(activePlayer.getId());
ability.getTargets().add(target);
}
// target controller must be active player (even for copies)
for (Target target : ability.getTargets()) {
target.setTargetController(game.getActivePlayerId());
}
}
public OathOfLieges(final OathOfLieges card) {
super(card);
this.originalId = card.originalId;
}
@Override
@ -93,7 +84,7 @@ class OathOfLiegesEffect extends OneShotEffect {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle your library?", source, game)) {
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, true, Outcome.PutLandInPlay, true);
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, false, Outcome.PutLandInPlay, true);
effect.setTargetPointer(new FixedTarget(game.getActivePlayerId()));
return effect.apply(game, source);
}
@ -110,18 +101,25 @@ class OathOfLiegesPredicate implements ObjectSourcePlayerPredicate<ObjectSourceP
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
// input.getPlayerId() -- source controller id
// input.getObject() -- checking player
Player targetPlayer = input.getObject();
//Get active input.playerId because adjust target is used after canTarget function
UUID activePlayerId = game.getActivePlayerId();
if (targetPlayer == null || activePlayerId == null) {
return false;
}
if (!targetPlayer.hasOpponent(activePlayerId, game)) {
return false;
}
int countTargetPlayer = game.getBattlefield().countAll(FILTER, targetPlayer.getId(), game);
int countActivePlayer = game.getBattlefield().countAll(FILTER, activePlayerId, game);
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (targetPlayer == null || activePlayer == null) {
return false;
}
// must be opponent
if (!activePlayer.hasOpponent(targetPlayer.getId(), game)) {
return false;
}
// must have more lands than active player
int countTargetPlayer = game.getBattlefield().countAll(FILTER, targetPlayer.getId(), game);
int countActivePlayer = game.getBattlefield().countAll(FILTER, activePlayer.getId(), game);
return countTargetPlayer > countActivePlayer;
}

View file

@ -1,23 +1,20 @@
package mage.cards.p;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author LevelX2
@ -43,7 +40,7 @@ import mage.players.Player;
public final class PalisadeGiant extends CardImpl {
public PalisadeGiant(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
this.subtype.add(SubType.GIANT);
this.subtype.add(SubType.SOLDIER);
@ -51,7 +48,7 @@ public final class PalisadeGiant extends CardImpl {
this.toughness = new MageInt(7);
// All damage that would be dealt to you or another permanent you control is dealt to Palisade Giant instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PalisadeGiantReplacementEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PalisadeGiantReplacementEffect()));
}
public PalisadeGiant(final PalisadeGiant card) {
@ -77,7 +74,7 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
switch(event.getType()) {
switch (event.getType()) {
case DAMAGE_CREATURE:
case DAMAGE_PLAYER:
case DAMAGE_PLANESWALKER:
@ -89,17 +86,15 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event.getPlayerId().equals(source.getControllerId()))
{
return true;
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event.getPlayerId().equals(source.getControllerId())) {
return true;
}
if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER)
{
if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) {
Permanent targetPermanent = game.getPermanent(event.getTargetId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (targetPermanent != null &&
targetPermanent.isControlledBy(source.getControllerId()) &&
!targetPermanent.getName().equals(sourcePermanent.getName())) { // no redirection from or to other Palisade Giants
!CardUtil.haveSameNames(targetPermanent, sourcePermanent)) { // no redirection from or to other Palisade Giants
return true;
}
}
@ -108,7 +103,7 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent)event;
DamageEvent damageEvent = (DamageEvent) event;
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
// get name of old target
@ -118,13 +113,11 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl {
message.append(damageEvent.getAmount()).append(" damage redirected from ");
if (targetPermanent != null) {
message.append(targetPermanent.getName());
}
else {
} else {
Player targetPlayer = game.getPlayer(event.getTargetId());
if (targetPlayer != null) {
message.append(targetPlayer.getLogName());
}
else {
} else {
message.append("unknown");
}

View file

@ -0,0 +1,111 @@
package mage.cards.p;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
*/
public final class Paroxysm extends CardImpl {
public Paroxysm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// At the beginning of the upkeep of enchanted creature's controller, that player reveals the top card of his or her library.
// If that card is a land card, destroy that creature. Otherwise, it gets +3/+3 until end of turn.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD,
new ParoxysmEffect(),
TargetController.CONTROLLER_ATTACHED_TO,
false, false, "At the beginning of the upkeep of enchanted creature's controller, "));
}
public Paroxysm(final Paroxysm card) {
super(card);
}
@Override
public Paroxysm copy() {
return new Paroxysm(this);
}
}
class ParoxysmEffect extends OneShotEffect {
ParoxysmEffect() {
super(Outcome.BoostCreature);
this.staticText = "that player reveals the top card of his or her library. \n"
+ "If that card is a land card, destroy that creature. \n"
+ "Otherwise, it gets +3/+3 until end of turn.";
}
ParoxysmEffect(final ParoxysmEffect effect) {
super(effect);
}
@Override
public ParoxysmEffect copy() {
return new ParoxysmEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanent(source.getSourceId());
if (aura != null) {
Permanent creatureAttachedTo = game.getPermanent(aura.getAttachedTo());
if (creatureAttachedTo != null) {
Player controllerOfCreature = game.getPlayer(creatureAttachedTo.getControllerId());
if (controllerOfCreature != null) {
Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game);
if (revealCardFromTop != null) {
Cards cards = new CardsImpl();
cards.add(revealCardFromTop);
controllerOfCreature.revealCards(source, cards, game);
if (revealCardFromTop.isLand()) {
creatureAttachedTo.destroy(source.getSourceId(), game, false);
} else {
ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId()));
game.addEffect(effect, source);
}
return true;
}
}
}
}
return false;
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.DiesAttachedTriggeredAbility;
import mage.abilities.effects.Effect;
@ -11,22 +9,23 @@ import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.constants.SubType;
import mage.filter.common.FilterCreatureCard;
import mage.target.TargetPermanent;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class PatternOfRebirth extends CardImpl {
public PatternOfRebirth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -37,7 +36,7 @@ public final class PatternOfRebirth extends CardImpl {
this.addAbility(ability);
// When enchanted creature dies, that creature's controller may search their library for a creature card and put that card onto the battlefield. If that player does, he or she shuffles their library.
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterCreatureCard()), false, true, Outcome.PutCreatureInPlay);
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterCreatureCard()), false, false, Outcome.PutCreatureInPlay);
effect.setText("that creature's controller may search their library for a creature card and put that card onto the battlefield. If that player does, he or she shuffles their library");
this.addAbility(new DiesAttachedTriggeredAbility(effect, "enchanted creature", true, true, SetTargetPointer.ATTACHED_TO_CONTROLLER));

View file

@ -1,7 +1,5 @@
package mage.cards.p;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -20,8 +18,9 @@ import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com & L_J
*/
public final class PetraSphinx extends CardImpl {
@ -79,7 +78,7 @@ class PetraSphinxEffect extends OneShotEffect {
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards(source, cards, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
player.moveCards(cards, Zone.HAND, source, game);
} else {
player.moveCards(cards, Zone.GRAVEYARD, source, game);

View file

@ -1,6 +1,5 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
@ -13,9 +12,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Quercitron
*/
public final class Predict extends CardImpl {
@ -66,7 +67,7 @@ class PredictEffect extends OneShotEffect {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
amount = 2;
}
}

View file

@ -1,8 +1,5 @@
package mage.cards.p;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.CopyTargetSpellEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -17,15 +14,17 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author nantuko
*/
public final class PyromancerAscension extends CardImpl {
public PyromancerAscension(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{R}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
// Whenever you cast an instant or sorcery spell that has the same name as a card in your graveyard, you may put a quest counter on Pyromancer Ascension.
this.addAbility(new PyromancerAscensionQuestTriggeredAbility());
@ -75,7 +74,7 @@ class PyromancerAscensionQuestTriggeredAbility extends TriggeredAbilityImpl {
for (UUID uuid : game.getPlayer(this.getControllerId()).getGraveyard()) {
if (!uuid.equals(sourceCard.getId())) {
Card card = game.getCard(uuid);
if (card != null && card.getName().equals(sourceCard.getName())) {
if (CardUtil.haveSameNames(card, sourceCard)) {
return true;
}
}
@ -88,8 +87,8 @@ class PyromancerAscensionQuestTriggeredAbility extends TriggeredAbilityImpl {
private boolean isControlledInstantOrSorcery(Spell spell) {
return spell != null &&
(spell.isControlledBy(this.getControllerId())) &&
(spell.isInstant() || spell.isSorcery());
(spell.isControlledBy(this.getControllerId())) &&
(spell.isInstant() || spell.isSorcery());
}
@Override
@ -135,8 +134,8 @@ class PyromancerAscensionCopyTriggeredAbility extends TriggeredAbilityImpl {
private boolean isControlledInstantOrSorcery(Spell spell) {
return spell != null &&
(spell.isControlledBy(this.getControllerId())) &&
(spell.isInstant() || spell.isSorcery());
(spell.isControlledBy(this.getControllerId())) &&
(spell.isInstant() || spell.isSorcery());
}
@Override

View file

@ -0,0 +1,87 @@
package mage.cards.r;
import static java.lang.Integer.min;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.TargetPlayer;
/**
*
* @author jeffwadsworth
*/
public final class Ransack extends CardImpl {
public Ransack(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Look at the top five cards of target player's library.
//Put any number of them on the bottom of that library in any order
//and the rest on top of the library in any order.
this.getSpellAbility().addEffect(new RansackEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
}
public Ransack(final Ransack card) {
super(card);
}
@Override
public Ransack copy() {
return new Ransack(this);
}
}
class RansackEffect extends OneShotEffect {
public RansackEffect() {
super(Outcome.Detriment);
this.staticText = "Look at the top five cards of target player's library. "
+ "Put any number of them on the bottom of that library in any order "
+ "and the rest on top of the library in any order";
}
public RansackEffect(final RansackEffect effect) {
super(effect);
}
@Override
public RansackEffect copy() {
return new RansackEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
FilterCard filter = new FilterCard("cards to put on the bottom of your library");
if (player != null) {
int number = min(player.getLibrary().size(), 5);
Set<Card> cards = player.getLibrary().getTopCards(game, number);
Cards cardsRemaining = new CardsImpl();
cardsRemaining.addAll(cards);
TargetCard target = new TargetCard((true ? 0 : number), number, Zone.LIBRARY, filter);
if (player.choose(Outcome.DrawCard, cardsRemaining, target, game)) {
Cards pickedCards = new CardsImpl(target.getTargets());
cardsRemaining.removeAll(pickedCards);
player.putCardsOnBottomOfLibrary(pickedCards, game, source, true);
player.putCardsOnTopOfLibrary(cardsRemaining, game, source, true);
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,77 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterSpell;
import mage.filter.predicate.other.TargetsOnlyOnePlayerPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.TargetSpell;
/**
*
* @author jeffwadsworth
*/
public final class Rebound extends CardImpl {
public Rebound(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Change the target of target spell that targets only a player. The new target must be a player.
this.getSpellAbility().addEffect(new ReboundEffect());
FilterSpell filter = new FilterSpell("spell that targets only a player");
filter.add(new TargetsOnlyOnePlayerPredicate());
this.getSpellAbility().addTarget(new TargetSpell(filter));
}
public Rebound(final Rebound card) {
super(card);
}
@Override
public Rebound copy() {
return new Rebound(this);
}
}
class ReboundEffect extends OneShotEffect {
public ReboundEffect() {
super(Outcome.Neutral);
this.staticText = "Change the target of target spell that targets only a player. The new target must be a player";
}
public ReboundEffect(final ReboundEffect effect) {
super(effect);
}
@Override
public ReboundEffect copy() {
return new ReboundEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
if (spell != null
&& controller != null) {
spell.getSpellAbility().getTargets().clear();
TargetPlayer targetPlayer = new TargetPlayer();
if (controller.choose(Outcome.Neutral, targetPlayer, source.getSourceId(), game)) {
spell.getSpellAbility().addTarget(targetPlayer);
game.informPlayers("The target of the spell was changed to " + targetPlayer.getTargetedName(game));
return true;
}
}
return false;
}
}

View file

@ -1,8 +1,5 @@
package mage.cards.r;
import java.util.Objects;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -11,12 +8,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
@ -25,9 +17,12 @@ import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class ReflectorMage extends CardImpl {
@ -84,7 +79,7 @@ class ReflectorMageEffect extends OneShotEffect {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
controller.moveCards(targetCreature, Zone.HAND, source, game);
if (!targetCreature.getName().isEmpty()) { // if the creature had no name, no restrict effect will be created
if (!CardUtil.haveEmptyName(targetCreature)) { // if the creature had no name, no restrict effect will be created
game.addEffect(new ExclusionRitualReplacementEffect(targetCreature.getName(), targetCreature.getOwnerId()), source);
}
}
@ -125,7 +120,7 @@ class ExclusionRitualReplacementEffect extends ContinuousRuleModifyingEffectImpl
if (spell != null && spell.isFaceDown(game)) {
return false; // Face Down cast spell (Morph creature) has no name
}
return card.getName().equals(creatureName) && Objects.equals(ownerId, card.getOwnerId());
return CardUtil.haveSameNames(card.getName(), creatureName) && Objects.equals(ownerId, card.getOwnerId());
}
return false;
}

View file

@ -0,0 +1,58 @@
package mage.cards.s;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
/**
*
* @author jeffwadsworth
*/
public final class SamiteBlessing extends CardImpl {
private static final String rule = "Enchanted creature has \"{T}: The next time a source of your choice would deal damage to target creature this turn, prevent that damage.\"";
public SamiteBlessing(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Enchanted creature has "{tap}: The next time a source of your choice would deal damage to target creature this turn, prevent that damage."
Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventNextDamageFromChosenSourceToTargetEffect(Duration.EndOfTurn), new TapSourceCost());
ability2.addTarget(new TargetCreaturePermanent());
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability2, AttachmentType.AURA, Duration.WhileOnBattlefield, rule)));
}
public SamiteBlessing(final SamiteBlessing card) {
super(card);
}
@Override
public SamiteBlessing copy() {
return new SamiteBlessing(this);
}
}

View file

@ -0,0 +1,104 @@
package mage.cards.s;
import java.util.Arrays;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.util.RandomUtil;
/**
*
* @author jeffwadsworth
*/
/*
The card is chosen at random, so the computer just picks a card at random from
the controller's graveyard. Devs, feel free to set up something else...
*/
public final class SearchForSurvivors extends CardImpl {
public SearchForSurvivors(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}");
// Reorder your graveyard at random. An opponent chooses a card at random in your graveyard. If it's a creature card, put it onto the battlefield. Otherwise, exile it.
this.getSpellAbility().addEffect(new SearchForSurvivorsEffect());
}
public SearchForSurvivors(final SearchForSurvivors card) {
super(card);
}
@Override
public SearchForSurvivors copy() {
return new SearchForSurvivors(this);
}
}
class SearchForSurvivorsEffect extends OneShotEffect {
public SearchForSurvivorsEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "Reorder your graveyard at random. "
+ "An opponent chooses a card at random in your graveyard. "
+ "If it's a creature card, put it onto the battlefield. "
+ "Otherwise, exile it";
}
public SearchForSurvivorsEffect(final SearchForSurvivorsEffect effect) {
super(effect);
}
@Override
public SearchForSurvivorsEffect copy() {
return new SearchForSurvivorsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
game.informPlayers("The controller of Search for Survivors will have his or her graveyard randomized. "
+ " A card will be chosen at random from the controller's graveyard. "
+ " The result is essentially the same as the card rule");
// randomly arrange the graveyard
UUID[] shuffled = controller.getGraveyard().toArray(new UUID[0]);
for (int n = shuffled.length - 1; n > 0; n--) {
int r = RandomUtil.nextInt(n + 1);
UUID temp = shuffled[r];
shuffled[r] = shuffled[n];
shuffled[n] = temp;
}
controller.getGraveyard().clear();
controller.getGraveyard().addAll(Arrays.asList(shuffled));
// end of randomize
Cards cards = new CardsImpl();
controller.getGraveyard().getCards(game).forEach((card) -> {
cards.add(card);
});
if (!cards.isEmpty()) {
Card card = cards.getRandom(game);
cards.clear();
cards.add(card);
controller.revealCards(source, cards, game); // reveal the card randomly chosen.
if (card.isCreature()) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
controller.moveCards(card, Zone.EXILED, source, game);
}
}
return true;
}
return false;
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -22,9 +20,11 @@ import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.turn.TurnMod;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SearchTheCity extends CardImpl {
@ -157,7 +157,7 @@ class SearchTheCityExiledCardToHandEffect extends OneShotEffect {
ExileZone searchTheCityExileZone = game.getExile().getExileZone(source.getSourceId());
if (cardName != null && searchTheCityExileZone != null) {
for (Card card : searchTheCityExileZone.getCards(game)) {
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
if (card.moveToZone(Zone.HAND, source.getSourceId(), game, true)) {
game.informPlayers("Search the City: put " + card.getName() + " into owner's hand");
}

View file

@ -1,7 +1,5 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
@ -19,15 +17,17 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author North
*/
public final class SeverTheBloodline extends CardImpl {
public SeverTheBloodline(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}");
// Exile target creature and all other creatures with the same name as that creature.
@ -69,7 +69,7 @@ class SeverTheBloodlineEffect extends OneShotEffect {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (controller != null && targetPermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (targetPermanent.getName().isEmpty()) {
if (CardUtil.haveEmptyName(targetPermanent)) {
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(targetPermanent.getName()));

View file

@ -0,0 +1,98 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.ShroudAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.AbilityAddingRemovingEffects_6;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author jeffwadsworth
*/
public final class ShelteringPrayers extends CardImpl {
public ShelteringPrayers(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
// Basic lands each player controls have shroud as long as that player controls three or fewer lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ShelteringPrayersEffect()));
}
public ShelteringPrayers(final ShelteringPrayers card) {
super(card);
}
@Override
public ShelteringPrayers copy() {
return new ShelteringPrayers(this);
}
}
class ShelteringPrayersEffect extends ContinuousEffectImpl {
public ShelteringPrayersEffect() {
super(Duration.WhileOnBattlefield, Outcome.AddAbility);
staticText = "Basic lands each player controls have shroud as long as that player controls three or fewer lands.";
dependencyTypes.add(DependencyType.AddingAbility);
}
public ShelteringPrayersEffect(final ShelteringPrayersEffect effect) {
super(effect);
}
@Override
public ShelteringPrayersEffect copy() {
return new ShelteringPrayersEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null
&& game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), playerId, game).size() < 4) {
for (Permanent land : game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), playerId, game)) {
if (land != null
&& land.isBasic()) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
land.getAbilities().add(ShroudAbility.getInstance());
}
break;
}
}
}
}
}
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return Layer.AbilityAddingRemovingEffects_6 == layer;
}
}

View file

@ -1,14 +1,11 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.GainAbilitySpellsEffect;
import mage.abilities.effects.ReplacementEffectImpl;
@ -16,13 +13,7 @@ import mage.abilities.keyword.LifelinkAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.FilterObject;
import mage.filter.predicate.Predicates;
@ -30,13 +21,12 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SoulfireGrandMaster extends CardImpl {
@ -111,7 +101,7 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
MageObject mageObject = game.getObject(spellId);
if (!(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) {
if (!(mageObject instanceof Spell) || ((Spell) mageObject).isCopy()) {
return false;
} else {
Card sourceCard = game.getCard(spellId);

View file

@ -1,23 +1,20 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class SpoilsOfTheVault extends CardImpl {
@ -71,7 +68,7 @@ class SpoilsOfTheVaultEffect extends OneShotEffect {
for (Card card : controller.getLibrary().getCards(game)) {
if (card != null) {
cardsToReveal.add(card);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
controller.moveCards(card, Zone.HAND, source, game);
break;
} else {

View file

@ -1,9 +1,5 @@
package mage.cards.t;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -21,9 +17,14 @@ import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class ThoughtHemorrhage extends CardImpl {
@ -74,7 +75,7 @@ class ThoughtHemorrhageEffect extends OneShotEffect {
targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game);
int cardsFound = 0;
for (Card card : targetPlayer.getHand().getCards(game)) {
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
cardsFound++;
}
}

View file

@ -1,23 +1,20 @@
package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public final class TunnelVision extends CardImpl {
@ -76,7 +73,7 @@ class TunnelVisionEffect extends OneShotEffect {
for (Card card : targetPlayer.getLibrary().getCards(game)) {
cardsToReveal.add(card);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
namedCard = card;
break;
}

View file

@ -1,7 +1,5 @@
package mage.cards.v;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -18,9 +16,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com & L_J
*/
public final class VexingArcanix extends CardImpl {
@ -74,7 +74,7 @@ class VexingArcanixEffect extends OneShotEffect {
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards(sourceObject.getIdName(), cards, game);
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
player.moveCards(cards, Zone.HAND, source, game);
} else {
player.moveCards(cards, Zone.GRAVEYARD, source, game);

View file

@ -0,0 +1,132 @@
package mage.cards.v;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroySourceEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInHand;
/**
*
* @author jeffwadsworth
*/
public final class VolrathsDungeon extends CardImpl {
public VolrathsDungeon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}");
// Pay 5 life: Destroy Volrath's Dungeon. Any player may activate this ability but only during his or her turn.
ActivatedAbility ability = new SimpleActivatedAbility(
Zone.BATTLEFIELD,
new DestroySourceEffect().setText("Destroy {this}. Any player may activate this ability but only during his or her turn."),
new PayLifeActivePlayerCost(5));
ability.setMayActivate(TargetController.ACTIVE);
this.addAbility(ability);
// Discard a card: Target player puts a card from his or her hand on top of his or her library. Activate this ability only any time you could cast a sorcery.
FilterCard filter = new FilterCard("a card for payment");
Ability ability2 = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new VolrathsDungeonEffect(), new DiscardCardCost(filter));
ability2.addTarget(new TargetPlayer());
this.addAbility(ability2);
}
public VolrathsDungeon(final VolrathsDungeon card) {
super(card);
}
@Override
public VolrathsDungeon copy() {
return new VolrathsDungeon(this);
}
}
class PayLifeActivePlayerCost extends CostImpl {
private final DynamicValue amount;
public PayLifeActivePlayerCost(int amount) {
this.amount = new StaticValue(amount);
this.text = "Pay " + Integer.toString(amount) + " life";
}
public PayLifeActivePlayerCost(DynamicValue amount, String text) {
this.amount = amount.copy();
this.text = "Pay " + text;
}
public PayLifeActivePlayerCost(PayLifeActivePlayerCost cost) {
super(cost);
this.amount = cost.amount.copy();
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
int lifeToPayAmount = amount.calculate(game, ability, null);
return game.getPlayer(game.getActivePlayerId()).getLife() >= lifeToPayAmount;
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int lifeToPayAmount = amount.calculate(game, ability, null);
Player activatingPlayer = game.getPlayer(game.getActivePlayerId());
if (activatingPlayer != null
&& activatingPlayer.chooseUse(Outcome.LoseLife, "Do you wish to pay + lifeToPayAmount + life?", ability, game)) {
this.paid = game.getPlayer(game.getActivePlayerId()).loseLife(lifeToPayAmount, game, false) == lifeToPayAmount;
}
return paid;
}
@Override
public PayLifeActivePlayerCost copy() {
return new PayLifeActivePlayerCost(this);
}
}
class VolrathsDungeonEffect extends OneShotEffect {
public VolrathsDungeonEffect() {
super(Outcome.Detriment);
this.staticText = "Target player puts a card from his or her hand on top of his or her library";
}
public VolrathsDungeonEffect(final VolrathsDungeonEffect effect) {
super(effect);
}
@Override
public VolrathsDungeonEffect copy() {
return new VolrathsDungeonEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetedPlayer = game.getPlayer(source.getFirstTarget());
if (targetedPlayer != null) {
TargetCardInHand target = new TargetCardInHand();
if (targetedPlayer.choose(Outcome.Detriment, targetedPlayer.getHand(), target, game)) {
Card card = game.getCard(target.getFirstTarget());
return targetedPlayer.putCardOnTopXOfLibrary(card, game, source, 0);
}
}
return false;
}
}

View file

@ -28,6 +28,7 @@ public final class Exodus extends ExpansionSet {
this.numBoosterUncommon = 3;
this.numBoosterRare = 1;
this.ratioBoosterMythic = 0;
cards.add(new SetCardInfo("Aether Tide", 27, Rarity.COMMON, mage.cards.a.AetherTide.class));
cards.add(new SetCardInfo("Allay", 1, Rarity.COMMON, mage.cards.a.Allay.class));
cards.add(new SetCardInfo("Anarchist", 79, Rarity.COMMON, mage.cards.a.Anarchist.class));
cards.add(new SetCardInfo("Angelic Blessing", 2, Rarity.COMMON, mage.cards.a.AngelicBlessing.class));
@ -44,12 +45,14 @@ public final class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Convalescence", 5, Rarity.RARE, mage.cards.c.Convalescence.class));
cards.add(new SetCardInfo("Crashing Boars", 108, Rarity.UNCOMMON, mage.cards.c.CrashingBoars.class));
cards.add(new SetCardInfo("Culling the Weak", 55, Rarity.COMMON, mage.cards.c.CullingTheWeak.class));
cards.add(new SetCardInfo("Cunning", 28, Rarity.COMMON, mage.cards.c.Cunning.class));
cards.add(new SetCardInfo("Curiosity", 29, Rarity.UNCOMMON, mage.cards.c.Curiosity.class));
cards.add(new SetCardInfo("Cursed Flesh", 56, Rarity.COMMON, mage.cards.c.CursedFlesh.class));
cards.add(new SetCardInfo("Dauthi Cutthroat", 57, Rarity.UNCOMMON, mage.cards.d.DauthiCutthroat.class));
cards.add(new SetCardInfo("Dauthi Jackal", 58, Rarity.COMMON, mage.cards.d.DauthiJackal.class));
cards.add(new SetCardInfo("Dauthi Warlord", 59, Rarity.UNCOMMON, mage.cards.d.DauthiWarlord.class));
cards.add(new SetCardInfo("Death's Duet", 60, Rarity.COMMON, mage.cards.d.DeathsDuet.class));
cards.add(new SetCardInfo("Dizzying Gaze", 81, Rarity.COMMON, mage.cards.d.DizzyingGaze.class));
cards.add(new SetCardInfo("Dominating Licid", 30, Rarity.RARE, mage.cards.d.DominatingLicid.class));
cards.add(new SetCardInfo("Elven Palisade", 109, Rarity.UNCOMMON, mage.cards.e.ElvenPalisade.class));
cards.add(new SetCardInfo("Elvish Berserker", 110, Rarity.COMMON, mage.cards.e.ElvishBerserker.class));
@ -65,15 +68,18 @@ public final class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Forbid", 35, Rarity.UNCOMMON, mage.cards.f.Forbid.class));
cards.add(new SetCardInfo("Fugue", 62, Rarity.UNCOMMON, mage.cards.f.Fugue.class));
cards.add(new SetCardInfo("Furnace Brood", 84, Rarity.COMMON, mage.cards.f.FurnaceBrood.class));
cards.add(new SetCardInfo("Grollub", 63, Rarity.COMMON, mage.cards.g.Grollub.class));
cards.add(new SetCardInfo("Hatred", 64, Rarity.RARE, mage.cards.h.Hatred.class));
cards.add(new SetCardInfo("High Ground", 7, Rarity.UNCOMMON, mage.cards.h.HighGround.class));
cards.add(new SetCardInfo("Jackalope Herd", 111, Rarity.COMMON, mage.cards.j.JackalopeHerd.class));
cards.add(new SetCardInfo("Keeper of the Beasts", 112, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheBeasts.class));
cards.add(new SetCardInfo("Keeper of the Dead", 65, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheDead.class));
cards.add(new SetCardInfo("Keeper of the Flame", 85, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheFlame.class));
cards.add(new SetCardInfo("Keeper of the Light", 8, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheLight.class));
cards.add(new SetCardInfo("Keeper of the Mind", 36, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheMind.class));
cards.add(new SetCardInfo("Killer Whale", 37, Rarity.UNCOMMON, mage.cards.k.KillerWhale.class));
cards.add(new SetCardInfo("Kor Chant", 9, Rarity.COMMON, mage.cards.k.KorChant.class));
cards.add(new SetCardInfo("Limited Resources", 10, Rarity.RARE, mage.cards.l.LimitedResources.class));
cards.add(new SetCardInfo("Mage il-Vec", 86, Rarity.COMMON, mage.cards.m.MageIlVec.class));
cards.add(new SetCardInfo("Manabond", 113, Rarity.RARE, mage.cards.m.Manabond.class));
cards.add(new SetCardInfo("Mana Breach", 38, Rarity.UNCOMMON, mage.cards.m.ManaBreach.class));
@ -81,11 +87,13 @@ public final class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Medicine Bag", 133, Rarity.UNCOMMON, mage.cards.m.MedicineBag.class));
cards.add(new SetCardInfo("Memory Crystal", 134, Rarity.RARE, mage.cards.m.MemoryCrystal.class));
cards.add(new SetCardInfo("Merfolk Looter", 39, Rarity.COMMON, mage.cards.m.MerfolkLooter.class));
cards.add(new SetCardInfo("Mind Maggots", 66, Rarity.UNCOMMON, mage.cards.m.MindMaggots.class));
cards.add(new SetCardInfo("Mindless Automaton", 135, Rarity.RARE, mage.cards.m.MindlessAutomaton.class));
cards.add(new SetCardInfo("Mind Over Matter", 40, Rarity.RARE, mage.cards.m.MindOverMatter.class));
cards.add(new SetCardInfo("Mirozel", 41, Rarity.UNCOMMON, mage.cards.m.Mirozel.class));
cards.add(new SetCardInfo("Mirri, Cat Warrior", 114, Rarity.RARE, mage.cards.m.MirriCatWarrior.class));
cards.add(new SetCardInfo("Mogg Assassin", 88, Rarity.UNCOMMON, mage.cards.m.MoggAssassin.class));
cards.add(new SetCardInfo("Monstrous Hound", 89, Rarity.RARE, mage.cards.m.MonstrousHound.class));
cards.add(new SetCardInfo("Nausea", 67, Rarity.COMMON, mage.cards.n.Nausea.class));
cards.add(new SetCardInfo("Necrologia", 68, Rarity.UNCOMMON, mage.cards.n.Necrologia.class));
cards.add(new SetCardInfo("Null Brooch", 136, Rarity.RARE, mage.cards.n.NullBrooch.class));
@ -98,6 +106,7 @@ public final class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Onslaught", 92, Rarity.COMMON, mage.cards.o.Onslaught.class));
cards.add(new SetCardInfo("Paladin en-Vec", 12, Rarity.RARE, mage.cards.p.PaladinEnVec.class));
cards.add(new SetCardInfo("Pandemonium", 93, Rarity.RARE, mage.cards.p.Pandemonium.class));
cards.add(new SetCardInfo("Paroxysm", 94, Rarity.UNCOMMON, mage.cards.p.Paroxysm.class));
cards.add(new SetCardInfo("Peace of Mind", 13, Rarity.UNCOMMON, mage.cards.p.PeaceOfMind.class));
cards.add(new SetCardInfo("Pegasus Stampede", 14, Rarity.UNCOMMON, mage.cards.p.PegasusStampede.class));
cards.add(new SetCardInfo("Penance", 15, Rarity.UNCOMMON, mage.cards.p.Penance.class));
@ -154,6 +163,7 @@ public final class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Treasure Hunter", 23, Rarity.UNCOMMON, mage.cards.t.TreasureHunter.class));
cards.add(new SetCardInfo("Treasure Trove", 50, Rarity.UNCOMMON, mage.cards.t.TreasureTrove.class));
cards.add(new SetCardInfo("Vampire Hounds", 77, Rarity.COMMON, mage.cards.v.VampireHounds.class));
cards.add(new SetCardInfo("Volrath's Dungeon", 78, Rarity.RARE, mage.cards.v.VolrathsDungeon.class));
cards.add(new SetCardInfo("Wall of Nets", 24, Rarity.RARE, mage.cards.w.WallOfNets.class));
cards.add(new SetCardInfo("Wayward Soul", 51, Rarity.COMMON, mage.cards.w.WaywardSoul.class));
cards.add(new SetCardInfo("Welkin Hawk", 25, Rarity.COMMON, mage.cards.w.WelkinHawk.class));

View file

@ -20,6 +20,7 @@ public final class FifthEdition extends ExpansionSet {
this.numBoosterUncommon = 3;
this.numBoosterRare = 1;
this.ratioBoosterMythic = 0;
cards.add(new SetCardInfo("Abbey Gargoyles", 1, Rarity.UNCOMMON, mage.cards.a.AbbeyGargoyles.class));
cards.add(new SetCardInfo("Abyssal Specter", 139, Rarity.UNCOMMON, mage.cards.a.AbyssalSpecter.class));
cards.add(new SetCardInfo("Adarkar Wastes", 410, Rarity.RARE, mage.cards.a.AdarkarWastes.class));
@ -89,6 +90,7 @@ public final class FifthEdition extends ExpansionSet {
cards.add(new SetCardInfo("Circle of Protection: White", 21, Rarity.COMMON, mage.cards.c.CircleOfProtectionWhite.class));
cards.add(new SetCardInfo("City of Brass", 413, Rarity.RARE, mage.cards.c.CityOfBrass.class));
cards.add(new SetCardInfo("Clay Statue", 355, Rarity.COMMON, mage.cards.c.ClayStatue.class));
cards.add(new SetCardInfo("Cloak of Confusion", 151, Rarity.COMMON, mage.cards.c.CloakOfConfusion.class));
cards.add(new SetCardInfo("Clockwork Beast", 356, Rarity.RARE, mage.cards.c.ClockworkBeast.class));
cards.add(new SetCardInfo("Clockwork Steed", 357, Rarity.UNCOMMON, mage.cards.c.ClockworkSteed.class));
cards.add(new SetCardInfo("Cockatrice", 284, Rarity.RARE, mage.cards.c.Cockatrice.class));
@ -165,8 +167,8 @@ public final class FifthEdition extends ExpansionSet {
cards.add(new SetCardInfo("Flood", 87, Rarity.COMMON, mage.cards.f.Flood.class));
cards.add(new SetCardInfo("Flying Carpet", 371, Rarity.RARE, mage.cards.f.FlyingCarpet.class));
cards.add(new SetCardInfo("Fog", 293, Rarity.COMMON, mage.cards.f.Fog.class));
cards.add(new SetCardInfo("Force Spike", 88, Rarity.COMMON, mage.cards.f.ForceSpike.class));
cards.add(new SetCardInfo("Force of Nature", 294, Rarity.RARE, mage.cards.f.ForceOfNature.class));
cards.add(new SetCardInfo("Force Spike", 88, Rarity.COMMON, mage.cards.f.ForceSpike.class));
cards.add(new SetCardInfo("Forest", 446, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Forest", 447, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Forest", 448, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));

View file

@ -86,7 +86,7 @@ public final class GuildsOfRavnica extends ExpansionSet {
cards.add(new SetCardInfo("Deadly Visit", 68, Rarity.COMMON, mage.cards.d.DeadlyVisit.class));
cards.add(new SetCardInfo("Deafening Clarion", 165, Rarity.RARE, mage.cards.d.DeafeningClarion.class));
cards.add(new SetCardInfo("Demotion", 9, Rarity.UNCOMMON, mage.cards.d.Demotion.class));
cards.add(new SetCardInfo("Devious Cover-up", 35, Rarity.COMMON, mage.cards.d.DeviousCoverUp.class));
cards.add(new SetCardInfo("Devious Cover-Up", 35, Rarity.COMMON, mage.cards.d.DeviousCoverUp.class));
cards.add(new SetCardInfo("Devkarin Dissident", 127, Rarity.COMMON, mage.cards.d.DevkarinDissident.class));
cards.add(new SetCardInfo("Dimir Guildgate", 245, Rarity.COMMON, mage.cards.d.DimirGuildgate.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Dimir Guildgate", 246, Rarity.COMMON, mage.cards.d.DimirGuildgate.class, NON_FULL_USE_VARIOUS));

View file

@ -5,7 +5,6 @@ import mage.constants.Rarity;
import mage.constants.SetType;
/**
*
* @author North
*/
public final class IceAge extends ExpansionSet {
@ -25,6 +24,7 @@ public final class IceAge extends ExpansionSet {
this.numBoosterUncommon = 3;
this.numBoosterRare = 1;
this.ratioBoosterMythic = 0;
cards.add(new SetCardInfo("Abyssal Specter", 113, Rarity.UNCOMMON, mage.cards.a.AbyssalSpecter.class));
cards.add(new SetCardInfo("Adarkar Sentinel", 306, Rarity.UNCOMMON, mage.cards.a.AdarkarSentinel.class));
cards.add(new SetCardInfo("Adarkar Wastes", 351, Rarity.RARE, mage.cards.a.AdarkarWastes.class));
@ -70,6 +70,7 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Circle of Protection: Red", 15, Rarity.COMMON, mage.cards.c.CircleOfProtectionRed.class));
cards.add(new SetCardInfo("Circle of Protection: White", 16, Rarity.COMMON, mage.cards.c.CircleOfProtectionWhite.class));
cards.add(new SetCardInfo("Clairvoyance", 63, Rarity.COMMON, mage.cards.c.Clairvoyance.class));
cards.add(new SetCardInfo("Cloak of Confusion", 117, Rarity.COMMON, mage.cards.c.CloakOfConfusion.class));
cards.add(new SetCardInfo("Cold Snap", 17, Rarity.UNCOMMON, mage.cards.c.ColdSnap.class));
cards.add(new SetCardInfo("Conquer", 180, Rarity.UNCOMMON, mage.cards.c.Conquer.class));
cards.add(new SetCardInfo("Cooperation", 18, Rarity.COMMON, mage.cards.c.Cooperation.class));
@ -86,6 +87,7 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Diabolic Vision", 284, Rarity.UNCOMMON, mage.cards.d.DiabolicVision.class));
cards.add(new SetCardInfo("Dire Wolves", 230, Rarity.COMMON, mage.cards.d.DireWolves.class));
cards.add(new SetCardInfo("Disenchant", 20, Rarity.COMMON, mage.cards.d.Disenchant.class));
cards.add(new SetCardInfo("Dread Wight", 122, Rarity.RARE, mage.cards.d.DreadWight.class));
cards.add(new SetCardInfo("Dreams of the Dead", 66, Rarity.UNCOMMON, mage.cards.d.DreamsOfTheDead.class));
cards.add(new SetCardInfo("Drift of the Dead", 123, Rarity.UNCOMMON, mage.cards.d.DriftOfTheDead.class));
cards.add(new SetCardInfo("Drought", 21, Rarity.UNCOMMON, mage.cards.d.Drought.class));
@ -205,12 +207,12 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Lure", 253, Rarity.UNCOMMON, mage.cards.l.Lure.class));
cards.add(new SetCardInfo("Magus of the Unseen", 82, Rarity.RARE, mage.cards.m.MagusOfTheUnseen.class));
cards.add(new SetCardInfo("Malachite Talisman", 328, Rarity.UNCOMMON, mage.cards.m.MalachiteTalisman.class));
cards.add(new SetCardInfo("Marton Stromgald", 204, Rarity.RARE, mage.cards.m.MartonStromgald.class));
cards.add(new SetCardInfo("Melee", 199, Rarity.UNCOMMON, mage.cards.m.Melee.class));
cards.add(new SetCardInfo("Melting", 200, Rarity.UNCOMMON, mage.cards.m.Melting.class));
cards.add(new SetCardInfo("Marton Stromgald", 199, Rarity.RARE, mage.cards.m.MartonStromgald.class));
cards.add(new SetCardInfo("Melee", 200, Rarity.UNCOMMON, mage.cards.m.Melee.class));
cards.add(new SetCardInfo("Melting", 201, Rarity.UNCOMMON, mage.cards.m.Melting.class));
cards.add(new SetCardInfo("Merieke Ri Berit", 297, Rarity.RARE, mage.cards.m.MeriekeRiBerit.class));
cards.add(new SetCardInfo("Mesmeric Trance", 83, Rarity.RARE, mage.cards.m.MesmericTrance.class));
cards.add(new SetCardInfo("Meteor Shower", 201, Rarity.COMMON, mage.cards.m.MeteorShower.class));
cards.add(new SetCardInfo("Meteor Shower", 202, Rarity.COMMON, mage.cards.m.MeteorShower.class));
cards.add(new SetCardInfo("Mind Ravel", 147, Rarity.COMMON, mage.cards.m.MindRavel.class));
cards.add(new SetCardInfo("Mind Warp", 148, Rarity.UNCOMMON, mage.cards.m.MindWarp.class));
cards.add(new SetCardInfo("Minion of Leshrac", 150, Rarity.RARE, mage.cards.m.MinionOfLeshrac.class));
@ -219,12 +221,12 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Mole Worms", 152, Rarity.UNCOMMON, mage.cards.m.MoleWorms.class));
cards.add(new SetCardInfo("Monsoon", 298, Rarity.RARE, mage.cards.m.Monsoon.class));
cards.add(new SetCardInfo("Moor Fiend", 153, Rarity.COMMON, mage.cards.m.MoorFiend.class));
cards.add(new SetCardInfo("Mountain Goat", 202, Rarity.COMMON, mage.cards.m.MountainGoat.class));
cards.add(new SetCardInfo("Mountain Goat", 203, Rarity.COMMON, mage.cards.m.MountainGoat.class));
cards.add(new SetCardInfo("Mountain Titan", 299, Rarity.RARE, mage.cards.m.MountainTitan.class));
cards.add(new SetCardInfo("Mountain", 376, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 377, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 378, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mudslide", 203, Rarity.RARE, mage.cards.m.Mudslide.class));
cards.add(new SetCardInfo("Mudslide", 204, Rarity.RARE, mage.cards.m.Mudslide.class));
cards.add(new SetCardInfo("Mystic Might", 86, Rarity.RARE, mage.cards.m.MysticMight.class));
cards.add(new SetCardInfo("Mystic Remora", 87, Rarity.COMMON, mage.cards.m.MysticRemora.class));
cards.add(new SetCardInfo("Nacre Talisman", 329, Rarity.UNCOMMON, mage.cards.n.NacreTalisman.class));

View file

@ -60,6 +60,7 @@ public final class MastersEditionII extends ExpansionSet {
cards.add(new SetCardInfo("Burnout", 121, Rarity.UNCOMMON, mage.cards.b.Burnout.class));
cards.add(new SetCardInfo("Carapace", 155, Rarity.COMMON, mage.cards.c.Carapace.class));
cards.add(new SetCardInfo("Caribou Range", 8, Rarity.RARE, mage.cards.c.CaribouRange.class));
cards.add(new SetCardInfo("Cloak of Confusion", 82, Rarity.COMMON, mage.cards.c.CloakOfConfusion.class));
cards.add(new SetCardInfo("Clockwork Steed", 205, Rarity.UNCOMMON, mage.cards.c.ClockworkSteed.class));
cards.add(new SetCardInfo("Combat Medic", 9, Rarity.COMMON, mage.cards.c.CombatMedic.class));
cards.add(new SetCardInfo("Conquer", 122, Rarity.UNCOMMON, mage.cards.c.Conquer.class));

View file

@ -104,6 +104,7 @@ public final class MastersEditionIV extends ExpansionSet {
cards.add(new SetCardInfo("Dragon Engine", 197, Rarity.COMMON, mage.cards.d.DragonEngine.class));
cards.add(new SetCardInfo("Drain Power", 46, Rarity.RARE, mage.cards.d.DrainPower.class));
cards.add(new SetCardInfo("Dread Reaper", 78, Rarity.RARE, mage.cards.d.DreadReaper.class));
cards.add(new SetCardInfo("Dread Wight", 79, Rarity.UNCOMMON, mage.cards.d.DreadWight.class));
cards.add(new SetCardInfo("Drop of Honey", 150, Rarity.RARE, mage.cards.d.DropOfHoney.class));
cards.add(new SetCardInfo("Drowned", 47, Rarity.COMMON, mage.cards.d.Drowned.class));
cards.add(new SetCardInfo("Dust to Dust", 11, Rarity.UNCOMMON, mage.cards.d.DustToDust.class));

View file

@ -130,7 +130,9 @@ public final class Prophecy extends ExpansionSet {
cards.add(new SetCardInfo("Root Cage", 122, Rarity.UNCOMMON, mage.cards.r.RootCage.class));
cards.add(new SetCardInfo("Samite Sanctuary", 21, Rarity.RARE, mage.cards.s.SamiteSanctuary.class));
cards.add(new SetCardInfo("Scoria Cat", 101, Rarity.UNCOMMON, mage.cards.s.ScoriaCat.class));
cards.add(new SetCardInfo("Search for Survivors", 102, Rarity.RARE, mage.cards.s.SearchForSurvivors.class));
cards.add(new SetCardInfo("Searing Wind", 103, Rarity.RARE, mage.cards.s.SearingWind.class));
cards.add(new SetCardInfo("Sheltering Prayers", 22, Rarity.RARE, mage.cards.s.ShelteringPrayers.class));
cards.add(new SetCardInfo("Shield Dancer", 23, Rarity.UNCOMMON, mage.cards.s.ShieldDancer.class));
cards.add(new SetCardInfo("Shrouded Serpent", 47, Rarity.RARE, mage.cards.s.ShroudedSerpent.class));
cards.add(new SetCardInfo("Silt Crawler", 123, Rarity.COMMON, mage.cards.s.SiltCrawler.class));

View file

@ -137,6 +137,7 @@ public final class Starter1999 extends ExpansionSet {
cards.add(new SetCardInfo("Psychic Transfer", 46, Rarity.RARE, mage.cards.p.PsychicTransfer.class));
cards.add(new SetCardInfo("Raging Goblin", 114, Rarity.COMMON, mage.cards.r.RagingGoblin.class));
cards.add(new SetCardInfo("Raise Dead", 85, Rarity.COMMON, mage.cards.r.RaiseDead.class));
cards.add(new SetCardInfo("Ransack", 47, Rarity.RARE, mage.cards.r.Ransack.class));
cards.add(new SetCardInfo("Ravenous Rats", 86, Rarity.UNCOMMON, mage.cards.r.RavenousRats.class));
cards.add(new SetCardInfo("Relearn", 48, Rarity.UNCOMMON, mage.cards.r.Relearn.class));
cards.add(new SetCardInfo("Relentless Assault", 115, Rarity.RARE, mage.cards.r.RelentlessAssault.class));

View file

@ -1,4 +1,3 @@
package mage.sets;
import mage.cards.ExpansionSet;
@ -27,6 +26,7 @@ public final class Stronghold extends ExpansionSet {
this.numBoosterUncommon = 3;
this.numBoosterRare = 1;
this.ratioBoosterMythic = 0;
cards.add(new SetCardInfo("Acidic Sliver", 126, Rarity.UNCOMMON, mage.cards.a.AcidicSliver.class));
cards.add(new SetCardInfo("Amok", 76, Rarity.RARE, mage.cards.a.Amok.class));
cards.add(new SetCardInfo("Awakening", 101, Rarity.RARE, mage.cards.a.Awakening.class));
@ -77,6 +77,7 @@ public final class Stronghold extends ExpansionSet {
cards.add(new SetCardInfo("Hermit Druid", 108, Rarity.RARE, mage.cards.h.HermitDruid.class));
cards.add(new SetCardInfo("Hesitation", 33, Rarity.UNCOMMON, mage.cards.h.Hesitation.class));
cards.add(new SetCardInfo("Hibernation Sliver", 128, Rarity.UNCOMMON, mage.cards.h.HibernationSliver.class));
cards.add(new SetCardInfo("Hidden Retreat", 6, Rarity.RARE, mage.cards.h.HiddenRetreat.class));
cards.add(new SetCardInfo("Honor Guard", 7, Rarity.COMMON, mage.cards.h.HonorGuard.class));
cards.add(new SetCardInfo("Horn of Greed", 135, Rarity.RARE, mage.cards.h.HornOfGreed.class));
cards.add(new SetCardInfo("Hornet Cannon", 136, Rarity.UNCOMMON, mage.cards.h.HornetCannon.class));
@ -109,11 +110,14 @@ public final class Stronghold extends ExpansionSet {
cards.add(new SetCardInfo("Provoke", 113, Rarity.COMMON, mage.cards.p.Provoke.class));
cards.add(new SetCardInfo("Pursuit of Knowledge", 10, Rarity.RARE, mage.cards.p.PursuitOfKnowledge.class));
cards.add(new SetCardInfo("Rabid Rats", 67, Rarity.COMMON, mage.cards.r.RabidRats.class));
cards.add(new SetCardInfo("Ransack", 39, Rarity.UNCOMMON, mage.cards.r.Ransack.class));
cards.add(new SetCardInfo("Rebound", 40, Rarity.UNCOMMON, mage.cards.r.Rebound.class));
cards.add(new SetCardInfo("Reins of Power", 41, Rarity.RARE, mage.cards.r.ReinsOfPower.class));
cards.add(new SetCardInfo("Revenant", 68, Rarity.RARE, mage.cards.r.Revenant.class));
cards.add(new SetCardInfo("Rolling Stones", 11, Rarity.RARE, mage.cards.r.RollingStones.class));
cards.add(new SetCardInfo("Ruination", 95, Rarity.RARE, mage.cards.r.Ruination.class));
cards.add(new SetCardInfo("Sacred Ground", 12, Rarity.RARE, mage.cards.s.SacredGround.class));
cards.add(new SetCardInfo("Samite Blessing", 13, Rarity.COMMON, mage.cards.s.SamiteBlessing.class));
cards.add(new SetCardInfo("Scapegoat", 14, Rarity.UNCOMMON, mage.cards.s.Scapegoat.class));
cards.add(new SetCardInfo("Seething Anger", 96, Rarity.COMMON, mage.cards.s.SeethingAnger.class));
cards.add(new SetCardInfo("Serpent Warrior", 69, Rarity.COMMON, mage.cards.s.SerpentWarrior.class));
@ -123,7 +127,7 @@ public final class Stronghold extends ExpansionSet {
cards.add(new SetCardInfo("Shock", 98, Rarity.COMMON, mage.cards.s.Shock.class));
cards.add(new SetCardInfo("Sift", 42, Rarity.COMMON, mage.cards.s.Sift.class));
cards.add(new SetCardInfo("Silver Wyvern", 43, Rarity.RARE, mage.cards.s.SilverWyvern.class));
cards.add(new SetCardInfo("Skeleton Scavengers", 20, Rarity.RARE, mage.cards.s.SkeletonScavengers.class));
cards.add(new SetCardInfo("Skeleton Scavengers", 70, Rarity.RARE, mage.cards.s.SkeletonScavengers.class));
cards.add(new SetCardInfo("Skyshroud Archer", 114, Rarity.COMMON, mage.cards.s.SkyshroudArcher.class));
cards.add(new SetCardInfo("Skyshroud Falcon", 16, Rarity.COMMON, mage.cards.s.SkyshroudFalcon.class));
cards.add(new SetCardInfo("Skyshroud Troopers", 115, Rarity.COMMON, mage.cards.s.SkyshroudTroopers.class));

View file

@ -9,7 +9,6 @@
<version>1.4.32</version>
</parent>
<groupId>org.mage</groupId>
<artifactId>mage-stats</artifactId>
<packaging>war</packaging>
<name>XMage Stats Web Service</name>

View file

@ -1,13 +1,5 @@
package org.mage.test.clientside.base;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Date;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.game.match.MatchOptions;
@ -20,7 +12,15 @@ import mage.interfaces.callback.ClientCallback;
import mage.server.Main;
import mage.sets.Sets;
import mage.util.Logging;
import mage.view.*;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Date;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Base for starting Mage server. Controls interactions between MageAPI and Mage
@ -189,9 +189,9 @@ public class MageBase {
} catch (MageException ex) {
logger.log(Level.SEVERE, null, ex);
} catch (RemoteException ex) {
logger.log(Level.SEVERE, "Unable to connect to server - ", ex);
logger.log(Level.SEVERE, "Unable connect to server - ", ex);
} catch (NotBoundException ex) {
logger.log(Level.SEVERE, "Unable to connect to server - ", ex);
logger.log(Level.SEVERE, "Unable connect to server - ", ex);
}
}
@ -205,7 +205,7 @@ public class MageBase {
}
gameView = server.getGameView(gameId, sessionId, playerId);
for (CardView card : gameView.getHand().values()) {
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
return true;
}
}
@ -224,7 +224,7 @@ public class MageBase {
CardsView cards = gameView.getHand();
CardView cardToPlay = null;
for (CardView card : cards.values()) {
if (card.getName().equals(cardName)) {
if (CardUtil.haveSameNames(card.getName(), cardName)) {
cardToPlay = card;
}
}

View file

@ -59,7 +59,7 @@ public class LicidAbilityTest extends CardTestPlayerBase {
execute();
assertActionCount(playerA, 0);
assertActionsCount(playerA, 0);
assertAbility(playerA, "Pillarfield Ox", HasteAbility.getInstance(), false);
assertAbility(playerA, "Enraging Licid", new LicidAbility(new ColoredManaCost(ColoredManaSymbol.R), new ColoredManaCost(ColoredManaSymbol.R)), true);
assertType("Enraging Licid", CardType.ENCHANTMENT, false);

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.abilities.equipped;
import mage.constants.PhaseStep;
@ -9,7 +8,6 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class EquipRestrictedTest extends CardTestPlayerBase {
@ -21,7 +19,7 @@ public class EquipRestrictedTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Leonin Scimitar");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: Attach target Equipment you control to target creature you control.", "Leonin Scimitar");
addTarget(playerB, "Silvercout Lion");
addTarget(playerB, "Silvercoat Lion");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
@ -43,7 +41,7 @@ public class EquipRestrictedTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Konda's Banner");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: Attach target Equipment you control to target creature you control.", "Konda's Banner");
addTarget(playerB, "Silvercout Lion");
addTarget(playerB, "Silvercoat Lion");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();

View file

@ -37,32 +37,30 @@ public class CipherTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
// cast spell, create copy token, exile spell card and encode it to that token of Roil Elemental
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Stolen Identity", "Roil Elemental");
setChoice(playerA, "Yes");
setChoice(playerA, "Yes"); // Cipher activate
addTarget(playerA, "Roil Elemental"); // Cipher target for encode
checkPermanentCount("playerA must have Roil Elemental", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Roil Elemental", 1);
checkPermanentCount("playerB must have Roil Elemental", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Roil Elemental", 1);
checkExileCount("Stolen Identity must be in exile zone", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Stolen Identity", 1);
// Roil Elemental must activated on new land
playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Mountain");
setChoice(playerA, "Yes"); // activate landfall to control opponent creature
addTarget(playerA, "Silvercoat Lion"); // Triggered ability of copied Roil Elemental to gain control
checkPermanentCount("must gain control of Lion", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Silvercoat Lion", 1);
checkPermanentCount("must lose control of Lion", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Silvercoat Lion", 0);
attack(3, playerA, "Roil Elemental"); // Creature 3/2
addTarget(playerA, "Pillarfield Ox");
// on attack must activated ability to free cast
attack(5, playerA, "Roil Elemental");
setChoice(playerA, "Yes"); // activate free cast of encoded card
checkPermanentCount("playerA must have 2 Roil Elemental", 5, PhaseStep.POSTCOMBAT_MAIN, playerA, "Roil Elemental", 2);
checkPermanentCount("playerB must have Roil Elemental", 5, PhaseStep.POSTCOMBAT_MAIN, playerB, "Roil Elemental", 1);
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 17);
assertExileCount(playerA, "Stolen Identity", 1);
assertPermanentCount(playerA, "Mountain", 1);
assertPermanentCount(playerB, "Pillarfield Ox", 1);
assertPermanentCount(playerA, "Pillarfield Ox", 1); // a copy from the cipered Stolen Identity caused by the Roil Elelemtal Attack
assertPermanentCount(playerB, "Silvercoat Lion", 0);
assertPermanentCount(playerA, "Silvercoat Lion", 1); // Gain control from triggered ability of the copied Roil Elemental ????? TARGET ???
assertPermanentCount(playerB, "Roil Elemental", 1);
assertPermanentCount(playerA, "Roil Elemental", 1);
assertLife(playerB, 17); // -3 by Roil
}
}

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.abilities.keywords;
import mage.constants.PhaseStep;
@ -7,29 +6,27 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class EchoTest extends CardTestPlayerBase {
/*
* I flickered an Avalanche Riders with its Echo trigger on the stack with Restoration Angel.
* When the trigger resolved, my Riders was sacrificed, even though it should have been
* considered a new permanent.
*/
/*
* I flickered an Avalanche Riders with its Echo trigger on the stack with Restoration Angel.
* When the trigger resolved, my Riders was sacrificed, even though it should have been
* considered a new permanent.
*/
@Test
public void testEchoTriggerChecksIdentity() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
// Avalanche Riders Creature - Human Nomad 2/2
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
// Avalanche Riders Creature - Human Nomad 2/2 {3}{R}
// Haste
// Echo (At the beginning of your upkeep, if this came under your control since the beginning of your last upkeep, sacrifice it unless you pay its echo cost.)
// When Avalanche Riders enters the battlefield, destroy target land.
addCard(Zone.HAND, playerA, "Avalanche Riders");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
// Restoration Angel {3}{W}
// Flash
// Flying
@ -37,12 +34,19 @@ public class EchoTest extends CardTestPlayerBase {
// then return that card to the battlefield under your control.
addCard(Zone.HAND, playerA, "Restoration Angel");
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
// cast Avalanche Riders and destroy forest
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Avalanche Riders");
addTarget(playerA, "Forest");
// Avalanche Riders go to echo, cast Restoration Angel to restore rider (do not apply echo with 4 mana)
activateManaAbility(3, PhaseStep.UPKEEP, playerA, "{T}: Add {W}");
activateManaAbility(3, PhaseStep.UPKEEP, playerA, "{T}: Add {W}");
activateManaAbility(3, PhaseStep.UPKEEP, playerA, "{T}: Add {W}");
activateManaAbility(3, PhaseStep.UPKEEP, playerA, "{T}: Add {W}");
castSpell(3, PhaseStep.UPKEEP, playerA, "Restoration Angel", null, "Echo {3}{R} <i>(At the beginning of your upkeep, if this came under your control since the beginning of your last upkeep, sacrifice it unless you pay its echo cost.)</i>");
addTarget(playerA, "Avalanche Riders");
setChoice(playerA, "Yes"); // raider do restore
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();
@ -52,7 +56,9 @@ public class EchoTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Avalanche Riders", 1);
assertPermanentCount(playerA, "Restoration Angel", 1);
assertPermanentCount(playerB, "Mountain", 0);
assertPermanentCount(playerB, "Forest", 0);
assertTappedCount("Plains", true, 4);
assertTappedCount("Mountain", true, 0);
}

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.abilities.keywords;
import mage.abilities.keyword.TrampleAbility;
@ -9,7 +8,6 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class FlashbackTest extends CardTestPlayerBase {
@ -71,10 +69,9 @@ public class FlashbackTest extends CardTestPlayerBase {
}
/**
*
* Test Granting Flashback to spells with X in manacost which have targeting
* requirements depending on the choice of X
*
* <p>
* Specific instance: Snapcaster Mage granting Flashback to Repeal
*/
@Test
@ -84,7 +81,7 @@ public class FlashbackTest extends CardTestPlayerBase {
addCard(Zone.GRAVEYARD, playerA, "Repeal", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Snapcaster Mage");
setChoice(playerA, "Repeal");
addTarget(playerA, "Repeal");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback");
setChoice(playerA, "X=2");
@ -100,10 +97,9 @@ public class FlashbackTest extends CardTestPlayerBase {
}
/**
*
* Test Granting Flashback to spells with X in mana cost, where X has no
* influence on targeting requirements
*
* <p>
* Specific instance: Snapcaster Mage granting Flashback to Blaze
*/
@Test
@ -115,7 +111,7 @@ public class FlashbackTest extends CardTestPlayerBase {
addCard(Zone.GRAVEYARD, playerA, "Blaze", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Snapcaster Mage");
setChoice(playerA, "Blaze");
addTarget(playerA, "Blaze");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback");
setChoice(playerA, "X=1");
@ -133,7 +129,6 @@ public class FlashbackTest extends CardTestPlayerBase {
/**
* My opponent put Iona on the battlefield using Unburial Rites, but my game
* log didn't show me the color he has chosen.
*
*/
@Test
public void testUnburialRites() {
@ -238,7 +233,7 @@ public class FlashbackTest extends CardTestPlayerBase {
* Ancestral Vision has no casting cost (this is different to a casting cost
* of {0}). Snapcaster Mage, for example, is able to give it flashback
* whilst it is in the graveyard.
*
* <p>
* However the controller should not be able to cast Ancestral Visions from
* the graveyard for {0} mana.
*/
@ -348,7 +343,7 @@ public class FlashbackTest extends CardTestPlayerBase {
// When Snapcaster Mage enters the battlefield, target instant or sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Snapcaster Mage");
setChoice(playerA, "Terminate");
addTarget(playerA, "Terminate");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback"); // Flashback Terminate
addTarget(playerA, "Icefall Regent");
@ -537,7 +532,7 @@ public class FlashbackTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Snapcaster Mage");
setChoice(playerA, "Force of Will");
addTarget(playerA, "Force of Will");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Snapcaster Mage");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback", null, "Lightning Bolt");

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