diff --git a/Mage.Client/serverlist.txt b/Mage.Client/serverlist.txt index 2e71716dc9..138f37fe11 100644 --- a/Mage.Client/serverlist.txt +++ b/Mage.Client/serverlist.txt @@ -1,6 +1,7 @@ XMage.de 1 (Europe/Germany) fast :xmage.de:17171 woogerworks (North America/USA) :xmage.woogerworks.com:17171 xmage.lukeskywalk.com (North America) :xmage.lukeskywalk.com:17171 +play.xmage.net (North America/Canada) :play.xmage.net:17171 XMageBr. (South America/Brazil) :magic.ncs3sistemas.com.br:17171 XMage.tahiti :xmage.tahiti.one:443 Seedds Server (Asia) :115.29.203.80:17171 diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java index 1869334557..09806d887e 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Card.java +++ b/Mage.Client/src/main/java/mage/client/cards/Card.java @@ -68,7 +68,6 @@ import static mage.client.constants.Constants.*; @SuppressWarnings("serial") public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener { - protected static final DefaultActionCallback callback = DefaultActionCallback.getInstance(); protected Point p; protected final CardDimensions dimension; @@ -367,7 +366,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis @Override public void mousePressed(MouseEvent e) { requestFocusInWindow(); - callback.mouseClicked(e, gameId, card); + DefaultActionCallback.instance.mouseClicked(gameId, card); } @Override diff --git a/Mage.Client/src/main/java/mage/client/combat/CombatManager.java b/Mage.Client/src/main/java/mage/client/combat/CombatManager.java index 695a507133..b9be142a83 100644 --- a/Mage.Client/src/main/java/mage/client/combat/CombatManager.java +++ b/Mage.Client/src/main/java/mage/client/combat/CombatManager.java @@ -19,20 +19,14 @@ import java.util.UUID; /** * @author noxx */ -public class CombatManager { +public enum CombatManager { - private static CombatManager combatManager; + instance; private final Map combatAttackers = new HashMap<>(); private final Map combatBlockers = new HashMap<>(); private int globalBlockersCount; // we need global counter as there are several combat groups - public static CombatManager getInstance() { - if (combatManager == null) { - combatManager = new CombatManager(); - } - return combatManager; - } private Point parentPoint; diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java index 447db6bc4b..f3f6548dfc 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java @@ -34,6 +34,7 @@ import java.awt.GridBagLayout; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; @@ -142,6 +143,17 @@ public final class CollectionViewerPanel extends JPanel { next.addActionListener(e -> mageBook.next()); buttonPanel.add(next); + JLabel label4 = new JLabel("Show cards or tokens:"); + label3.setAlignmentX(Component.LEFT_ALIGNMENT); + label3.setForeground(Color.white); + // spjspj - put back in after reorg of tokens -- jPanel1.add(label4); + + JCheckBox cardsOrTokens = new JCheckBox("Display Cards"); + cardsOrTokens.setSelected(true); + cardsOrTokens.setToolTipText("Select to show Cards or Tokens(and emblems) for the chosen set"); + cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected())); + // spjspj - put back in after reorg of tokens -- jPanel1.add(cardsOrTokens); + formats.addActionListener(e -> { if (mageBook != null) { String format = (String)formats.getSelectedItem(); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java index bf9fdb1ecf..f724d2d0d9 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java @@ -57,9 +57,17 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.FileNotFoundException; import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.logging.Level; +import mage.game.permanent.PermanentToken; +import mage.game.permanent.token.Token; +import mage.view.PermanentView; +import org.mage.plugins.card.images.CardDownloadData; +import static org.mage.plugins.card.images.DownloadPictures.getTokenCardUrls; /** * Mage book with cards and page flipping. @@ -113,7 +121,7 @@ public class MageBook extends JComponent { } pageRight.setVisible(true); AudioManager.playPrevPage(); - showCards(); + showCardsOrTokens(); }); image = ImageHelper.loadImage(RIGHT_PAGE_BUTTON_IMAGE_PATH); @@ -125,7 +133,7 @@ public class MageBook extends JComponent { pageLeft.setVisible(true); pageRight.setVisible(false); AudioManager.playNextPage(); - showCards(); + showCardsOrTokens(); }); addSetTabs(); @@ -170,7 +178,7 @@ public class MageBook extends JComponent { final String _set = set; final int _index = count; tab.setObserver(() -> { - if (!currentSet.equals(_set) || currentPage != 0) { + if (!currentSet.equals(_set) || currentPage != 0 || stateChanged) { AudioManager.playAnotherTab(); synchronized (MageBook.this) { selectedTab = _index; @@ -180,7 +188,7 @@ public class MageBook extends JComponent { pageLeft.setVisible(false); pageRight.setVisible(false); addSetTabs(); - showCards(); + showCardsOrTokens(); } }); tabs.add(tab); @@ -203,6 +211,15 @@ public class MageBook extends JComponent { } } + private void showCardsOrTokens() { + stateChanged = false; + if (showCardsOrTokens) { + showCards(); + } else { + showTokens(); + } + } + public void showCards() { jLayeredPane.removeAll(); addLeftRightPageButtons(); @@ -232,6 +249,37 @@ public class MageBook extends JComponent { jLayeredPane.repaint(); } + public void showTokens() { + jLayeredPane.removeAll(); + addLeftRightPageButtons(); + + List tokens = getTokens(currentPage, currentSet); + int size = tokens.size(); + + if (tokens != null && tokens.size() > 0) { + Rectangle rectangle = new Rectangle(); + rectangle.translate(OFFSET_X, OFFSET_Y); + for (int i = 0; i < Math.min(conf.CARDS_PER_PAGE / 2, size); i++) { + Token token = tokens.get(i); + addToken(token, bigCard, null, rectangle); + rectangle = CardPosition.translatePosition(i, rectangle, conf); + } + + // calculate the x offset of the second (right) page + int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) + - (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X; + + rectangle.setLocation(second_page_x, OFFSET_Y); + for (int i = conf.CARDS_PER_PAGE / 2; i < Math.min(conf.CARDS_PER_PAGE, size); i++) { + Token token = tokens.get(i); + addToken(token, bigCard, null, rectangle); + rectangle = CardPosition.translatePosition(i - conf.CARDS_PER_PAGE / 2, rectangle, conf); + } + + jLayeredPane.repaint(); + } + } + private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) { if (cardDimension == null) { cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); @@ -252,6 +300,19 @@ public class MageBook extends JComponent { jLayeredPane.add(label); } + private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) { + if (cardDimension == null) { + cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); + } + PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null); + PermanentView theToken = new PermanentView(newToken, null, null, null); + final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true); + cardImg.setBounds(rectangle); + jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10); + cardImg.update(theToken); + cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight); + } + private List getCards(int page, String set) { CardCriteria criteria = new CardCriteria(); criteria.setCodes(set); @@ -268,6 +329,50 @@ public class MageBook extends JComponent { return cards.subList(start, end); } + private List getTokens(int page, String set) { + ArrayList allTokens = getTokenCardUrls(); + ArrayList tokens = new ArrayList<>(); + + for (CardDownloadData token : allTokens) { + if (token.getSet().equals(set)) { + try { + String className = token.getName(); + className = className.replaceAll("[^a-zA-Z0-9]", ""); + className = className + "Token"; + Class c = Class.forName("mage.game.permanent.token." + className); + Constructor cons = c.getConstructor(); + Object newToken = cons.newInstance(); + if (newToken != null && newToken instanceof mage.game.permanent.token.Token) { + tokens.add((Token) newToken); + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } catch (NoSuchMethodException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } catch (SecurityException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalArgumentException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } catch (InvocationTargetException ex) { + java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + int start = page * conf.CARDS_PER_PAGE; + int end = page * conf.CARDS_PER_PAGE + conf.CARDS_PER_PAGE; + if (end > tokens.size()) { + end = tokens.size(); + } + if (tokens.size() > end) { + pageRight.setVisible(true); + } + return tokens.subList(start, end); + } + private ImagePanel getImagePanel(String filename, ImagePanelStyle type) { try { InputStream is = this.getClass().getResourceAsStream(filename); @@ -320,6 +425,15 @@ public class MageBook extends JComponent { } } + public void cardsOrTokens(boolean showCards) { + synchronized (this) { + selectedTab = 0; + showCardsOrTokens = !showCardsOrTokens; + stateChanged = true; + tabs.get(selectedTab).execute(); + } + } + public void updateSize(String size) { switch (size) { case LAYOUT_3x3: @@ -415,6 +529,8 @@ public class MageBook extends JComponent { private java.util.List setsToDisplay = new ArrayList<>(); private final java.util.List tabs = new ArrayList<>(); private int selectedTab; + private boolean showCardsOrTokens = true; + private boolean stateChanged = false; private static final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg"; private static final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg"; diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java index e7d73e423b..cc54162334 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java @@ -181,12 +181,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid { } } } else { - for (CardView cv : view) { - if (cv.getId().equals(entry.getKey())) { - view.remove(cv); - break; - } - } + view.removeIf(cardView -> cardView.getId().equals(entry.getKey())); } } } @@ -296,12 +291,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid { public void removeCard(UUID cardId) { cards.remove(cardId); - for (CardView cv : view) { - if (cv.getId().equals(cardId)) { - view.remove(cv); - break; - } - } + view.removeIf(cardView -> cardView.getId().equals(cardId)); } @Override diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index 2cb9a38765..9b61573a4c 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -860,9 +860,9 @@ public final class GamePanel extends javax.swing.JPanel { showRevealed(game); showLookedAt(game); if (!game.getCombat().isEmpty()) { - CombatManager.getInstance().showCombat(game.getCombat(), gameId); + CombatManager.instance.showCombat(game.getCombat(), gameId); } else { - CombatManager.getInstance().hideCombat(gameId); + CombatManager.instance.hideCombat(gameId); } for (PlayerView player : game.getPlayers()) { diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index baddaf08b1..87b06a62dd 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -22,7 +22,6 @@ import javax.swing.JPopupMenu; import javax.swing.Popup; import javax.swing.PopupFactory; import javax.swing.SwingUtilities; - import mage.cards.MageCard; import mage.cards.action.ActionCallback; import mage.cards.action.TransferData; @@ -67,7 +66,6 @@ public class MageActionCallback implements ActionCallback { private Popup tooltipPopup; private JPopupMenu jPopupMenu; private BigCard bigCard; - protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); private CardView tooltipCard; private TransferData popupData; @@ -178,21 +176,21 @@ public class MageActionCallback implements ActionCallback { public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException { final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE); SwingUtilities.invokeLater(() -> { - if (!popupTextWindowOpen - || enlargedWindowState != EnlargedWindowState.CLOSED) { - return; - } - if (data.locationOnScreen == null) { - data.locationOnScreen = data.component.getLocationOnScreen(); - } + if (!popupTextWindowOpen + || enlargedWindowState != EnlargedWindowState.CLOSED) { + return; + } + if (data.locationOnScreen == null) { + data.locationOnScreen = data.component.getLocationOnScreen(); + } - Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40); - location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent); - location.translate(-parentPoint.x, -parentPoint.y); - popupContainer.setLocation(location); - popupContainer.setVisible(true); - c.repaint(); - } + Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40); + location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent); + location.translate(-parentPoint.x, -parentPoint.y); + popupContainer.setLocation(location); + popupContainer.setVisible(true); + c.repaint(); + } ); } }); @@ -236,14 +234,14 @@ public class MageActionCallback implements ActionCallback { this.startedDragging = false; if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements transferData.component.requestFocusInWindow(); - defaultCallback.mouseClicked(e, transferData.gameId, transferData.card); + DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card); // Closes popup & enlarged view if a card/Permanent is selected hideTooltipPopup(); } e.consume(); } else { transferData.component.requestFocusInWindow(); - defaultCallback.mouseClicked(e, transferData.gameId, transferData.card); + DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card); // Closes popup & enlarged view if a card/Permanent is selected hideTooltipPopup(); e.consume(); @@ -464,7 +462,7 @@ public class MageActionCallback implements ActionCallback { int notches = e.getWheelRotation(); if (enlargedWindowState != EnlargedWindowState.CLOSED) { // same move direction will be ignored, opposite direction closes the enlarged window - if (new Date().getTime() - enlargeredViewOpened.getTime() > 1000) { + if (enlargeredViewOpened != null && new Date().getTime() - enlargeredViewOpened.getTime() > 1000) { // if the opening is back more than 1 seconds close anyway hideEnlargedCard(); handleOverNewView(transferData); @@ -492,7 +490,7 @@ public class MageActionCallback implements ActionCallback { * Show the big card image on mouse position while hovering over a card * * @param showAlternative defines if the original image (if it's a copied - * card) or the opposite side of a transformable card will be shown + * card) or the opposite side of a transformable card will be shown */ public void enlargeCard(EnlargeMode showAlternative) { if (enlargedWindowState == EnlargedWindowState.CLOSED) { diff --git a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java index 7a678e49be..33fc7f803c 100644 --- a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java @@ -7,17 +7,11 @@ import mage.client.SessionHandler; import mage.view.CardView; -public class DefaultActionCallback { +public enum DefaultActionCallback { - private static final DefaultActionCallback INSTANCE = new DefaultActionCallback(); + instance; - private DefaultActionCallback() {} - - public static DefaultActionCallback getInstance() { - return INSTANCE; - } - - public void mouseClicked(MouseEvent e, UUID gameId, CardView card) { + public void mouseClicked(UUID gameId, CardView card) { if (gameId != null) { if (card.isAbility() && card.getAbility() != null) { SessionHandler.sendPlayerUUID(gameId, card.getAbility().getId()); diff --git a/Mage.Client/src/main/java/mage/client/util/ImageHelper.java b/Mage.Client/src/main/java/mage/client/util/ImageHelper.java index 05eecea9a1..0759447298 100644 --- a/Mage.Client/src/main/java/mage/client/util/ImageHelper.java +++ b/Mage.Client/src/main/java/mage/client/util/ImageHelper.java @@ -140,13 +140,8 @@ public final class ImageHelper { * @return */ public static Image getImageFromResources(String path) { - InputStream stream; - stream = UI.class.getResourceAsStream(path); - if (stream == null) { - throw new IllegalArgumentException("Couldn't find image in resources: " + path); - } - try { + try(InputStream stream = UI.class.getResourceAsStream(path)) { ImageIO.setUseCache(false); BufferedImage image = ImageIO.read(stream); return image; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java index ba7356c073..080772869e 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java @@ -151,7 +151,7 @@ public class CardPluginImpl implements CardPlugin { outerLoop: // for (MagePermanent permanent : permanents) { - if (!CardUtil.isLand(permanent) || CardUtil.isCreature(permanent)) { + if (!permanent.isLand() || permanent.isCreature()) { continue; } @@ -418,11 +418,11 @@ public class CardPluginImpl implements CardPlugin { public boolean isType(MagePermanent card) { switch (this) { case land: - return CardUtil.isLand(card); + return card.isLand(); case creature: - return CardUtil.isCreature(card); + return card.isCreature(); case other: - return !CardUtil.isLand(card) && !CardUtil.isCreature(card); + return !card.isLand() && !card.isCreature(); case attached: return card.getOriginalPermanent().isAttachedToPermanent(); default: diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java index 55a30c8fb0..517fa64221 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java @@ -37,19 +37,12 @@ import java.util.HashMap; * * @author spjspj */ -public class AltMtgOnlTokensImageSource implements CardImageSource { +public enum AltMtgOnlTokensImageSource implements CardImageSource { + instance; private static final Logger logger = Logger.getLogger(AltMtgOnlTokensImageSource.class); - private static CardImageSource instance = new AltMtgOnlTokensImageSource(); private static int maxTimes = 0; - public static CardImageSource getInstance() { - if (instance == null) { - instance = new AltMtgOnlTokensImageSource(); - } - return instance; - } - @Override public String getSourceName() { return "http://alternative.mtg.onl/tokens/"; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java index e7750f0801..f0b6aa02d4 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java @@ -37,19 +37,12 @@ import org.mage.plugins.card.images.CardDownloadData; * * @author spjspj */ -public class GrabbagImageSource implements CardImageSource { +public enum GrabbagImageSource implements CardImageSource { + instance; private static final Logger logger = Logger.getLogger(GrabbagImageSource.class); - private static CardImageSource instance = new GrabbagImageSource(); private static int maxTimes = 0; - public static CardImageSource getInstance() { - if (instance == null) { - instance = new GrabbagImageSource(); - } - return instance; - } - @Override public String getSourceName() { return ""; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java index 1dbab36890..fc51c866b9 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagicCardsImageSource.java @@ -10,10 +10,9 @@ import org.mage.plugins.card.utils.CardImageUtils; * * @author North */ -public class MagicCardsImageSource implements CardImageSource { - - private static CardImageSource instance = new MagicCardsImageSource(); +public enum MagicCardsImageSource implements CardImageSource { + instance; private static final Map setNameTokenReplacement = new HashMap() { { put("10E", "tenth-edition"); @@ -146,12 +145,6 @@ public class MagicCardsImageSource implements CardImageSource { return "magiccards.info"; } - public static CardImageSource getInstance() { - if (instance == null) { - instance = new MagicCardsImageSource(); - } - return instance; - } @Override public String getNextHttpImageUrl() { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java index 2c36c20333..2c0ab80e75 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java @@ -36,15 +36,9 @@ import java.net.URI; * @author Pete Rossi */ -public class MagidexImageSource implements CardImageSource { - private static CardImageSource instance = new MagidexImageSource(); +public enum MagidexImageSource implements CardImageSource { + instance; - public static CardImageSource getInstance() { - if (instance == null) { - instance = new MagidexImageSource(); - } - return instance; - } @Override public String getSourceName() { return "magidex.com"; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgImageSource.java index 6473257293..e8e811e34f 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgImageSource.java @@ -39,16 +39,9 @@ import org.mage.plugins.card.images.CardDownloadData; * @author LevelX2 */ -public class MtgImageSource implements CardImageSource { +public enum MtgImageSource implements CardImageSource { - private static CardImageSource instance = new MtgImageSource(); - - public static CardImageSource getInstance() { - if (instance == null) { - instance = new MtgImageSource(); - } - return instance; - } + instance; @Override public String getSourceName() { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java index 16b01a508e..56f42fac5a 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java @@ -37,19 +37,12 @@ import java.util.HashMap; * * @author spjspj */ -public class MtgOnlTokensImageSource implements CardImageSource { +public enum MtgOnlTokensImageSource implements CardImageSource { + instance; private static final Logger logger = Logger.getLogger(MtgOnlTokensImageSource.class); - private static CardImageSource instance = new MtgOnlTokensImageSource(); private static int maxTimes = 0; - public static CardImageSource getInstance() { - if (instance == null) { - instance = new MtgOnlTokensImageSource(); - } - return instance; - } - @Override public String getSourceName() { return "http://mtg.onl/token-list/tokens/"; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java index 47661ee8d4..6f6d8cce20 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java @@ -54,27 +54,21 @@ import org.mage.plugins.card.images.CardDownloadData; * * @author LevelX2 */ -public class MythicspoilerComSource implements CardImageSource { +public enum MythicspoilerComSource implements CardImageSource { - private static CardImageSource instance; - private static Map setsAliases; - private static Map cardNameAliases; - private static Map> cardNameAliasesStart; + instance; + private Map setsAliases; + private Map cardNameAliases; + private Map> cardNameAliasesStart; private final Map> sets; - public static CardImageSource getInstance() { - if (instance == null) { - instance = new MythicspoilerComSource(); - } - return instance; - } @Override public String getSourceName() { return "mythicspoiler.com"; } - public MythicspoilerComSource() { + MythicspoilerComSource() { sets = new LinkedHashMap<>(); setsAliases = new HashMap<>(); setsAliases.put("exp", "bfz"); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java index 25ee59c06a..2f58b13a2c 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java @@ -44,23 +44,16 @@ import java.util.Map; * * @author Quercitron */ -public class TokensMtgImageSource implements CardImageSource { +public enum TokensMtgImageSource implements CardImageSource { + instance; private static final Logger logger = Logger.getLogger(TokensMtgImageSource.class); - private static CardImageSource instance = new TokensMtgImageSource(); private List tokensData; private final Object tokensDataSync = new Object(); - public static CardImageSource getInstance() { - if (instance == null) { - instance = new TokensMtgImageSource(); - } - return instance; - } - @Override public String getSourceName() { return "tokens.mtg.onl"; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java index d75337f6bb..b9f13e5f23 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java @@ -42,6 +42,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.prefs.Preferences; + import mage.client.MageFrame; import mage.client.dialog.PreferencesDialog; import mage.remote.Connection; @@ -53,29 +54,22 @@ import org.jsoup.select.Elements; import org.mage.plugins.card.images.CardDownloadData; /** - * * @author North */ -public class WizardCardsImageSource implements CardImageSource { +public enum WizardCardsImageSource implements CardImageSource { - private static CardImageSource instance; - private static Map setsAliases; - private static Map languageAliases; + instance; + private Map setsAliases; + private Map languageAliases; private final Map> sets; - public static CardImageSource getInstance() { - if (instance == null) { - instance = new WizardCardsImageSource(); - } - return instance; - } @Override public String getSourceName() { return "WOTC Gatherer"; } - public WizardCardsImageSource() { + WizardCardsImageSource() { sets = new HashMap<>(); setsAliases = new HashMap<>(); setsAliases.put("2ED", "Unlimited Edition"); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java index e93a4f881d..c62bb18a64 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java @@ -117,7 +117,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab }); jComboBox1 = new JComboBox(); - cardImageSource = MagicCardsImageSource.getInstance(); + cardImageSource = MagicCardsImageSource.instance; jComboBox1.setModel(jComboBox1Model); jComboBox1.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -125,28 +125,28 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab JComboBox cb = (JComboBox) e.getSource(); switch (cb.getSelectedIndex()) { case 0: - cardImageSource = MagicCardsImageSource.getInstance(); + cardImageSource = MagicCardsImageSource.instance; break; case 1: - cardImageSource = WizardCardsImageSource.getInstance(); + cardImageSource = WizardCardsImageSource.instance; break; case 2: - cardImageSource = MythicspoilerComSource.getInstance(); + cardImageSource = MythicspoilerComSource.instance; break; case 3: - cardImageSource = TokensMtgImageSource.getInstance(); + cardImageSource = TokensMtgImageSource.instance; break; case 4: - cardImageSource = MtgOnlTokensImageSource.getInstance(); + cardImageSource = MtgOnlTokensImageSource.instance; break; case 5: - cardImageSource = AltMtgOnlTokensImageSource.getInstance(); + cardImageSource = AltMtgOnlTokensImageSource.instance; break; case 6: - cardImageSource = GrabbagImageSource.getInstance(); + cardImageSource = GrabbagImageSource.instance; break; case 7: - cardImageSource = MagidexImageSource.getInstance(); + cardImageSource = MagidexImageSource.instance; break; } updateCardsToDownload(); @@ -336,7 +336,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab return new ArrayList<>(cardsToDownload); } - private static ArrayList getTokenCardUrls() throws RuntimeException { + public static ArrayList getTokenCardUrls() throws RuntimeException { ArrayList list = new ArrayList<>(); InputStream in = DownloadPictures.class.getClassLoader().getResourceAsStream("card-pictures-tok.txt"); diff --git a/Mage.Client/src/main/resources/card-pictures-tok.txt b/Mage.Client/src/main/resources/card-pictures-tok.txt index 68c2d0e5d2..5a05b4347e 100644 --- a/Mage.Client/src/main/resources/card-pictures-tok.txt +++ b/Mage.Client/src/main/resources/card-pictures-tok.txt @@ -525,16 +525,12 @@ |Generate|TOK:M13|Wurm|| |Generate|EMBLEM:AVR|Tamiyo, the Moon Sage||Emblem Tamiyo| -|Generate|TOK:AVR|Angel|1| -|Generate|TOK:AVR|Angel|2| -|Generate|TOK:AVR|Angel|3| +|Generate|TOK:AVR|Angel|| +|Generate|TOK:AVR|Demon|| |Generate|TOK:AVR|Human|1| |Generate|TOK:AVR|Human|2| |Generate|TOK:AVR|Spirit|1| |Generate|TOK:AVR|Spirit|2| -|Generate|TOK:AVR|Demon|1| -|Generate|TOK:AVR|Demon|2| -|Generate|TOK:AVR|Demon|3| |Generate|TOK:AVR|Zombie|| |Generate|EMBLEM:DDI|Venser, the Sojourner||Emblem Venser| diff --git a/Mage.Client/src/test/java/mage/client/game/TokensMtgImageSourceTest.java b/Mage.Client/src/test/java/mage/client/game/TokensMtgImageSourceTest.java index 16599a8379..8e485c801e 100644 --- a/Mage.Client/src/test/java/mage/client/game/TokensMtgImageSourceTest.java +++ b/Mage.Client/src/test/java/mage/client/game/TokensMtgImageSourceTest.java @@ -16,7 +16,7 @@ public class TokensMtgImageSourceTest { @Test public void generateTokenUrlTest() throws Exception { - CardImageSource imageSource = TokensMtgImageSource.getInstance(); + CardImageSource imageSource = TokensMtgImageSource.instance; String url = imageSource.generateTokenUrl(new CardDownloadData("Thopter", "ORI", "0", false, 1, "ORI", "")); Assert.assertEquals("http://tokens.mtg.onl/tokens/ORI_010-Thopter.jpg", url); diff --git a/Mage.Common/src/main/java/mage/cards/MagePermanent.java b/Mage.Common/src/main/java/mage/cards/MagePermanent.java index acbcd5de07..a8320821b5 100644 --- a/Mage.Common/src/main/java/mage/cards/MagePermanent.java +++ b/Mage.Common/src/main/java/mage/cards/MagePermanent.java @@ -10,4 +10,12 @@ public abstract class MagePermanent extends MageCard { public abstract void update(PermanentView card); public abstract PermanentView getOriginalPermanent(); + public boolean isCreature(){ + return getOriginal().isCreature(); + } + + public boolean isLand(){ + return getOriginal().isLand(); + } + } diff --git a/Mage.Common/src/main/java/mage/utils/CardUtil.java b/Mage.Common/src/main/java/mage/utils/CardUtil.java index da99b4de7f..ccd928f988 100644 --- a/Mage.Common/src/main/java/mage/utils/CardUtil.java +++ b/Mage.Common/src/main/java/mage/utils/CardUtil.java @@ -21,25 +21,6 @@ public final class CardUtil { private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*"; private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*"; - - - - public static boolean isCreature(MagePermanent card) { - return is(card.getOriginal(), CardType.CREATURE); - } - - public static boolean isPlaneswalker(MagePermanent card) { - return is(card.getOriginal(), CardType.PLANESWALKER); - } - - public static boolean isLand(MagePermanent card) { - return is(card.getOriginal(), CardType.LAND); - } - - public static boolean is(CardView card, CardType type) { - return card.getCardTypes().contains(type); - } - public static int getColorIdentitySortValue(List manaCost, ObjectColor originalColor, List rules) { ObjectColor color = new ObjectColor(originalColor); for (String rule : rules) { diff --git a/Mage.Common/src/main/java/mage/utils/MageVersion.java b/Mage.Common/src/main/java/mage/utils/MageVersion.java index 170ed59aae..0bef34f64b 100644 --- a/Mage.Common/src/main/java/mage/utils/MageVersion.java +++ b/Mage.Common/src/main/java/mage/utils/MageVersion.java @@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable { public final static int MAGE_VERSION_MAJOR = 1; public final static int MAGE_VERSION_MINOR = 4; public final static int MAGE_VERSION_PATCH = 23; - public final static String MAGE_VERSION_MINOR_PATCH = "V3"; + public final static String MAGE_VERSION_MINOR_PATCH = "V4"; public final static String MAGE_VERSION_INFO = ""; private final int major; diff --git a/Mage.Common/src/main/java/mage/view/CardView.java b/Mage.Common/src/main/java/mage/view/CardView.java index 8b567d89da..5471d549f0 100644 --- a/Mage.Common/src/main/java/mage/view/CardView.java +++ b/Mage.Common/src/main/java/mage/view/CardView.java @@ -28,6 +28,7 @@ package mage.view; import java.util.*; +import java.util.stream.Collectors; import mage.MageObject; import mage.ObjectColor; import mage.abilities.Abilities; @@ -64,7 +65,7 @@ public class CardView extends SimpleCardView { protected List rules; protected String power; protected String toughness; - protected String loyalty; + protected String loyalty = ""; protected String startingLoyalty; protected EnumSet cardTypes; protected List subTypes; @@ -344,12 +345,12 @@ public class CardView extends SimpleCardView { if (card instanceof Permanent) { this.mageObjectType = MageObjectType.PERMANENT; Permanent permanent = (Permanent) card; - this.loyalty = Integer.toString(permanent.getCounters(game).getCount(CounterType.LOYALTY)); - this.pairedCard = permanent.getPairedCard() != null ? permanent.getPairedCard().getSourceId() : null; - if (!permanent.getControllerId().equals(permanent.getOwnerId())) { - controlledByOwner = false; - } if (game != null && permanent.getCounters(game) != null && !permanent.getCounters(game).isEmpty()) { + this.loyalty = Integer.toString(permanent.getCounters(game).getCount(CounterType.LOYALTY)); + this.pairedCard = permanent.getPairedCard() != null ? permanent.getPairedCard().getSourceId() : null; + if (!permanent.getControllerId().equals(permanent.getOwnerId())) { + controlledByOwner = false; + } counters = new ArrayList<>(); for (Counter counter : permanent.getCounters(game).values()) { counters.add(new CounterView(counter)); @@ -963,44 +964,24 @@ public class CardView extends SimpleCardView { } public String getColorText() { - if (getColor().getColorCount() == 0) { - return "Colorless"; - } else if (getColor().getColorCount() > 1) { - return "Gold"; - } else if (getColor().isBlack()) { - return "Black"; - } else if (getColor().isBlue()) { - return "Blue"; - } else if (getColor().isWhite()) { - return "White"; - } else if (getColor().isGreen()) { - return "Green"; - } else if (getColor().isRed()) { - return "Red"; - } - return ""; + + String color = getColor().getDescription(); + return color.substring(0, 1).toUpperCase() + color.substring(1); } public String getTypeText() { StringBuilder type = new StringBuilder(); - for (SuperType superType : getSuperTypes()) { - type.append(superType.toString()); - type.append(' '); + if (!getSuperTypes().isEmpty()) { + type.append(String.join(" ", getSuperTypes().stream().map(SuperType::toString).collect(Collectors.toList()))); + type.append(" "); } - for (CardType cardType : getCardTypes()) { - type.append(cardType.toString()); - type.append(' '); + if (!getCardTypes().isEmpty()) { + type.append(String.join(" ", getCardTypes().stream().map(CardType::toString).collect(Collectors.toList()))); + type.append(" "); } if (!getSubTypes().isEmpty()) { - type.append("- "); - for (String subType : getSubTypes()) { - type.append(subType); - type.append(' '); - } - } - if (type.length() > 0) { - // remove trailing space - type.deleteCharAt(type.length() - 1); + type.append(" - "); + type.append(String.join(" ", getSubTypes())); } return type.toString(); } diff --git a/Mage.Common/src/main/java/mage/view/GameView.java b/Mage.Common/src/main/java/mage/view/GameView.java index a9f7bfa9ee..2e16415ad6 100644 --- a/Mage.Common/src/main/java/mage/view/GameView.java +++ b/Mage.Common/src/main/java/mage/view/GameView.java @@ -197,7 +197,7 @@ public class GameView implements Serializable { this.special = false; } - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null) { spellsCastCurrentTurn = watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn(); } else { diff --git a/Mage.Common/src/main/java/mage/view/PermanentView.java b/Mage.Common/src/main/java/mage/view/PermanentView.java index 003af1f693..5dee91191f 100644 --- a/Mage.Common/src/main/java/mage/view/PermanentView.java +++ b/Mage.Common/src/main/java/mage/view/PermanentView.java @@ -62,8 +62,8 @@ public class PermanentView extends CardView { private final boolean attachedToPermanent; public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) { - super(permanent, game, permanent.getControllerId().equals(createdForPlayerId)); - this.controlled = permanent.getControllerId().equals(createdForPlayerId); + super(permanent, game, (permanent.getControllerId() == null) ? false : permanent.getControllerId().equals(createdForPlayerId)); + this.controlled = (permanent.getControllerId() == null) ? false : permanent.getControllerId().equals(createdForPlayerId); this.rules = permanent.getRules(game); this.tapped = permanent.isTapped(); this.flipped = permanent.isFlipped(); @@ -106,7 +106,7 @@ public class PermanentView extends CardView { } } } - if (!permanent.getOwnerId().equals(permanent.getControllerId())) { + if (permanent.getOwnerId() != null && !permanent.getOwnerId().equals(permanent.getControllerId())) { Player owner = game.getPlayer(permanent.getOwnerId()); if (owner != null) { this.nameOwner = owner.getName(); diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java index 5d3bf90c67..1854a9ff3e 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java @@ -150,7 +150,7 @@ public class Commander extends Constructed { invalid.put("Commander", "Commander without Partner (" + commander.getName() + ')'); valid = false; } - FilterMana commanderColor = CardUtil.getColorIdentity(commander); + FilterMana commanderColor = commander.getColorIdentity(); if (commanderColor.isWhite()) { colorIdentity.setWhite(true); } @@ -194,7 +194,7 @@ public class Commander extends Constructed { } public boolean cardHasValidColor(FilterMana commander, Card card) { - FilterMana cardColor = CardUtil.getColorIdentity(card); + FilterMana cardColor = card.getColorIdentity(); return !(cardColor.isBlack() && !commander.isBlack() || cardColor.isBlue() && !commander.isBlue() || cardColor.isGreen() && !commander.isGreen() @@ -654,7 +654,7 @@ public class Commander extends Constructed { color = color.union(commander.getColor(null)); } - FilterMana commanderColor = CardUtil.getColorIdentity(commander); + FilterMana commanderColor = commander.getColorIdentity(); if (commanderColor.isWhite()) { color.setWhite(true); } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java index 65c1667d00..107f6eedad 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java @@ -24,11 +24,11 @@ * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. -*/ - + */ package mage.deck; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.GregorianCalendar; @@ -56,13 +56,18 @@ public class Standard extends Constructed { } }); int blocksAdded = 0; - for (Iterator iter = sets.iterator(); iter.hasNext() && blocksAdded < 3; ) { + int blocksToAdd = 3; + for (Iterator iter = sets.iterator(); iter.hasNext() && blocksAdded < blocksToAdd;) { ExpansionSet set = iter.next(); if (set.getSetType() == SetType.CORE || set.getSetType() == SetType.EXPANSION || set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL) { // Still adding core sets because of Magic Origins + setCodes.add(set.getCode()); - if (set.getReleaseDate().before(current.getTime()) // This stops spoiled sets from counting as "new" blocks + if (set.getReleaseDate().before(current.getTime()) // This stops spoiled sets from counting as "new" blocks && set.getParentSet() == null && set.getSetType() == SetType.EXPANSION) { + if (blocksAdded == 0 && !isFallBlock(set)) { // if the most current block is no fall block, 4 blocks are added + blocksToAdd++; + } blocksAdded++; } } @@ -72,4 +77,11 @@ public class Standard extends Constructed { banned.add("Smuggler's Copter"); banned.add("Felidar Guardian"); } + + private static boolean isFallBlock(ExpansionSet set) { + Calendar cal = Calendar.getInstance(); + cal.setTime(set.getReleaseDate()); + // Sets from fall block are normally released in September and January + return cal.get(Calendar.MONTH) > 8 || cal.get(Calendar.MONTH) < 2; + } } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java index 6fb852e129..11a170899a 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java @@ -177,7 +177,7 @@ public class TinyLeaders extends Constructed { if ((commander.isCreature() && commander.isLegendary()) || (commander.isPlaneswalker() && commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) { if (!bannedCommander.contains(commander.getName())) { - FilterMana color = CardUtil.getColorIdentity(commander); + FilterMana color = commander.getColorIdentity(); for (Card card : deck.getCards()) { if (!isCardFormatValid(card, commander, color)) { valid = false; @@ -249,7 +249,7 @@ public class TinyLeaders extends Constructed { * @return True if card has a valid color identity */ public boolean cardHasValideColor(FilterMana commander, Card card) { - FilterMana cardColor = CardUtil.getColorIdentity(card); + FilterMana cardColor = card.getColorIdentity(); return !(cardColor.isBlack() && !commander.isBlack() || cardColor.isBlue() && !commander.isBlue() || cardColor.isGreen() && !commander.isGreen() diff --git a/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java b/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java index 67a8a6c28c..8f77117ad1 100644 --- a/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java +++ b/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java @@ -77,7 +77,7 @@ class AetherfluxReservoirDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/a/Aggravate.java b/Mage.Sets/src/mage/cards/a/Aggravate.java index 10c3302621..0585b216b2 100644 --- a/Mage.Sets/src/mage/cards/a/Aggravate.java +++ b/Mage.Sets/src/mage/cards/a/Aggravate.java @@ -88,7 +88,7 @@ class AggravateRequirementEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(permanent, game); } diff --git a/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java b/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java index 668a943e9c..5c71c20e86 100644 --- a/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java +++ b/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java @@ -140,7 +140,7 @@ class AlhammarretsArchiveReplacementEffect extends ReplacementEffectImpl { if (event.getPlayerId().equals(source.getControllerId())) { if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) { - CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep"); + CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/a/AlphaAuthority.java b/Mage.Sets/src/mage/cards/a/AlphaAuthority.java index 82db9980b4..0a83bd64c3 100644 --- a/Mage.Sets/src/mage/cards/a/AlphaAuthority.java +++ b/Mage.Sets/src/mage/cards/a/AlphaAuthority.java @@ -47,13 +47,12 @@ import mage.util.CardUtil; import java.util.UUID; /** - * * @author LevelX2 */ public class AlphaAuthority extends CardImpl { public AlphaAuthority(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); this.subtype.add("Aura"); @@ -66,7 +65,7 @@ public class AlphaAuthority extends CardImpl { // Enchanted creature has hexproof and can't be blocked by more than one creature. ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(HexproofAbility.getInstance(), AttachmentType.AURA, Duration.WhileOnBattlefield)); - Effect effect = new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.AURA,1); + Effect effect = new CantBeBlockedByMoreThanOneAttachedEffect(AttachmentType.AURA, 1); effect.setText("and can't be blocked by more than one creature"); ability.addEffect(effect); this.addAbility(ability); @@ -95,7 +94,7 @@ class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl { super(duration, Outcome.Benefit); this.amount = amount; this.attachmentType = attachmentType; - staticText = (attachmentType == AttachmentType.AURA ? "Enchanted" : "Equipped") + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s"); + staticText = attachmentType.verb() + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount == 1 ? "" : "s"); } public CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) { diff --git a/Mage.Sets/src/mage/cards/a/AngelicArbiter.java b/Mage.Sets/src/mage/cards/a/AngelicArbiter.java index 459a6c314e..7a78563c87 100644 --- a/Mage.Sets/src/mage/cards/a/AngelicArbiter.java +++ b/Mage.Sets/src/mage/cards/a/AngelicArbiter.java @@ -137,7 +137,7 @@ class AngelicArbiterCantAttackTargetEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (game.getActivePlayerId().equals(permanent.getControllerId()) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(permanent.getControllerId()) > 0) { return true; } @@ -185,7 +185,7 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { - AngelicArbiterWatcher2 watcher = (AngelicArbiterWatcher2) game.getState().getWatchers().get("PlayerAttacked"); + AngelicArbiterWatcher2 watcher = (AngelicArbiterWatcher2) game.getState().getWatchers().get(AngelicArbiterWatcher2.class.getSimpleName()); if (watcher != null && watcher.hasPlayerAttackedThisTurn(event.getPlayerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java b/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java index 91629952d2..3a9eac03fc 100644 --- a/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java +++ b/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java @@ -97,7 +97,7 @@ class AngelsTrumpetTapEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game))) { continue; } diff --git a/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java b/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java index fe964aabca..a058d12f3b 100644 --- a/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java +++ b/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java @@ -62,7 +62,7 @@ class ApproachOfTheSecondSunEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(source.getSourceId()); if (controller != null && spell != null) { ApproachOfTheSecondSunWatcher watcher - = (ApproachOfTheSecondSunWatcher) game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getName()); + = (ApproachOfTheSecondSunWatcher) game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getSimpleName()); if (watcher != null && watcher.getApproachesCast(controller.getId()) > 1 && spell.getFromZone() == Zone.HAND) { // Win the game controller.won(game); @@ -109,7 +109,7 @@ class ApproachOfTheSecondSunWatcher extends Watcher { private Map approachesCast = new HashMap<>(); public ApproachOfTheSecondSunWatcher() { - super(ApproachOfTheSecondSunWatcher.class.getName(), WatcherScope.GAME); + super(ApproachOfTheSecondSunWatcher.class.getSimpleName(), WatcherScope.GAME); } public ApproachOfTheSecondSunWatcher(final ApproachOfTheSecondSunWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/a/ArchiveTrap.java b/Mage.Sets/src/mage/cards/a/ArchiveTrap.java index a2af1dbd23..41d8a03f1b 100644 --- a/Mage.Sets/src/mage/cards/a/ArchiveTrap.java +++ b/Mage.Sets/src/mage/cards/a/ArchiveTrap.java @@ -58,7 +58,7 @@ public class ArchiveTrap extends CardImpl { this.subtype.add("Trap"); // If an opponent searched his or her library this turn, you may pay {0} rather than pay Archive Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new GenericManaCost(0), OpponentSearchesLibCondition.getInstance()), new ArchiveTrapWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new GenericManaCost(0), OpponentSearchesLibCondition.instance), new ArchiveTrapWatcher()); // Target opponent puts the top thirteen cards of his or her library into his or her graveyard. this.getSpellAbility().addTarget(new TargetOpponent()); @@ -80,7 +80,7 @@ class ArchiveTrapWatcher extends Watcher { Set playerIds = new HashSet<>(); public ArchiveTrapWatcher() { - super("LibrarySearched", WatcherScope.GAME); + super(ArchiveTrapWatcher.class.getSimpleName(), WatcherScope.GAME); } public ArchiveTrapWatcher(final ArchiveTrapWatcher watcher) { @@ -112,17 +112,13 @@ class ArchiveTrapWatcher extends Watcher { } } -class OpponentSearchesLibCondition implements Condition { +enum OpponentSearchesLibCondition implements Condition { - private static final OpponentSearchesLibCondition instance = new OpponentSearchesLibCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - ArchiveTrapWatcher watcher = (ArchiveTrapWatcher) game.getState().getWatchers().get("LibrarySearched"); + ArchiveTrapWatcher watcher = (ArchiveTrapWatcher) game.getState().getWatchers().get(ArchiveTrapWatcher.class.getSimpleName()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && watcher != null) { for (UUID playerId : watcher.getPlayersSearchedLibrary()) { diff --git a/Mage.Sets/src/mage/cards/a/ArchmageAscension.java b/Mage.Sets/src/mage/cards/a/ArchmageAscension.java index aa0a0c2beb..031ab9fc70 100644 --- a/Mage.Sets/src/mage/cards/a/ArchmageAscension.java +++ b/Mage.Sets/src/mage/cards/a/ArchmageAscension.java @@ -102,7 +102,7 @@ class ArchmageAscensionTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent archmage = game.getPermanent(super.getSourceId()); CardsAmountDrawnThisTurnWatcher watcher = - (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.BASIC_KEY); + (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); return archmage != null && watcher != null && watcher.getAmountCardsDrawn(this.getControllerId()) >= 2; } diff --git a/Mage.Sets/src/mage/cards/a/ArrowVolleyTrap.java b/Mage.Sets/src/mage/cards/a/ArrowVolleyTrap.java index f0f22d13bc..55894fe7bc 100644 --- a/Mage.Sets/src/mage/cards/a/ArrowVolleyTrap.java +++ b/Mage.Sets/src/mage/cards/a/ArrowVolleyTrap.java @@ -47,11 +47,11 @@ import java.util.UUID; public class ArrowVolleyTrap extends CardImpl { public ArrowVolleyTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W}{W}"); this.subtype.add("Trap"); // If four or more creatures are attacking, you may pay {1}{W} rather than pay Arrow Volley Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{1}{W}"), ArrowVolleyTrapCondition.getInstance())); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{1}{W}"), ArrowVolleyTrapCondition.instance)); // Arrow Volley Trap deals 5 damage divided as you choose among any number of target attacking creatures. this.getSpellAbility().addEffect(new DamageMultiEffect(5)); @@ -69,13 +69,9 @@ public class ArrowVolleyTrap extends CardImpl { } } -class ArrowVolleyTrapCondition implements Condition { +enum ArrowVolleyTrapCondition implements Condition { - private static final ArrowVolleyTrapCondition instance = new ArrowVolleyTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java b/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java index e568a74a9a..c1a1af8b3a 100644 --- a/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java +++ b/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java @@ -83,7 +83,7 @@ class AsmiraHolyAvengerWatcher extends Watcher { private int creaturesCount = 0; public AsmiraHolyAvengerWatcher() { - super("YourCreaturesDied", WatcherScope.PLAYER); + super(AsmiraHolyAvengerWatcher.class.getSimpleName(), WatcherScope.PLAYER); condition = true; } @@ -122,7 +122,7 @@ class AsmiraHolyAvengerDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - AsmiraHolyAvengerWatcher watcher = (AsmiraHolyAvengerWatcher) game.getState().getWatchers().get("YourCreaturesDied", sourceAbility.getControllerId()); + AsmiraHolyAvengerWatcher watcher = (AsmiraHolyAvengerWatcher) game.getState().getWatchers().get(AsmiraHolyAvengerWatcher.class.getSimpleName(), sourceAbility.getControllerId()); if (watcher != null) { return watcher.getCreaturesCount(); } diff --git a/Mage.Sets/src/mage/cards/a/AureliasFury.java b/Mage.Sets/src/mage/cards/a/AureliasFury.java index 876f7293b0..3afbded3e3 100644 --- a/Mage.Sets/src/mage/cards/a/AureliasFury.java +++ b/Mage.Sets/src/mage/cards/a/AureliasFury.java @@ -52,28 +52,26 @@ import mage.target.common.TargetCreatureOrPlayerAmount; import mage.target.targetpointer.FixedTarget; import mage.watchers.Watcher; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; /** * GATECRASH FAQ 11.01.2013 - * + *

* You announce the value of X and how the damage will be divided as part of * casting Aurelia's Fury. Each chosen target must receive at least 1 damage. - * + *

* Aurelia's Fury can't deal damage to both a planeswalker and that * planeswalker's controller. If damage dealt by Aurelia's Fury is redirected * from a player to a planeswalker he or she controls, that player will be able * to cast noncreature spells that turn. If you want to stop a player from * casting noncreature spells this turn, you can't choose to redirect the * damage to a planeswalker he or she controls. - * + *

* If Aurelia's Fury has multiple targets, and some but not all of them are * illegal targets when Aurelia's Fury resolves, Aurelia's Fury will still * deal damage to the remaining legal targets according to the original damage * division. - * + *

* If all of the targets are illegal when Aurelia's Fury tries to resolve, * it will be countered and none of its effects will happen. No creature or * player will be dealt damage. @@ -83,7 +81,7 @@ import java.util.UUID; public class AureliasFury extends CardImpl { public AureliasFury(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{R}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{R}{W}"); // Aurelia's Fury deals X damage divided as you choose among any number of target creatures and/or players. @@ -107,39 +105,39 @@ public class AureliasFury extends CardImpl { } class AureliasFuryEffect extends OneShotEffect { - + public AureliasFuryEffect() { super(Outcome.Benefit); this.staticText = "Tap each creature dealt damage this way. Players dealt damage this way can't cast noncreature spells this turn"; } - + public AureliasFuryEffect(final AureliasFuryEffect effect) { super(effect); } - + @Override public AureliasFuryEffect copy() { return new AureliasFuryEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - AureliasFuryDamagedByWatcher watcher = (AureliasFuryDamagedByWatcher) game.getState().getWatchers().get("AureliasFuryDamagedByWatcher", source.getSourceId()); + AureliasFuryDamagedByWatcher watcher = (AureliasFuryDamagedByWatcher) game.getState().getWatchers().get(AureliasFuryDamagedByWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { - for(UUID creatureId : watcher.damagedCreatures) { + for (UUID creatureId : watcher.damagedCreatures) { Permanent permanent = game.getPermanent(creatureId); if (permanent != null) { permanent.tap(game); } } - for(UUID playerId : watcher.damagedPlayers) { + for (UUID playerId : watcher.damagedPlayers) { ContinuousEffect effect = new AureliasFuryCantCastEffect(); effect.setTargetPointer(new FixedTarget(playerId)); game.addEffect(effect, source); } watcher.reset(); } - + return false; } } @@ -178,7 +176,7 @@ class AureliasFuryCantCastEffect extends ContinuousRuleModifyingEffectImpl { public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.CAST_SPELL; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); @@ -194,11 +192,11 @@ class AureliasFuryCantCastEffect extends ContinuousRuleModifyingEffectImpl { class AureliasFuryDamagedByWatcher extends Watcher { - public List damagedCreatures = new ArrayList<>(); - public List damagedPlayers = new ArrayList<>(); + public Set damagedCreatures = new HashSet<>(); + public Set damagedPlayers = new HashSet<>(); public AureliasFuryDamagedByWatcher() { - super("AureliasFuryDamagedByWatcher", WatcherScope.CARD); + super(AureliasFuryDamagedByWatcher.class.getSimpleName(), WatcherScope.CARD); } public AureliasFuryDamagedByWatcher(final AureliasFuryDamagedByWatcher watcher) { @@ -217,7 +215,7 @@ class AureliasFuryDamagedByWatcher extends Watcher { if (event.getType() == EventType.DAMAGED_CREATURE) { MageObject obj = game.getObject(event.getSourceId()); if (obj instanceof Spell) { - if (sourceId.equals(((Spell) obj).getSourceId()) && !damagedCreatures.contains(event.getTargetId())) { + if (sourceId.equals(((Spell) obj).getSourceId())) { damagedCreatures.add(event.getTargetId()); } } @@ -225,7 +223,7 @@ class AureliasFuryDamagedByWatcher extends Watcher { if (event.getType() == EventType.DAMAGED_PLAYER) { MageObject obj = game.getObject(event.getSourceId()); if (obj instanceof Spell) { - if (sourceId.equals(((Spell) obj).getSourceId()) && !damagedPlayers.contains(event.getTargetId())) { + if (sourceId.equals(((Spell) obj).getSourceId())) { damagedPlayers.add(event.getTargetId()); } } diff --git a/Mage.Sets/src/mage/cards/a/AvengingArrow.java b/Mage.Sets/src/mage/cards/a/AvengingArrow.java index c02c3f3211..daca860209 100644 --- a/Mage.Sets/src/mage/cards/a/AvengingArrow.java +++ b/Mage.Sets/src/mage/cards/a/AvengingArrow.java @@ -81,7 +81,7 @@ class AvengingArrowTarget extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); if (watcher != null) { if (watcher.damageSources.contains(id)) { return super.canTarget(id, source, game); @@ -94,7 +94,7 @@ class AvengingArrowTarget extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); if (watcher != null) { for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/b/BalothCageTrap.java b/Mage.Sets/src/mage/cards/b/BalothCageTrap.java index 7a9ee33e3e..db670b8ccc 100644 --- a/Mage.Sets/src/mage/cards/b/BalothCageTrap.java +++ b/Mage.Sets/src/mage/cards/b/BalothCageTrap.java @@ -44,17 +44,16 @@ import java.util.List; import java.util.UUID; /** - * * @author jeffwadsworth */ public class BalothCageTrap extends CardImpl { public BalothCageTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{G}{G}"); this.subtype.add("Trap"); // If an opponent had an artifact enter the battlefield under his or her control this turn, you may pay {1}{G} rather than pay Baloth Cage Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{1}{G}"), BalothCageTrapCondition.getInstance()), new PermanentsEnteredBattlefieldWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{1}{G}"), BalothCageTrapCondition.instance), new PermanentsEnteredBattlefieldWatcher()); // Create a 4/4 green Beast creature token. this.getSpellAbility().addEffect(new CreateTokenEffect(new BeastToken2())); @@ -70,17 +69,13 @@ public class BalothCageTrap extends CardImpl { } } -class BalothCageTrapCondition implements Condition { +enum BalothCageTrapCondition implements Condition { - private static final BalothCageTrapCondition instance = new BalothCageTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/b/Berserk.java b/Mage.Sets/src/mage/cards/b/Berserk.java index f192e321d5..6940c476d3 100644 --- a/Mage.Sets/src/mage/cards/b/Berserk.java +++ b/Mage.Sets/src/mage/cards/b/Berserk.java @@ -102,7 +102,7 @@ class BerserkReplacementEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) { - CombatDamageStepStartedWatcher watcher = (CombatDamageStepStartedWatcher) game.getState().getWatchers().get("CombatDamageStepStarted"); + CombatDamageStepStartedWatcher watcher = (CombatDamageStepStartedWatcher) game.getState().getWatchers().get(CombatDamageStepStartedWatcher.class.getSimpleName()); return watcher == null || watcher.conditionMet(); } return false; @@ -122,7 +122,7 @@ class BerserkReplacementEffect extends ContinuousRuleModifyingEffectImpl { class CombatDamageStepStartedWatcher extends Watcher { public CombatDamageStepStartedWatcher() { - super("CombatDamageStepStarted", WatcherScope.GAME); + super(CombatDamageStepStartedWatcher.class.getSimpleName(), WatcherScope.GAME); } public CombatDamageStepStartedWatcher(final CombatDamageStepStartedWatcher watcher) { @@ -196,7 +196,7 @@ class BerserkDelayedDestroyEffect extends OneShotEffect { if (controller != null) { Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { return permanent.destroy(source.getSourceId(), game, false); diff --git a/Mage.Sets/src/mage/cards/b/BloodLust.java b/Mage.Sets/src/mage/cards/b/BloodLust.java index 90ebfd4f50..12f8a3de96 100644 --- a/Mage.Sets/src/mage/cards/b/BloodLust.java +++ b/Mage.Sets/src/mage/cards/b/BloodLust.java @@ -50,7 +50,6 @@ import mage.target.common.TargetCreaturePermanent; import java.util.UUID; /** - * * @author jeffwadsworth */ public class BloodLust extends CardImpl { @@ -62,12 +61,12 @@ public class BloodLust extends CardImpl { } public BloodLust(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}"); // If target creature has toughness 5 or greater, it gets +4/-4 until end of turn. Otherwise, it gets +4/-X until end of turn, where X is its toughness minus 1. this.getSpellAbility().addEffect(new ConditionalContinuousEffect( new BoostTargetEffect(4, -4, Duration.EndOfTurn), - new BoostTargetEffect(new StaticValue(4), new SignInversionDynamicValue(new TargetPermanentToughnessMinus1Value()), Duration.WhileOnBattlefield), + new BoostTargetEffect(new StaticValue(4), new SignInversionDynamicValue(TargetPermanentToughnessMinus1Value.instance), Duration.WhileOnBattlefield), new TargetMatchesFilterCondition(filter), "If target creature has toughness 5 or greater, it gets +4/-4 until end of turn. Otherwise, it gets +4/-X until end of turn, where X is its toughness minus 1")); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); @@ -104,13 +103,9 @@ class TargetMatchesFilterCondition implements Condition { } } -class TargetPermanentToughnessMinus1Value implements DynamicValue { +enum TargetPermanentToughnessMinus1Value implements DynamicValue { - private static final TargetPermanentToughnessMinus1Value instance = new TargetPermanentToughnessMinus1Value(); - - public static TargetPermanentToughnessMinus1Value getInstance() { - return instance; - } + instance; @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { @@ -123,7 +118,7 @@ class TargetPermanentToughnessMinus1Value implements DynamicValue { @Override public TargetPermanentToughnessMinus1Value copy() { - return new TargetPermanentToughnessMinus1Value(); + return instance; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java b/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java index c3afe95167..2fb3e97381 100644 --- a/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java +++ b/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java @@ -96,7 +96,7 @@ class BloodcrazedGoblinEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId()); // BloodthirstWatcher + BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); // BloodthirstWatcher return !watcher.conditionMet(); } return false; diff --git a/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java b/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java index 6736154c0e..574cc827bc 100644 --- a/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java +++ b/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java @@ -134,7 +134,7 @@ class BontuTheGlorifiedRestrictionEffect extends RestrictionEffect { public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { Player controller = game.getPlayer(source.getControllerId()); - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get("CreaturesDiedWatcher"); + CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); if (controller != null && watcher != null) { return (watcher.getAmountOfCreaturesDiesThisTurn(controller.getId()) == 0); diff --git a/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java b/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java index 4c7f7aad76..5e53460f8a 100644 --- a/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java +++ b/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java @@ -89,7 +89,7 @@ class BoseijuWhoSheltersAllWatcher extends Watcher { public List spells = new ArrayList<>(); public BoseijuWhoSheltersAllWatcher() { - super("ManaPaidFromBoseijuWhoSheltersAllWatcher", WatcherScope.GAME); + super(BoseijuWhoSheltersAllWatcher.class.getSimpleName(), WatcherScope.GAME); } public BoseijuWhoSheltersAllWatcher(final BoseijuWhoSheltersAllWatcher watcher) { @@ -158,7 +158,7 @@ class BoseijuWhoSheltersAllCantCounterEffect extends ContinuousRuleModifyingEffe @Override public boolean applies(GameEvent event, Ability source, Game game) { - BoseijuWhoSheltersAllWatcher watcher = (BoseijuWhoSheltersAllWatcher) game.getState().getWatchers().get("ManaPaidFromBoseijuWhoSheltersAllWatcher"); + BoseijuWhoSheltersAllWatcher watcher = (BoseijuWhoSheltersAllWatcher) game.getState().getWatchers().get(BoseijuWhoSheltersAllWatcher.class.getSimpleName()); Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && watcher.spells.contains(spell.getId())) { if (filter.match(spell.getCard(), game)) { diff --git a/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java b/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java index cebd9af153..c7d7886b1a 100644 --- a/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java +++ b/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java @@ -48,13 +48,12 @@ import java.util.List; import java.util.UUID; /** - * * @author LevelX2 */ public class BriarbridgePatrol extends CardImpl { public BriarbridgePatrol(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); this.subtype.add("Human"); this.subtype.add("Warrior"); this.power = new MageInt(3); @@ -64,7 +63,7 @@ public class BriarbridgePatrol extends CardImpl { this.addAbility(new DealsDamageToOneOrMoreCreaturesTriggeredAbility(new InvestigateEffect(), false, false, false)); // At the beginning of each end step, if you sacrificed three or more Clues this turn, you may put a creature card from your hand onto the battlefield. this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new PutPermanentOnBattlefieldEffect(new FilterCreatureCard("a creature card")), TargetController.ANY, - BriarbridgePatrolCondition.getInstance(), true), new PermanentsSacrificedWatcher()); + BriarbridgePatrolCondition.instance, true), new PermanentsSacrificedWatcher()); } @@ -78,17 +77,13 @@ public class BriarbridgePatrol extends CardImpl { } } -class BriarbridgePatrolCondition implements Condition { +enum BriarbridgePatrolCondition implements Condition { - private static final BriarbridgePatrolCondition instance = new BriarbridgePatrolCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PermanentsSacrificedWatcher watcher = (PermanentsSacrificedWatcher) game.getState().getWatchers().get(PermanentsSacrificedWatcher.class.getName()); + PermanentsSacrificedWatcher watcher = (PermanentsSacrificedWatcher) game.getState().getWatchers().get(PermanentsSacrificedWatcher.class.getSimpleName()); if (watcher != null) { List sacrificedPermanents = watcher.getThisTurnSacrificedPermanents(source.getControllerId()); if (sacrificedPermanents != null && !sacrificedPermanents.isEmpty()) { @@ -109,4 +104,4 @@ class BriarbridgePatrolCondition implements Condition { return "if you sacrificed three or more Clues this turn"; } -} + } diff --git a/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java b/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java index f825212a34..94e8b4a2c7 100644 --- a/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java +++ b/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java @@ -38,6 +38,7 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCreatureOrPlayer; import mage.watchers.Watcher; +import mage.watchers.common.MorbidWatcher; import java.util.UUID; @@ -80,7 +81,7 @@ class BrimstoneVolleyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int damage = 3; - Watcher watcher = game.getState().getWatchers().get("Morbid"); + Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); if (watcher.conditionMet()) { damage = 5; } diff --git a/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java b/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java index cacb44b340..f1e2007d2c 100644 --- a/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java +++ b/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java @@ -86,7 +86,7 @@ class CallerOfTheClawWatcher extends Watcher { private int creaturesCount = 0; public CallerOfTheClawWatcher() { - super(CallerOfTheClawWatcher.class.getName(), WatcherScope.PLAYER); + super(CallerOfTheClawWatcher.class.getSimpleName(), WatcherScope.PLAYER); condition = true; } @@ -140,7 +140,7 @@ class CallerOfTheClawDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CallerOfTheClawWatcher watcher = (CallerOfTheClawWatcher) game.getState().getWatchers().get(CallerOfTheClawWatcher.class.getName(), sourceAbility.getControllerId()); + CallerOfTheClawWatcher watcher = (CallerOfTheClawWatcher) game.getState().getWatchers().get(CallerOfTheClawWatcher.class.getSimpleName(), sourceAbility.getControllerId()); if (watcher != null) { return watcher.getCreaturesCount(); } diff --git a/Mage.Sets/src/mage/cards/c/CathedralMembrane.java b/Mage.Sets/src/mage/cards/c/CathedralMembrane.java index 544b9137aa..f5db2ac016 100644 --- a/Mage.Sets/src/mage/cards/c/CathedralMembrane.java +++ b/Mage.Sets/src/mage/cards/c/CathedralMembrane.java @@ -40,18 +40,15 @@ import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.watchers.Watcher; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; /** - * * @author BetaSteward */ public class CathedralMembrane extends CardImpl { public CathedralMembrane(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{1}{W/P}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}{W/P}"); this.subtype.add("Wall"); this.power = new MageInt(0); @@ -94,7 +91,7 @@ class CathedralMembraneAbility extends ZoneChangeTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { if (game.getPhase().getType() == TurnPhase.COMBAT) { - return true; + return true; } } return false; @@ -120,7 +117,7 @@ class CathedralMembraneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get("CathedralMembraneWatcher", source.getSourceId()); + CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get(CathedralMembraneWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { for (UUID uuid : watcher.blockedCreatures) { Permanent permanent = game.getPermanent(uuid); @@ -135,10 +132,10 @@ class CathedralMembraneEffect extends OneShotEffect { class CathedralMembraneWatcher extends Watcher { - public List blockedCreatures = new ArrayList<>(); + public Set blockedCreatures = new HashSet<>(); public CathedralMembraneWatcher() { - super("CathedralMembraneWatcher", WatcherScope.CARD); + super(CathedralMembraneWatcher.class.getSimpleName(), WatcherScope.CARD); } public CathedralMembraneWatcher(final CathedralMembraneWatcher watcher) { @@ -154,9 +151,7 @@ class CathedralMembraneWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED && event.getSourceId().equals(sourceId)) { - if (!blockedCreatures.contains(event.getTargetId())) { - blockedCreatures.add(event.getTargetId()); - } + blockedCreatures.add(event.getTargetId()); } } diff --git a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java index 9e4487669d..8fcc5ae9d0 100644 --- a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java +++ b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java @@ -152,7 +152,7 @@ class CavernOfSoulsWatcher extends Watcher { private final String originalId; public CavernOfSoulsWatcher(UUID originalId) { - super("ManaPaidFromCavernOfSoulsWatcher", WatcherScope.CARD); + super(CavernOfSoulsWatcher.class.getSimpleName(), WatcherScope.CARD); this.originalId = originalId.toString(); } @@ -224,7 +224,7 @@ class CavernOfSoulsCantCounterEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get("ManaPaidFromCavernOfSoulsWatcher", source.getSourceId()); + CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get(CavernOfSoulsWatcher.class.getSimpleName(), source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId()); } diff --git a/Mage.Sets/src/mage/cards/c/CerebralVortex.java b/Mage.Sets/src/mage/cards/c/CerebralVortex.java index 95bfc1fead..6828fe34fa 100644 --- a/Mage.Sets/src/mage/cards/c/CerebralVortex.java +++ b/Mage.Sets/src/mage/cards/c/CerebralVortex.java @@ -93,7 +93,7 @@ class CerebralVortexEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { - CerebralVortexWatcher watcher = (CerebralVortexWatcher) game.getState().getWatchers().get("CerebralVortexWatcher"); + CerebralVortexWatcher watcher = (CerebralVortexWatcher) game.getState().getWatchers().get(CerebralVortexWatcher.class.getSimpleName()); if (watcher != null) { targetPlayer.damage(watcher.getDraws(targetPlayer.getId()), source.getSourceId(), game, false, true); return true; @@ -108,7 +108,7 @@ class CerebralVortexWatcher extends Watcher { private final Map draws = new HashMap<>(); CerebralVortexWatcher() { - super("CerebralVortexWatcher", WatcherScope.GAME); + super(CerebralVortexWatcher.class.getSimpleName(), WatcherScope.GAME); } CerebralVortexWatcher(final CerebralVortexWatcher watcher) { @@ -136,10 +136,7 @@ class CerebralVortexWatcher extends Watcher { } public int getDraws(UUID playerId) { - if (draws.containsKey(playerId)) { - return draws.get(playerId); - } - return 0; + return draws.getOrDefault(playerId, 0); } @Override diff --git a/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java b/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java index 6e0088dd3e..5eb0071f49 100644 --- a/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java +++ b/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java @@ -113,7 +113,7 @@ class ChainsOfMephistophelesReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) { - CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep"); + CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java b/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java index ff84cb2bf4..a0e4c83a50 100644 --- a/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java +++ b/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java @@ -88,8 +88,8 @@ class ChargingCinderhornCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); - if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + if (watcher != null) { return watcher.getAttackedThisTurnCreatures().isEmpty(); } return true; diff --git a/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java b/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java index f0d308f8b0..dbacc7be8f 100644 --- a/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java +++ b/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java @@ -78,7 +78,7 @@ class SourceControllerLostLifeCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getLiveLost(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/c/CivilizedScholar.java b/Mage.Sets/src/mage/cards/c/CivilizedScholar.java index b18b64fae2..6e34eb7867 100644 --- a/Mage.Sets/src/mage/cards/c/CivilizedScholar.java +++ b/Mage.Sets/src/mage/cards/c/CivilizedScholar.java @@ -83,7 +83,7 @@ public class CivilizedScholar extends CardImpl { class HomicidalBruteWatcher extends Watcher { public HomicidalBruteWatcher() { - super("HomicidalBruteAttacked", WatcherScope.CARD); + super(HomicidalBruteWatcher.class.getSimpleName(), WatcherScope.CARD); } public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/c/CobraTrap.java b/Mage.Sets/src/mage/cards/c/CobraTrap.java index ce895f6bdb..1dbcb41b09 100644 --- a/Mage.Sets/src/mage/cards/c/CobraTrap.java +++ b/Mage.Sets/src/mage/cards/c/CobraTrap.java @@ -49,17 +49,16 @@ import java.util.Set; import java.util.UUID; /** - * * @author Rafbill */ public class CobraTrap extends CardImpl { public CobraTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{G}{G}"); this.subtype.add("Trap"); // If a noncreature permanent under your control was destroyed this turn by a spell or ability an opponent controlled, you may pay {G} rather than pay Cobra Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{G}"), CobraTrapCondition.getInstance()), new CobraTrapWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{G}"), CobraTrapCondition.instance), new CobraTrapWatcher()); // Create four 1/1 green Snake creature tokens. this.getSpellAbility().addEffect(new CreateTokenEffect(new SnakeToken(), 4)); @@ -75,17 +74,13 @@ public class CobraTrap extends CardImpl { } } -class CobraTrapCondition implements Condition { +enum CobraTrapCondition implements Condition { - private static final CobraTrapCondition instance = new CobraTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - CobraTrapWatcher watcher = (CobraTrapWatcher) game.getState().getWatchers().get(CobraTrapWatcher.class.getName()); + CobraTrapWatcher watcher = (CobraTrapWatcher) game.getState().getWatchers().get(CobraTrapWatcher.class.getSimpleName()); return watcher != null && watcher.conditionMet(source.getControllerId()); } @@ -101,7 +96,7 @@ class CobraTrapWatcher extends Watcher { Set players = new HashSet<>(); public CobraTrapWatcher() { - super(CobraTrapWatcher.class.getName(), WatcherScope.GAME); + super(CobraTrapWatcher.class.getSimpleName(), WatcherScope.GAME); } public CobraTrapWatcher(final CobraTrapWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java b/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java index a74e1bb076..62d6813a55 100644 --- a/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java +++ b/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java @@ -56,7 +56,6 @@ import java.util.Map; import java.util.UUID; /** - * * @author LevelX2 */ public class ConduitOfRuin extends CardImpl { @@ -71,7 +70,7 @@ public class ConduitOfRuin extends CardImpl { } public ConduitOfRuin(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}"); this.subtype.add("Eldrazi"); this.power = new MageInt(5); this.toughness = new MageInt(5); @@ -102,7 +101,7 @@ class ConduitOfRuinWatcher extends Watcher { int spellCount = 0; public ConduitOfRuinWatcher() { - super("FirstCreatureSpellCastThisTurn", WatcherScope.GAME); + super(ConduitOfRuinWatcher.class.getSimpleName(), WatcherScope.GAME); playerCreatureSpells = new HashMap<>(); } @@ -117,20 +116,13 @@ class ConduitOfRuinWatcher extends Watcher { if (event.getType() == GameEvent.EventType.SPELL_CAST) { Spell spell = (Spell) game.getObject(event.getTargetId()); if (spell != null && spell.isCreature()) { - if (playerCreatureSpells.containsKey(event.getPlayerId())) { - playerCreatureSpells.put(event.getPlayerId(), playerCreatureSpells.get(event.getPlayerId()) + 1); - } else { - playerCreatureSpells.put(event.getPlayerId(), 1); - } + playerCreatureSpells.put(event.getPlayerId(), creatureSpellsCastThisTurn(event.getPlayerId()) + 1); } } } public int creatureSpellsCastThisTurn(UUID playerId) { - if (playerCreatureSpells.containsKey(playerId)) { - return playerCreatureSpells.get(playerId); - } - return 0; + return playerCreatureSpells.getOrDefault(playerId, 0); } @Override @@ -151,7 +143,7 @@ class FirstCastCreatureSpellPredicate implements ObjectPlayerPredicate input, Game game) { if (input.getObject() instanceof Spell && ((Spell) input.getObject()).isCreature()) { - ConduitOfRuinWatcher watcher = (ConduitOfRuinWatcher) game.getState().getWatchers().get("FirstCreatureSpellCastThisTurn"); + ConduitOfRuinWatcher watcher = (ConduitOfRuinWatcher) game.getState().getWatchers().get(ConduitOfRuinWatcher.class.getSimpleName()); return watcher != null && watcher.creatureSpellsCastThisTurn(input.getPlayerId()) == 0; } return false; diff --git a/Mage.Sets/src/mage/cards/c/ContainmentPriest.java b/Mage.Sets/src/mage/cards/c/ContainmentPriest.java index 304bb4676f..94b80f22c9 100644 --- a/Mage.Sets/src/mage/cards/c/ContainmentPriest.java +++ b/Mage.Sets/src/mage/cards/c/ContainmentPriest.java @@ -128,7 +128,7 @@ class ContainmentPriestReplacementEffect extends ReplacementEffectImpl { card = card.getSecondCardFace(); } if (card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly - CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get("CreatureWasCast"); + CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get(CreatureWasCastWatcher.class.getSimpleName()); if (watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/CopperLeafAngel.java b/Mage.Sets/src/mage/cards/c/CopperLeafAngel.java new file mode 100644 index 0000000000..27fb1d19b5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CopperLeafAngel.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.c; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeXTargetCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.dynamicvalue.common.GetXValue; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterControlledLandPermanent; + +/** + * + * @author Rene - bugisemail at gmail.com + */ +public class CopperLeafAngel extends CardImpl { + + public CopperLeafAngel(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}"); + + this.subtype.add("Angel"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // {tap}, Sacrifice X lands: Put X +1/+1 counters on Copper-Leaf Angel. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance(),new GetXValue(), false), new TapSourceCost()); + ability.addCost(new SacrificeXTargetCost(new FilterControlledLandPermanent("lands"), false)); + this.addAbility(ability); + } + + public CopperLeafAngel(final CopperLeafAngel card) { + super(card); + } + + @Override + public CopperLeafAngel copy() { + return new CopperLeafAngel(this); + } +} diff --git a/Mage.Sets/src/mage/cards/c/Counterbalance.java b/Mage.Sets/src/mage/cards/c/Counterbalance.java index 920c06f7b2..7149248f74 100644 --- a/Mage.Sets/src/mage/cards/c/Counterbalance.java +++ b/Mage.Sets/src/mage/cards/c/Counterbalance.java @@ -99,7 +99,7 @@ class CounterbalanceEffect extends OneShotEffect { CardsImpl cards = new CardsImpl(); cards.add(topcard); controller.revealCards(sourcePermanent.getName(), cards, game); - if (CardUtil.convertedManaCostsIsEqual(topcard, spell)) { + if (topcard.getConvertedManaCost() == spell.getConvertedManaCost()) { return game.getStack().counter(spell.getId(), source.getSourceId(), game); } } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java b/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java index 0556bce5c1..c8602f0080 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java @@ -107,7 +107,7 @@ class CurseOfExhaustionEffect extends ContinuousRuleModifyingEffectImpl { if (enchantment != null && enchantment.getAttachedTo() != null) { Player player = game.getPlayer(enchantment.getAttachedTo()); if (player != null && event.getPlayerId().equals(player.getId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java b/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java index 86cc0ff33e..78d9765e80 100644 --- a/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java +++ b/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java @@ -179,7 +179,7 @@ class CyclopeanTombEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObjectReference mor = new MageObjectReference(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game); - CyclopeanTombCounterWatcher watcher = (CyclopeanTombCounterWatcher) game.getState().getWatchers().get(CyclopeanTombCounterWatcher.class.getName()); + CyclopeanTombCounterWatcher watcher = (CyclopeanTombCounterWatcher) game.getState().getWatchers().get(CyclopeanTombCounterWatcher.class.getSimpleName()); if (controller != null && watcher != null) { Set landRef = watcher.landMiredByCyclopeanTombInstance(mor, game); @@ -221,7 +221,7 @@ class CyclopeanTombCounterWatcher extends Watcher { public HashMap> counterData = new HashMap<>(); public CyclopeanTombCounterWatcher() { - super(CyclopeanTombCounterWatcher.class.getName(), WatcherScope.GAME); + super(CyclopeanTombCounterWatcher.class.getSimpleName(), WatcherScope.GAME); } public CyclopeanTombCounterWatcher(final CyclopeanTombCounterWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/d/DeathSpark.java b/Mage.Sets/src/mage/cards/d/DeathSpark.java index 99ecc69b5f..c37e62ef32 100644 --- a/Mage.Sets/src/mage/cards/d/DeathSpark.java +++ b/Mage.Sets/src/mage/cards/d/DeathSpark.java @@ -68,7 +68,7 @@ public class DeathSpark extends CardImpl { new DoIfCostPaid(new ReturnSourceFromGraveyardToHandEffect(), new GenericManaCost(1)), TargetController.YOU, false), - new DeathSparkCondition(), + DeathSparkCondition.instance, "At the beginning of your upkeep, if {this} is in your graveyard with a creature card directly above it, you may pay {1}. If you do, return {this} to your hand.")); } @@ -82,13 +82,9 @@ public class DeathSpark extends CardImpl { } } -class DeathSparkCondition implements Condition { +enum DeathSparkCondition implements Condition { - private static final DeathSparkCondition instance = new DeathSparkCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java b/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java index d4aed13bd3..d891e90faf 100644 --- a/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java +++ b/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java @@ -44,13 +44,12 @@ import java.util.HashMap; import java.util.UUID; /** - * * @author jeffwadsworth */ public class DescentOfTheDragons extends CardImpl { public DescentOfTheDragons(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{R}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{R}{R}"); // Destroy any number of target creatures. For each creature destroyed this way, its controller creates a 4/4 red Dragon creature token with flying. this.getSpellAbility().addEffect(new DescentOfTheDragonsEffect()); @@ -95,18 +94,15 @@ class DescentOfTheDragonsEffect extends OneShotEffect { if (permanent != null) { UUID controllerOfTargetId = permanent.getControllerId(); if (permanent.destroy(source.getSourceId(), game, false)) { - if(playersWithTargets.containsKey(controllerOfTargetId)) { - playersWithTargets.put(controllerOfTargetId, playersWithTargets.get(controllerOfTargetId) + 1); - } - else { - playersWithTargets.put(controllerOfTargetId, 1); - } + int count = playersWithTargets.getOrDefault(controllerOfTargetId, 0); + playersWithTargets.put(controllerOfTargetId, count + 1); + } } } } DragonToken dragonToken = new DragonToken(); - for(UUID playerId : playersWithTargets.keySet()) { + for (UUID playerId : playersWithTargets.keySet()) { dragonToken.putOntoBattlefield(playersWithTargets.get(playerId), game, source.getSourceId(), playerId); } return true; diff --git a/Mage.Sets/src/mage/cards/d/DraconicRoar.java b/Mage.Sets/src/mage/cards/d/DraconicRoar.java index 57135017bb..ee8fb30c20 100644 --- a/Mage.Sets/src/mage/cards/d/DraconicRoar.java +++ b/Mage.Sets/src/mage/cards/d/DraconicRoar.java @@ -116,7 +116,7 @@ class DraconicRoarEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/d/DreamSalvage.java b/Mage.Sets/src/mage/cards/d/DreamSalvage.java index b7848104e0..7f5d06b5ca 100644 --- a/Mage.Sets/src/mage/cards/d/DreamSalvage.java +++ b/Mage.Sets/src/mage/cards/d/DreamSalvage.java @@ -46,13 +46,12 @@ import java.util.Map.Entry; import java.util.UUID; /** - * * @author jeffwadsworth */ public class DreamSalvage extends CardImpl { public DreamSalvage(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U/B}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U/B}"); // Draw cards equal to the number of cards target opponent discarded this turn. @@ -77,7 +76,7 @@ class CardsDiscardedThisTurnWatcher extends Watcher { private final Map amountOfCardsDiscardedThisTurn = new HashMap<>(); public CardsDiscardedThisTurnWatcher() { - super("CardsDiscardedThisTurnWatcher", WatcherScope.GAME); + super(CardsDiscardedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public CardsDiscardedThisTurnWatcher(final CardsDiscardedThisTurnWatcher watcher) { @@ -92,23 +91,13 @@ class CardsDiscardedThisTurnWatcher extends Watcher { if (event.getType() == GameEvent.EventType.DISCARDED_CARD) { UUID playerId = event.getPlayerId(); if (playerId != null) { - Integer amount = amountOfCardsDiscardedThisTurn.get(playerId); - if (amount == null) { - amount = 1; - } else { - amount++; - } - amountOfCardsDiscardedThisTurn.put(playerId, amount); + amountOfCardsDiscardedThisTurn.put(playerId, getAmountCardsDiscarded(playerId) + 1); } } } public int getAmountCardsDiscarded(UUID playerId) { - Integer amount = amountOfCardsDiscardedThisTurn.get(playerId); - if (amount != null) { - return amount; - } - return 0; + return amountOfCardsDiscardedThisTurn.getOrDefault(playerId, 0); } @Override @@ -140,7 +129,7 @@ class DreamSalvageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsDiscardedThisTurnWatcher watcher = (CardsDiscardedThisTurnWatcher) game.getState().getWatchers().get("CardsDiscardedThisTurnWatcher"); + CardsDiscardedThisTurnWatcher watcher = (CardsDiscardedThisTurnWatcher) game.getState().getWatchers().get(CardsDiscardedThisTurnWatcher.class.getSimpleName()); Player targetOpponent = game.getPlayer(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); if (targetOpponent != null diff --git a/Mage.Sets/src/mage/cards/d/DreamThief.java b/Mage.Sets/src/mage/cards/d/DreamThief.java index 47f357f2c9..2b2e9170bb 100644 --- a/Mage.Sets/src/mage/cards/d/DreamThief.java +++ b/Mage.Sets/src/mage/cards/d/DreamThief.java @@ -82,7 +82,7 @@ class CastBlueSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { for (Spell spell : watcher.getSpellsCastThisTurn(source.getControllerId())) { if (!spell.getSourceId().equals(source.getSourceId()) && spell.getColor(game).isBlue()) { diff --git a/Mage.Sets/src/mage/cards/d/DuelingGrounds.java b/Mage.Sets/src/mage/cards/d/DuelingGrounds.java index 4ad7859c70..7367ea3ae3 100644 --- a/Mage.Sets/src/mage/cards/d/DuelingGrounds.java +++ b/Mage.Sets/src/mage/cards/d/DuelingGrounds.java @@ -100,7 +100,7 @@ class NoMoreThanOneCreatureCanAttackEachTurnEffect extends RestrictionEffect { if (!game.getCombat().getAttackers().isEmpty()) { return false; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); Set attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures(); return attackedThisTurnCreatures.isEmpty() || (attackedThisTurnCreatures.size() == 1 && attackedThisTurnCreatures.contains(new MageObjectReference(attacker, game))); @@ -134,7 +134,7 @@ class NoMoreThanOneCreatureCanBlockEachTurnEffect extends RestrictionEffect { if (!game.getCombat().getBlockers().isEmpty()) { return false; } - BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get("BlockedThisTurn"); + BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); Set blockedThisTurnCreatures = watcher.getBlockedThisTurnCreatures(); MageObjectReference blockerReference = new MageObjectReference(blocker.getId(), blocker.getZoneChangeCounter(game), game); return blockedThisTurnCreatures.isEmpty() diff --git a/Mage.Sets/src/mage/cards/e/Entangler.java b/Mage.Sets/src/mage/cards/e/Entangler.java new file mode 100644 index 0000000000..712e568c8a --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/Entangler.java @@ -0,0 +1,81 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.e; + +import java.util.UUID; +import mage.target.common.TargetCreaturePermanent; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.combat.CanBlockAdditionalCreatureEffect; +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 Rene bugisemail at gmail dot com + */ +public class Entangler extends CardImpl { + + public Entangler(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}"); + + this.subtype.add("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 can block any number of creatures. + SimpleStaticAbility blockAbility = new SimpleStaticAbility(Zone.BATTLEFIELD,new CanBlockAdditionalCreatureEffect(0)); + Effect effect = new GainAbilityAttachedEffect(blockAbility,AttachmentType.AURA, Duration.WhileOnBattlefield); + effect.setText("Enchanted creature can block any number of creatures."); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); + } + + public Entangler(final Entangler card) { + super(card); + } + + @Override + public Entangler copy() { + return new Entangler(this); + } +} diff --git a/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java b/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java index 8b89980706..f1ed1b52c5 100644 --- a/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java +++ b/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java @@ -95,7 +95,7 @@ enum HadAnotherCreatureEnterTheBattlefieldCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); return sourcePermanent != null && watcher != null && watcher.AnotherCreatureEnteredBattlefieldUnderPlayersControlLastTurn(sourcePermanent, game); diff --git a/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java b/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java index 4403c060d6..452084646d 100644 --- a/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java +++ b/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java @@ -104,7 +104,7 @@ class ErayoSoratamiAscendantTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); return watcher != null && watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() == 4; } @@ -153,7 +153,7 @@ class ErayosEssenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 1) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); diff --git a/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java b/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java index 33d845dce8..7f1542109f 100644 --- a/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java +++ b/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java @@ -45,13 +45,12 @@ import java.util.HashMap; import java.util.UUID; /** - * * @author LevelX2 */ public class ErdwalIlluminator extends CardImpl { public ErdwalIlluminator(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.subtype.add("Spirit"); this.power = new MageInt(1); this.toughness = new MageInt(3); @@ -91,7 +90,7 @@ class ErdwalIlluminatorTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - InvestigatedWatcher watcher = (InvestigatedWatcher) game.getState().getWatchers().get(InvestigatedWatcher.class.getName()); + InvestigatedWatcher watcher = (InvestigatedWatcher) game.getState().getWatchers().get(InvestigatedWatcher.class.getSimpleName()); return watcher != null && watcher.getTimesInvestigated(getControllerId()) == 1; } @@ -111,7 +110,7 @@ class InvestigatedWatcher extends Watcher { private final HashMap timesInvestigated = new HashMap<>(); public InvestigatedWatcher() { - super(InvestigatedWatcher.class.getName(), WatcherScope.GAME); + super(InvestigatedWatcher.class.getSimpleName(), WatcherScope.GAME); } public InvestigatedWatcher(final InvestigatedWatcher watcher) { @@ -126,11 +125,8 @@ class InvestigatedWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { if (event.getType() == EventType.INVESTIGATED) { - if (!timesInvestigated.containsKey(event.getPlayerId())) { - timesInvestigated.put(event.getPlayerId(), 1); - } else { - timesInvestigated.put(event.getPlayerId(), timesInvestigated.get(event.getPlayerId()) + 1); - } + timesInvestigated.put(event.getPlayerId(), getTimesInvestigated(event.getPlayerId()) + 1); + } } @@ -141,9 +137,6 @@ class InvestigatedWatcher extends Watcher { } public int getTimesInvestigated(UUID playerId) { - if (timesInvestigated.containsKey(playerId)) { - return timesInvestigated.get(playerId); - } - return 0; + return timesInvestigated.getOrDefault(playerId, 0); } } diff --git a/Mage.Sets/src/mage/cards/e/ErgRaiders.java b/Mage.Sets/src/mage/cards/e/ErgRaiders.java index 0b1f9564aa..0566d72b8b 100644 --- a/Mage.Sets/src/mage/cards/e/ErgRaiders.java +++ b/Mage.Sets/src/mage/cards/e/ErgRaiders.java @@ -80,7 +80,7 @@ class ErgRaidersCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent raiders = game.getPermanentOrLKIBattlefield(source.getSourceId()); - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); // wasControlledFromStartOfControllerTurn should be checked during resolution I guess, but shouldn't be relevant return raiders.wasControlledFromStartOfControllerTurn() && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(raiders, game)); } diff --git a/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java b/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java index b382fe7608..7d54b2cdd6 100644 --- a/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java +++ b/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java @@ -78,7 +78,7 @@ class EtherswornCanonistWatcher extends Watcher { private Set castNonartifactSpell = new HashSet<>(); public EtherswornCanonistWatcher() { - super(EtherswornCanonistWatcher.class.getName(), WatcherScope.GAME); + super(EtherswornCanonistWatcher.class.getSimpleName(), WatcherScope.GAME); } public EtherswornCanonistWatcher(final EtherswornCanonistWatcher watcher) { @@ -143,7 +143,7 @@ class EtherswornCanonistReplacementEffect extends ContinuousRuleModifyingEffectI public boolean applies(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getSourceId()); if (card != null && !card.isArtifact()) { - EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher) game.getState().getWatchers().get(EtherswornCanonistWatcher.class.getName()); + EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher) game.getState().getWatchers().get(EtherswornCanonistWatcher.class.getSimpleName()); return watcher != null && watcher.castNonArtifactSpell(event.getPlayerId()); } return false; diff --git a/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java b/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java index 1d38457d6b..44fc58f00c 100644 --- a/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java +++ b/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java @@ -84,7 +84,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); if (watcher != null) { if (watcher.damageSources.contains(id)) { return super.canTarget(id, source, game); @@ -101,7 +101,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { } int count = 0; MageObject targetSource = game.getObject(sourceId); - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); if (watcher != null) { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (!targets.containsKey(permanent.getId()) && watcher.damageSources.contains(permanent.getId())) { @@ -121,7 +121,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); if (watcher != null) { for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java b/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java index 803f740086..bb8ed01473 100644 --- a/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java +++ b/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java @@ -49,7 +49,6 @@ import java.util.Set; import java.util.UUID; /** - * * @author spjspj */ public class FairgroundsTrumpeter extends CardImpl { @@ -62,9 +61,9 @@ public class FairgroundsTrumpeter extends CardImpl { // At the beginning of each end step, if a +1/+1 counter was placed on a permanent under your control this turn, put a +1/+1 counter on Fairgrounds Trumpeter. this.addAbility(new ConditionalTriggeredAbility(new BeginningOfEndStepTriggeredAbility( - new AddCountersSourceEffect(CounterType.P1P1.createInstance()), - TargetController.ANY, false), FairgroundsTrumpeterCondition.getInstance(), - "At the beginning of each end step, if a +1/+1 counter was placed on a permanent under your control this turn, put a +1/+1 counter on {this}."), + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), + TargetController.ANY, false), FairgroundsTrumpeterCondition.instance, + "At the beginning of each end step, if a +1/+1 counter was placed on a permanent under your control this turn, put a +1/+1 counter on {this}."), new FairgroundsTrumpeterWatcher()); } @@ -78,17 +77,13 @@ public class FairgroundsTrumpeter extends CardImpl { } } -class FairgroundsTrumpeterCondition implements Condition { +enum FairgroundsTrumpeterCondition implements Condition { - private static final FairgroundsTrumpeterCondition instance = new FairgroundsTrumpeterCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - FairgroundsTrumpeterWatcher watcher = (FairgroundsTrumpeterWatcher) game.getState().getWatchers().get(FairgroundsTrumpeterWatcher.class.getName()); + FairgroundsTrumpeterWatcher watcher = (FairgroundsTrumpeterWatcher) game.getState().getWatchers().get(FairgroundsTrumpeterWatcher.class.getSimpleName()); return watcher != null && watcher.p1p1AddedToPermanent(source.getControllerId()); } @@ -104,7 +99,7 @@ class FairgroundsTrumpeterWatcher extends Watcher { private final Set players = new HashSet<>(); public FairgroundsTrumpeterWatcher() { - super(FairgroundsTrumpeterWatcher.class.getName(), WatcherScope.GAME); + super(FairgroundsTrumpeterWatcher.class.getSimpleName(), WatcherScope.GAME); } public FairgroundsTrumpeterWatcher(final FairgroundsTrumpeterWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/f/FaithsReward.java b/Mage.Sets/src/mage/cards/f/FaithsReward.java index 0ea52836eb..c560afe275 100644 --- a/Mage.Sets/src/mage/cards/f/FaithsReward.java +++ b/Mage.Sets/src/mage/cards/f/FaithsReward.java @@ -82,7 +82,7 @@ class FaithsRewardEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FaithsRewardWatcher watcher = (FaithsRewardWatcher) game.getState().getWatchers().get("FaithsRewardWatcher"); + FaithsRewardWatcher watcher = (FaithsRewardWatcher) game.getState().getWatchers().get(FaithsRewardWatcher.class.getSimpleName()); if (watcher != null) { for (UUID id : watcher.cards) { Card c = game.getCard(id); @@ -105,7 +105,7 @@ class FaithsRewardWatcher extends Watcher { ArrayList cards = new ArrayList<>(); public FaithsRewardWatcher() { - super("FaithsRewardWatcher", WatcherScope.GAME); + super(FaithsRewardWatcher.class.getSimpleName(), WatcherScope.GAME); } public FaithsRewardWatcher(final FaithsRewardWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java b/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java index 045209bd6b..6e08312975 100644 --- a/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java +++ b/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java @@ -59,7 +59,7 @@ public class FeastOnTheFallen extends CardImpl { new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.P1P1.createInstance()), TargetController.ANY, false), - FeastOnTheFallenCondition.getInstance(), + FeastOnTheFallenCondition.instance, "At the beginning of each upkeep, if an opponent lost life last turn, put a +1/+1 counter on target creature you control."); ability.addTarget(new TargetControlledCreaturePermanent()); this.addAbility(ability); @@ -75,17 +75,13 @@ public class FeastOnTheFallen extends CardImpl { } } -class FeastOnTheFallenCondition implements Condition { +enum FeastOnTheFallenCondition implements Condition { - private static final FeastOnTheFallenCondition instance = new FeastOnTheFallenCondition(); - - public static FeastOnTheFallenCondition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getLiveLostLastTurn(opponentId) > 0) { diff --git a/Mage.Sets/src/mage/cards/f/FellShepherd.java b/Mage.Sets/src/mage/cards/f/FellShepherd.java index c3baaa8425..d14f87a448 100644 --- a/Mage.Sets/src/mage/cards/f/FellShepherd.java +++ b/Mage.Sets/src/mage/cards/f/FellShepherd.java @@ -98,7 +98,7 @@ class FellShepherdWatcher extends Watcher { private Set creatureIds = new HashSet<>(); public FellShepherdWatcher() { - super("YourCreaturesPutToGraveFromBattlefield", WatcherScope.PLAYER); + super(FellShepherdWatcher.class.getSimpleName(), WatcherScope.PLAYER); condition = true; } @@ -151,7 +151,7 @@ class FellShepherdEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FellShepherdWatcher watcher = (FellShepherdWatcher) game.getState().getWatchers().get("YourCreaturesPutToGraveFromBattlefield", source.getControllerId()); + FellShepherdWatcher watcher = (FellShepherdWatcher) game.getState().getWatchers().get(FellShepherdWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null) { StringBuilder sb = new StringBuilder(); for (UUID creatureId : watcher.getCreaturesIds()) { diff --git a/Mage.Sets/src/mage/cards/f/FinalPunishment.java b/Mage.Sets/src/mage/cards/f/FinalPunishment.java index add3872613..07f7aa4e91 100644 --- a/Mage.Sets/src/mage/cards/f/FinalPunishment.java +++ b/Mage.Sets/src/mage/cards/f/FinalPunishment.java @@ -72,7 +72,7 @@ class FinalPunishmentAmount implements DynamicValue { @Override public int calculate(Game game, Ability source, Effect effect) { AmountOfDamageAPlayerReceivedThisTurnWatcher watcher - = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get("AmountOfDamageReceivedThisTurn"); + = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); if(watcher != null) { return watcher.getAmountOfDamageReceivedThisTurn(source.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/f/FiremaneAngel.java b/Mage.Sets/src/mage/cards/f/FiremaneAngel.java index a172b2286f..b609b86716 100644 --- a/Mage.Sets/src/mage/cards/f/FiremaneAngel.java +++ b/Mage.Sets/src/mage/cards/f/FiremaneAngel.java @@ -69,7 +69,7 @@ public class FiremaneAngel extends CardImpl { // At the beginning of your upkeep, if Firemane Angel is in your graveyard or on the battlefield, you may gain 1 life. Ability ability = new ConditionalTriggeredAbility( new BeginningOfUpkeepTriggeredAbility(Zone.ALL, new GainLifeEffect(1), TargetController.YOU, true), - SourceOnBattelfieldOrGraveyardCondition.getInstance(), + SourceOnBattlefieldOrGraveyardCondition.instance, "At the beginning of your upkeep, if {this} is in your graveyard or on the battlefield, you may gain 1 life"); this.addAbility(ability); // {6}{R}{R}{W}{W}: Return Firemane Angel from your graveyard to the battlefield. Activate this ability only during your upkeep. @@ -87,13 +87,9 @@ public class FiremaneAngel extends CardImpl { } } -class SourceOnBattelfieldOrGraveyardCondition implements Condition { +enum SourceOnBattlefieldOrGraveyardCondition implements Condition { - private static final SourceOnBattelfieldOrGraveyardCondition instance = new SourceOnBattelfieldOrGraveyardCondition(); - - public static SourceOnBattelfieldOrGraveyardCondition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/f/FirstResponse.java b/Mage.Sets/src/mage/cards/f/FirstResponse.java index 41210761f6..a1a30a4a7a 100644 --- a/Mage.Sets/src/mage/cards/f/FirstResponse.java +++ b/Mage.Sets/src/mage/cards/f/FirstResponse.java @@ -84,7 +84,7 @@ class FirstResponseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { if (watcher.getLiveLostLastTurn(source.getControllerId()) > 0) { return new CreateTokenEffect(new SoldierToken()).apply(game, source); diff --git a/Mage.Sets/src/mage/cards/f/Flamebreak.java b/Mage.Sets/src/mage/cards/f/Flamebreak.java index f702ee66cf..98a6822f8f 100644 --- a/Mage.Sets/src/mage/cards/f/Flamebreak.java +++ b/Mage.Sets/src/mage/cards/f/Flamebreak.java @@ -103,7 +103,7 @@ class FlamebreakCantRegenerateEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.REGENERATE) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/f/Flash.java b/Mage.Sets/src/mage/cards/f/Flash.java index 2fd40a12b1..f7a1fcb359 100644 --- a/Mage.Sets/src/mage/cards/f/Flash.java +++ b/Mage.Sets/src/mage/cards/f/Flash.java @@ -101,7 +101,7 @@ class FlashEffect extends OneShotEffect { if (card != null) { card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId()); - ManaCosts reducedCost = CardUtil.removeVariableManaCost(CardUtil.reduceCost(card.getManaCost(), 2)); + ManaCosts reducedCost = ManaCosts.removeVariableManaCost(CardUtil.reduceCost(card.getManaCost(), 2)); StringBuilder sb = new StringBuilder("Pay ").append(reducedCost.getText()).append('?'); if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) { reducedCost.clearPaid(); diff --git a/Mage.Sets/src/mage/cards/f/FleshAllergy.java b/Mage.Sets/src/mage/cards/f/FleshAllergy.java index 1251257f4b..1f45012677 100644 --- a/Mage.Sets/src/mage/cards/f/FleshAllergy.java +++ b/Mage.Sets/src/mage/cards/f/FleshAllergy.java @@ -83,7 +83,7 @@ class FleshAllergyWatcher extends Watcher { public int creaturesDiedThisTurn = 0; public FleshAllergyWatcher() { - super("CreaturesDied", WatcherScope.GAME); + super(FleshAllergyWatcher.class.getSimpleName(), WatcherScope.GAME); } public FleshAllergyWatcher(final FleshAllergyWatcher watcher) { @@ -131,7 +131,7 @@ class FleshAllergyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FleshAllergyWatcher watcher = (FleshAllergyWatcher) game.getState().getWatchers().get("CreaturesDied"); + FleshAllergyWatcher watcher = (FleshAllergyWatcher) game.getState().getWatchers().get(FleshAllergyWatcher.class.getSimpleName()); Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (permanent != null && watcher != null) { Player player = game.getPlayer(permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java b/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java index 09938de420..a544e618ea 100644 --- a/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java +++ b/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java @@ -116,7 +116,7 @@ class FoulTongueInvocationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { controller.gainLife(4, game); } diff --git a/Mage.Sets/src/mage/cards/f/FreshMeat.java b/Mage.Sets/src/mage/cards/f/FreshMeat.java index 87d68b3468..0151843f27 100644 --- a/Mage.Sets/src/mage/cards/f/FreshMeat.java +++ b/Mage.Sets/src/mage/cards/f/FreshMeat.java @@ -68,7 +68,7 @@ class FreshMeatDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get("CreaturesDiedWatcher"); + CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getAmountOfCreaturesDiesThisTurn(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/g/GateToTheAfterlife.java b/Mage.Sets/src/mage/cards/g/GateToTheAfterlife.java index b04415be31..62d30eacb5 100644 --- a/Mage.Sets/src/mage/cards/g/GateToTheAfterlife.java +++ b/Mage.Sets/src/mage/cards/g/GateToTheAfterlife.java @@ -27,9 +27,8 @@ */ package mage.cards.g; -import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldAllTriggeredAbility; import mage.abilities.condition.common.CardsInControllerGraveCondition; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; @@ -59,8 +58,9 @@ import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInYourGraveyard; +import java.util.UUID; + /** - * * @author LevelX2 */ public class GateToTheAfterlife extends CardImpl { @@ -76,7 +76,7 @@ public class GateToTheAfterlife extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); // Whenever a nontoken creature you control dies, you gain 1 life. Then you may draw a card. If you do, discard a card. - Ability ability = new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(1), filter, false); + Ability ability = new PutIntoGraveFromBattlefieldAllTriggeredAbility(new GainLifeEffect(1), false, filter, false, true); Effect effect = new DrawDiscardControllerEffect(1, 1, true); effect.setText("Then you may draw a card. If you do, discard a card"); ability.addEffect(effect); diff --git a/Mage.Sets/src/mage/cards/g/GathererOfGraces.java b/Mage.Sets/src/mage/cards/g/GathererOfGraces.java new file mode 100644 index 0000000000..abd84b3848 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GathererOfGraces.java @@ -0,0 +1,52 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.dynamicvalue.common.AuraAttachedCount; +import mage.abilities.effects.common.RegenerateSourceEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; + +public class GathererOfGraces extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("an aura"); + + static { + filter.add(new SubtypePredicate("Aura")); + } + + public GathererOfGraces(UUID ownerId, CardSetInfo cardSetInfo) { + super(ownerId, cardSetInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + this.subtype.add("Human"); + this.subtype.add("Druid"); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // Gatherer of Graces gets +1/+1 for each Aura attached to it. + AuraAttachedCount count = new AuraAttachedCount(1); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(count, count, Duration.WhileOnBattlefield))); + + // Sacrifice an Aura: Regenerate Gatherer of Graces + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new SacrificeTargetCost(new TargetControlledPermanent(filter)))); + } + + public GathererOfGraces(GathererOfGraces gathererOfGraces) { + super(gathererOfGraces); + } + + @Override + public GathererOfGraces copy() { + return new GathererOfGraces(this); + } +} diff --git a/Mage.Sets/src/mage/cards/g/GeneratorServant.java b/Mage.Sets/src/mage/cards/g/GeneratorServant.java index 7b602ff536..ec12f77635 100644 --- a/Mage.Sets/src/mage/cards/g/GeneratorServant.java +++ b/Mage.Sets/src/mage/cards/g/GeneratorServant.java @@ -90,7 +90,7 @@ class GeneratorServantWatcher extends Watcher { public List creatures = new ArrayList<>(); public GeneratorServantWatcher() { - super("GeneratorServantWatcher", WatcherScope.CARD); + super(GeneratorServantWatcher.class.getSimpleName(), WatcherScope.CARD); } public GeneratorServantWatcher(final GeneratorServantWatcher watcher) { @@ -141,7 +141,7 @@ class GeneratorServantHasteEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - GeneratorServantWatcher watcher = (GeneratorServantWatcher) game.getState().getWatchers().get("GeneratorServantWatcher", source.getSourceId()); + GeneratorServantWatcher watcher = (GeneratorServantWatcher) game.getState().getWatchers().get(GeneratorServantWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { for (Permanent perm : game.getBattlefield().getAllActivePermanents()) { if (watcher.creatures.contains(perm.getId())) { diff --git a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java index 72d5b4bbce..7ed98aa5f7 100644 --- a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java +++ b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java @@ -49,13 +49,12 @@ import java.util.Set; import java.util.UUID; /** - * * @author BetaSteward_at_googlemail.com */ public class GiltspireAvenger extends CardImpl { public GiltspireAvenger(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{G}{W}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{W}{U}"); this.subtype.add("Human"); this.subtype.add("Soldier"); @@ -97,7 +96,7 @@ class GiltspireAvengerTarget extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",source.getControllerId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null && watcher.hasSourceDoneDamage(id, game)) { return super.canTarget(id, source, game); } @@ -108,10 +107,10 @@ class GiltspireAvengerTarget extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); - if(permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)){ + if (permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)) { possibleTargets.add(targetId); } } @@ -126,15 +125,15 @@ class GiltspireAvengerTarget extends TargetPermanent { } int count = 0; MageObject targetSource = game.getObject(sourceId); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); - for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { - if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { + if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) { - count++; - if (count >= remainingTargets) { - return true; - } + count++; + if (count >= remainingTargets) { + return true; } + } } return false; } diff --git a/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java b/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java index 0d1184313f..68fc4291ae 100644 --- a/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java +++ b/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java @@ -143,7 +143,7 @@ class GisaAndGeralfCastFromGraveyardEffect extends AsThoughEffectImpl { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { - GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatchers().get("GisaAndGeralfWatcher", source.getSourceId()); + GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatchers().get(GisaAndGeralfWatcher.class.getSimpleName(), source.getSourceId()); return !watcher.isAbilityUsed(); } } diff --git a/Mage.Sets/src/mage/cards/g/Gleancrawler.java b/Mage.Sets/src/mage/cards/g/Gleancrawler.java index 5a4e0c3d80..257340e5eb 100644 --- a/Mage.Sets/src/mage/cards/g/Gleancrawler.java +++ b/Mage.Sets/src/mage/cards/g/Gleancrawler.java @@ -99,7 +99,7 @@ class GleancrawlerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get("CardsPutIntoGraveyardWatcher"); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && watcher != null) { Set cardsToGraveyardThisTurn = watcher.getCardsPutToGraveyardFromBattlefield(); diff --git a/Mage.Sets/src/mage/cards/g/GlyphKeeper.java b/Mage.Sets/src/mage/cards/g/GlyphKeeper.java index fff800de40..5a11239d09 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphKeeper.java +++ b/Mage.Sets/src/mage/cards/g/GlyphKeeper.java @@ -104,7 +104,7 @@ class GlyphKeeperAbility extends TriggeredAbilityImpl { if (event.getTargetId().equals(this.getSourceId())) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isCreature()) { - NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getName()); + NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getSimpleName()); if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent, game)) { for (Effect effect : getEffects()) { diff --git a/Mage.Sets/src/mage/cards/g/GoblinCohort.java b/Mage.Sets/src/mage/cards/g/GoblinCohort.java index 4525bfd6ba..b9b67fd42e 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinCohort.java +++ b/Mage.Sets/src/mage/cards/g/GoblinCohort.java @@ -95,7 +95,7 @@ class GoblinCohortEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatchers().get("PlayerCastCreature"); + PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatchers().get(PlayerCastCreatureWatcher.class.getSimpleName()); if (watcher != null && !watcher.playerDidCastCreatureThisTurn(source.getControllerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/g/Gomazoa.java b/Mage.Sets/src/mage/cards/g/Gomazoa.java index 4eb27b36df..ccd19fb855 100644 --- a/Mage.Sets/src/mage/cards/g/Gomazoa.java +++ b/Mage.Sets/src/mage/cards/g/Gomazoa.java @@ -112,7 +112,7 @@ class GomazoaEffect extends OneShotEffect { players.add(gomazoa.getOwnerId()); } - BlockedByWatcher watcher = (BlockedByWatcher) game.getState().getWatchers().get("BlockedByWatcher", source.getSourceId()); + BlockedByWatcher watcher = (BlockedByWatcher) game.getState().getWatchers().get(BlockedByWatcher.class.getSimpleName(), source.getSourceId()); creaturesBlocked = watcher.blockedByWatcher; for (UUID blockedById : creaturesBlocked) { @@ -143,7 +143,7 @@ class BlockedByWatcher extends Watcher { public List blockedByWatcher = new ArrayList<>(); public BlockedByWatcher() { - super("BlockedByWatcher", WatcherScope.CARD); + super(BlockedByWatcher.class.getSimpleName(), WatcherScope.CARD); } public BlockedByWatcher(final BlockedByWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/g/GontisMachinations.java b/Mage.Sets/src/mage/cards/g/GontisMachinations.java index b1aa454a01..ab9abe1cf9 100644 --- a/Mage.Sets/src/mage/cards/g/GontisMachinations.java +++ b/Mage.Sets/src/mage/cards/g/GontisMachinations.java @@ -96,7 +96,7 @@ class GontisMachinationsTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(getControllerId())) { GontisMachinationsFirstLostLifeThisTurnWatcher watcher - = (GontisMachinationsFirstLostLifeThisTurnWatcher) game.getState().getWatchers().get(GontisMachinationsFirstLostLifeThisTurnWatcher.class.getName()); + = (GontisMachinationsFirstLostLifeThisTurnWatcher) game.getState().getWatchers().get(GontisMachinationsFirstLostLifeThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.timesLostLifeThisTurn(event.getTargetId()) < 2) { return true; } @@ -120,7 +120,7 @@ class GontisMachinationsFirstLostLifeThisTurnWatcher extends Watcher { private final Map playersLostLife = new HashMap<>(); public GontisMachinationsFirstLostLifeThisTurnWatcher() { - super(GontisMachinationsFirstLostLifeThisTurnWatcher.class.getName(), WatcherScope.GAME); + super(GontisMachinationsFirstLostLifeThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public GontisMachinationsFirstLostLifeThisTurnWatcher(final GontisMachinationsFirstLostLifeThisTurnWatcher watcher) { @@ -152,10 +152,7 @@ class GontisMachinationsFirstLostLifeThisTurnWatcher extends Watcher { } public int timesLostLifeThisTurn(UUID playerId) { - if (playersLostLife.containsKey(playerId)) { - return playersLostLife.get(playerId); - } - return 0; + return playersLostLife.getOrDefault(playerId, 0); } } diff --git a/Mage.Sets/src/mage/cards/g/GrimReturn.java b/Mage.Sets/src/mage/cards/g/GrimReturn.java index b9e8664047..c36f8c9588 100644 --- a/Mage.Sets/src/mage/cards/g/GrimReturn.java +++ b/Mage.Sets/src/mage/cards/g/GrimReturn.java @@ -76,7 +76,7 @@ public class GrimReturn extends CardImpl { @Override public void adjustTargets(Ability ability, Game game) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get("CardsPutIntoGraveyardWatcher"); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); if (watcher != null) { FilterCard filter = new FilterCreatureCard(textFilter); List uuidPredicates = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java b/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java index b0920e567a..eb39f8c1c3 100644 --- a/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java +++ b/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java @@ -109,7 +109,7 @@ class HallowedMoonlightEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) event; if (entersTheBattlefieldEvent.getTarget().isCreature()) { - CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get("CreatureWasCast"); + CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get(CreatureWasCastWatcher.class.getSimpleName()); if (watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/h/HardenedBerserker.java b/Mage.Sets/src/mage/cards/h/HardenedBerserker.java index 8d82b5e036..f8ddd497bc 100644 --- a/Mage.Sets/src/mage/cards/h/HardenedBerserker.java +++ b/Mage.Sets/src/mage/cards/h/HardenedBerserker.java @@ -87,7 +87,7 @@ class HardenedBerserkerSpellsCostReductionEffect extends CostModificationEffectI @Override public void init(Ability source, Game game) { super.init(source, game); - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null) { spellsCast = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()); } @@ -101,7 +101,7 @@ class HardenedBerserkerSpellsCostReductionEffect extends CostModificationEffectI @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null) { if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) > spellsCast) { discard(); // only one use diff --git a/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java b/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java index c6b4a54447..2af3d7ebf8 100644 --- a/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java +++ b/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java @@ -86,7 +86,7 @@ class HarnessTheStormTriggeredAbility extends SpellCastControllerTriggeredAbilit @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getName()); + CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName()); if (watcher != null && watcher.spellWasCastFromHand(event.getSourceId())) { Spell spell = game.getState().getStack().getSpell(event.getSourceId()); if (spell != null) { diff --git a/Mage.Sets/src/mage/cards/h/HeatStroke.java b/Mage.Sets/src/mage/cards/h/HeatStroke.java new file mode 100644 index 0000000000..0a85d9fabb --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HeatStroke.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.h; + +import mage.abilities.common.EndOfCombatTriggeredAbility; +import mage.abilities.effects.common.DestroyAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.BlockedPredicate; +import mage.filter.predicate.permanent.BlockingPredicate; + +import java.util.UUID; + +/** + * @author dustinroepsch + */ +public class HeatStroke extends CardImpl { + private static final FilterPermanent filter = new FilterCreaturePermanent(); + + static { + filter.add(Predicates.or( + new BlockedPredicate(), new BlockingPredicate() + )); + } + + public HeatStroke(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}"); + + // At end of combat, destroy each creature that blocked or was blocked this turn. + this.addAbility( + new EndOfCombatTriggeredAbility( + new DestroyAllEffect(filter).setText("destroy each creature that blocked or was blocked this turn."), + false + ) + ); + } + + public HeatStroke(final HeatStroke card) { + super(card); + } + + @Override + public HeatStroke copy() { + return new HeatStroke(this); + } +} + diff --git a/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java b/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java index af67d55df0..bd37ebd2f8 100644 --- a/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java +++ b/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java @@ -145,7 +145,7 @@ class HisokaMinamoSenseiCounterEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null) { HisokaMinamoSenseiDiscardTargetCost cost = (HisokaMinamoSenseiDiscardTargetCost) source.getCosts().get(0); - if (cost != null && CardUtil.convertedManaCostsIsEqual(cost.getDiscardedCard(), spell)) { + if (cost != null && cost.getDiscardedCard().getConvertedManaCost() == spell.getConvertedManaCost()) { return game.getStack().counter(targetPointer.getFirst(game, source), source.getSourceId(), game); } } diff --git a/Mage.Sets/src/mage/cards/h/HomicidalBrute.java b/Mage.Sets/src/mage/cards/h/HomicidalBrute.java index b81af06e19..87057ff3ba 100644 --- a/Mage.Sets/src/mage/cards/h/HomicidalBrute.java +++ b/Mage.Sets/src/mage/cards/h/HomicidalBrute.java @@ -34,6 +34,7 @@ import mage.abilities.effects.common.TapSourceEffect; import mage.abilities.effects.common.TransformSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.c.CivilizedScholar; import mage.constants.CardType; import mage.constants.Zone; import mage.game.Game; @@ -98,7 +99,7 @@ class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.controllerId)) { - Watcher watcher = game.getState().getWatchers().get("HomicidalBruteAttacked", sourceId); + Watcher watcher = game.getState().getWatchers().get("HomicidalBruteWatcher", sourceId); if (watcher == null || !watcher.conditionMet()) { return true; } diff --git a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java index ec384254cd..9dcc7bfffc 100644 --- a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java +++ b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java @@ -161,7 +161,7 @@ class HopeOfGhirapurPlayerLostLifePredicate implements Predicate { @Override public boolean apply(Player input, Game game) { - HopeOfGhirapurCombatDamageWatcher watcher = (HopeOfGhirapurCombatDamageWatcher) game.getState().getWatchers().get(HopeOfGhirapurCombatDamageWatcher.class.getName()); + HopeOfGhirapurCombatDamageWatcher watcher = (HopeOfGhirapurCombatDamageWatcher) game.getState().getWatchers().get(HopeOfGhirapurCombatDamageWatcher.class.getSimpleName()); if (watcher != null) { return watcher.playerGotCombatDamage(sourceReference, input.getId()); } @@ -174,7 +174,7 @@ class HopeOfGhirapurCombatDamageWatcher extends Watcher { private final HashMap> combatDamagedPlayers = new HashMap<>(); public HopeOfGhirapurCombatDamageWatcher() { - super(HopeOfGhirapurCombatDamageWatcher.class.getName(), WatcherScope.GAME); + super(HopeOfGhirapurCombatDamageWatcher.class.getSimpleName(), WatcherScope.GAME); } public HopeOfGhirapurCombatDamageWatcher(final HopeOfGhirapurCombatDamageWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/h/HotheadedGiant.java b/Mage.Sets/src/mage/cards/h/HotheadedGiant.java index 73c94fddc6..fc6cc5d12f 100644 --- a/Mage.Sets/src/mage/cards/h/HotheadedGiant.java +++ b/Mage.Sets/src/mage/cards/h/HotheadedGiant.java @@ -87,7 +87,7 @@ class CastRedSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - HotHeadedGiantWatcher watcher = (HotHeadedGiantWatcher) game.getState().getWatchers().get("HotHeadedGiantWatcher", source.getControllerId()); + HotHeadedGiantWatcher watcher = (HotHeadedGiantWatcher) game.getState().getWatchers().get(HotHeadedGiantWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -106,7 +106,7 @@ class HotHeadedGiantWatcher extends Watcher { private UUID cardId; public HotHeadedGiantWatcher(UUID cardId) { - super("HotHeadedGiantWatcher", WatcherScope.PLAYER); + super(HotHeadedGiantWatcher.class.getSimpleName(), WatcherScope.PLAYER); this.cardId = cardId; } diff --git a/Mage.Sets/src/mage/cards/i/ImpactResonance.java b/Mage.Sets/src/mage/cards/i/ImpactResonance.java index 2ee8511465..f57a768bf6 100644 --- a/Mage.Sets/src/mage/cards/i/ImpactResonance.java +++ b/Mage.Sets/src/mage/cards/i/ImpactResonance.java @@ -88,7 +88,7 @@ enum GreatestAmountOfDamageDealtValue implements DynamicValue, MageSingleton { } public int calculate(Game game, UUID controllerId) { - GreatestAmountOfDamageWatcher watcher = (GreatestAmountOfDamageWatcher) game.getState().getWatchers().get("GreatestAmountOfDamage"); + GreatestAmountOfDamageWatcher watcher = (GreatestAmountOfDamageWatcher) game.getState().getWatchers().get(GreatestAmountOfDamageWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getGreatestAmountOfDamage(); } @@ -116,7 +116,7 @@ class GreatestAmountOfDamageWatcher extends Watcher { private int damageAmount; public GreatestAmountOfDamageWatcher() { - super("GreatestAmountOfDamage", WatcherScope.GAME); + super(GreatestAmountOfDamageWatcher.class.getSimpleName(), WatcherScope.GAME); } public GreatestAmountOfDamageWatcher(final GreatestAmountOfDamageWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/i/Impatience.java b/Mage.Sets/src/mage/cards/i/Impatience.java index 7cb6842a92..647759f495 100644 --- a/Mage.Sets/src/mage/cards/i/Impatience.java +++ b/Mage.Sets/src/mage/cards/i/Impatience.java @@ -72,7 +72,7 @@ class ImpatienceCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(game.getActivePlayerId()) == 0; } diff --git a/Mage.Sets/src/mage/cards/i/Incinerate.java b/Mage.Sets/src/mage/cards/i/Incinerate.java index a7c05681bd..2f82ee3423 100644 --- a/Mage.Sets/src/mage/cards/i/Incinerate.java +++ b/Mage.Sets/src/mage/cards/i/Incinerate.java @@ -96,7 +96,7 @@ class IncinerateEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java b/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java index 0ef3d936b0..e9a6151aae 100644 --- a/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java +++ b/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java @@ -94,7 +94,7 @@ class IncursionTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/i/InfernoTrap.java b/Mage.Sets/src/mage/cards/i/InfernoTrap.java index 35af6a6bf0..b82da5db81 100644 --- a/Mage.Sets/src/mage/cards/i/InfernoTrap.java +++ b/Mage.Sets/src/mage/cards/i/InfernoTrap.java @@ -32,6 +32,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.UUID; + import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.condition.Condition; @@ -49,17 +50,16 @@ import mage.target.common.TargetCreaturePermanent; import mage.watchers.Watcher; /** - * * @author jeffwadsworth */ public class InfernoTrap extends CardImpl { public InfernoTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}"); this.subtype.add("Trap"); // If you've been dealt damage by two or more creatures this turn, you may pay {R} rather than pay Inferno Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{R}"), InfernoTrapCondition.getInstance()), new InfernoTrapWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{R}"), InfernoTrapCondition.instance), new InfernoTrapWatcher()); // Inferno Trap deals 4 damage to target creature. this.getSpellAbility().addEffect(new DamageTargetEffect(4)); @@ -76,20 +76,16 @@ public class InfernoTrap extends CardImpl { } } -class InfernoTrapCondition implements Condition { +enum InfernoTrapCondition implements Condition { - private static final InfernoTrapCondition instance = new InfernoTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - InfernoTrapWatcher watcher = (InfernoTrapWatcher) game.getState().getWatchers().get(InfernoTrapWatcher.class.getName()); + InfernoTrapWatcher watcher = (InfernoTrapWatcher) game.getState().getWatchers().get(InfernoTrapWatcher.class.getSimpleName()); if (watcher != null) { Set damagingCreatures = watcher.getDamagingCreatures(source.getControllerId()); - return damagingCreatures != null && damagingCreatures.size() > 1; + return damagingCreatures.size() > 1; } return false; } @@ -105,7 +101,7 @@ class InfernoTrapWatcher extends Watcher { Map> playerDamagedByCreature = new HashMap<>(); public InfernoTrapWatcher() { - super(InfernoTrapWatcher.class.getName(), WatcherScope.GAME); + super(InfernoTrapWatcher.class.getSimpleName(), WatcherScope.GAME); } public InfernoTrapWatcher(final InfernoTrapWatcher watcher) { @@ -119,23 +115,18 @@ class InfernoTrapWatcher extends Watcher { && event.getTargetId().equals(controllerId)) { Permanent damageBy = game.getPermanentOrLKIBattlefield(event.getSourceId()); if (damageBy != null && damageBy.isCreature()) { - Set damagingCreatures; - if (playerDamagedByCreature.containsKey(event.getTargetId())) { - damagingCreatures = playerDamagedByCreature.get(event.getTargetId()); - } else { - damagingCreatures = new HashSet<>(); - playerDamagedByCreature.put(event.getTargetId(), damagingCreatures); - } + Set damagingCreatures = playerDamagedByCreature.getOrDefault(event.getTargetId(), new HashSet<>()); + MageObjectReference damagingCreature = new MageObjectReference(damageBy, game); - if (!damagingCreatures.contains(damagingCreature)) { - damagingCreatures.add(damagingCreature); - } + damagingCreatures.add(damagingCreature); + playerDamagedByCreature.put(event.getTargetId(), damagingCreatures); + } } } public Set getDamagingCreatures(UUID playerId) { - return playerDamagedByCreature.get(playerId); + return playerDamagedByCreature.getOrDefault(playerId, new HashSet<>()); } @Override diff --git a/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java b/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java index abd0d595e8..4d43d1b7b6 100644 --- a/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java +++ b/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java @@ -87,7 +87,7 @@ class InsatiableRakghoulEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - NonArtifactCreaturesDiedWatcher watcher = (NonArtifactCreaturesDiedWatcher) game.getState().getWatchers().get("NonArtifactCreaturesDiedWatcher"); + NonArtifactCreaturesDiedWatcher watcher = (NonArtifactCreaturesDiedWatcher) game.getState().getWatchers().get(NonArtifactCreaturesDiedWatcher.class.getSimpleName()); if (watcher != null && watcher.conditionMet()) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { @@ -108,7 +108,7 @@ class InsatiableRakghoulEffect extends OneShotEffect { class NonArtifactCreaturesDiedWatcher extends Watcher { public NonArtifactCreaturesDiedWatcher() { - super("NonArtifactCreaturesDiedWatcher", WatcherScope.GAME); + super(NonArtifactCreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME); } public NonArtifactCreaturesDiedWatcher(final NonArtifactCreaturesDiedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/i/Insist.java b/Mage.Sets/src/mage/cards/i/Insist.java index 61005a0e34..6fdb81bb49 100644 --- a/Mage.Sets/src/mage/cards/i/Insist.java +++ b/Mage.Sets/src/mage/cards/i/Insist.java @@ -28,6 +28,7 @@ package mage.cards.i; import java.util.UUID; + import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; @@ -45,18 +46,17 @@ import mage.game.stack.Spell; import mage.watchers.Watcher; /** - * * @author fireshoes */ public class Insist extends CardImpl { public Insist(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}"); // The next creature spell you cast this turn can't be countered by spells or abilities. this.getSpellAbility().addEffect(new InsistEffect()); this.getSpellAbility().addWatcher(new InsistWatcher()); - + // Draw a card. Effect effect = new DrawCardSourceControllerEffect(1); effect.setText("

Draw a card"); @@ -74,7 +74,7 @@ public class Insist extends CardImpl { } class InsistEffect extends ContinuousRuleModifyingEffectImpl { - + InsistEffect() { super(Duration.EndOfTurn, Outcome.Benefit); staticText = "The next creature spell you cast this turn can't be countered by spells or abilities"; @@ -92,10 +92,10 @@ class InsistEffect extends ContinuousRuleModifyingEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - InsistWatcher watcher = (InsistWatcher) game.getState().getWatchers().get("insistWatcher", source.getControllerId()); - if (watcher != null) { - watcher.setReady(); - } + InsistWatcher watcher = (InsistWatcher) game.getState().getWatchers().get(InsistWatcher.class.getSimpleName(), source.getControllerId()); + if (watcher != null) { + watcher.setReady(); + } } @Override @@ -111,16 +111,16 @@ class InsistEffect extends ContinuousRuleModifyingEffectImpl { } return null; } - + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.COUNTER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - InsistWatcher watcher = (InsistWatcher) game.getState().getWatchers().get("insistWatcher", source.getControllerId()); + InsistWatcher watcher = (InsistWatcher) game.getState().getWatchers().get(InsistWatcher.class.getSimpleName(), source.getControllerId()); return spell != null && watcher != null && watcher.isUncounterable(spell.getId()); } } @@ -131,7 +131,7 @@ class InsistWatcher extends Watcher { protected UUID uncounterableSpell; InsistWatcher() { - super("insistWatcher", WatcherScope.PLAYER); + super(InsistWatcher.class.getSimpleName(), WatcherScope.PLAYER); } InsistWatcher(final InsistWatcher watcher) { @@ -160,7 +160,7 @@ class InsistWatcher extends Watcher { public boolean isUncounterable(UUID spellId) { return spellId.equals(uncounterableSpell); } - + public void setReady() { ready = true; } diff --git a/Mage.Sets/src/mage/cards/j/JaceUnravelerOfSecrets.java b/Mage.Sets/src/mage/cards/j/JaceUnravelerOfSecrets.java index 947f425938..76081f445b 100644 --- a/Mage.Sets/src/mage/cards/j/JaceUnravelerOfSecrets.java +++ b/Mage.Sets/src/mage/cards/j/JaceUnravelerOfSecrets.java @@ -125,7 +125,7 @@ class JaceUnravelerOfSecretsTriggeredAbility extends SpellCastOpponentTriggeredA @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/j/JandorsRing.java b/Mage.Sets/src/mage/cards/j/JandorsRing.java index e6a272225e..a47065b6e8 100644 --- a/Mage.Sets/src/mage/cards/j/JandorsRing.java +++ b/Mage.Sets/src/mage/cards/j/JandorsRing.java @@ -28,6 +28,7 @@ package mage.cards.j; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.costs.common.TapSourceCost; @@ -50,18 +51,17 @@ import mage.players.Player; import mage.watchers.Watcher; /** - * * @author MarcoMarin */ public class JandorsRing extends CardImpl { public JandorsRing(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}"); Watcher watcher = new JandorsRingWatcher(); // {2}, {tap}, Discard the last card you drew this turn: Draw a card. - Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new DiscardAndDrawEffect(), new ManaCostsImpl("{2}"), new WatchedCardInHandCondition(), "Last drawn card still in hand?"); - ability.addCost(new TapSourceCost()); + Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new DiscardAndDrawEffect(), new ManaCostsImpl("{2}"), WatchedCardInHandCondition.instance, "Last drawn card still in hand?"); + ability.addCost(new TapSourceCost()); this.addAbility(ability, watcher); } @@ -75,31 +75,31 @@ public class JandorsRing extends CardImpl { } } -class DiscardAndDrawEffect extends OneShotEffect{ - - +class DiscardAndDrawEffect extends OneShotEffect { + + public DiscardAndDrawEffect() { super(Outcome.Discard); } - + public DiscardAndDrawEffect(final DiscardAndDrawEffect effect) { super(effect); } - + @Override public DiscardAndDrawEffect copy() { return new DiscardAndDrawEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatchers().get("JandorsRingWatcher"); - + JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatchers().get(JandorsRingWatcher.class.getSimpleName()); + FilterCard filter = new FilterCard(game.getCard(watcher.lastDrawnCard).getName()); filter.add(new CardIdPredicate(watcher.lastDrawnCard)); DiscardCardYouChooseTargetEffect effect = new DiscardCardYouChooseTargetEffect(filter, TargetController.YOU); - - if (effect.apply(game, source)){//Conditional was already checked, card should be in hand, but if for some weird reason it fails, the card won't be drawn, although the cost will already be paid + + if (effect.apply(game, source)) {//Conditional was already checked, card should be in hand, but if for some weird reason it fails, the card won't be drawn, although the cost will already be paid Player controller = game.getPlayer(source.getControllerId()); controller.drawCards(1, game); return true; @@ -114,21 +114,21 @@ class JandorsRingWatcher extends Watcher { UUID lastDrawnCard; public JandorsRingWatcher() { - super("JandorsRingWatcher", WatcherScope.PLAYER); + super(JandorsRingWatcher.class.getSimpleName(), WatcherScope.PLAYER); this.lastDrawnCard = null; } public JandorsRingWatcher(final JandorsRingWatcher watcher) { - super(watcher); + super(watcher); this.lastDrawnCard = watcher.lastDrawnCard; } @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DREW_CARD) { + if (event.getType() == GameEvent.EventType.DREW_CARD) { lastDrawnCard = event.getTargetId(); } - if (event.getType() == GameEvent.EventType.CLEANUP_STEP_POST) { + if (event.getType() == GameEvent.EventType.CLEANUP_STEP_POST) { lastDrawnCard = null; } } @@ -145,19 +145,15 @@ class JandorsRingWatcher extends Watcher { } } -class WatchedCardInHandCondition implements Condition { +enum WatchedCardInHandCondition implements Condition { - private static final WatchedCardInHandCondition instance = new WatchedCardInHandCondition(); + instance; - public static WatchedCardInHandCondition getInstance() { - return instance; - } - @Override public boolean apply(Game game, Ability source) { - JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatchers().get("JandorsRingWatcher"); - - return watcher.lastDrawnCard!=null && game.getPlayer(source.getControllerId()).getHand().contains(watcher.lastDrawnCard); + JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatchers().get(JandorsRingWatcher.class.getSimpleName()); + + return watcher.lastDrawnCard != null && game.getPlayer(source.getControllerId()).getHand().contains(watcher.lastDrawnCard); } @Override @@ -165,5 +161,5 @@ class WatchedCardInHandCondition implements Condition { return "if last drawn card is still in hand"; } - + } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java b/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java index 56004758cd..2e22e1e3c4 100644 --- a/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java +++ b/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java @@ -130,7 +130,7 @@ class CantRegenerateEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.REGENERATE) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java b/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java index c397716dbb..24f7facf6f 100644 --- a/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java +++ b/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java @@ -109,7 +109,7 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Card sourceCard = game.getCard(source.getSourceId()); if (controller != null && sourceCard != null) { - JelevaNephaliasWatcher watcher = (JelevaNephaliasWatcher) game.getState().getWatchers().get("ManaPaidToCastJelevaNephalias", source.getSourceId()); + JelevaNephaliasWatcher watcher = (JelevaNephaliasWatcher) game.getState().getWatchers().get(JelevaNephaliasWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { int xValue = watcher.getManaSpentToCastLastTime(sourceCard.getZoneChangeCounter(game) - 1); if (xValue > 0) { @@ -176,7 +176,7 @@ class JelevaNephaliasWatcher extends Watcher { private final Map manaSpendToCast = new HashMap<>(); // cast public JelevaNephaliasWatcher() { - super("ManaPaidToCastJelevaNephalias", WatcherScope.CARD); + super(JelevaNephaliasWatcher.class.getSimpleName(), WatcherScope.CARD); } public JelevaNephaliasWatcher(final JelevaNephaliasWatcher watcher) { @@ -205,10 +205,7 @@ class JelevaNephaliasWatcher extends Watcher { } public int getManaSpentToCastLastTime(int zoneChangeCounter) { - if (manaSpendToCast.containsKey(zoneChangeCounter)) { - return manaSpendToCast.get(zoneChangeCounter); - } - return 0; + return manaSpendToCast.getOrDefault(zoneChangeCounter, 0); } @Override diff --git a/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java b/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java index 758842f1b1..2d52cab59e 100644 --- a/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java +++ b/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java @@ -93,7 +93,7 @@ class JoriEnTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java b/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java index aa7c8372c9..aac09e20db 100644 --- a/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java +++ b/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java @@ -174,7 +174,7 @@ class KaradorGhostChieftainCastFromGraveyardEffect extends AsThoughEffectImpl { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { - KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatchers().get("KaradorGhostChieftainWatcher", source.getSourceId()); + KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatchers().get(KaradorGhostChieftainWatcher.class.getSimpleName(), source.getSourceId()); return !watcher.isAbilityUsed(); } } @@ -187,7 +187,7 @@ class KaradorGhostChieftainWatcher extends Watcher { boolean abilityUsed = false; KaradorGhostChieftainWatcher() { - super("KaradorGhostChieftainWatcher", WatcherScope.CARD); + super(KaradorGhostChieftainWatcher.class.getSimpleName(), WatcherScope.CARD); } KaradorGhostChieftainWatcher(final KaradorGhostChieftainWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java b/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java index 167a26e335..98a0478818 100644 --- a/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java +++ b/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java @@ -120,7 +120,7 @@ class KeranosGodOfStormsTriggeredAbility extends TriggeredAbilityImpl { if (event.getPlayerId().equals(this.getControllerId())) { if (game.getActivePlayerId().equals(this.getControllerId())) { CardsAmountDrawnThisTurnWatcher watcher = - (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.BASIC_KEY); + (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) { return false; } diff --git a/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java b/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java index 0c1bf2bdb8..ea48e7c169 100644 --- a/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java +++ b/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java @@ -108,7 +108,7 @@ class KiraGreatGlassSpinnerAbility extends TriggeredAbilityImpl { if (event.getTargetId().equals(this.getSourceId())) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isCreature()) { - NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getName()); + NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getSimpleName()); if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent, game)) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getSourceId())); diff --git a/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java b/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java index ba1885ce0a..277d84c153 100644 --- a/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java +++ b/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java @@ -110,7 +110,7 @@ class BecomesMonarchTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - MonarchAtTurnStartWatcher watcher = (MonarchAtTurnStartWatcher) game.getState().getWatchers().get("MonarchAtTurnStartWatcher"); + MonarchAtTurnStartWatcher watcher = (MonarchAtTurnStartWatcher) game.getState().getWatchers().get(MonarchAtTurnStartWatcher.class.getSimpleName()); return watcher != null && getControllerId().equals(watcher.getMonarchIdAtTurnStart()); } @@ -130,7 +130,7 @@ class MonarchAtTurnStartWatcher extends Watcher { private UUID monarchIdAtTurnStart; public MonarchAtTurnStartWatcher() { - super("MonarchAtTurnStartWatcher", WatcherScope.GAME); + super(MonarchAtTurnStartWatcher.class.getSimpleName(), WatcherScope.GAME); } public MonarchAtTurnStartWatcher(final MonarchAtTurnStartWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KnollspineDragon.java b/Mage.Sets/src/mage/cards/k/KnollspineDragon.java index 47a41ac230..6eaf03b6c8 100644 --- a/Mage.Sets/src/mage/cards/k/KnollspineDragon.java +++ b/Mage.Sets/src/mage/cards/k/KnollspineDragon.java @@ -93,7 +93,7 @@ class KnollspineDragonEffect extends OneShotEffect { if (controller != null) { new DiscardHandControllerEffect().apply(game, source); if (targetOpponent != null) { - AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get("AmountOfDamageReceivedThisTurn"); + AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); if (watcher != null) { int drawAmount = watcher.getAmountOfDamageReceivedThisTurn(targetOpponent.getId()); controller.drawCards(drawAmount, game); diff --git a/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java b/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java index 67dde9e079..fd9e41940f 100644 --- a/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java +++ b/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java @@ -106,7 +106,7 @@ class KraumLudevicsOpusTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(controllerId).contains(event.getPlayerId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/k/KumanosBlessing.java b/Mage.Sets/src/mage/cards/k/KumanosBlessing.java index 6dca519262..08a1365722 100644 --- a/Mage.Sets/src/mage/cards/k/KumanosBlessing.java +++ b/Mage.Sets/src/mage/cards/k/KumanosBlessing.java @@ -120,7 +120,7 @@ class KumanosBlessingEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { ZoneChangeEvent zce = (ZoneChangeEvent) event; if (zce.isDiesEvent()) { - DamagedByEnchantedWatcher watcher = (DamagedByEnchantedWatcher) game.getState().getWatchers().get("DamagedByEnchantedWatcher", source.getSourceId()); + DamagedByEnchantedWatcher watcher = (DamagedByEnchantedWatcher) game.getState().getWatchers().get(DamagedByEnchantedWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(zce.getTarget(), game); } @@ -135,7 +135,7 @@ class DamagedByEnchantedWatcher extends Watcher { private final Set damagedCreatures = new HashSet<>(); public DamagedByEnchantedWatcher() { - super("DamagedByEnchantedWatcher", WatcherScope.CARD); + super(DamagedByEnchantedWatcher.class.getSimpleName(), WatcherScope.CARD); } public DamagedByEnchantedWatcher(final DamagedByEnchantedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java b/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java index 86a11817c9..7c80355ae9 100644 --- a/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java +++ b/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java @@ -109,7 +109,7 @@ enum KuonOgreAscendantCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get("CreaturesDiedWatcher"); + CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getAmountOfCreaturesDiesThisTurn() > 2; } diff --git a/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java b/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java index 0903406382..b5cb649a64 100644 --- a/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java +++ b/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java @@ -83,8 +83,8 @@ class CardsDrawnThisTurnDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getName()); - return watcher.getNumCardsDrawnThisTurn(sourceAbility.getControllerId()); + KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName()); + return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId()).size(); } @Override @@ -108,7 +108,7 @@ class KydeleCardsDrawnThisTurnWatcher extends Watcher { private final Map> cardsDrawnThisTurn = new HashMap<>(); public KydeleCardsDrawnThisTurnWatcher() { - super(KydeleCardsDrawnThisTurnWatcher.class.getName(), WatcherScope.GAME); + super(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public KydeleCardsDrawnThisTurnWatcher(final KydeleCardsDrawnThisTurnWatcher watcher) { @@ -119,20 +119,14 @@ class KydeleCardsDrawnThisTurnWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.DREW_CARD) { - if (!cardsDrawnThisTurn.containsKey(event.getPlayerId())) { - Set cardsDrawn = new LinkedHashSet<>(); - cardsDrawnThisTurn.put(event.getPlayerId(), cardsDrawn); - } - Set cardsDrawn = cardsDrawnThisTurn.get(event.getPlayerId()); + Set cardsDrawn = getCardsDrawnThisTurn(event.getPlayerId()); cardsDrawn.add(event.getTargetId()); + cardsDrawnThisTurn.put(event.getPlayerId(), cardsDrawn); } } - public int getNumCardsDrawnThisTurn(UUID playerId) { - if (cardsDrawnThisTurn.get(playerId) == null) { - return 0; - } - return cardsDrawnThisTurn.get(playerId).size(); + public Set getCardsDrawnThisTurn(UUID playerId) { + return cardsDrawnThisTurn.getOrDefault(playerId, new LinkedHashSet<>()); } @Override diff --git a/Mage.Sets/src/mage/cards/k/KyrenNegotiations.java b/Mage.Sets/src/mage/cards/k/KyrenNegotiations.java new file mode 100644 index 0000000000..5fcb2ae795 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KyrenNegotiations.java @@ -0,0 +1,49 @@ +package mage.cards.k; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.target.TargetPlayer; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + + +/** + * + * @author ingmargoudt + */ +public class KyrenNegotiations extends CardImpl { + + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creature you control"); + + static { + filter.add(Predicates.not(new TappedPredicate())); + } + + public KyrenNegotiations(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}"); + + // Tap an untapped creature you control: Kyren Negotiations deals 1 damage to target player. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, false))); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + } + + public KyrenNegotiations(final KyrenNegotiations card) { + super(card); + } + + @Override + public KyrenNegotiations copy() { + return new KyrenNegotiations(this); + } +} diff --git a/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java b/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java index ebd9fdf4ca..6e6c91ef32 100644 --- a/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java +++ b/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java @@ -98,7 +98,7 @@ class KytheonHeroOfAkrosCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanent(source.getSourceId()); if (sourceObject != null) { - AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getName()); + AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName()); if (watcher != null) { boolean sourceFound = false; int number = 0; diff --git a/Mage.Sets/src/mage/cards/l/LavaballTrap.java b/Mage.Sets/src/mage/cards/l/LavaballTrap.java index 3cd38d796c..b51e94de92 100644 --- a/Mage.Sets/src/mage/cards/l/LavaballTrap.java +++ b/Mage.Sets/src/mage/cards/l/LavaballTrap.java @@ -56,7 +56,7 @@ public class LavaballTrap extends CardImpl { this.subtype.add("Trap"); // If an opponent had two or more lands enter the battlefield under his or her control this turn, you may pay {3}{R}{R} rather than pay Lavaball Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{3}{R}{R}"), LavaballTrapCondition.getInstance()), new PermanentsEnteredBattlefieldWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{3}{R}{R}"), LavaballTrapCondition.instance), new PermanentsEnteredBattlefieldWatcher()); // Destroy two target lands. Lavaball Trap deals 4 damage to each creature. this.getSpellAbility().addEffect(new DestroyTargetEffect()); @@ -75,17 +75,13 @@ public class LavaballTrap extends CardImpl { } } -class LavaballTrapCondition implements Condition { +enum LavaballTrapCondition implements Condition { - private static final LavaballTrapCondition instance = new LavaballTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java b/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java index 86360cee20..d11cbe93eb 100644 --- a/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java +++ b/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java @@ -97,7 +97,7 @@ class LeovoldEmissaryOfTrestEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - CardsAmountDrawnThisTurnWatcher watcher = (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.BASIC_KEY); + CardsAmountDrawnThisTurnWatcher watcher = (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); Player controller = game.getPlayer(source.getControllerId()); return watcher != null && controller != null && watcher.getAmountCardsDrawn(event.getPlayerId()) >= 1 && game.isOpponent(controller, event.getPlayerId()); diff --git a/Mage.Sets/src/mage/cards/l/LethargyTrap.java b/Mage.Sets/src/mage/cards/l/LethargyTrap.java index a7ac563535..3fa4519c18 100644 --- a/Mage.Sets/src/mage/cards/l/LethargyTrap.java +++ b/Mage.Sets/src/mage/cards/l/LethargyTrap.java @@ -58,7 +58,7 @@ public class LethargyTrap extends CardImpl { this.subtype.add("Trap"); // If three or more creatures are attacking, you may pay {U} rather than pay Lethargy Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{U}"), LethargyTrapCondition.getInstance())); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{U}"), LethargyTrapCondition.instance)); // Attacking creatures get -3/-0 until end of turn. this.getSpellAbility().addEffect(new BoostAllEffect(-3, 0, Duration.EndOfTurn, filter, false)); @@ -75,13 +75,9 @@ public class LethargyTrap extends CardImpl { } } -class LethargyTrapCondition implements Condition { +enum LethargyTrapCondition implements Condition { - private static final LethargyTrapCondition instance = new LethargyTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java index 93e646d334..19389fa1df 100644 --- a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java +++ b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java @@ -80,7 +80,7 @@ class LudevicNecroAlchemistCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); UUID player = game.getActivePlayerId(); PlayerList playerList = game.getState().getPlayerList().copy(); Player currentPlayer = null; diff --git a/Mage.Sets/src/mage/cards/l/LuminarchAscension.java b/Mage.Sets/src/mage/cards/l/LuminarchAscension.java index 2b9ea42f4e..d71594e5ff 100644 --- a/Mage.Sets/src/mage/cards/l/LuminarchAscension.java +++ b/Mage.Sets/src/mage/cards/l/LuminarchAscension.java @@ -61,7 +61,7 @@ public class LuminarchAscension extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}"); // At the beginning of each opponent's end step, if you didn't lose life this turn, you may put a quest counter on Luminarch Ascension. - this.addAbility(new ConditionalTriggeredAbility(new LuminarchAscensionTriggeredAbility(), YouLostNoLifeThisTurnCondition.getInstance(), rule)); + this.addAbility(new ConditionalTriggeredAbility(new LuminarchAscensionTriggeredAbility(), YouLostNoLifeThisTurnCondition.instance, rule)); // {1}{W}: Create a 4/4 white Angel creature token with flying. Activate this ability only if Luminarch Ascension has four or more quest counters on it. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new AngelToken()), new ManaCostsImpl("{1}{W}")); @@ -139,17 +139,14 @@ class SourceHasCountersCost extends CostImpl { } } -class YouLostNoLifeThisTurnCondition implements Condition { +enum YouLostNoLifeThisTurnCondition implements Condition { - private static final YouLostNoLifeThisTurnCondition instance = new YouLostNoLifeThisTurnCondition(); - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { return (watcher.getLiveLost(source.getControllerId()) == 0); } diff --git a/Mage.Sets/src/mage/cards/m/MaelstromNexus.java b/Mage.Sets/src/mage/cards/m/MaelstromNexus.java index 4542b9e861..f925d5efde 100644 --- a/Mage.Sets/src/mage/cards/m/MaelstromNexus.java +++ b/Mage.Sets/src/mage/cards/m/MaelstromNexus.java @@ -95,7 +95,7 @@ class MaelstromNexusGainCascadeFirstSpellEffect extends ContinuousEffectImpl { // only spells cast, so no copies of spells if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) { Spell spell = (Spell) stackObject; - FirstSpellCastThisTurnWatcher watcher = (FirstSpellCastThisTurnWatcher) game.getState().getWatchers().get("FirstSpellCastThisTurn"); + FirstSpellCastThisTurnWatcher watcher = (FirstSpellCastThisTurnWatcher) game.getState().getWatchers().get(FirstSpellCastThisTurnWatcher.class.getSimpleName()); if (watcher != null && spell.getId().equals(watcher.getIdOfFirstCastSpell(source.getControllerId()))) { game.getState().addOtherAbility(spell.getCard(), cascadeAbility); } diff --git a/Mage.Sets/src/mage/cards/m/ManaMaze.java b/Mage.Sets/src/mage/cards/m/ManaMaze.java index 84840aa727..9730300223 100644 --- a/Mage.Sets/src/mage/cards/m/ManaMaze.java +++ b/Mage.Sets/src/mage/cards/m/ManaMaze.java @@ -90,7 +90,7 @@ class ManaMazeEffect extends ContinuousRuleModifyingEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getSourceId()); if (card != null) { - LastSpellCastWatcher watcher = (LastSpellCastWatcher) game.getState().getWatchers().get(LastSpellCastWatcher.class.getName()); + LastSpellCastWatcher watcher = (LastSpellCastWatcher) game.getState().getWatchers().get(LastSpellCastWatcher.class.getSimpleName()); if (watcher != null && watcher.lastSpellCast != null) { return card.getColor(game).contains(watcher.lastSpellCast.getColor(game)); @@ -115,7 +115,7 @@ class LastSpellCastWatcher extends Watcher { Spell lastSpellCast = null; public LastSpellCastWatcher() { - super(LastSpellCastWatcher.class.getName(), WatcherScope.GAME); + super(LastSpellCastWatcher.class.getSimpleName(), WatcherScope.GAME); } public LastSpellCastWatcher(final LastSpellCastWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/m/ManorGargoyle.java b/Mage.Sets/src/mage/cards/m/ManorGargoyle.java index 618e6a1d04..4085eaddc3 100644 --- a/Mage.Sets/src/mage/cards/m/ManorGargoyle.java +++ b/Mage.Sets/src/mage/cards/m/ManorGargoyle.java @@ -87,7 +87,7 @@ public class ManorGargoyle extends CardImpl { // Manor Gargoyle has indestructible as long as it has defender. GainAbilitySourceEffect gainEffect = new GainAbilitySourceEffect(IndestructibleAbility.getInstance()); gainEffect.setDependedToType(DependencyType.LooseDefenderEffect); - ConditionalContinuousEffect effect = new ConditionalContinuousEffect(gainEffect, HasDefenderCondition.getInstance(), rule); + ConditionalContinuousEffect effect = new ConditionalContinuousEffect(gainEffect, HasDefenderCondition.instance, rule); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); @@ -112,19 +112,9 @@ public class ManorGargoyle extends CardImpl { } } -class HasDefenderCondition implements Condition { +enum HasDefenderCondition implements Condition { - private static HasDefenderCondition INSTANCE; - - private HasDefenderCondition() { - } - - public static HasDefenderCondition getInstance() { - if (INSTANCE == null) { - INSTANCE = new HasDefenderCondition(); - } - return INSTANCE; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/m/MedomaiTheAgeless.java b/Mage.Sets/src/mage/cards/m/MedomaiTheAgeless.java index a01f218602..d6623e5409 100644 --- a/Mage.Sets/src/mage/cards/m/MedomaiTheAgeless.java +++ b/Mage.Sets/src/mage/cards/m/MedomaiTheAgeless.java @@ -66,7 +66,7 @@ public class MedomaiTheAgeless extends CardImpl { // Whenever Medomai the Ageless deals combat damage to a player, take an extra turn after this one. this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new AddExtraTurnControllerEffect(), false)); // Medomai the Ageless can't attack during extra turns. - Effect effect = new ConditionalRestrictionEffect(new CantAttackAnyPlayerSourceEffect(Duration.WhileOnBattlefield), ExtraTurnCondition.getInstance()); + Effect effect = new ConditionalRestrictionEffect(new CantAttackAnyPlayerSourceEffect(Duration.WhileOnBattlefield), ExtraTurnCondition.instance); effect.setText("{this} can't attack during extra turns"); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } @@ -81,18 +81,9 @@ public class MedomaiTheAgeless extends CardImpl { } } -class ExtraTurnCondition implements Condition { +enum ExtraTurnCondition implements Condition { - private static ExtraTurnCondition instance = null; - - private ExtraTurnCondition() {} - - public static Condition getInstance() { - if (instance == null) { - instance = new ExtraTurnCondition(); - } - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/m/MightMakesRight.java b/Mage.Sets/src/mage/cards/m/MightMakesRight.java index 110820e519..4b59d1f078 100644 --- a/Mage.Sets/src/mage/cards/m/MightMakesRight.java +++ b/Mage.Sets/src/mage/cards/m/MightMakesRight.java @@ -29,6 +29,7 @@ package mage.cards.m; import java.util.List; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.TriggeredAbility; import mage.abilities.common.BeginningOfCombatTriggeredAbility; @@ -50,22 +51,21 @@ import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; /** - * * @author Quercitron */ public class MightMakesRight extends CardImpl { private static final String ruleText = "At the beginning of combat on your turn, if you control each creature on the battlefield with the greatest power, " + "gain control of target creature an opponent controls until end of turn. Untap that creature. It gains haste until end of turn."; - + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); - + static { filter.add(new ControllerPredicate(TargetController.OPPONENT)); } - + public MightMakesRight(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{5}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{5}{R}"); // At the beginning of combat on your turn, if you control each creature on the battlefield with the greatest power, gain control @@ -74,7 +74,7 @@ public class MightMakesRight extends CardImpl { gainControlAbility.addEffect(new UntapTargetEffect()); gainControlAbility.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn)); gainControlAbility.addTarget(new TargetCreaturePermanent(filter)); - Ability conditionalAbility = new ConditionalTriggeredAbility(gainControlAbility, ControlsEachCreatureWithGreatestPowerCondition.getInstance(), ruleText); + Ability conditionalAbility = new ConditionalTriggeredAbility(gainControlAbility, ControlsEachCreatureWithGreatestPowerCondition.instance, ruleText); this.addAbility(conditionalAbility); } @@ -88,16 +88,12 @@ public class MightMakesRight extends CardImpl { } } -class ControlsEachCreatureWithGreatestPowerCondition implements Condition { +enum ControlsEachCreatureWithGreatestPowerCondition implements Condition { + + instance; - private static final ControlsEachCreatureWithGreatestPowerCondition instance = new ControlsEachCreatureWithGreatestPowerCondition(); - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); - public static Condition getInstance() { - return instance; - } - @Override public boolean apply(Game game, Ability source) { Integer maxPower = null; @@ -118,5 +114,5 @@ class ControlsEachCreatureWithGreatestPowerCondition implements Condition { } return result; } - + } diff --git a/Mage.Sets/src/mage/cards/m/MightOfTheNephilim.java b/Mage.Sets/src/mage/cards/m/MightOfTheNephilim.java index c99a9b5d0c..2ca37243aa 100644 --- a/Mage.Sets/src/mage/cards/m/MightOfTheNephilim.java +++ b/Mage.Sets/src/mage/cards/m/MightOfTheNephilim.java @@ -51,7 +51,7 @@ public class MightOfTheNephilim extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}"); // Target creature gets +2/+2 until end of turn for each of its colors. - DynamicValue boostValue = MightOfTheNephilimValue.getInstance(); + DynamicValue boostValue = MightOfTheNephilimValue.instance; Effect effect = new BoostTargetEffect(boostValue, boostValue, Duration.EndOfTurn, true); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); @@ -67,15 +67,9 @@ public class MightOfTheNephilim extends CardImpl { } } -class MightOfTheNephilimValue implements DynamicValue { +enum MightOfTheNephilimValue implements DynamicValue { - private static final MightOfTheNephilimValue instance = new MightOfTheNephilimValue(); - - public static MightOfTheNephilimValue getInstance() { - return instance; - } - - private MightOfTheNephilimValue() {} + instance; @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { diff --git a/Mage.Sets/src/mage/cards/m/MindbreakTrap.java b/Mage.Sets/src/mage/cards/m/MindbreakTrap.java index 102a99dcd0..0d02eaf326 100644 --- a/Mage.Sets/src/mage/cards/m/MindbreakTrap.java +++ b/Mage.Sets/src/mage/cards/m/MindbreakTrap.java @@ -28,6 +28,7 @@ package mage.cards.m; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.costs.AlternativeCostSourceAbility; @@ -42,7 +43,6 @@ import mage.target.TargetSpell; import mage.watchers.common.CastSpellLastTurnWatcher; /** - * * @author Rafbill */ public class MindbreakTrap extends CardImpl { @@ -50,11 +50,11 @@ public class MindbreakTrap extends CardImpl { private static final FilterSpell filter = new FilterSpell("spell to exile"); public MindbreakTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); this.subtype.add("Trap"); // If an opponent cast three or more spells this turn, you may pay {0} rather than pay Mindbreak Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new GenericManaCost(0), MindbreakTrapCondition.getInstance())); + this.addAbility(new AlternativeCostSourceAbility(new GenericManaCost(0), MindbreakTrapCondition.instance)); // Exile any number of target spells. this.getSpellAbility().addTarget(new TargetSpell(0, Integer.MAX_VALUE, filter)); @@ -71,17 +71,13 @@ public class MindbreakTrap extends CardImpl { } } -class MindbreakTrapCondition implements Condition { +enum MindbreakTrapCondition implements Condition { - private static final MindbreakTrapCondition instance = new MindbreakTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(opponentId) > 2) { diff --git a/Mage.Sets/src/mage/cards/m/MindsDilation.java b/Mage.Sets/src/mage/cards/m/MindsDilation.java index 7785c7c34c..3d5ad7e4b2 100644 --- a/Mage.Sets/src/mage/cards/m/MindsDilation.java +++ b/Mage.Sets/src/mage/cards/m/MindsDilation.java @@ -90,7 +90,7 @@ class MindsDilationTriggeredAbility extends SpellCastOpponentTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/m/MoggConscripts.java b/Mage.Sets/src/mage/cards/m/MoggConscripts.java index a6daee0180..21cf31d2c3 100644 --- a/Mage.Sets/src/mage/cards/m/MoggConscripts.java +++ b/Mage.Sets/src/mage/cards/m/MoggConscripts.java @@ -92,7 +92,7 @@ class MoggConscriptsEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatchers().get("PlayerCastCreature"); + PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatchers().get(PlayerCastCreatureWatcher.class.getSimpleName()); if (watcher != null && !watcher.playerDidCastCreatureThisTurn(source.getControllerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/m/MoltenPsyche.java b/Mage.Sets/src/mage/cards/m/MoltenPsyche.java index a841e6dd88..5798b5e07e 100644 --- a/Mage.Sets/src/mage/cards/m/MoltenPsyche.java +++ b/Mage.Sets/src/mage/cards/m/MoltenPsyche.java @@ -107,13 +107,13 @@ class MoltenPsycheEffect extends OneShotEffect { if (player != null) { player.drawCards(cardsToDraw.get(playerId), game); if (MetalcraftCondition.instance.apply(game, source) && !playerId.equals(source.getControllerId())) { - MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get("CardsDrawn"); + MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get(MoltenPsycheWatcher.class.getSimpleName()); player.damage(watcher.getDraws(playerId), source.getSourceId(), game, false, true); } } } if (MetalcraftCondition.instance.apply(game, source)) { - MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get("CardsDrawn"); + MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get(MoltenPsycheWatcher.class.getSimpleName()); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (game.isOpponent(controller, playerId)) { Player player = game.getPlayer(playerId); @@ -141,7 +141,7 @@ class MoltenPsycheWatcher extends Watcher { private final Map draws = new HashMap<>(); public MoltenPsycheWatcher() { - super("CardsDrawn", WatcherScope.GAME); + super(MoltenPsycheWatcher.class.getSimpleName(), WatcherScope.GAME); } public MoltenPsycheWatcher(final MoltenPsycheWatcher watcher) { @@ -167,10 +167,7 @@ class MoltenPsycheWatcher extends Watcher { } public int getDraws(UUID playerId) { - if (draws.containsKey(playerId)) { - return draws.get(playerId); - } - return 0; + return draws.getOrDefault(playerId, 0); } @Override diff --git a/Mage.Sets/src/mage/cards/m/MosswortBridge.java b/Mage.Sets/src/mage/cards/m/MosswortBridge.java index 38b4e3f809..6236e7183e 100644 --- a/Mage.Sets/src/mage/cards/m/MosswortBridge.java +++ b/Mage.Sets/src/mage/cards/m/MosswortBridge.java @@ -61,7 +61,7 @@ public class MosswortBridge extends CardImpl { // {G}, {T}: You may play the exiled card without paying its mana cost if creatures you control have total power 10 or greater. Ability ability = new ActivateIfConditionActivatedAbility( - Zone.BATTLEFIELD, new HideawayPlayEffect(), new ManaCostsImpl("{G}"), MosswortBridgeTotalPowerCondition.getInstance()); + Zone.BATTLEFIELD, new HideawayPlayEffect(), new ManaCostsImpl("{G}"), MosswortBridgeTotalPowerCondition.instance); ability.addCost(new TapSourceCost()); this.addAbility(ability); } @@ -81,9 +81,6 @@ enum MosswortBridgeTotalPowerCondition implements Condition { instance; private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); - public static Condition getInstance() { - return instance; - } @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/n/NeedleDrop.java b/Mage.Sets/src/mage/cards/n/NeedleDrop.java index 0258bf0095..2e5ee87641 100644 --- a/Mage.Sets/src/mage/cards/n/NeedleDrop.java +++ b/Mage.Sets/src/mage/cards/n/NeedleDrop.java @@ -85,7 +85,7 @@ class DamagedThisTurnPredicate implements Predicate { @Override public boolean apply(MageItem input, Game game) { - DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get("DamageDone"); + DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get(DamageDoneWatcher.class.getSimpleName()); if (watcher != null) { if (input instanceof MageObject) { return watcher.isDamaged(input.getId(), ((MageObject) input).getZoneChangeCounter(game), game); diff --git a/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java b/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java index 8ae6408b45..a4f831a94e 100644 --- a/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java +++ b/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java @@ -28,6 +28,7 @@ package mage.cards.n; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.costs.AlternativeCostSourceAbility; @@ -42,7 +43,6 @@ import mage.target.TargetPlayer; import mage.watchers.common.PlayerGainedLifeWatcher; /** - * * @author LevelX2 */ public class NeedlebiteTrap extends CardImpl { @@ -52,7 +52,7 @@ public class NeedlebiteTrap extends CardImpl { this.subtype.add("Trap"); // If an opponent gained life this turn, you may pay {B} rather than pay Needlebite Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{B}"), NeedlebiteTrapCondition.getInstance()), new PlayerGainedLifeWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{B}"), NeedlebiteTrapCondition.instance), new PlayerGainedLifeWatcher()); // Target player loses 5 life and you gain 5 life. this.getSpellAbility().addEffect(new LoseLifeTargetEffect(5)); @@ -70,17 +70,13 @@ public class NeedlebiteTrap extends CardImpl { } } -class NeedlebiteTrapCondition implements Condition { +enum NeedlebiteTrapCondition implements Condition { - private static final NeedlebiteTrapCondition instance = new NeedlebiteTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getName()); + PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getLiveGained(opponentId) > 0) { diff --git a/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java b/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java index 49b10b5f52..553cc5bf11 100644 --- a/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java +++ b/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java @@ -86,7 +86,7 @@ class NoRestForTheWickedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatchers().get("NoRestForTheWickedWatcher"); + NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatchers().get(NoRestForTheWickedWatcher.class.getSimpleName()); Player controller = game.getPlayer(source.getControllerId()); if (watcher != null && controller != null) { Cards cardsToHand = new CardsImpl(); @@ -118,7 +118,7 @@ class NoRestForTheWickedWatcher extends Watcher { ArrayList cards; public NoRestForTheWickedWatcher() { - super("NoRestForTheWickedWatcher", WatcherScope.GAME); + super(NoRestForTheWickedWatcher.class.getSimpleName(), WatcherScope.GAME); this.cards = new ArrayList<>(); } diff --git a/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java b/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java index 298e2becf4..5cf57ba81e 100644 --- a/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java +++ b/Mage.Sets/src/mage/cards/n/NotOfThisWorld.java @@ -69,7 +69,7 @@ public class NotOfThisWorld extends CardImpl { new TargetStackObjectTargetingControlledPermanent()); this.getSpellAbility().addEffect(new CounterTargetEffect()); // Not of This World costs {7} less to cast if it targets a spell or ability that targets a creature you control with power 7 or greater. - this.addAbility(new SimpleStaticAbility(Zone.STACK, new SpellCostReductionSourceEffect(7, NotOfThisWorldCondition.getInstance()))); + this.addAbility(new SimpleStaticAbility(Zone.STACK, new SpellCostReductionSourceEffect(7, NotOfThisWorldCondition.instance))); } public NotOfThisWorld(final NotOfThisWorld card) { @@ -165,8 +165,8 @@ class TargetStackObjectTargetingControlledPermanent extends TargetObject { } -class NotOfThisWorldCondition implements Condition { - +enum NotOfThisWorldCondition implements Condition { + instance; private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control with power 7 or greater"); static { @@ -174,11 +174,7 @@ class NotOfThisWorldCondition implements Condition { filter.add(new ControllerPredicate(TargetController.YOU)); } - private static final NotOfThisWorldCondition instance = new NotOfThisWorldCondition(); - public static Condition getInstance() { - return instance; - } @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/n/NotionThief.java b/Mage.Sets/src/mage/cards/n/NotionThief.java index 0a5c5e4042..ee8f2825b8 100644 --- a/Mage.Sets/src/mage/cards/n/NotionThief.java +++ b/Mage.Sets/src/mage/cards/n/NotionThief.java @@ -115,7 +115,7 @@ class NotionThiefReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getStep().getType() == PhaseStep.DRAW) { - CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep"); + CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/n/NotoriousThrong.java b/Mage.Sets/src/mage/cards/n/NotoriousThrong.java index e8cda95734..7b01f3398a 100644 --- a/Mage.Sets/src/mage/cards/n/NotoriousThrong.java +++ b/Mage.Sets/src/mage/cards/n/NotoriousThrong.java @@ -95,7 +95,7 @@ class NotoriousThrongEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get("AmountOfDamageReceivedThisTurn"); + AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); if(controller != null && watcher != null) { int numTokens = 0; for(UUID opponentId: game.getOpponents(controller.getId())) { diff --git a/Mage.Sets/src/mage/cards/o/OathOfChandra.java b/Mage.Sets/src/mage/cards/o/OathOfChandra.java index 680cac01ef..5599ab43b2 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfChandra.java +++ b/Mage.Sets/src/mage/cards/o/OathOfChandra.java @@ -96,7 +96,7 @@ enum OathOfChandraCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - OathOfChandraWatcher watcher = (OathOfChandraWatcher) game.getState().getWatchers().get("OathOfChandraWatcher"); + OathOfChandraWatcher watcher = (OathOfChandraWatcher) game.getState().getWatchers().get(OathOfChandraWatcher.class.getSimpleName()); return watcher != null && watcher.enteredPlaneswalkerForPlayer(source.getControllerId()); } @@ -112,7 +112,7 @@ class OathOfChandraWatcher extends Watcher { private final Set players = new HashSet<>(); public OathOfChandraWatcher() { - super("OathOfChandraWatcher", WatcherScope.GAME); + super(OathOfChandraWatcher.class.getSimpleName(), WatcherScope.GAME); } public OathOfChandraWatcher(final OathOfChandraWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/o/OathOfLiliana.java b/Mage.Sets/src/mage/cards/o/OathOfLiliana.java index 8b300454fa..9ab46b8fc8 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfLiliana.java +++ b/Mage.Sets/src/mage/cards/o/OathOfLiliana.java @@ -49,13 +49,12 @@ import java.util.Set; import java.util.UUID; /** - * * @author fireshoes */ public class OathOfLiliana extends CardImpl { public OathOfLiliana(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}"); addSuperType(SuperType.LEGENDARY); // When Oath of Liliana enters the battlefield, each opponent sacrifices a creature. @@ -64,7 +63,7 @@ public class OathOfLiliana extends CardImpl { // At the beginning of each end step, if a planeswalker entered the battlefield under your control this turn, create a 2/2 black Zombie creature token. this.addAbility(new ConditionalTriggeredAbility(new BeginningOfEndStepTriggeredAbility( new CreateTokenEffect(new ZombieToken()), - TargetController.ANY, false), OathOfLilianaCondition.getInstance(), + TargetController.ANY, false), OathOfLilianaCondition.instance, "At the beginning of each end step, if a planeswalker entered the battlefield under your control this turn, " + "create a 2/2 black Zombie creature token."), new OathOfLilianaWatcher()); } @@ -79,17 +78,13 @@ public class OathOfLiliana extends CardImpl { } } -class OathOfLilianaCondition implements Condition { +enum OathOfLilianaCondition implements Condition { - private static final OathOfLilianaCondition instance = new OathOfLilianaCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - OathOfLilianaWatcher watcher = (OathOfLilianaWatcher) game.getState().getWatchers().get("OathOfLilianaWatcher"); + OathOfLilianaWatcher watcher = (OathOfLilianaWatcher) game.getState().getWatchers().get(OathOfLilianaWatcher.class.getSimpleName()); return watcher != null && watcher.enteredPlaneswalkerForPlayer(source.getControllerId()); } @@ -105,7 +100,7 @@ class OathOfLilianaWatcher extends Watcher { private final Set players = new HashSet<>(); public OathOfLilianaWatcher() { - super("OathOfLilianaWatcher", WatcherScope.GAME); + super(OathOfLilianaWatcher.class.getSimpleName(), WatcherScope.GAME); } public OathOfLilianaWatcher(final OathOfLilianaWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/o/OpalPalace.java b/Mage.Sets/src/mage/cards/o/OpalPalace.java index b746593bde..9bb13f2cb4 100644 --- a/Mage.Sets/src/mage/cards/o/OpalPalace.java +++ b/Mage.Sets/src/mage/cards/o/OpalPalace.java @@ -93,7 +93,7 @@ class OpalPalaceWatcher extends Watcher { private final String originalId; public OpalPalaceWatcher(String originalId) { - super("ManaPaidFromOpalPalaceWatcher", WatcherScope.CARD); + super(OpalPalaceWatcher.class.getSimpleName(), WatcherScope.CARD); this.originalId = originalId; } @@ -156,7 +156,7 @@ class OpalPalaceEntersBattlefieldEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - OpalPalaceWatcher watcher = (OpalPalaceWatcher) game.getState().getWatchers().get("ManaPaidFromOpalPalaceWatcher", source.getSourceId()); + OpalPalaceWatcher watcher = (OpalPalaceWatcher) game.getState().getWatchers().get(OpalPalaceWatcher.class.getSimpleName(), source.getSourceId()); return watcher != null && watcher.commanderId.contains(event.getTargetId()); } diff --git a/Mage.Sets/src/mage/cards/o/OracleEnVec.java b/Mage.Sets/src/mage/cards/o/OracleEnVec.java index 3081e6c392..42f02c7200 100644 --- a/Mage.Sets/src/mage/cards/o/OracleEnVec.java +++ b/Mage.Sets/src/mage/cards/o/OracleEnVec.java @@ -268,7 +268,7 @@ class OracleEnVecDestroyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); if (watcher != null) { for (UUID targetId : chosenCreatures) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java b/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java index eca4ad6bd0..30c0371441 100644 --- a/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java +++ b/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java @@ -125,7 +125,7 @@ class OratorOfOjutaiTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { //Intervening if must be checked Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); return event.getTargetId().equals(getSourceId()) && watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId()); @@ -165,7 +165,7 @@ class OratorOfOjutaiEffect extends OneShotEffect { if (controller != null) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); if (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())) { controller.drawCards(1, game); return true; diff --git a/Mage.Sets/src/mage/cards/o/Overmaster.java b/Mage.Sets/src/mage/cards/o/Overmaster.java index a610502ab2..c74d0f3a83 100644 --- a/Mage.Sets/src/mage/cards/o/Overmaster.java +++ b/Mage.Sets/src/mage/cards/o/Overmaster.java @@ -93,7 +93,7 @@ class OvermasterEffect extends ContinuousRuleModifyingEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatchers().get("overmasterWatcher", source.getControllerId()); + OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatchers().get(OvermasterWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null) { watcher.setReady(); } @@ -121,7 +121,7 @@ class OvermasterEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatchers().get("overmasterWatcher", source.getControllerId()); + OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatchers().get(OvermasterWatcher.class.getSimpleName(), source.getControllerId()); return spell != null && watcher != null && watcher.isUncounterable(spell.getId()); } } @@ -132,7 +132,7 @@ class OvermasterWatcher extends Watcher { protected UUID uncounterableSpell; OvermasterWatcher() { - super("overmasterWatcher", WatcherScope.PLAYER); + super(OvermasterWatcher.class.getSimpleName(), WatcherScope.PLAYER); } OvermasterWatcher(final OvermasterWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/ParadoxHaze.java b/Mage.Sets/src/mage/cards/p/ParadoxHaze.java index bff6da05e8..d87ac200ab 100644 --- a/Mage.Sets/src/mage/cards/p/ParadoxHaze.java +++ b/Mage.Sets/src/mage/cards/p/ParadoxHaze.java @@ -105,7 +105,7 @@ class ParadoxHazeTriggeredAbility extends TriggeredAbilityImpl { if (permanent != null) { Player player = game.getPlayer(permanent.getAttachedTo()); if (player != null && game.getActivePlayerId().equals(player.getId())) { - FirstTimeStepWatcher watcher = (FirstTimeStepWatcher) game.getState().getWatchers().get(EventType.UPKEEP_STEP_POST.toString() + FirstTimeStepWatcher.class.getName()); + FirstTimeStepWatcher watcher = (FirstTimeStepWatcher) game.getState().getWatchers().get(EventType.UPKEEP_STEP_POST.toString() + FirstTimeStepWatcher.class.getSimpleName()); if (watcher != null && !watcher.conditionMet()) { this.getEffects().get(0).setTargetPointer(new FixedTarget(player.getId())); return true; diff --git a/Mage.Sets/src/mage/cards/p/PathOfBravery.java b/Mage.Sets/src/mage/cards/p/PathOfBravery.java index 27a26c7144..ff316f63e7 100644 --- a/Mage.Sets/src/mage/cards/p/PathOfBravery.java +++ b/Mage.Sets/src/mage/cards/p/PathOfBravery.java @@ -28,6 +28,7 @@ package mage.cards.p; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; @@ -48,7 +49,6 @@ import mage.game.Game; import mage.players.Player; /** - * * @author jeffwadsworth */ public class PathOfBravery extends CardImpl { @@ -58,13 +58,14 @@ public class PathOfBravery extends CardImpl { static { filter.add(new ControllerPredicate(TargetController.YOU)); } + static final String rule = "As long as your life total is greater than or equal to your starting life total, creatures you control get +1/+1"; public PathOfBravery(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); // As long as your life total is greater than or equal to your starting life total, creatures you control get +1/+1. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, true), new LifeCondition(), rule))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, true), LifeCondition.instance, rule))); // Whenever one or more creatures you control attack, you gain life equal to the number of attacking creatures. this.addAbility(new AttacksWithCreaturesTriggeredAbility(new PathOfBraveryEffect(), 1)); @@ -81,13 +82,9 @@ public class PathOfBravery extends CardImpl { } } -class LifeCondition implements Condition { +enum LifeCondition implements Condition { - private static LifeCondition instance = new LifeCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/p/PatriciansScorn.java b/Mage.Sets/src/mage/cards/p/PatriciansScorn.java index a10f84fa27..f5220339ed 100644 --- a/Mage.Sets/src/mage/cards/p/PatriciansScorn.java +++ b/Mage.Sets/src/mage/cards/p/PatriciansScorn.java @@ -77,7 +77,7 @@ class CastWhiteSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PatriciansScornWatcher watcher = (PatriciansScornWatcher) game.getState().getWatchers().get("PatriciansScornWatcher", source.getSourceId()); + PatriciansScornWatcher watcher = (PatriciansScornWatcher) game.getState().getWatchers().get(PatriciansScornWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.conditionMet(); } @@ -98,7 +98,7 @@ class PatriciansScornWatcher extends Watcher { } public PatriciansScornWatcher() { - super("PatriciansScornWatcher", WatcherScope.CARD); + super(PatriciansScornWatcher.class.getSimpleName(), WatcherScope.CARD); } public PatriciansScornWatcher(final PatriciansScornWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PermafrostTrap.java b/Mage.Sets/src/mage/cards/p/PermafrostTrap.java index 8965db050e..9a84a65886 100644 --- a/Mage.Sets/src/mage/cards/p/PermafrostTrap.java +++ b/Mage.Sets/src/mage/cards/p/PermafrostTrap.java @@ -54,7 +54,7 @@ public class PermafrostTrap extends CardImpl { this.subtype.add("Trap"); // If an opponent had a green creature enter the battlefield under his or her control this turn, you may pay {U} rather than pay Permafrost Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{U}"), PermafrostTrapCondition.getInstance()), new PermanentsEnteredBattlefieldWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{U}"), PermafrostTrapCondition.instance), new PermanentsEnteredBattlefieldWatcher()); // Tap up to two target creatures. Those creatures don't untap during their controller's next untap step. this.getSpellAbility().addEffect(new TapTargetEffect()); @@ -72,17 +72,13 @@ public class PermafrostTrap extends CardImpl { } } -class PermafrostTrapCondition implements Condition { +enum PermafrostTrapCondition implements Condition { - private static final PermafrostTrapCondition instance = new PermafrostTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/p/PitfallTrap.java b/Mage.Sets/src/mage/cards/p/PitfallTrap.java index f9073c40b3..e5942a0d41 100644 --- a/Mage.Sets/src/mage/cards/p/PitfallTrap.java +++ b/Mage.Sets/src/mage/cards/p/PitfallTrap.java @@ -60,7 +60,7 @@ public class PitfallTrap extends CardImpl { this.subtype.add("Trap"); // If exactly one creature is attacking, you may pay {W} rather than pay Pitfall Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{W}"), PitfallTrapCondition.getInstance())); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{W}"), PitfallTrapCondition.instance)); // Destroy target attacking creature without flying. this.getSpellAbility().addEffect(new DestroyTargetEffect()); @@ -77,13 +77,9 @@ public class PitfallTrap extends CardImpl { } } -class PitfallTrapCondition implements Condition { +enum PitfallTrapCondition implements Condition { - private static final PitfallTrapCondition instance = new PitfallTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/p/PowerSurge.java b/Mage.Sets/src/mage/cards/p/PowerSurge.java index 2c34402795..bfbc33132d 100644 --- a/Mage.Sets/src/mage/cards/p/PowerSurge.java +++ b/Mage.Sets/src/mage/cards/p/PowerSurge.java @@ -90,7 +90,7 @@ class PowerSurgeDamageEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatchers().get(PowerSurgeWatcher.class.getName()); + PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatchers().get(PowerSurgeWatcher.class.getSimpleName()); int damage = watcher.getUntappedLandCount(); player.damage(damage, source.getSourceId(), game, false, true); return true; @@ -115,7 +115,7 @@ class PowerSurgeWatcher extends Watcher { private int untappedLandCount; public PowerSurgeWatcher() { - super(PowerSurgeWatcher.class.getName(), WatcherScope.GAME); + super(PowerSurgeWatcher.class.getSimpleName(), WatcherScope.GAME); } public PowerSurgeWatcher(final PowerSurgeWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java b/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java index b0e3c11c0f..5617f4faeb 100644 --- a/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java +++ b/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java @@ -78,7 +78,7 @@ class DidNotCastCreatureCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { - Watcher watcher = game.getState().getWatchers().get("CastCreature", source.getSourceId()); + Watcher watcher = game.getState().getWatchers().get(CastCreatureWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null && !watcher.conditionMet()) { return true; } @@ -96,7 +96,7 @@ class DidNotCastCreatureCondition implements Condition { class CastCreatureWatcher extends Watcher { public CastCreatureWatcher() { - super("CastCreature", WatcherScope.CARD); + super(CastCreatureWatcher.class.getSimpleName(), WatcherScope.CARD); } public CastCreatureWatcher(final CastCreatureWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java b/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java index 97374c1e38..835ca9dac0 100644 --- a/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java +++ b/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java @@ -114,7 +114,7 @@ class PrizedAmalgamTriggerdAbility extends EntersBattlefieldAllTriggeredAbility if (entersEvent.getFromZone() == Zone.GRAVEYARD) { result = true; } else if (entersEvent.getFromZone() == Zone.STACK && entersEvent.getTarget().getControllerId().equals(getControllerId())) { - CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatchers().get(CastFromGraveyardWatcher.class.getName()); + CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatchers().get(CastFromGraveyardWatcher.class.getSimpleName()); if (watcher != null) { int zcc = game.getState().getZoneChangeCounter(event.getSourceId()); result = watcher.spellWasCastFromGraveyard(event.getSourceId(), zcc - 1); diff --git a/Mage.Sets/src/mage/cards/p/PyromancersAssault.java b/Mage.Sets/src/mage/cards/p/PyromancersAssault.java index 2bd2d11409..8cd1de94a8 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersAssault.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersAssault.java @@ -89,7 +89,7 @@ class PyromancersAssaultTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/q/QueenMarchesa.java b/Mage.Sets/src/mage/cards/q/QueenMarchesa.java index c5a2744a69..ea968f102c 100644 --- a/Mage.Sets/src/mage/cards/q/QueenMarchesa.java +++ b/Mage.Sets/src/mage/cards/q/QueenMarchesa.java @@ -72,7 +72,7 @@ public class QueenMarchesa extends CardImpl { // At the beginning of your upkeep, if an opponent is the monarch, create a 1/1 black Assassin creature token with deathtouch and haste. this.addAbility(new ConditionalTriggeredAbility( new BeginningOfUpkeepTriggeredAbility(new CreateTokenEffect(new QueenMarchesaAssassinToken()), TargetController.YOU, false), - OpponentIsMonarchCondition.getInstance(), + OpponentIsMonarchCondition.instance, "At the beginning of your upkeep, if an opponent is the monarch, create a 1/1 black Assassin creature token with deathtouch and haste.")); } @@ -86,13 +86,9 @@ public class QueenMarchesa extends CardImpl { } } -class OpponentIsMonarchCondition implements Condition { +enum OpponentIsMonarchCondition implements Condition { - private final static OpponentIsMonarchCondition instance = new OpponentIsMonarchCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/q/Quicken.java b/Mage.Sets/src/mage/cards/q/Quicken.java index d55ec3a77c..9955f7452a 100644 --- a/Mage.Sets/src/mage/cards/q/Quicken.java +++ b/Mage.Sets/src/mage/cards/q/Quicken.java @@ -30,6 +30,7 @@ package mage.cards.q; import java.util.ArrayList; import java.util.List; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.common.DrawCardSourceControllerEffect; @@ -47,14 +48,12 @@ import mage.game.stack.Spell; import mage.watchers.Watcher; /** - * * @author LevelX2 - * */ public class Quicken extends CardImpl { public Quicken(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}"); // The next sorcery card you cast this turn can be cast as though it had flash. this.getSpellAbility().addEffect(new QuickenAsThoughEffect()); @@ -92,7 +91,7 @@ class QuickenAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - quickenWatcher = (QuickenWatcher) game.getState().getWatchers().get("consumeQuickenWatcher"); + quickenWatcher = (QuickenWatcher) game.getState().getWatchers().get(QuickenWatcher.class.getSimpleName()); Card card = game.getCard(source.getSourceId()); if (quickenWatcher != null && card != null) { zoneChangeCounter = card.getZoneChangeCounter(game); @@ -128,7 +127,7 @@ class QuickenWatcher extends Watcher { public List activeQuickenSpells = new ArrayList<>(); public QuickenWatcher() { - super("consumeQuickenWatcher", WatcherScope.GAME); + super(QuickenWatcher.class.getSimpleName(), WatcherScope.GAME); } public QuickenWatcher(final QuickenWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java b/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java index e4ea73af40..958498e228 100644 --- a/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java +++ b/Mage.Sets/src/mage/cards/q/QuicksilverFountain.java @@ -27,7 +27,6 @@ */ package mage.cards.q; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -38,12 +37,9 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.BecomesBasicLandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.CounterType; +import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -51,9 +47,11 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.Target; -import mage.target.common.TargetLandPermanent; +import mage.target.TargetPermanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -84,7 +82,7 @@ public class QuicksilverFountain extends CardImpl { class QuicksilverFountainEffect extends OneShotEffect { - static final private FilterLandPermanent filterNonIslandLand = new FilterLandPermanent("non-Island land"); + static final private FilterControlledLandPermanent filterNonIslandLand = new FilterControlledLandPermanent("non-Island land"); static { filterNonIslandLand.add(Predicates.not(new SubtypePredicate("Island"))); @@ -102,7 +100,7 @@ class QuicksilverFountainEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); - Target targetNonIslandLand = new TargetLandPermanent(filterNonIslandLand); + Target targetNonIslandLand = new TargetPermanent(filterNonIslandLand); if (player != null) { if (player.choose(Outcome.Neutral, targetNonIslandLand, source.getId(), game)) { Permanent landChosen = game.getPermanent(targetNonIslandLand.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java b/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java index a13f2826ea..b311dc1925 100644 --- a/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java +++ b/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java @@ -95,7 +95,7 @@ class RashmiEternitiesCrafterTriggeredAbility extends SpellCastControllerTrigger @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java b/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java index 755b32951e..2ab0a4627d 100644 --- a/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java +++ b/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java @@ -57,7 +57,6 @@ import java.util.Set; import java.util.UUID; /** - * * @author emerald000 */ public class RasputinDreamweaver extends CardImpl { @@ -83,9 +82,9 @@ public class RasputinDreamweaver extends CardImpl { // At the beginning of your upkeep, if Rasputin started the turn untapped, put a dream counter on it. this.addAbility( new ConditionalTriggeredAbility( - new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.DREAM.createInstance()), TargetController.YOU, false), - new RasputinDreamweaverStartedUntappedCondition(), - "At the beginning of your upkeep, if {this} started the turn untapped, put a dream counter on it."), + new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.DREAM.createInstance()), TargetController.YOU, false), + RasputinDreamweaverStartedUntappedCondition.instance, + "At the beginning of your upkeep, if {this} started the turn untapped, put a dream counter on it."), new RasputinDreamweaverStartedUntappedWatcher()); // Rasputin can't have more than seven dream counters on it. @@ -102,17 +101,13 @@ public class RasputinDreamweaver extends CardImpl { } } -class RasputinDreamweaverStartedUntappedCondition implements Condition { +enum RasputinDreamweaverStartedUntappedCondition implements Condition { - private static final RasputinDreamweaverStartedUntappedCondition instance = new RasputinDreamweaverStartedUntappedCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - RasputinDreamweaverStartedUntappedWatcher watcher = (RasputinDreamweaverStartedUntappedWatcher) game.getState().getWatchers().get(RasputinDreamweaverStartedUntappedWatcher.class.getName()); + RasputinDreamweaverStartedUntappedWatcher watcher = (RasputinDreamweaverStartedUntappedWatcher) game.getState().getWatchers().get(RasputinDreamweaverStartedUntappedWatcher.class.getSimpleName()); if (watcher != null) { return watcher.startedUntapped(source.getSourceId()); } @@ -128,6 +123,7 @@ class RasputinDreamweaverStartedUntappedCondition implements Condition { class RasputinDreamweaverStartedUntappedWatcher extends Watcher { private static final FilterPermanent filter = new FilterPermanent("Untapped permanents"); + static { filter.add(Predicates.not(new TappedPredicate())); } @@ -135,7 +131,7 @@ class RasputinDreamweaverStartedUntappedWatcher extends Watcher { private final Set startedUntapped = new HashSet<>(0); RasputinDreamweaverStartedUntappedWatcher() { - super(RasputinDreamweaverStartedUntappedWatcher.class.getName(), WatcherScope.GAME); + super(RasputinDreamweaverStartedUntappedWatcher.class.getSimpleName(), WatcherScope.GAME); } RasputinDreamweaverStartedUntappedWatcher(final RasputinDreamweaverStartedUntappedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/r/RavenousTrap.java b/Mage.Sets/src/mage/cards/r/RavenousTrap.java index 67e666d284..19c17083fc 100644 --- a/Mage.Sets/src/mage/cards/r/RavenousTrap.java +++ b/Mage.Sets/src/mage/cards/r/RavenousTrap.java @@ -51,7 +51,7 @@ public class RavenousTrap extends CardImpl { this.subtype.add("Trap"); // If an opponent had three or more cards put into his or her graveyard from anywhere this turn, you may pay {0} rather than pay Ravenous Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{0}"), RavenousTrapCondition.getInstance()), new CardsPutIntoGraveyardWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{0}"), RavenousTrapCondition.instance), new CardsPutIntoGraveyardWatcher()); // Exile all cards from target player's graveyard. this.getSpellAbility().addEffect(new ExileGraveyardAllTargetPlayerEffect()); @@ -68,17 +68,13 @@ public class RavenousTrap extends CardImpl { } } -class RavenousTrapCondition implements Condition { +enum RavenousTrapCondition implements Condition { - private static final RavenousTrapCondition instance = new RavenousTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get("CardsPutIntoGraveyardWatcher"); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getAmountCardsPutToGraveyard(opponentId) > 2) { diff --git a/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java b/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java index cf41de263f..03d8472e30 100644 --- a/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java +++ b/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java @@ -46,6 +46,7 @@ import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.target.common.TargetCreaturePermanent; import mage.watchers.Watcher; +import mage.watchers.common.MorbidWatcher; /** * @@ -105,7 +106,7 @@ class ReaperFromTheAbyssAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - Watcher watcher = game.getState().getWatchers().get("Morbid"); + Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); return watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/r/Reciprocate.java b/Mage.Sets/src/mage/cards/r/Reciprocate.java index 050ca5fcd4..9ffae04e16 100644 --- a/Mage.Sets/src/mage/cards/r/Reciprocate.java +++ b/Mage.Sets/src/mage/cards/r/Reciprocate.java @@ -80,7 +80,7 @@ class ReciprocateTarget extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", source.getControllerId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null && watcher.hasSourceDoneDamage(id, game)) { return super.canTarget(id, source, game); } @@ -91,7 +91,7 @@ class ReciprocateTarget extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); if (permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)) { @@ -109,7 +109,7 @@ class ReciprocateTarget extends TargetPermanent { } int count = 0; MageObject targetSource = game.getObject(sourceId); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/r/RefractionTrap.java b/Mage.Sets/src/mage/cards/r/RefractionTrap.java index 6f7d67fb19..4594e1ea09 100644 --- a/Mage.Sets/src/mage/cards/r/RefractionTrap.java +++ b/Mage.Sets/src/mage/cards/r/RefractionTrap.java @@ -29,6 +29,7 @@ package mage.cards.r; import java.util.List; import java.util.UUID; + import mage.MageObject; import mage.abilities.Ability; import mage.abilities.condition.Condition; @@ -52,17 +53,16 @@ import mage.target.common.TargetCreatureOrPlayer; import mage.watchers.common.SpellsCastWatcher; /** - * * @author jeffwadsworth */ public class RefractionTrap extends CardImpl { public RefractionTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W}"); this.subtype.add("Trap"); // If an opponent cast a red instant or sorcery spell this turn, you may pay {W} rather than pay Refraction Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{W}"), RefractionTrapCondition.getInstance()), new SpellsCastWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{W}"), RefractionTrapCondition.instance), new SpellsCastWatcher()); // Prevent the next 3 damage that a source of your choice would deal to you and/or permanents you control this turn. If damage is prevented this way, Refraction Trap deals that much damage to target creature or player. this.getSpellAbility().addEffect(new RefractionTrapPreventDamageEffect(Duration.EndOfTurn, 3)); @@ -79,17 +79,12 @@ public class RefractionTrap extends CardImpl { } } -class RefractionTrapCondition implements Condition { - - private static final RefractionTrapCondition instance = new RefractionTrapCondition(); - - public static Condition getInstance() { - return instance; - } +enum RefractionTrapCondition implements Condition { + instance; @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List spells = watcher.getSpellsCastThisTurn(opponentId); diff --git a/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java b/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java index 78934a6738..924ee8a569 100644 --- a/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java +++ b/Mage.Sets/src/mage/cards/r/ResoluteArchangel.java @@ -58,7 +58,7 @@ public class ResoluteArchangel extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); // When Resolute Angel enters the battlefield, if your life total is lower than your starting life total, it becomes equal to your starting life total. - this.addAbility(new EntersBattlefieldTriggeredAbility(new ConditionalOneShotEffect(new ResoluteArchangelEffect(), ControllerLifeLowerThanStrtingLife.getInstance(), + this.addAbility(new EntersBattlefieldTriggeredAbility(new ConditionalOneShotEffect(new ResoluteArchangelEffect(), ControllerLifeLowerThanStrtingLife.instance, "if your life total is lower than your starting life total, it becomes equal to your starting life total"))); } @@ -99,13 +99,9 @@ class ResoluteArchangelEffect extends OneShotEffect { } } -class ControllerLifeLowerThanStrtingLife implements Condition { +enum ControllerLifeLowerThanStrtingLife implements Condition { - private static final ControllerLifeLowerThanStrtingLife instance = new ControllerLifeLowerThanStrtingLife(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/r/RestoreThePeace.java b/Mage.Sets/src/mage/cards/r/RestoreThePeace.java index 16e294fd67..9340de0fd7 100644 --- a/Mage.Sets/src/mage/cards/r/RestoreThePeace.java +++ b/Mage.Sets/src/mage/cards/r/RestoreThePeace.java @@ -28,6 +28,7 @@ package mage.cards.r; import java.util.UUID; + import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -40,13 +41,12 @@ import mage.game.permanent.Permanent; import mage.watchers.common.SourceDidDamageWatcher; /** - * * @author LevelX2 */ public class RestoreThePeace extends CardImpl { public RestoreThePeace(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}{U}"); // Return each creature that dealt damage this turn to its owner's hand. @@ -66,33 +66,33 @@ public class RestoreThePeace extends CardImpl { } class RestoreThePeaceEffect extends OneShotEffect { - + public RestoreThePeaceEffect() { super(Outcome.ReturnToHand); this.staticText = "Return each creature that dealt damage this turn to its owner's hand"; } - + public RestoreThePeaceEffect(final RestoreThePeaceEffect effect) { super(effect); } - + @Override public RestoreThePeaceEffect copy() { return new RestoreThePeaceEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); if (watcher != null) { - for (UUID permId :watcher.damageSources) { + for (UUID permId : watcher.damageSources) { Permanent perm = game.getPermanent(permId); if (perm != null) { perm.moveToZone(Zone.HAND, source.getSourceId(), game, true); } } return true; - } + } return false; } } diff --git a/Mage.Sets/src/mage/cards/r/Revenge.java b/Mage.Sets/src/mage/cards/r/Revenge.java index 68a8fffaec..146b8ea231 100644 --- a/Mage.Sets/src/mage/cards/r/Revenge.java +++ b/Mage.Sets/src/mage/cards/r/Revenge.java @@ -59,7 +59,7 @@ public class Revenge extends CardImpl { // Target creature you control gets +4/+0 until end of turn before it fights if you lost life this turn. this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new RevengeEffect(), - LostLifeCondition.getInstance(), + LostLifeCondition.instance, "Target creature you control gets +4/+0 until end of turn before it fights if you lost life this turn")); // Target creature you control fights target creature an opponent controls. @@ -85,13 +85,10 @@ enum LostLifeCondition implements Condition { instance; - public static Condition getInstance() { - return instance; - } @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); UUID player = source.getControllerId(); if (watcher != null && player != null) { return watcher.getLiveLost(player) > 0; diff --git a/Mage.Sets/src/mage/cards/r/RicochetTrap.java b/Mage.Sets/src/mage/cards/r/RicochetTrap.java index 3d95024219..b3dd912984 100644 --- a/Mage.Sets/src/mage/cards/r/RicochetTrap.java +++ b/Mage.Sets/src/mage/cards/r/RicochetTrap.java @@ -29,6 +29,7 @@ package mage.cards.r; import java.util.List; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.costs.AlternativeCostSourceAbility; @@ -45,7 +46,6 @@ import mage.target.TargetSpell; import mage.watchers.common.SpellsCastWatcher; /** - * * @author jeffwadsworth */ public class RicochetTrap extends CardImpl { @@ -57,11 +57,11 @@ public class RicochetTrap extends CardImpl { } public RicochetTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}"); this.subtype.add("Trap"); // If an opponent cast a blue spell this turn, you may pay {R} rather than pay Ricochet Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{R}"), RicochetTrapCondition.getInstance())); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{R}"), RicochetTrapCondition.instance)); // Change the target of target spell with a single target. this.getSpellAbility().addEffect(new ChooseNewTargetsTargetEffect(true, true)); @@ -80,17 +80,13 @@ public class RicochetTrap extends CardImpl { } } -class RicochetTrapCondition implements Condition { +enum RicochetTrapCondition implements Condition { - private static final RicochetTrapCondition instance = new RicochetTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List spells = watcher.getSpellsCastThisTurn(opponentId); diff --git a/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java b/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java index 3caa4e3a58..2e63ee1e4d 100644 --- a/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java +++ b/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java @@ -98,7 +98,7 @@ class PlayerLostLifePredicate implements Predicate { @Override public boolean apply(Player input, Game game) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { return (0 < watcher.getLiveLost(input.getId())); } diff --git a/Mage.Sets/src/mage/cards/r/RocketLauncher.java b/Mage.Sets/src/mage/cards/r/RocketLauncher.java index a2965cf2db..dfe832e41b 100644 --- a/Mage.Sets/src/mage/cards/r/RocketLauncher.java +++ b/Mage.Sets/src/mage/cards/r/RocketLauncher.java @@ -82,7 +82,7 @@ class RocketLauncherWatcher extends Watcher { UUID cardId = null; public RocketLauncherWatcher(UUID cardId) { - super("RocketLauncherWatcher", WatcherScope.GAME); + super(RocketLauncherWatcher.class.getSimpleName(), WatcherScope.GAME); this.changedControllerOR1stTurn = true; this.cardId = cardId; } @@ -123,7 +123,7 @@ enum ControlledTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatchers().get("RocketLauncherWatcher"); + RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatchers().get(RocketLauncherWatcher.class.getSimpleName()); return !watcher.changedControllerOR1stTurn; } diff --git a/Mage.Sets/src/mage/cards/r/RuneflareTrap.java b/Mage.Sets/src/mage/cards/r/RuneflareTrap.java index 4f847aade0..f63a24676b 100644 --- a/Mage.Sets/src/mage/cards/r/RuneflareTrap.java +++ b/Mage.Sets/src/mage/cards/r/RuneflareTrap.java @@ -54,7 +54,7 @@ public class RuneflareTrap extends CardImpl { this.subtype.add("Trap"); // If an opponent drew three or more cards this turn, you may pay {R} rather than pay Runeflare Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{R}"), RuneflareTrapCondition.getInstance()), new CardsAmountDrawnThisTurnWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{R}"), RuneflareTrapCondition.instance), new CardsAmountDrawnThisTurnWatcher()); // Runeflare Trap deals damage to target player equal to the number of cards in that player's hand. this.getSpellAbility().addEffect(new DamageTargetEffect(new TargetPlayerCardsInHandCount())); @@ -100,18 +100,14 @@ class TargetPlayerCardsInHandCount implements DynamicValue { } } -class RuneflareTrapCondition implements Condition { +enum RuneflareTrapCondition implements Condition { - private static final RuneflareTrapCondition instance = new RuneflareTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { CardsAmountDrawnThisTurnWatcher watcher = - (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.BASIC_KEY); + (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); return watcher != null && watcher.opponentDrewXOrMoreCards(source.getControllerId(), 3, game); } diff --git a/Mage.Sets/src/mage/cards/s/SavageSummoning.java b/Mage.Sets/src/mage/cards/s/SavageSummoning.java index 3986eb2461..38a715d438 100644 --- a/Mage.Sets/src/mage/cards/s/SavageSummoning.java +++ b/Mage.Sets/src/mage/cards/s/SavageSummoning.java @@ -108,7 +108,7 @@ class SavageSummoningAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (SavageSummoningWatcher) game.getState().getWatchers().get("consumeSavageSummoningWatcher", source.getControllerId()); + watcher = (SavageSummoningWatcher) game.getState().getWatchers().get(SavageSummoningWatcher.class.getSimpleName(), source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher != null && card != null) { watcher.setSavageSummoningSpellActive(card, game); @@ -155,7 +155,7 @@ class SavageSummoningWatcher extends Watcher { private Map> cardsCastWithSavageSummoning = new LinkedHashMap<>(); public SavageSummoningWatcher() { - super("consumeSavageSummoningWatcher", WatcherScope.PLAYER); + super(SavageSummoningWatcher.class.getSimpleName(), WatcherScope.PLAYER); } public SavageSummoningWatcher(final SavageSummoningWatcher watcher) { @@ -240,7 +240,7 @@ class SavageSummoningCantCounterEffect extends ContinuousRuleModifyingEffectImpl @Override public void init(Ability source, Game game) { - watcher = (SavageSummoningWatcher) game.getState().getWatchers().get("consumeSavageSummoningWatcher", source.getControllerId()); + watcher = (SavageSummoningWatcher) game.getState().getWatchers().get(SavageSummoningWatcher.class.getSimpleName(), source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher == null || card == null) { throw new IllegalArgumentException("Consume Savage watcher or card could not be found"); @@ -298,7 +298,7 @@ class SavageSummoningEntersBattlefieldEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (SavageSummoningWatcher) game.getState().getWatchers().get("consumeSavageSummoningWatcher", source.getControllerId()); + watcher = (SavageSummoningWatcher) game.getState().getWatchers().get(SavageSummoningWatcher.class.getSimpleName(), source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher == null || card == null) { throw new IllegalArgumentException("Consume Savage watcher or card could not be found"); diff --git a/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java b/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java index 1625f1b0f6..83edeed9c9 100644 --- a/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java +++ b/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java @@ -72,7 +72,7 @@ public class ScaleguardSentinels extends CardImpl { // Scaleguard Sentinels enters the battlefield with a +1/+1 counter on it if you revealed a Dragon card or controlled a Dragon as you cast Scaleguard Sentinels. this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(), true), - ScaleguardSentinelsCondition.getInstance(), + ScaleguardSentinelsCondition.instance, "{this} enters the battlefield with a +1/+1 counter on it if you revealed a Dragon card or controlled a Dragon as you cast {this}", ""), new DragonOnTheBattlefieldWhileSpellWasCastWatcher()); @@ -100,19 +100,15 @@ public class ScaleguardSentinels extends CardImpl { } } -class ScaleguardSentinelsCondition implements Condition { +enum ScaleguardSentinelsCondition implements Condition { - private static final ScaleguardSentinelsCondition instance = new ScaleguardSentinelsCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); if (sourcePermanent != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); return (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())); } return false; diff --git a/Mage.Sets/src/mage/cards/s/ScoutsWarning.java b/Mage.Sets/src/mage/cards/s/ScoutsWarning.java index b7ad2a982f..c5ebbd30d6 100644 --- a/Mage.Sets/src/mage/cards/s/ScoutsWarning.java +++ b/Mage.Sets/src/mage/cards/s/ScoutsWarning.java @@ -91,7 +91,7 @@ class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (ScoutsWarningWatcher) game.getState().getWatchers().get("consumeScoutsWarningWatcher", source.getControllerId()); + watcher = (ScoutsWarningWatcher) game.getState().getWatchers().get(ScoutsWarningWatcher.class.getSimpleName(), source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher != null && card != null) { zoneChangeCounter = card.getZoneChangeCounter(game); @@ -127,7 +127,7 @@ class ScoutsWarningWatcher extends Watcher { public List activeScoutsWarningSpells = new ArrayList<>(); public ScoutsWarningWatcher() { - super("consumeScoutsWarningWatcher", WatcherScope.PLAYER); + super(ScoutsWarningWatcher.class.getSimpleName(), WatcherScope.PLAYER); } public ScoutsWarningWatcher(final ScoutsWarningWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SearingBlaze.java b/Mage.Sets/src/mage/cards/s/SearingBlaze.java index 79f8400cd1..56dabba7cd 100644 --- a/Mage.Sets/src/mage/cards/s/SearingBlaze.java +++ b/Mage.Sets/src/mage/cards/s/SearingBlaze.java @@ -93,7 +93,7 @@ class SearingBlazeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get("LandPlayed"); + LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get(LandfallWatcher.class.getSimpleName()); Player player = game.getPlayer(source.getTargets().get(0).getFirstTarget()); Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); int damage = 1; diff --git a/Mage.Sets/src/mage/cards/s/SecondGuess.java b/Mage.Sets/src/mage/cards/s/SecondGuess.java index ea25f36aad..b3811482b1 100644 --- a/Mage.Sets/src/mage/cards/s/SecondGuess.java +++ b/Mage.Sets/src/mage/cards/s/SecondGuess.java @@ -76,7 +76,7 @@ class SecondSpellPredicate implements Predicate { @Override public boolean apply(Spell input, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher.getSpellOrder(new MageObjectReference(input.getId(), game), game) == 2) { return true; diff --git a/Mage.Sets/src/mage/cards/s/SecondSunrise.java b/Mage.Sets/src/mage/cards/s/SecondSunrise.java index 066c52f497..6fa5d32a70 100644 --- a/Mage.Sets/src/mage/cards/s/SecondSunrise.java +++ b/Mage.Sets/src/mage/cards/s/SecondSunrise.java @@ -82,7 +82,7 @@ class SecondSunriseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - SecondSunriseWatcher watcher = (SecondSunriseWatcher) game.getState().getWatchers().get("SecondSunriseWatcher"); + SecondSunriseWatcher watcher = (SecondSunriseWatcher) game.getState().getWatchers().get(SecondSunriseWatcher.class.getSimpleName()); if (watcher != null) { for (UUID id : watcher.cards) { Card c = game.getCard(id); @@ -107,7 +107,7 @@ class SecondSunriseWatcher extends Watcher { ArrayList cards = new ArrayList<>(); public SecondSunriseWatcher() { - super("SecondSunriseWatcher", WatcherScope.GAME); + super(SecondSunriseWatcher.class.getSimpleName(), WatcherScope.GAME); } public SecondSunriseWatcher(final SecondSunriseWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java b/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java index 289144b798..b72a36c6e1 100644 --- a/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java +++ b/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java @@ -81,7 +81,7 @@ class CastNonCreatureSpellCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { List spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spellsCast != null) { diff --git a/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java b/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java index 3ebf33a742..24ad465131 100644 --- a/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java +++ b/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java @@ -84,8 +84,7 @@ class ShadowOfTheGraveEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState() - .getWatchers().get(CardsCycledOrDiscardedThisTurnWatcher.class.getName()); + CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState().getWatchers().get(CardsCycledOrDiscardedThisTurnWatcher.class.getSimpleName()); if (controller != null && watcher != null) { for (Card card : watcher.getCardsCycledOrDiscardedThisTurn(controller.getId()).getCards(game)) { diff --git a/Mage.Sets/src/mage/cards/s/SiftThroughSands.java b/Mage.Sets/src/mage/cards/s/SiftThroughSands.java index f300672b8e..7b936ee4d2 100644 --- a/Mage.Sets/src/mage/cards/s/SiftThroughSands.java +++ b/Mage.Sets/src/mage/cards/s/SiftThroughSands.java @@ -90,7 +90,7 @@ class SiftThroughSandsCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SiftThroughSandsWatcher watcher = (SiftThroughSandsWatcher) game.getState().getWatchers().get("SiftThroughSandsWatcher", source.getControllerId()); + SiftThroughSandsWatcher watcher = (SiftThroughSandsWatcher) game.getState().getWatchers().get(SiftThroughSandsWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -104,7 +104,7 @@ class SiftThroughSandsWatcher extends Watcher { boolean castReachThroughMists = false; public SiftThroughSandsWatcher() { - super("SiftThroughSandsWatcher", WatcherScope.PLAYER); + super(SiftThroughSandsWatcher.class.getSimpleName(), WatcherScope.PLAYER); } public SiftThroughSandsWatcher(final SiftThroughSandsWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java b/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java index 7ac1159b66..e2ed528ea4 100644 --- a/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java +++ b/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java @@ -94,7 +94,7 @@ class SilburlindSnapperEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { List spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spellsCast != null) { diff --git a/Mage.Sets/src/mage/cards/s/SilentChantZubera.java b/Mage.Sets/src/mage/cards/s/SilentChantZubera.java index b54f1a403e..754bbe7c34 100644 --- a/Mage.Sets/src/mage/cards/s/SilentChantZubera.java +++ b/Mage.Sets/src/mage/cards/s/SilentChantZubera.java @@ -74,7 +74,7 @@ class SilentChantZuberaDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied"); + ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); return watcher.zuberasDiedThisTurn * 2; } diff --git a/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java b/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java index 8ef8211f34..d54fdac63f 100644 --- a/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java +++ b/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java @@ -119,7 +119,7 @@ class SilumgarsScornCounterEffect extends OneShotEffect { if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); if (player != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); boolean condition = watcher != null && watcher.castWithConditionTrue(source.getId()); if (!condition) { for (Cost cost: source.getCosts()) { diff --git a/Mage.Sets/src/mage/cards/s/Simulacrum.java b/Mage.Sets/src/mage/cards/s/Simulacrum.java index fbcc10505d..b32fe21852 100644 --- a/Mage.Sets/src/mage/cards/s/Simulacrum.java +++ b/Mage.Sets/src/mage/cards/s/Simulacrum.java @@ -73,7 +73,7 @@ class SimulacrumAmount implements DynamicValue { @Override public int calculate(Game game, Ability source, Effect effect) { - AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get("AmountOfDamageReceivedThisTurn"); + AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); if(watcher != null) { return watcher.getAmountOfDamageReceivedThisTurn(source.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/s/SirensCall.java b/Mage.Sets/src/mage/cards/s/SirensCall.java index a8154c1874..e92fc7079f 100644 --- a/Mage.Sets/src/mage/cards/s/SirensCall.java +++ b/Mage.Sets/src/mage/cards/s/SirensCall.java @@ -145,7 +145,7 @@ class SirensCallDestroyEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { continue; } diff --git a/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java b/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java index 3c8de0e3f8..fe8687dba3 100644 --- a/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java +++ b/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java @@ -86,7 +86,7 @@ class OpponentWasDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId()); + BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); return watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/s/Skeletonize.java b/Mage.Sets/src/mage/cards/s/Skeletonize.java index db616aafb8..223759a967 100644 --- a/Mage.Sets/src/mage/cards/s/Skeletonize.java +++ b/Mage.Sets/src/mage/cards/s/Skeletonize.java @@ -122,7 +122,7 @@ class SkeletonizeDelayedTriggeredAbility extends DelayedTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeEvent zce = (ZoneChangeEvent) event; if (zce.isDiesEvent()) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", this.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), this.getSourceId()); if (watcher != null) { return watcher.wasDamaged(zce.getTarget(), game); } diff --git a/Mage.Sets/src/mage/cards/s/SlingbowTrap.java b/Mage.Sets/src/mage/cards/s/SlingbowTrap.java index fa8c9d5fa5..c7ea736c4c 100644 --- a/Mage.Sets/src/mage/cards/s/SlingbowTrap.java +++ b/Mage.Sets/src/mage/cards/s/SlingbowTrap.java @@ -28,6 +28,7 @@ package mage.cards.s; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.costs.AlternativeCostSourceAbility; @@ -44,7 +45,6 @@ import mage.game.permanent.Permanent; import mage.target.common.TargetAttackingCreature; /** - * * @author jeffwadsworth */ public class SlingbowTrap extends CardImpl { @@ -56,11 +56,11 @@ public class SlingbowTrap extends CardImpl { } public SlingbowTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{G}"); this.subtype.add("Trap"); // If a black creature with flying is attacking, you may pay {G} rather than pay Slingbow Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{G}"), SlingbowTrapCondition.getInstance())); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{G}"), SlingbowTrapCondition.instance)); // Destroy target attacking creature with flying. this.getSpellAbility().addEffect(new DestroyTargetEffect()); @@ -77,13 +77,9 @@ public class SlingbowTrap extends CardImpl { } } -class SlingbowTrapCondition implements Condition { +enum SlingbowTrapCondition implements Condition { - private static final SlingbowTrapCondition instance = new SlingbowTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/s/SokenzanRenegade.java b/Mage.Sets/src/mage/cards/s/SokenzanRenegade.java index 3c48a75f29..af634cee43 100644 --- a/Mage.Sets/src/mage/cards/s/SokenzanRenegade.java +++ b/Mage.Sets/src/mage/cards/s/SokenzanRenegade.java @@ -69,7 +69,7 @@ public class SokenzanRenegade extends CardImpl { // At the beginning of your upkeep, if a player has more cards in hand than each other player, the player who has the most cards in hand gains control of Sokenzan Renegade. this.addAbility(new ConditionalTriggeredAbility( new BeginningOfUntapTriggeredAbility(Zone.BATTLEFIELD, new SokenzanRenegadeEffect(), TargetController.YOU, false), - OnePlayerHasTheMostCards.getInstance(), + OnePlayerHasTheMostCards.instance, "At the beginning of your upkeep, if a player has more cards in hand than each other player, the player who has the most cards in hand gains control of {this}" )); @@ -135,10 +135,6 @@ enum OnePlayerHasTheMostCards implements Condition { instance; - public static Condition getInstance() { - return instance; - } - @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/s/SoulReap.java b/Mage.Sets/src/mage/cards/s/SoulReap.java index 08d48687ff..9fe45702ad 100644 --- a/Mage.Sets/src/mage/cards/s/SoulReap.java +++ b/Mage.Sets/src/mage/cards/s/SoulReap.java @@ -91,7 +91,7 @@ class CastBlackSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SoulReapWatcher watcher = (SoulReapWatcher) game.getState().getWatchers().get("SoulReapWatcher", source.getControllerId()); + SoulReapWatcher watcher = (SoulReapWatcher) game.getState().getWatchers().get(SoulReapWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -110,7 +110,7 @@ class SoulReapWatcher extends Watcher { private UUID cardId; public SoulReapWatcher(UUID cardId) { - super("SoulReapWatcher", WatcherScope.PLAYER); + super(SoulReapWatcher.class.getSimpleName(), WatcherScope.PLAYER); this.cardId = cardId; } diff --git a/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java b/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java index ca6dbc120b..50ef58334f 100644 --- a/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java +++ b/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java @@ -95,7 +95,7 @@ class SpinerockKnollCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int maxDamageReceived = 0; - SpinerockKnollWatcher watcher = (SpinerockKnollWatcher) game.getState().getWatchers().get("SpinerockKnollWatcher", source.getSourceId()); + SpinerockKnollWatcher watcher = (SpinerockKnollWatcher) game.getState().getWatchers().get(SpinerockKnollWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { int damageReceived = watcher.getDamageReceived(opponentId); @@ -118,7 +118,7 @@ class SpinerockKnollWatcher extends Watcher { private final Map amountOfDamageReceivedThisTurn = new HashMap<>(1); SpinerockKnollWatcher() { - super("SpinerockKnollWatcher", WatcherScope.CARD); + super(SpinerockKnollWatcher.class.getSimpleName(), WatcherScope.CARD); } SpinerockKnollWatcher(final SpinerockKnollWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SpiritOfResistance.java b/Mage.Sets/src/mage/cards/s/SpiritOfResistance.java index eb69e1f59a..205a6eca65 100644 --- a/Mage.Sets/src/mage/cards/s/SpiritOfResistance.java +++ b/Mage.Sets/src/mage/cards/s/SpiritOfResistance.java @@ -47,18 +47,17 @@ import mage.game.permanent.Permanent; import mage.players.Player; /** - * * @author Quercitron */ public class SpiritOfResistance extends CardImpl { public SpiritOfResistance(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); // As long as you control a permanent of each color, prevent all damage that would be dealt to you. Effect effect = new ConditionalReplacementEffect( new PreventDamageToControllerEffect(Duration.WhileOnBattlefield), - SpiritOfResistanceCondition.getInstance()); + SpiritOfResistanceCondition.instance); effect.setText("As long as you control a permanent of each color, prevent all damage that would be dealt to you."); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } @@ -73,15 +72,9 @@ public class SpiritOfResistance extends CardImpl { } } -class SpiritOfResistanceCondition implements Condition { +enum SpiritOfResistanceCondition implements Condition { - private static final SpiritOfResistanceCondition instance = new SpiritOfResistanceCondition(); - - public static SpiritOfResistanceCondition getInstance() { - return instance; - } - - private SpiritOfResistanceCondition() {} + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java b/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java index be3808944e..8f00bfe51f 100644 --- a/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java +++ b/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java @@ -74,7 +74,7 @@ class SpiritOfTheLabyrinthWatcher extends Watcher { private final HashSet playersThatDrewCard; public SpiritOfTheLabyrinthWatcher() { - super("DrewCard", WatcherScope.GAME); + super(SpiritOfTheLabyrinthWatcher.class.getSimpleName(), WatcherScope.GAME); this.playersThatDrewCard = new HashSet<>(); } @@ -137,7 +137,7 @@ class SpiritOfTheLabyrinthEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatchers().get("DrewCard"); + SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatchers().get(SpiritOfTheLabyrinthWatcher.class.getSimpleName()); if (watcher != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java b/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java index fca6a43524..d4244495c3 100644 --- a/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java +++ b/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java @@ -87,7 +87,7 @@ class SpoilsOfBloodEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - CreaturesDiedThisTurnWatcher watcher = (CreaturesDiedThisTurnWatcher) game.getState().getWatchers().get("CreaturesDied"); + CreaturesDiedThisTurnWatcher watcher = (CreaturesDiedThisTurnWatcher) game.getState().getWatchers().get(CreaturesDiedThisTurnWatcher.class.getSimpleName()); if (watcher != null) { new CreateTokenEffect(new SpoilsOfBloodHorrorToken(watcher.creaturesDiedThisTurn)).apply(game, source); } @@ -109,7 +109,7 @@ class CreaturesDiedThisTurnWatcher extends Watcher { public int creaturesDiedThisTurn = 0; public CreaturesDiedThisTurnWatcher() { - super("CreaturesDied", WatcherScope.GAME); + super(CreaturesDiedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public CreaturesDiedThisTurnWatcher(final CreaturesDiedThisTurnWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SteelHellkite.java b/Mage.Sets/src/mage/cards/s/SteelHellkite.java index cc2b6fdb1e..244697bf5e 100644 --- a/Mage.Sets/src/mage/cards/s/SteelHellkite.java +++ b/Mage.Sets/src/mage/cards/s/SteelHellkite.java @@ -28,6 +28,7 @@ package mage.cards.s; import java.util.UUID; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.LimitedTimesPerTurnActivatedAbility; @@ -54,7 +55,7 @@ import mage.watchers.common.PlayerDamagedBySourceWatcher; public class SteelHellkite extends CardImpl { public SteelHellkite(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}"); this.subtype.add("Dragon"); this.power = new MageInt(5); @@ -97,9 +98,9 @@ class SteelHellkiteDestroyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int xValue = source.getManaCostsToPay().getX(); - for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { if (permanent.getConvertedManaCost() == xValue) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", permanent.getControllerId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), permanent.getControllerId()); if (watcher != null && watcher.hasSourceDoneDamage(source.getSourceId(), game)) { permanent.destroy(source.getSourceId(), game, false); } diff --git a/Mage.Sets/src/mage/cards/s/StormEntity.java b/Mage.Sets/src/mage/cards/s/StormEntity.java index 49d7f56c9c..ccd54edfba 100644 --- a/Mage.Sets/src/mage/cards/s/StormEntity.java +++ b/Mage.Sets/src/mage/cards/s/StormEntity.java @@ -79,7 +79,7 @@ class OtherSpellsCastThisTurnCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); return watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() - 1; } diff --git a/Mage.Sets/src/mage/cards/s/SummoningTrap.java b/Mage.Sets/src/mage/cards/s/SummoningTrap.java index cf7e3ba828..13f6c70749 100644 --- a/Mage.Sets/src/mage/cards/s/SummoningTrap.java +++ b/Mage.Sets/src/mage/cards/s/SummoningTrap.java @@ -65,7 +65,7 @@ public class SummoningTrap extends CardImpl { this.subtype.add("Trap"); // If a creature spell you cast this turn was countered by a spell or ability an opponent controlled, you may pay {0} rather than pay Summoning Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{0}"), SummoningTrapCondition.getInstance()), new SummoningTrapWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{0}"), SummoningTrapCondition.instance), new SummoningTrapWatcher()); // Look at the top seven cards of your library. You may put a creature card from among them onto the battlefield. Put the rest on the bottom of your library in any order. this.getSpellAbility().addEffect(new SummoningTrapEffect()); @@ -81,17 +81,13 @@ public class SummoningTrap extends CardImpl { } } -class SummoningTrapCondition implements Condition { +enum SummoningTrapCondition implements Condition { - private static final SummoningTrapCondition instance = new SummoningTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - SummoningTrapWatcher watcher = (SummoningTrapWatcher) game.getState().getWatchers().get("CreatureSpellCountered"); + SummoningTrapWatcher watcher = (SummoningTrapWatcher) game.getState().getWatchers().get(SummoningTrapWatcher.class.getSimpleName()); return watcher != null && watcher.creatureSpellOfPlayerWasCountered(source.getControllerId()); } @@ -106,7 +102,7 @@ class SummoningTrapWatcher extends Watcher { Set players = new HashSet<>(); public SummoningTrapWatcher() { - super("CreatureSpellCountered", WatcherScope.GAME); + super(SummoningTrapWatcher.class.getSimpleName(), WatcherScope.GAME); } public SummoningTrapWatcher(final SummoningTrapWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SuturedGhoul.java b/Mage.Sets/src/mage/cards/s/SuturedGhoul.java index 58eb9dda62..8d767e5ffa 100644 --- a/Mage.Sets/src/mage/cards/s/SuturedGhoul.java +++ b/Mage.Sets/src/mage/cards/s/SuturedGhoul.java @@ -28,6 +28,7 @@ package mage.cards.s; import java.util.UUID; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -61,7 +62,7 @@ public class SuturedGhoul extends CardImpl { private static final String staticText2 = "Sutured Ghoul's power is equal to the total power of the exiled cards and its toughness is equal to their total toughness"; public SuturedGhoul(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{B}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}{B}"); this.subtype.add("Zombie"); this.power = new MageInt(0); @@ -73,7 +74,7 @@ public class SuturedGhoul extends CardImpl { this.addAbility(new AsEntersBattlefieldAbility(new SuturedGhoulEffect(), staticText)); // Sutured Ghoul's power is equal to the total power of the exiled cards and its toughness is equal to their total toughness. - BoostSourceEffect effect = new BoostSourceEffect(new SuturedGhoulPowerCount(), new SuturedGhoulToughnessCount(), Duration.WhileOnBattlefield); + BoostSourceEffect effect = new BoostSourceEffect(SuturedGhoulPowerCount.instance, SuturedGhoulToughnessCount.instance, Duration.WhileOnBattlefield); effect.setText(staticText2); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } @@ -137,16 +138,9 @@ class SuturedGhoulEffect extends OneShotEffect { } } -class SuturedGhoulPowerCount implements DynamicValue { +enum SuturedGhoulPowerCount implements DynamicValue { - private static SuturedGhoulPowerCount instance; - - public static SuturedGhoulPowerCount getInstance() { - if (instance == null) { - instance = new SuturedGhoulPowerCount(); - } - return instance; - } + instance; @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { @@ -165,7 +159,7 @@ class SuturedGhoulPowerCount implements DynamicValue { @Override public DynamicValue copy() { - return getInstance(); + return instance; } @Override @@ -179,16 +173,9 @@ class SuturedGhoulPowerCount implements DynamicValue { } } -class SuturedGhoulToughnessCount implements DynamicValue { +enum SuturedGhoulToughnessCount implements DynamicValue { - private static SuturedGhoulToughnessCount instance; - - public static SuturedGhoulToughnessCount getInstance() { - if (instance == null) { - instance = new SuturedGhoulToughnessCount(); - } - return instance; - } + instance; @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { @@ -207,7 +194,7 @@ class SuturedGhoulToughnessCount implements DynamicValue { @Override public DynamicValue copy() { - return getInstance(); + return instance; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SylvanLibrary.java b/Mage.Sets/src/mage/cards/s/SylvanLibrary.java index 5643ca41fc..c0acfd3801 100644 --- a/Mage.Sets/src/mage/cards/s/SylvanLibrary.java +++ b/Mage.Sets/src/mage/cards/s/SylvanLibrary.java @@ -99,7 +99,7 @@ class SylvanLibraryEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { controller.drawCards(2, game); - SylvanLibraryCardsDrawnThisTurnWatcher watcher = (SylvanLibraryCardsDrawnThisTurnWatcher) game.getState().getWatchers().get("SylvanLibraryCardsDrawnThisTurnWatcher"); + SylvanLibraryCardsDrawnThisTurnWatcher watcher = (SylvanLibraryCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(SylvanLibraryCardsDrawnThisTurnWatcher.class.getSimpleName()); if (watcher != null) { Cards cards = new CardsImpl(); Set cardsDrawnThisTurn = watcher.getCardsDrawnThisTurn(controller.getId()); @@ -146,7 +146,7 @@ class SylvanLibraryCardsDrawnThisTurnWatcher extends Watcher { private final Map> cardsDrawnThisTurn = new HashMap<>(); public SylvanLibraryCardsDrawnThisTurnWatcher() { - super("SylvanLibraryCardsDrawnThisTurnWatcher", WatcherScope.GAME); + super(SylvanLibraryCardsDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public SylvanLibraryCardsDrawnThisTurnWatcher(final SylvanLibraryCardsDrawnThisTurnWatcher watcher) { @@ -157,17 +157,15 @@ class SylvanLibraryCardsDrawnThisTurnWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.DREW_CARD) { - if (!cardsDrawnThisTurn.containsKey(event.getPlayerId())) { - Set cardsDrawn = new LinkedHashSet<>(); - cardsDrawnThisTurn.put(event.getPlayerId(), cardsDrawn); - } - Set cardsDrawn = cardsDrawnThisTurn.get(event.getPlayerId()); + + Set cardsDrawn = getCardsDrawnThisTurn(event.getPlayerId()); cardsDrawn.add(event.getTargetId()); + cardsDrawnThisTurn.put(event.getPlayerId(), cardsDrawn); } } public Set getCardsDrawnThisTurn(UUID playerId) { - return cardsDrawnThisTurn.get(playerId); + return cardsDrawnThisTurn.getOrDefault(playerId, new LinkedHashSet<>()); } @Override diff --git a/Mage.Sets/src/mage/cards/t/TaintedSigil.java b/Mage.Sets/src/mage/cards/t/TaintedSigil.java index ef4522403a..8ab13f4f50 100644 --- a/Mage.Sets/src/mage/cards/t/TaintedSigil.java +++ b/Mage.Sets/src/mage/cards/t/TaintedSigil.java @@ -83,7 +83,7 @@ class AllPlayersLostLifeCount implements DynamicValue { } public int calculate(Game game, UUID controllerId) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { int amountLifeLost = 0; for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TalarasBattalion.java b/Mage.Sets/src/mage/cards/t/TalarasBattalion.java index 430a9a52a3..a32c19be7c 100644 --- a/Mage.Sets/src/mage/cards/t/TalarasBattalion.java +++ b/Mage.Sets/src/mage/cards/t/TalarasBattalion.java @@ -119,7 +119,7 @@ class CastGreenSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - TalarasBattalionWatcher watcher = (TalarasBattalionWatcher) game.getState().getWatchers().get("TalarasBattalionWatcher", source.getControllerId()); + TalarasBattalionWatcher watcher = (TalarasBattalionWatcher) game.getState().getWatchers().get(TalarasBattalionWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -137,7 +137,7 @@ class TalarasBattalionWatcher extends Watcher { private final UUID cardId; public TalarasBattalionWatcher(UUID cardId) { - super("TalarasBattalionWatcher", WatcherScope.PLAYER); + super(TalarasBattalionWatcher.class.getSimpleName(), WatcherScope.PLAYER); this.cardId = cardId; } diff --git a/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java b/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java index 0b0f158693..373e2bcdaf 100644 --- a/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java +++ b/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java @@ -61,7 +61,7 @@ public class TapestryOfTheAges extends CardImpl { Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new ManaCostsImpl<>("{2}"), - PlayerCastNonCreatureSpellCondition.getInstance()); + PlayerCastNonCreatureSpellCondition.instance); ability.addCost(new TapSourceCost()); this.addAbility(ability, new PlayerCastNonCreatureSpellWatcher()); @@ -80,13 +80,9 @@ public class TapestryOfTheAges extends CardImpl { enum PlayerCastNonCreatureSpellCondition implements Condition { instance; - public static Condition getInstance() { - return instance; - } - @Override public boolean apply(Game game, Ability source) { - PlayerCastNonCreatureSpellWatcher watcher = (PlayerCastNonCreatureSpellWatcher) game.getState().getWatchers().get("PlayerCastNonCreatureSpell"); + PlayerCastNonCreatureSpellWatcher watcher = (PlayerCastNonCreatureSpellWatcher) game.getState().getWatchers().get(PlayerCastNonCreatureSpellWatcher.class.getSimpleName()); return watcher != null && watcher.playerDidCastNonCreatureSpellThisTurn(source.getControllerId()); } @@ -101,7 +97,7 @@ class PlayerCastNonCreatureSpellWatcher extends Watcher { Set playerIds = new HashSet<>(); public PlayerCastNonCreatureSpellWatcher() { - super("PlayerCastNonCreatureSpell", WatcherScope.GAME); + super(PlayerCastNonCreatureSpellWatcher.class.getSimpleName(), WatcherScope.GAME); } public PlayerCastNonCreatureSpellWatcher(final PlayerCastNonCreatureSpellWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/t/Tariff.java b/Mage.Sets/src/mage/cards/t/Tariff.java index a11d11ec6b..df12602769 100644 --- a/Mage.Sets/src/mage/cards/t/Tariff.java +++ b/Mage.Sets/src/mage/cards/t/Tariff.java @@ -33,6 +33,8 @@ import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCost; +import mage.abilities.costs.mana.ManaCostImpl; +import mage.abilities.costs.mana.ManaCosts; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -113,7 +115,7 @@ class TariffEffect extends OneShotEffect { Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures); if (creatureToPayFor != null) { - ManaCost manaCost = CardUtil.removeVariableManaCost(creatureToPayFor.getManaCost()); + ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost()); String message = new StringBuilder("Pay ").append(manaCost.getText()).append(" (otherwise sacrifice ") .append(creatureToPayFor.getName()).append(")?").toString(); if (player.chooseUse(Outcome.Benefit, message, source, game)) { diff --git a/Mage.Sets/src/mage/cards/t/Terastodon.java b/Mage.Sets/src/mage/cards/t/Terastodon.java index c47a49b844..349040715d 100644 --- a/Mage.Sets/src/mage/cards/t/Terastodon.java +++ b/Mage.Sets/src/mage/cards/t/Terastodon.java @@ -106,10 +106,7 @@ class TerastodonEffect extends OneShotEffect { if (permanent != null) { if (permanent.destroy(source.getSourceId(), game, false)) { if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) { - int numberPermanents = 0; - if (destroyedPermanents.containsKey(permanent.getControllerId())) { - numberPermanents = destroyedPermanents.get(permanent.getControllerId()); - } + int numberPermanents = destroyedPermanents.getOrDefault(permanent.getControllerId(), 0); destroyedPermanents.put(permanent.getControllerId(), numberPermanents + 1); } } diff --git a/Mage.Sets/src/mage/cards/t/TheChainVeil.java b/Mage.Sets/src/mage/cards/t/TheChainVeil.java index e88302184d..b809c01e85 100644 --- a/Mage.Sets/src/mage/cards/t/TheChainVeil.java +++ b/Mage.Sets/src/mage/cards/t/TheChainVeil.java @@ -87,7 +87,7 @@ class ActivatedLoyaltyAbilityWatcher extends Watcher { private final Set playerIds = new HashSet<>(); public ActivatedLoyaltyAbilityWatcher() { - super("ActivatedLoyaltyAbilityWatcher", WatcherScope.GAME); + super(ActivatedLoyaltyAbilityWatcher.class.getSimpleName(), WatcherScope.GAME); } public ActivatedLoyaltyAbilityWatcher(final ActivatedLoyaltyAbilityWatcher watcher) { @@ -166,7 +166,7 @@ enum TheChainVeilCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - ActivatedLoyaltyAbilityWatcher watcher = (ActivatedLoyaltyAbilityWatcher) game.getState().getWatchers().get("ActivatedLoyaltyAbilityWatcher"); + ActivatedLoyaltyAbilityWatcher watcher = (ActivatedLoyaltyAbilityWatcher) game.getState().getWatchers().get(ActivatedLoyaltyAbilityWatcher.class.getSimpleName()); if (watcher != null) { if (!watcher.activatedLoyaltyAbility(source.getControllerId())) { return true; diff --git a/Mage.Sets/src/mage/cards/t/TimeToReflect.java b/Mage.Sets/src/mage/cards/t/TimeToReflect.java index 4c23e0f9fc..112b440a2d 100644 --- a/Mage.Sets/src/mage/cards/t/TimeToReflect.java +++ b/Mage.Sets/src/mage/cards/t/TimeToReflect.java @@ -71,7 +71,7 @@ public class TimeToReflect extends CardImpl { if (ability instanceof SpellAbility) { List creaturesThatBlockedOrWereBlockedByAZombie = new ArrayList<>(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that blocked or was blocked by a Zombie this turn.").copy(); - BlockedOrWasBlockedByAZombieWatcher watcher = (BlockedOrWasBlockedByAZombieWatcher) game.getState().getWatchers().get("BlockedOrWasBlockedByAZombieWatcher"); + BlockedOrWasBlockedByAZombieWatcher watcher = (BlockedOrWasBlockedByAZombieWatcher) game.getState().getWatchers().get(BlockedOrWasBlockedByAZombieWatcher.class.getSimpleName()); if (watcher != null) { for (MageObjectReference mor : watcher.getBlockedThisTurnCreatures()) { Permanent permanent = mor.getPermanent(game); @@ -101,7 +101,7 @@ class BlockedOrWasBlockedByAZombieWatcher extends Watcher { private final Set blockedOrWasBlockedByAZombieWatcher; public BlockedOrWasBlockedByAZombieWatcher() { - super("BlockedOrWasBlockedByAZombieWatcher", WatcherScope.GAME); + super(BlockedOrWasBlockedByAZombieWatcher.class.getSimpleName(), WatcherScope.GAME); blockedOrWasBlockedByAZombieWatcher = new HashSet<>(); } diff --git a/Mage.Sets/src/mage/cards/t/TunnelIgnus.java b/Mage.Sets/src/mage/cards/t/TunnelIgnus.java index 908e5664b1..b84557970b 100644 --- a/Mage.Sets/src/mage/cards/t/TunnelIgnus.java +++ b/Mage.Sets/src/mage/cards/t/TunnelIgnus.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; + import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; @@ -53,7 +54,7 @@ import mage.watchers.Watcher; public class TunnelIgnus extends CardImpl { public TunnelIgnus(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}"); this.subtype.add("Elemental"); this.power = new MageInt(2); @@ -78,7 +79,7 @@ class TunnelIgnusWatcher extends Watcher { protected Map counts = new HashMap<>(); public TunnelIgnusWatcher() { - super("LandPlayedCount", WatcherScope.PLAYER); + super(TunnelIgnusWatcher.class.getSimpleName(), WatcherScope.PLAYER); } public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) { @@ -98,11 +99,9 @@ class TunnelIgnusWatcher extends Watcher { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent.isLand() && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) { - int count = 1; - if (counts.containsKey(permanent.getControllerId())) { - count += counts.get(permanent.getControllerId()); - } - counts.put(permanent.getControllerId(), count); + + int count = counts.getOrDefault(permanent.getControllerId(), 0); + counts.put(permanent.getControllerId(), count + 1); } } } @@ -138,7 +137,7 @@ class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isLand() && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) { - TunnelIgnusWatcher watcher = (TunnelIgnusWatcher) game.getState().getWatchers().get("LandPlayedCount", this.controllerId); + TunnelIgnusWatcher watcher = (TunnelIgnusWatcher) game.getState().getWatchers().get(TunnelIgnusWatcher.class.getSimpleName(), this.controllerId); if (watcher != null && watcher.counts.get(permanent.getControllerId()) > 1) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); diff --git a/Mage.Sets/src/mage/cards/t/TwilightShepherd.java b/Mage.Sets/src/mage/cards/t/TwilightShepherd.java index b30dcd34d8..b4fbd281d9 100644 --- a/Mage.Sets/src/mage/cards/t/TwilightShepherd.java +++ b/Mage.Sets/src/mage/cards/t/TwilightShepherd.java @@ -106,7 +106,7 @@ class TwilightShepherdEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get("CardsPutIntoGraveyardWatcher"); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && watcher != null) { Set cardsInGraveyard = watcher.getCardsPutToGraveyardFromBattlefield(); diff --git a/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java b/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java index 1613562b68..015816d825 100644 --- a/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java +++ b/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java @@ -104,7 +104,7 @@ class TymnaTheWeaverEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - TymnaTheWeaverWatcher watcher = (TymnaTheWeaverWatcher) game.getState().getWatchers().get(TymnaTheWeaverWatcher.class.getName()); + TymnaTheWeaverWatcher watcher = (TymnaTheWeaverWatcher) game.getState().getWatchers().get(TymnaTheWeaverWatcher.class.getSimpleName()); if (watcher != null) { int cardsToDraw = watcher.opponentsThatGotCombatDamage(source.getControllerId(), game); Cost cost = new PayLifeCost(cardsToDraw); @@ -125,7 +125,7 @@ class TymnaTheWeaverWatcher extends Watcher { private final HashMap> players = new HashMap<>(); public TymnaTheWeaverWatcher() { - super(TymnaTheWeaverWatcher.class.getName(), WatcherScope.GAME); + super(TymnaTheWeaverWatcher.class.getSimpleName(), WatcherScope.GAME); } public TymnaTheWeaverWatcher(final TymnaTheWeaverWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/u/UbaMask.java b/Mage.Sets/src/mage/cards/u/UbaMask.java index b8d03cd94f..32f7a1a173 100644 --- a/Mage.Sets/src/mage/cards/u/UbaMask.java +++ b/Mage.Sets/src/mage/cards/u/UbaMask.java @@ -101,7 +101,7 @@ class UbaMaskReplacementEffect extends ReplacementEffectImpl { Card card = player.getLibrary().getFromTop(game); if (card != null) { if (player.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName())) { - UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatchers().get(UbaMaskExiledCardsWatcher.class.getName()); + UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatchers().get(UbaMaskExiledCardsWatcher.class.getSimpleName()); if (watcher != null) { watcher.addExiledCard(event.getPlayerId(), card, game); } @@ -149,7 +149,7 @@ class UbaMaskPlayEffect extends AsThoughEffectImpl { if (card != null && affectedControllerId.equals(card.getOwnerId()) && game.getState().getZone(card.getId()) == Zone.EXILED) { - UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatchers().get(UbaMaskExiledCardsWatcher.class.getName()); + UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatchers().get(UbaMaskExiledCardsWatcher.class.getSimpleName()); if (watcher != null) { List exiledThisTurn = watcher.getUbaMaskExiledCardsThisTurn(affectedControllerId); return exiledThisTurn != null @@ -165,7 +165,7 @@ class UbaMaskExiledCardsWatcher extends Watcher { private final HashMap> exiledCards = new HashMap<>(); public UbaMaskExiledCardsWatcher() { - super(UbaMaskExiledCardsWatcher.class.getName(), WatcherScope.GAME); + super(UbaMaskExiledCardsWatcher.class.getSimpleName(), WatcherScope.GAME); } public UbaMaskExiledCardsWatcher(final UbaMaskExiledCardsWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/u/UrborgJustice.java b/Mage.Sets/src/mage/cards/u/UrborgJustice.java index 7bd618cfd6..528e7f2130 100644 --- a/Mage.Sets/src/mage/cards/u/UrborgJustice.java +++ b/Mage.Sets/src/mage/cards/u/UrborgJustice.java @@ -92,7 +92,7 @@ class UrborgJusticeDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get("CardsPutIntoGraveyardWatcher"); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); int count = 0; Player controller = game.getPlayer(sourceAbility.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/u/UrzasMiter.java b/Mage.Sets/src/mage/cards/u/UrzasMiter.java index d9c2054bfb..2a80ece079 100644 --- a/Mage.Sets/src/mage/cards/u/UrzasMiter.java +++ b/Mage.Sets/src/mage/cards/u/UrzasMiter.java @@ -84,7 +84,7 @@ class UrzasMiterDoIfCostPaid extends DoIfCostPaid { @Override public boolean apply(Game game, Ability source) { - UrzasMiterWatcher watcher = (UrzasMiterWatcher) game.getState().getWatchers().get("UrzasMiterWatcher"); + UrzasMiterWatcher watcher = (UrzasMiterWatcher) game.getState().getWatchers().get(UrzasMiterWatcher.class.getSimpleName()); if(!watcher.cards.contains(source.getFirstTarget())) return super.apply(game, source); @@ -98,7 +98,7 @@ class UrzasMiterWatcher extends Watcher { ArrayList cards; public UrzasMiterWatcher() { - super("UrzasMiterWatcher", WatcherScope.PLAYER); + super(UrzasMiterWatcher.class.getSimpleName(), WatcherScope.PLAYER); this.cards = new ArrayList<>(); } diff --git a/Mage.Sets/src/mage/cards/v/VengefulFirebrand.java b/Mage.Sets/src/mage/cards/v/VengefulFirebrand.java index 49fe2f0d29..79206e2937 100644 --- a/Mage.Sets/src/mage/cards/v/VengefulFirebrand.java +++ b/Mage.Sets/src/mage/cards/v/VengefulFirebrand.java @@ -64,7 +64,7 @@ public class VengefulFirebrand extends CardImpl { // Vengeful Firebrand has haste as long as a Warrior card is in your graveyard. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect( new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield), - VengefulFirebrandCondition.getInstance(), + VengefulFirebrandCondition.instance, "{this} has haste as long as a Warrior card is in your graveyard"))); // {R}: Vengeful Firebrand gets +1/+0 until end of turn. @@ -90,10 +90,6 @@ enum VengefulFirebrandCondition implements Condition { filter.add(new SubtypePredicate("Warrior")); } - public static Condition getInstance() { - return instance; - } - @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/v/Vengevine.java b/Mage.Sets/src/mage/cards/v/Vengevine.java index 50b5c9fee7..8001f5949e 100644 --- a/Mage.Sets/src/mage/cards/v/Vengevine.java +++ b/Mage.Sets/src/mage/cards/v/Vengevine.java @@ -95,7 +95,7 @@ class VengevineAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - Watcher watcher = game.getState().getWatchers().get("CreatureCast", controllerId); + Watcher watcher = game.getState().getWatchers().get(VengevineWatcher.class.getSimpleName(), controllerId); if (watcher != null && watcher.conditionMet()) { return true; } @@ -116,7 +116,7 @@ class VengevineWatcher extends Watcher { int creatureSpellCount = 0; public VengevineWatcher() { - super("CreatureCast", WatcherScope.PLAYER); + super(VengevineWatcher.class.getSimpleName(), WatcherScope.PLAYER); } public VengevineWatcher(final VengevineWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java b/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java index de2d072c27..6a540cffe3 100644 --- a/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java +++ b/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java @@ -100,7 +100,7 @@ class VialSmasherTheFierceTriggeredAbility extends SpellCastControllerTriggeredA @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/v/VileRedeemer.java b/Mage.Sets/src/mage/cards/v/VileRedeemer.java index ad2beefe04..b24de752d9 100644 --- a/Mage.Sets/src/mage/cards/v/VileRedeemer.java +++ b/Mage.Sets/src/mage/cards/v/VileRedeemer.java @@ -29,6 +29,7 @@ package mage.cards.v; import java.util.HashMap; import java.util.UUID; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; @@ -52,13 +53,12 @@ import mage.players.Player; import mage.watchers.Watcher; /** - * * @author LevelX2 */ public class VileRedeemer extends CardImpl { public VileRedeemer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); this.subtype.add("Eldrazi"); this.power = new MageInt(3); this.toughness = new MageInt(3); @@ -103,7 +103,7 @@ class VileRedeemerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - VileRedeemerNonTokenCreaturesDiedWatcher watcher = (VileRedeemerNonTokenCreaturesDiedWatcher) game.getState().getWatchers().get("VileRedeemerNonTokenCreaturesDiedWatcher"); + VileRedeemerNonTokenCreaturesDiedWatcher watcher = (VileRedeemerNonTokenCreaturesDiedWatcher) game.getState().getWatchers().get(VileRedeemerNonTokenCreaturesDiedWatcher.class.getSimpleName()); if (watcher != null) { int amount = watcher.getAmountOfNontokenCreatureDiedThisTurn(controller.getId()); if (amount > 0) { @@ -121,7 +121,7 @@ class VileRedeemerNonTokenCreaturesDiedWatcher extends Watcher { private final HashMap amountOfCreaturesThatDied = new HashMap<>(); public VileRedeemerNonTokenCreaturesDiedWatcher() { - super("VileRedeemerNonTokenCreaturesDiedWatcher", WatcherScope.GAME); + super(VileRedeemerNonTokenCreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME); } public VileRedeemerNonTokenCreaturesDiedWatcher(final VileRedeemerNonTokenCreaturesDiedWatcher watcher) { @@ -136,8 +136,7 @@ class VileRedeemerNonTokenCreaturesDiedWatcher extends Watcher { if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTarget().isCreature() && !(zEvent.getTarget() instanceof PermanentToken)) { - int count = amountOfCreaturesThatDied.containsKey(zEvent.getTarget().getControllerId()) - ? amountOfCreaturesThatDied.get(zEvent.getTarget().getControllerId()) : 0; + int count = getAmountOfNontokenCreatureDiedThisTurn(zEvent.getTargetId()); amountOfCreaturesThatDied.put(zEvent.getTarget().getControllerId(), ++count); } } @@ -150,7 +149,7 @@ class VileRedeemerNonTokenCreaturesDiedWatcher extends Watcher { } public int getAmountOfNontokenCreatureDiedThisTurn(UUID playerId) { - return amountOfCreaturesThatDied.containsKey(playerId) ? amountOfCreaturesThatDied.get(playerId) : 0; + return amountOfCreaturesThatDied.getOrDefault(playerId, 0); } @Override diff --git a/Mage.Sets/src/mage/cards/v/ViridianBetrayers.java b/Mage.Sets/src/mage/cards/v/ViridianBetrayers.java index ae4f229646..41bd1a3b3d 100644 --- a/Mage.Sets/src/mage/cards/v/ViridianBetrayers.java +++ b/Mage.Sets/src/mage/cards/v/ViridianBetrayers.java @@ -46,7 +46,6 @@ import mage.game.Game; import mage.players.Player; /** - * * @author North */ public class ViridianBetrayers extends CardImpl { @@ -54,7 +53,7 @@ public class ViridianBetrayers extends CardImpl { private static final String rule = "{this} has infect as long as an opponent is poisoned."; public ViridianBetrayers(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}"); this.subtype.add("Elf"); this.subtype.add("Warrior"); @@ -63,7 +62,7 @@ public class ViridianBetrayers extends CardImpl { this.toughness = new MageInt(1); // Viridian Betrayers has infect as long as an opponent is poisoned. - ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainAbilitySourceEffect(InfectAbility.getInstance()), PoisonedCondition.getInstance(), rule); + ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainAbilitySourceEffect(InfectAbility.getInstance()), PoisonedCondition.instance, rule); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } @@ -77,13 +76,9 @@ public class ViridianBetrayers extends CardImpl { } } -class PoisonedCondition implements Condition { +enum PoisonedCondition implements Condition { - private static PoisonedCondition instance = new PoisonedCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java b/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java index 0f5920131b..1cf223d0a1 100644 --- a/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java +++ b/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java @@ -85,8 +85,8 @@ public class VizierOfDeferment extends CardImpl { if (ability instanceof EntersBattlefieldTriggeredAbility) { List creaturesThatCanBeTargeted = new ArrayList<>(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that attacked or blocked this turn."); - AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); - BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get("BlockedThisTurn"); + AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); if (watcherAttacked != null) { for (MageObjectReference mor : watcherAttacked.getAttackedThisTurnCreatures()) { Permanent permanent = mor.getPermanent(game); diff --git a/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java b/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java index 62ae1b9d40..55abd6a36f 100644 --- a/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java +++ b/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java @@ -97,7 +97,7 @@ class VizierOfManyFacesApplyToPermanent extends ApplyToPermanent { for (Permanent entering : game.getPermanentsEntering().values()) { if (entering.getId().equals(copyToObjectId) && entering instanceof PermanentToken) { UUID originalCardId = ((PermanentToken) entering).getToken().getCopySourceCard().getId(); - EmbalmedThisTurnWatcher watcher = (EmbalmedThisTurnWatcher) game.getState().getWatchers().get(EmbalmedThisTurnWatcher.class.getName()); + EmbalmedThisTurnWatcher watcher = (EmbalmedThisTurnWatcher) game.getState().getWatchers().get(EmbalmedThisTurnWatcher.class.getSimpleName()); if (watcher != null) { for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) { if (mor.getSourceId().equals(originalCardId) && game.getState().getZoneChangeCounter(originalCardId) == mor.getZoneChangeCounter()) { @@ -122,7 +122,7 @@ class EmbalmedThisTurnWatcher extends Watcher { private final Set embalmedThisTurnTokens; public EmbalmedThisTurnWatcher() { - super(EmbalmedThisTurnWatcher.class.getName(), WatcherScope.GAME); + super(EmbalmedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); embalmedThisTurnTokens = new HashSet<>(); } diff --git a/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java b/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java index 367ca1a8c1..003c041f2e 100644 --- a/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java +++ b/Mage.Sets/src/mage/cards/v/VorracBattlehorns.java @@ -93,7 +93,7 @@ class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl { super(duration, Outcome.Benefit); this.amount = amount; this.attachmentType = attachmentType; - staticText = (attachmentType == AttachmentType.AURA ? "Enchanted" : "Equipped") + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s"); + staticText = attachmentType.verb() + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s"); } public CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) { diff --git a/Mage.Sets/src/mage/cards/w/WardenOfTheBeyond.java b/Mage.Sets/src/mage/cards/w/WardenOfTheBeyond.java index 08bc4ebfc3..df13b681b0 100644 --- a/Mage.Sets/src/mage/cards/w/WardenOfTheBeyond.java +++ b/Mage.Sets/src/mage/cards/w/WardenOfTheBeyond.java @@ -62,7 +62,7 @@ public class WardenOfTheBeyond extends CardImpl { this.addAbility(VigilanceAbility.getInstance()); // Warden of the Beyond gets +2/+2 as long as an opponent owns a card in exile. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, - new ConditionalContinuousEffect(new BoostSourceEffect(2,2,Duration.WhileOnBattlefield), OpponentOwnsCardInExileCondition.getInstance(), + new ConditionalContinuousEffect(new BoostSourceEffect(2,2,Duration.WhileOnBattlefield), OpponentOwnsCardInExileCondition.instance, "{this} gets +2/+2 as long as an opponent owns a card in exile"))); } @@ -76,13 +76,9 @@ public class WardenOfTheBeyond extends CardImpl { } } -class OpponentOwnsCardInExileCondition implements Condition { +enum OpponentOwnsCardInExileCondition implements Condition { - private static final OpponentOwnsCardInExileCondition instance = new OpponentOwnsCardInExileCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/w/WhiplashTrap.java b/Mage.Sets/src/mage/cards/w/WhiplashTrap.java index dddf56a5cf..f66339963c 100644 --- a/Mage.Sets/src/mage/cards/w/WhiplashTrap.java +++ b/Mage.Sets/src/mage/cards/w/WhiplashTrap.java @@ -29,6 +29,7 @@ package mage.cards.w; import java.util.List; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.costs.AlternativeCostSourceAbility; @@ -43,17 +44,16 @@ import mage.target.common.TargetCreaturePermanent; import mage.watchers.common.PermanentsEnteredBattlefieldWatcher; /** - * * @author jeffwadsworth */ public class WhiplashTrap extends CardImpl { public WhiplashTrap(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}{U}"); this.subtype.add("Trap"); // If an opponent had two or more creatures enter the battlefield under his or her control this turn, you may pay {U} rather than pay Whiplash Trap's mana cost. - this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{U}"), WhiplashTrapCondition.getInstance()), new PermanentsEnteredBattlefieldWatcher()); + this.addAbility(new AlternativeCostSourceAbility(new ManaCostsImpl("{U}"), WhiplashTrapCondition.instance), new PermanentsEnteredBattlefieldWatcher()); // Return two target creatures to their owners' hands. this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); @@ -71,17 +71,13 @@ public class WhiplashTrap extends CardImpl { } } -class WhiplashTrapCondition implements Condition { +enum WhiplashTrapCondition implements Condition { - private static final WhiplashTrapCondition instance = new WhiplashTrapCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/w/WickedAkuba.java b/Mage.Sets/src/mage/cards/w/WickedAkuba.java index 88c0855629..35596bda25 100644 --- a/Mage.Sets/src/mage/cards/w/WickedAkuba.java +++ b/Mage.Sets/src/mage/cards/w/WickedAkuba.java @@ -85,7 +85,7 @@ class WickedAkubaPredicate implements ObjectSourcePlayerPredicate input, Game game) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", input.getObject().getId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), input.getObject().getId()); if (watcher != null) { return watcher.hasSourceDoneDamage(input.getSourceId(), game); } diff --git a/Mage.Sets/src/mage/cards/w/WildPair.java b/Mage.Sets/src/mage/cards/w/WildPair.java index fb2ba5744e..1ef670c87c 100644 --- a/Mage.Sets/src/mage/cards/w/WildPair.java +++ b/Mage.Sets/src/mage/cards/w/WildPair.java @@ -163,7 +163,7 @@ class CastFromHandTargetCondition implements Condition { return false; } } - CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getName()); + CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName()); if (watcher != null && watcher.spellWasCastFromHand(targetId)) { return true; } diff --git a/Mage.Sets/src/mage/cards/w/WindbriskHeights.java b/Mage.Sets/src/mage/cards/w/WindbriskHeights.java index 5b687b2ef3..e22981a3e8 100644 --- a/Mage.Sets/src/mage/cards/w/WindbriskHeights.java +++ b/Mage.Sets/src/mage/cards/w/WindbriskHeights.java @@ -58,7 +58,7 @@ public class WindbriskHeights extends CardImpl { this.addAbility(new WhiteManaAbility()); // {W}, {tap}: You may play the exiled card without paying its mana cost if you attacked with three or more creatures this turn. Ability ability = new ActivateIfConditionActivatedAbility( - Zone.BATTLEFIELD, new HideawayPlayEffect(), new ManaCostsImpl("{W}"), WindbriskHeightsAttackersCondition.getInstance()); + Zone.BATTLEFIELD, new HideawayPlayEffect(), new ManaCostsImpl("{W}"), WindbriskHeightsAttackersCondition.instance); ability.addCost(new TapSourceCost()); this.addAbility(ability, new PlayerAttackedWatcher()); @@ -74,17 +74,13 @@ public class WindbriskHeights extends CardImpl { } } -class WindbriskHeightsAttackersCondition implements Condition { +enum WindbriskHeightsAttackersCondition implements Condition { - private static final WindbriskHeightsAttackersCondition instance = new WindbriskHeightsAttackersCondition(); - - public static Condition getInstance() { - return instance; - } + instance; @Override public boolean apply(Game game, Ability source) { - PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get("PlayerAttackedWatcher"); + PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName()); return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) >= 3; } diff --git a/Mage.Sets/src/mage/cards/w/WindwrightMage.java b/Mage.Sets/src/mage/cards/w/WindwrightMage.java index cff63cf30f..50964f6266 100644 --- a/Mage.Sets/src/mage/cards/w/WindwrightMage.java +++ b/Mage.Sets/src/mage/cards/w/WindwrightMage.java @@ -65,7 +65,7 @@ public class WindwrightMage extends CardImpl { // Windwright Mage has flying as long as an artifact card is in your graveyard. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect( new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.WhileOnBattlefield), - WindwrightMageCondition.getInstance(), + WindwrightMageCondition.instance, "{this} has flying as long as an artifact card is in your graveyard"))); } @@ -79,18 +79,14 @@ public class WindwrightMage extends CardImpl { } } -class WindwrightMageCondition implements Condition { - - private static WindwrightMageCondition instance = new WindwrightMageCondition(); +enum WindwrightMageCondition implements Condition { + instance; private static final FilterCard filter = new FilterCard("artifact"); static { filter.add(new CardTypePredicate(CardType.ARTIFACT)); } - public static Condition getInstance() { - return instance; - } @Override public boolean apply(Game game, Ability source) { diff --git a/Mage.Sets/src/mage/cards/w/WorldAtWar.java b/Mage.Sets/src/mage/cards/w/WorldAtWar.java index 88af98857c..76b8a95b9d 100644 --- a/Mage.Sets/src/mage/cards/w/WorldAtWar.java +++ b/Mage.Sets/src/mage/cards/w/WorldAtWar.java @@ -168,7 +168,7 @@ class UntapAttackingThisTurnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); for (MageObjectReference mor : attackedThisTurn) { diff --git a/Mage.Sets/src/mage/cards/w/WoundReflection.java b/Mage.Sets/src/mage/cards/w/WoundReflection.java index 2ef5fc0819..3ab42e6b2b 100644 --- a/Mage.Sets/src/mage/cards/w/WoundReflection.java +++ b/Mage.Sets/src/mage/cards/w/WoundReflection.java @@ -83,7 +83,7 @@ class WoundReflectionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (controller != null && watcher != null) { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/Guildpact.java b/Mage.Sets/src/mage/sets/Guildpact.java index 9e4901744b..c35d3d03de 100644 --- a/Mage.Sets/src/mage/sets/Guildpact.java +++ b/Mage.Sets/src/mage/sets/Guildpact.java @@ -86,6 +86,7 @@ public class Guildpact extends ExpansionSet { cards.add(new SetCardInfo("Fencer's Magemark", 65, Rarity.COMMON, mage.cards.f.FencersMagemark.class)); cards.add(new SetCardInfo("Feral Animist", 112, Rarity.UNCOMMON, mage.cards.f.FeralAnimist.class)); cards.add(new SetCardInfo("Frazzle", 25, Rarity.UNCOMMON, mage.cards.f.Frazzle.class)); + cards.add(new SetCardInfo("Gatherer of Graces", 85, Rarity.UNCOMMON, mage.cards.g.GathererOfGraces.class)); cards.add(new SetCardInfo("Gelectrode", 113, Rarity.UNCOMMON, mage.cards.g.Gelectrode.class)); cards.add(new SetCardInfo("Ghor-Clan Bloodscale", 66, Rarity.UNCOMMON, mage.cards.g.GhorClanBloodscale.class)); cards.add(new SetCardInfo("Ghor-Clan Savage", 86, Rarity.COMMON, mage.cards.g.GhorClanSavage.class)); diff --git a/Mage.Sets/src/mage/sets/MercadianMasques.java b/Mage.Sets/src/mage/sets/MercadianMasques.java index cbde16664e..727ee4bc20 100644 --- a/Mage.Sets/src/mage/sets/MercadianMasques.java +++ b/Mage.Sets/src/mage/sets/MercadianMasques.java @@ -33,7 +33,6 @@ import mage.constants.Rarity; import mage.constants.SetType; /** - * * @author North */ public class MercadianMasques extends ExpansionSet { @@ -177,6 +176,7 @@ public class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("Kris Mage", 195, Rarity.COMMON, mage.cards.k.KrisMage.class)); cards.add(new SetCardInfo("Kyren Glider", 196, Rarity.COMMON, mage.cards.k.KyrenGlider.class)); cards.add(new SetCardInfo("Kyren Legate", 197, Rarity.UNCOMMON, mage.cards.k.KyrenLegate.class)); + cards.add(new SetCardInfo("Kyren Negotiations", 198, Rarity.UNCOMMON, mage.cards.k.KyrenNegotiations.class)); cards.add(new SetCardInfo("Kyren Sniper", 199, Rarity.COMMON, mage.cards.k.KyrenSniper.class)); cards.add(new SetCardInfo("Kyren Toy", 303, Rarity.RARE, mage.cards.k.KyrenToy.class)); cards.add(new SetCardInfo("Land Grant", 255, Rarity.COMMON, mage.cards.l.LandGrant.class)); @@ -317,7 +317,7 @@ public class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("War Tax", 113, Rarity.UNCOMMON, mage.cards.w.WarTax.class)); cards.add(new SetCardInfo("Warmonger", 225, Rarity.UNCOMMON, mage.cards.w.Warmonger.class)); cards.add(new SetCardInfo("Waterfront Bouncer", 114, Rarity.COMMON, mage.cards.w.WaterfrontBouncer.class)); - cards.add(new SetCardInfo("Wave of Reckoning", 56, Rarity.RARE, mage.cards.w.WaveOfReckoning.class)); + cards.add(new SetCardInfo("Wave of Reckoning", 56, Rarity.RARE, mage.cards.w.WaveOfReckoning.class)); cards.add(new SetCardInfo("Wild Jhovall", 227, Rarity.COMMON, mage.cards.w.WildJhovall.class)); cards.add(new SetCardInfo("Word of Blasting", 228, Rarity.UNCOMMON, mage.cards.w.WordOfBlasting.class)); } diff --git a/Mage.Sets/src/mage/sets/Prophecy.java b/Mage.Sets/src/mage/sets/Prophecy.java index 4c0fbba0e9..8337a9ba8b 100644 --- a/Mage.Sets/src/mage/sets/Prophecy.java +++ b/Mage.Sets/src/mage/sets/Prophecy.java @@ -74,11 +74,13 @@ public class Prophecy extends ExpansionSet { cards.add(new SetCardInfo("Chimeric Idol", 136, Rarity.UNCOMMON, mage.cards.c.ChimericIdol.class)); cards.add(new SetCardInfo("Citadel of Pain", 86, Rarity.UNCOMMON, mage.cards.c.CitadelOfPain.class)); cards.add(new SetCardInfo("Coastal Hornclaw", 31, Rarity.COMMON, mage.cards.c.CoastalHornclaw.class)); + cards.add(new SetCardInfo("Copper-Leaf Angel", 137, Rarity.RARE, mage.cards.c.CopperLeafAngel.class)); cards.add(new SetCardInfo("Darba", 111, Rarity.UNCOMMON, mage.cards.d.Darba.class)); cards.add(new SetCardInfo("Denying Wind", 32, Rarity.RARE, mage.cards.d.DenyingWind.class)); cards.add(new SetCardInfo("Despoil", 62, Rarity.COMMON, mage.cards.d.Despoil.class)); cards.add(new SetCardInfo("Devastate", 87, Rarity.COMMON, mage.cards.d.Devastate.class)); cards.add(new SetCardInfo("Diving Griffin", 6, Rarity.COMMON, mage.cards.d.DivingGriffin.class)); + cards.add(new SetCardInfo("Entangler", 7, Rarity.UNCOMMON, mage.cards.e.Entangler.class)); cards.add(new SetCardInfo("Excavation", 33, Rarity.UNCOMMON, mage.cards.e.Excavation.class)); cards.add(new SetCardInfo("Fault Riders", 88, Rarity.COMMON, mage.cards.f.FaultRiders.class)); cards.add(new SetCardInfo("Fen Stalker", 64, Rarity.COMMON, mage.cards.f.FenStalker.class)); diff --git a/Mage.Sets/src/mage/sets/Weatherlight.java b/Mage.Sets/src/mage/sets/Weatherlight.java index 065500d14f..a34539fa60 100644 --- a/Mage.Sets/src/mage/sets/Weatherlight.java +++ b/Mage.Sets/src/mage/sets/Weatherlight.java @@ -120,6 +120,7 @@ public class Weatherlight extends ExpansionSet { cards.add(new SetCardInfo("Guided Strike", 132, Rarity.COMMON, mage.cards.g.GuidedStrike.class)); cards.add(new SetCardInfo("Harvest Wurm", 72, Rarity.COMMON, mage.cards.h.HarvestWurm.class)); cards.add(new SetCardInfo("Haunting Misery", 13, Rarity.COMMON, mage.cards.h.HauntingMisery.class)); + cards.add(new SetCardInfo("Heat Stroke", 107, Rarity.RARE, mage.cards.h.HeatStroke.class)); cards.add(new SetCardInfo("Heavy Ballista", 133, Rarity.COMMON, mage.cards.h.HeavyBallista.class)); cards.add(new SetCardInfo("Hidden Horror", 14, Rarity.UNCOMMON, mage.cards.h.HiddenHorror.class)); cards.add(new SetCardInfo("Hurloon Shaman", 108, Rarity.UNCOMMON, mage.cards.h.HurloonShaman.class)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CyclingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CyclingTest.java index 06d35a74f8..5e6e1fdc0c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CyclingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CyclingTest.java @@ -164,4 +164,20 @@ public class CyclingTest extends CardTestPlayerBase { assertGraveyardCount(playerA, "Akroma's Vengeance", 1); assertHandCount(playerA, 7); } + + + @Test + public void cycleShadowOfTheGrave(){ + addCard(Zone.HAND, playerA, "Darkwatch Elves", 1 ); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 20); + addCard(Zone.HAND, playerA, "Shadow of the Grave", 1); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cycling"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shadow of the Grave"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + assertGraveyardCount(playerA, "Darkwatch Elves", 0); + assertHandCount(playerA, "Darkwatch Elves", 1); + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/NestOfScarabsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/NestOfScarabsTest.java new file mode 100644 index 0000000000..1a15d98b04 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/NestOfScarabsTest.java @@ -0,0 +1,53 @@ +package org.mage.test.cards.enchantments; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author escplan9 + */ +public class NestOfScarabsTest extends CardTestPlayerBase { + + /* + * Reported bug: Nest of Scarabs not triggering off -1/-1 counters placed on creatures. + * NOTE: this test is failing due to bug in code. See issue #3174 + */ + @Test + public void scarabsWithSoulStinger_TwoCountersTwoTokens() { + + /* + Nest of Scarabs 2B + Enchantment + Whenever you put one or more -1/-1 counters on a creature, create that many 1/1 black Insect creature tokens. + */ + String nScarabs = "Nest of Scarabs"; + + /* + Soulstinger 3B + Creature - Scorpion Demon 4/5 + When Soulstinger enters the battlefield, put two -1/-1 counter on target creature you control. + When Soulstinger dies, you may put a -1/-1 counter on target creature for each -1/-1 counter on Soulstinger. + */ + String stinger = "Soulstinger"; + + addCard(Zone.BATTLEFIELD, playerA, nScarabs); + addCard(Zone.HAND, playerA, stinger); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, stinger); + addTarget(playerA, stinger); // place two -1/-1 counters on himself + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, nScarabs, 1); + assertPermanentCount(playerA, stinger, 1); + assertCounterCount(playerA, stinger, CounterType.M1M1, 2); + assertPowerToughness(playerA, stinger, 2, 3); // 4/5 with two -1/-1 counters + assertPermanentCount(playerA, "Insect", 2); // two counters = two insects + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/commander/CommanderColorIdentityTest.java b/Mage.Tests/src/test/java/org/mage/test/commander/CommanderColorIdentityTest.java index 346839bac5..f6d0fc77bf 100644 --- a/Mage.Tests/src/test/java/org/mage/test/commander/CommanderColorIdentityTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/commander/CommanderColorIdentityTest.java @@ -96,7 +96,7 @@ public class CommanderColorIdentityTest extends CardTestCommander3PlayersFFA { throw new IllegalArgumentException("Couldn't find the card " + cardName + " in the DB."); } Card card = cardInfo.getCard(); - FilterMana filterMana = CardUtil.getColorIdentity(card); + FilterMana filterMana = card.getColorIdentity(); return filterMana.toString(); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java index a224b3071c..ef4a90dc6c 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java @@ -24,7 +24,7 @@ public enum AttackedOrBlockedThisCombatSourceCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null) { - AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getName()); + AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName()); if (watcher != null) { for (MageObjectReference mor : watcher.getAttackedThisTurnCreatures()) { if (mor.refersTo(sourceObject, game)) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java index b047628e52..c813524465 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java @@ -33,7 +33,7 @@ public enum CastFromHandSourceCondition implements Condition { return false; } } - CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getName()); + CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName()); if (watcher != null && watcher.spellWasCastFromHand(source.getSourceId())) { return true; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java b/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java index 192d0cf571..94279aa914 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java +++ b/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java @@ -44,7 +44,7 @@ public class DealtDamageToAnOpponent implements Condition { @Override public boolean apply(Game game, Ability source) { for (UUID opponentId: game.getOpponents(source.getControllerId())) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", opponentId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), opponentId); if (watcher != null) { return watcher.hasSourceDoneDamage(source.getSourceId(), game); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java b/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java index fbaa76e892..2c1c1d0335 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java @@ -44,7 +44,7 @@ public enum HateCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getName()); + LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getSimpleName()); return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId(), game); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java b/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java index 07a1a4b868..44686f489e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java @@ -13,7 +13,7 @@ public enum LandfallCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get("LandPlayed"); + LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get(LandfallWatcher.class.getSimpleName()); return watcher != null && watcher.landPlayed(source.getControllerId()); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java index be0984f282..593175a09c 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java @@ -56,7 +56,7 @@ public class ManaWasSpentCondition implements Condition { if (source.getAbilityType() == AbilityType.SPELL) { return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0); } - ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get("ManaSpentToCast", source.getSourceId()); + ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get(ManaSpentToCastWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { Mana payment = watcher.getAndResetLastPayment(); if (payment != null) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java index a03c56e163..92d4163ab7 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java @@ -31,6 +31,7 @@ import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.game.Game; import mage.watchers.Watcher; +import mage.watchers.common.MorbidWatcher; /** * @author nantuko @@ -41,7 +42,7 @@ public enum MorbidCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get("Morbid"); + Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); return watcher.conditionMet(); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java index bbd489f907..f0ab900489 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java @@ -49,7 +49,7 @@ public enum NoSpellsWereCastLastTurnCondition implements Condition { return false; } - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); // if any player cast spell, return false for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) { if (count > 0) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java index 738cb089c9..7a603b40b5 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java @@ -49,7 +49,7 @@ public class OpponentLostLifeCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int maxLostLive = 0; - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { int lostLive = watcher.getLiveLost(opponentId); diff --git a/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java b/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java index fb3490b67e..72856c0629 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java @@ -42,7 +42,7 @@ public enum RaidCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get("PlayerAttackedWatcher"); + PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName()); return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) > 0; } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java b/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java index c0ce944719..21142738a1 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java @@ -41,7 +41,7 @@ public enum RevoltCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - RevoltWatcher watcher = (RevoltWatcher) game.getState().getWatchers().get(RevoltWatcher.class.getName()); + RevoltWatcher watcher = (RevoltWatcher) game.getState().getWatchers().get(RevoltWatcher.class.getSimpleName()); return watcher != null && watcher.revoltActive(source.getControllerId()); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java index 479eb4e336..38bb87a2c2 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java @@ -24,7 +24,7 @@ public class SourceDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get("DamageDone"); + DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get(DamageDoneWatcher.class.getSimpleName()); return watcher != null && watcher.damageDoneBy(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game) >= value; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java index 3b20835c00..fbf07b135d 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java @@ -43,7 +43,7 @@ public enum TargetAttackedThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanentOrLKIBattlefield(source.getTargets().getFirstTarget()); - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); return watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game)); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java index a2a9ea8d19..9b5bab3a3e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java @@ -41,7 +41,7 @@ public enum TwoOrMoreSpellsWereCastLastTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); // if any player cast more than two spells, return true for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) { if (count >= 2) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java index 6806e28777..f19ff14b8e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java @@ -18,7 +18,7 @@ public class YouGainedLifeCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int gainedLife = 0; - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getName()); + PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); if (watcher != null) { gainedLife = watcher.getLiveGained(source.getControllerId()); } diff --git a/Mage/src/main/java/mage/abilities/costs/mana/ManaCosts.java b/Mage/src/main/java/mage/abilities/costs/mana/ManaCosts.java index 2fe86c5345..4a129a6cc1 100644 --- a/Mage/src/main/java/mage/abilities/costs/mana/ManaCosts.java +++ b/Mage/src/main/java/mage/abilities/costs/mana/ManaCosts.java @@ -61,4 +61,16 @@ public interface ManaCosts extends List, ManaCost { @Override ManaCosts copy(); + + static ManaCosts removeVariableManaCost(ManaCosts m) { + ManaCosts manaCosts = new ManaCostsImpl<>(); + for(ManaCost manaCost : m){ + if(!(manaCost instanceof VariableManaCost)){ + manaCosts.add(manaCost); + + } + } + return manaCosts; + } + } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java index 37bf103244..51609ffe3f 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java @@ -59,7 +59,7 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton { } public int calculate(Game game, UUID controllerId) { - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getName()); + PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getLiveGained(controllerId); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java index 5f596b8353..98672401b8 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java @@ -40,7 +40,7 @@ public class CreaturesDiedThisTurnCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher)game.getState().getWatchers().get("CreaturesDiedWatcher"); + CreaturesDiedWatcher watcher = (CreaturesDiedWatcher)game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getAmountOfCreaturesDiesThisTurn(); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java index f433406dca..b25f9c88ed 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java @@ -32,6 +32,7 @@ import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; import mage.game.Game; +import mage.players.Player; import mage.watchers.common.PlayerLostLifeWatcher; /** @@ -46,7 +47,7 @@ public class OpponentsLostLifeCount implements DynamicValue { } public int calculate(Game game, UUID controllerId) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher"); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { int amountLifeLost = 0; for (UUID opponentId : game.getOpponents(controllerId)) { diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java index fa8562af72..85a86a8375 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java @@ -13,7 +13,7 @@ public class ZuberasDiedDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied"); + ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); return watcher.zuberasDiedThisTurn; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java index f402b22683..f5a366b6c1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java @@ -62,7 +62,7 @@ public class UntapAllThatAttackedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); for (MageObjectReference mor : attackedThisTurn) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java index 50fb89e2d3..b4c4ec8f1d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java @@ -60,7 +60,7 @@ public class AttacksIfAbleAllEffect extends RequirementEffect { if (eachCombat) { return true; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game)); } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java index 79a014a8d0..e2a9529237 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java @@ -73,7 +73,7 @@ public class AttacksIfAbleSourceEffect extends RequirementEffect { if (eachCombat) { return true; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game)); } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java index f242fd2cf5..8094d51a13 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java @@ -59,7 +59,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect { Permanent attackingCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (attackingCreature != null && attackingCreature.isAttacking()) { if (source.getAbilityType() != AbilityType.STATIC) { - BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher"); + BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attackingCreature, permanent, game)) { // has already blocked this turn, so no need to do again return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java index ad1244d1b8..bd56cd1051 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java @@ -62,7 +62,7 @@ public class MustBeBlockedByTargetSourceEffect extends RequirementEffect { if (blocker != null && blocker.canBlock(source.getSourceId(), game)) { Permanent attacker = (Permanent) source.getSourceObjectIfItStillExists(game); if (attacker != null) { - BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher"); + BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attacker, blocker, game)) { // has already blocked this turn, so no need to do again return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java index 8d9caa0865..3dbf157b81 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java @@ -95,7 +95,7 @@ public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifyingEffec return false; } } - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java b/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java index dc716b5026..6dbd12b997 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java +++ b/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java @@ -90,7 +90,7 @@ public class DealtDamageToCreatureBySourceDies extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { ZoneChangeEvent zce = (ZoneChangeEvent) event; if (zce.isDiesEvent()) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(zce.getTarget(), game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java index e0fc0786f4..73c85fbe67 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java @@ -58,7 +58,7 @@ public class CastOnlyIfYouHaveCastAnotherSpellEffect extends ContinuousRuleModif @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getSourceId().equals(source.getSourceId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) { return true; } diff --git a/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java b/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java index 93941494ba..873e0c82c9 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java @@ -69,7 +69,7 @@ class BloodthirstEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId()); + BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); if (watcher != null && watcher.conditionMet()) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { diff --git a/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java b/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java index 93c6e696e6..70bbcbbb19 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java @@ -136,7 +136,7 @@ class ExertReplacementEffect extends ReplacementEffectImpl { if (creature != null && controller != null) { if (exertOnlyOncePerTurn) { MageObjectReference creatureReference = new MageObjectReference(creature.getId(), creature.getZoneChangeCounter(game), game); - ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getName()); + ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getSimpleName()); if (watcher != null && watcher.getExertedThisTurnCreatures().contains(creatureReference)) { return false; } @@ -172,7 +172,7 @@ class ExertedThisTurnWatcher extends Watcher { private final Set exertedThisTurnCreatures; public ExertedThisTurnWatcher() { - super(ExertedThisTurnWatcher.class.getName(), WatcherScope.GAME); + super(ExertedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); exertedThisTurnCreatures = new HashSet<>(); } diff --git a/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java b/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java index eb1601830e..e11cdf5b4f 100644 --- a/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java @@ -100,7 +100,7 @@ class GravestormEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef"); if (spellRef != null) { - GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get("GravestormWatcher"); + GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get(GravestormWatcher.class.getSimpleName()); int gravestormCount = watcher.getGravestormCount(); if (gravestormCount > 0) { Spell spell = (Spell) this.getValue("GravestormSpell"); diff --git a/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java b/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java index f8e2238198..04d14eff93 100644 --- a/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java @@ -108,7 +108,7 @@ class MeleeDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - MeleeWatcher watcher = (MeleeWatcher) game.getState().getWatchers().get("MeleeWatcher"); + MeleeWatcher watcher = (MeleeWatcher) game.getState().getWatchers().get(MeleeWatcher.class.getSimpleName()); if (watcher != null) { return watcher.getNumberOfAttackedPlayers(sourceAbility.getControllerId()); } diff --git a/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java b/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java index 9d59fdf140..40462bb1aa 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java @@ -117,7 +117,7 @@ public class ProwlAbility extends StaticAbility implements AlternativeSourceCost public boolean askToActivateAlternativeCosts(Ability ability, Game game) { if (ability instanceof SpellAbility) { Player player = game.getPlayer(controllerId); - ProwlWatcher prowlWatcher = (ProwlWatcher) game.getState().getWatchers().get("Prowl"); + ProwlWatcher prowlWatcher = (ProwlWatcher) game.getState().getWatchers().get(ProwlWatcher.class.getSimpleName()); Card card = game.getCard(ability.getSourceId()); if (player == null || prowlWatcher == null || card == null) { throw new IllegalArgumentException("Params can't be null"); diff --git a/Mage/src/main/java/mage/abilities/keyword/StormAbility.java b/Mage/src/main/java/mage/abilities/keyword/StormAbility.java index 8b5071e590..26f4f4fb88 100644 --- a/Mage/src/main/java/mage/abilities/keyword/StormAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/StormAbility.java @@ -100,7 +100,7 @@ class StormEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { MageObjectReference spellRef = (MageObjectReference) this.getValue("StormSpellRef"); if (spellRef != null) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); int stormCount = watcher.getSpellOrder(spellRef, game) - 1; if (stormCount > 0) { Spell spell = (Spell) this.getValue("StormSpell"); diff --git a/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java b/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java index 7696744cf0..d03a394d6b 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java @@ -68,7 +68,7 @@ public class SurgeAbility extends SpellAbility { @Override public boolean canActivate(UUID playerId, Game game) { // check if controller or teammate has already cast a spell this turn - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); if (watcher != null) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage/src/main/java/mage/abilities/mana/CommanderColorIdentityManaAbility.java b/Mage/src/main/java/mage/abilities/mana/CommanderColorIdentityManaAbility.java index 8e2a7c2330..3f0a768997 100644 --- a/Mage/src/main/java/mage/abilities/mana/CommanderColorIdentityManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/CommanderColorIdentityManaAbility.java @@ -75,7 +75,7 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl for (UUID commanderId : controller.getCommandersIds()) { Card commander = game.getCard(commanderId); if (commander != null) { - FilterMana commanderMana = CardUtil.getColorIdentity(commander); + FilterMana commanderMana = commander.getColorIdentity(); if (commanderMana.isBlack()) { netMana.add(new Mana(ColoredManaSymbol.B)); } @@ -130,7 +130,7 @@ class CommanderIdentityManaEffect extends ManaEffect { for (UUID commanderId : controller.getCommandersIds()) { Card commander = game.getCard(commanderId); if (commander != null) { - FilterMana commanderMana = CardUtil.getColorIdentity(commander); + FilterMana commanderMana = commander.getColorIdentity(); if (commanderMana.isWhite()) { choice.getChoices().add("White"); } diff --git a/Mage/src/main/java/mage/cards/Card.java b/Mage/src/main/java/mage/cards/Card.java index 49e41a9b21..8e7debf751 100644 --- a/Mage/src/main/java/mage/cards/Card.java +++ b/Mage/src/main/java/mage/cards/Card.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.UUID; import mage.MageObject; import mage.Mana; +import mage.ObjectColor; import mage.abilities.Abilities; import mage.abilities.Ability; import mage.abilities.SpellAbility; @@ -40,12 +41,21 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.counters.Counter; import mage.counters.Counters; +import mage.filter.FilterMana; import mage.game.Game; import mage.game.GameState; import mage.game.permanent.Permanent; public interface Card extends MageObject { + + final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*"; + final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*"; + final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*"; + final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*"; + final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*"; + + UUID getOwnerId(); String getCardNumber(); @@ -176,6 +186,67 @@ public interface Card extends MageObject { */ Card getMainCard(); + /** + * Gets the colors that are in the casting cost but also in the rules text + * as far as not included in reminder text. + * + * @return + */ + default FilterMana getColorIdentity() { + FilterMana mana = new FilterMana(); + mana.setBlack(getManaCost().getText().matches(regexBlack)); + mana.setBlue(getManaCost().getText().matches(regexBlue)); + mana.setGreen(getManaCost().getText().matches(regexGreen)); + mana.setRed(getManaCost().getText().matches(regexRed)); + mana.setWhite(getManaCost().getText().matches(regexWhite)); + for (String rule : getRules()) { + rule = rule.replaceAll("(?i)", ""); // Ignoring reminder text in italic + if (!mana.isBlack() && rule.matches(regexBlack)) { + mana.setBlack(true); + } + if (!mana.isBlue() && rule.matches(regexBlue)) { + mana.setBlue(true); + } + if (!mana.isGreen() && rule.matches(regexGreen)) { + mana.setGreen(true); + } + if (!mana.isRed() && rule.matches(regexRed)) { + mana.setRed(true); + } + if (!mana.isWhite() && rule.matches(regexWhite)) { + mana.setWhite(true); + } + } + if (isTransformable()) { + Card secondCard = getSecondCardFace(); + ObjectColor color = secondCard.getColor(null); + mana.setBlack(mana.isBlack() || color.isBlack()); + mana.setGreen(mana.isGreen() || color.isGreen()); + mana.setRed(mana.isRed() || color.isRed()); + mana.setBlue(mana.isBlue() || color.isBlue()); + mana.setWhite(mana.isWhite() || color.isWhite()); + for (String rule : secondCard.getRules()) { + rule = rule.replaceAll("(?i)", ""); // Ignoring reminder text in italic + if (!mana.isBlack() && rule.matches(regexBlack)) { + mana.setBlack(true); + } + if (!mana.isBlue() && rule.matches(regexBlue)) { + mana.setBlue(true); + } + if (!mana.isGreen() && rule.matches(regexGreen)) { + mana.setGreen(true); + } + if (!mana.isRed() && rule.matches(regexRed)) { + mana.setRed(true); + } + if (!mana.isWhite() && rule.matches(regexWhite)) { + mana.setWhite(true); + } + } + } + + return mana; + } } diff --git a/Mage/src/main/java/mage/cards/repository/CardRepository.java b/Mage/src/main/java/mage/cards/repository/CardRepository.java index 0b637e79ac..80ca63d33a 100644 --- a/Mage/src/main/java/mage/cards/repository/CardRepository.java +++ b/Mage/src/main/java/mage/cards/repository/CardRepository.java @@ -58,7 +58,7 @@ public enum CardRepository { // raise this if db structure was changed private static final long CARD_DB_VERSION = 51; // raise this if new cards were added to the server - private static final long CARD_CONTENT_VERSION = 78; + private static final long CARD_CONTENT_VERSION = 79; private final TreeSet landTypes = new TreeSet<>(); private Dao cardDao; private Set classNames; diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java index 715044b4af..45b42d0c64 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java @@ -54,14 +54,14 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate NON_CREATURE_SUBTYPES = new HashSet<>(Arrays.asList(NON_CHANGELING_SUBTYPES_VALUES)); - - - - /** * Increase spell or ability cost to be paid. * @@ -163,15 +155,6 @@ public final class CardUtil { return adjustedCost; } - public static ManaCosts removeVariableManaCost(ManaCosts manaCosts) { - ManaCosts adjustedCost = new ManaCostsImpl<>(); - for (ManaCost manaCost : manaCosts) { - if (!(manaCost instanceof VariableManaCost)) { - adjustedCost.add(manaCost); - } - } - return adjustedCost; - } public static void reduceCost(SpellAbility spellAbility, ManaCosts manaCostsToReduce) { adjustCost(spellAbility, manaCostsToReduce, true); @@ -193,8 +176,8 @@ public final class CardUtil { * * @param spellAbility * @param manaCostsToReduce costs to reduce - * @param convertToGeneric colored mana does reduce generic mana if no - * appropriate colored mana is in the costs included + * @param convertToGeneric colored mana does reduce generic mana if no + * appropriate colored mana is in the costs included */ public static void adjustCost(SpellAbility spellAbility, ManaCosts manaCostsToReduce, boolean convertToGeneric) { ManaCosts previousCost = spellAbility.getManaCostsToPay(); @@ -284,8 +267,8 @@ public final class CardUtil { } } - if(mana.getColorless() > 0 && reduceMana.getColorless() > 0) { - if(reduceMana.getColorless() > mana.getColorless()) { + if (mana.getColorless() > 0 && reduceMana.getColorless() > 0) { + if (reduceMana.getColorless() > mana.getColorless()) { reduceMana.setColorless(reduceMana.getColorless() - mana.getColorless()); mana.setColorless(0); } else { @@ -379,7 +362,7 @@ public final class CardUtil { * * @param number number to convert to text * @param forOne if the number is 1, this string will be returnedinstead of - * "one". + * "one". * @return */ public static String numberToText(int number, String forOne) { @@ -424,7 +407,7 @@ public final class CardUtil { /** * Creates and saves a (card + zoneChangeCounter) specific exileId. * - * @param game the current game + * @param game the current game * @param source source ability * @return the specific UUID */ @@ -459,9 +442,9 @@ public final class CardUtil { * be specific to a permanent instance. So they won't match, if a permanent * was e.g. exiled and came back immediately. * - * @param text short value to describe the value + * @param text short value to describe the value * @param cardId id of the card - * @param game the game + * @param game the game * @return */ public static String getCardZoneString(String text, UUID cardId, Game game) { @@ -521,91 +504,7 @@ public final class CardUtil { return "" + text + ""; } - public static boolean convertedManaCostsIsEqual(MageObject object1, MageObject object2) { - Set cmcObject1 = getCMC(object1); - Set cmcObject2 = getCMC(object2); - for (Integer integer : cmcObject1) { - if (cmcObject2.contains(integer)) { - return true; - } - } - return false; - } - public static Set getCMC(MageObject object) { - Set cmcObject = new HashSet<>(); - if (object instanceof Spell) { - cmcObject.add(object.getConvertedManaCost()); - } else if (object instanceof Card) { - Card card = (Card) object; - cmcObject.add(card.getConvertedManaCost()); - } - return cmcObject; - } - - /** - * Gets the colors that are in the casting cost but also in the rules text - * as far as not included in reminder text. - * - * @param card - * @return - */ - public static FilterMana getColorIdentity(Card card) { - FilterMana mana = new FilterMana(); - mana.setBlack(card.getManaCost().getText().matches(regexBlack)); - mana.setBlue(card.getManaCost().getText().matches(regexBlue)); - mana.setGreen(card.getManaCost().getText().matches(regexGreen)); - mana.setRed(card.getManaCost().getText().matches(regexRed)); - mana.setWhite(card.getManaCost().getText().matches(regexWhite)); - - for (String rule : card.getRules()) { - rule = rule.replaceAll("(?i)", ""); // Ignoring reminder text in italic - if (!mana.isBlack() && rule.matches(regexBlack)) { - mana.setBlack(true); - } - if (!mana.isBlue() && rule.matches(regexBlue)) { - mana.setBlue(true); - } - if (!mana.isGreen() && rule.matches(regexGreen)) { - mana.setGreen(true); - } - if (!mana.isRed() && rule.matches(regexRed)) { - mana.setRed(true); - } - if (!mana.isWhite() && rule.matches(regexWhite)) { - mana.setWhite(true); - } - } - if (card.isTransformable()) { - Card secondCard = card.getSecondCardFace(); - ObjectColor color = secondCard.getColor(null); - mana.setBlack(mana.isBlack() || color.isBlack()); - mana.setGreen(mana.isGreen() || color.isGreen()); - mana.setRed(mana.isRed() || color.isRed()); - mana.setBlue(mana.isBlue() || color.isBlue()); - mana.setWhite(mana.isWhite() || color.isWhite()); - for (String rule : secondCard.getRules()) { - rule = rule.replaceAll("(?i)", ""); // Ignoring reminder text in italic - if (!mana.isBlack() && rule.matches(regexBlack)) { - mana.setBlack(true); - } - if (!mana.isBlue() && rule.matches(regexBlue)) { - mana.setBlue(true); - } - if (!mana.isGreen() && rule.matches(regexGreen)) { - mana.setGreen(true); - } - if (!mana.isRed() && rule.matches(regexRed)) { - mana.setRed(true); - } - if (!mana.isWhite() && rule.matches(regexWhite)) { - mana.setWhite(true); - } - } - } - - return mana; - } public static boolean isNonCreatureSubtype(String subtype) { return NON_CREATURE_SUBTYPES.contains(subtype); diff --git a/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java index e372d8d612..0274ab84c9 100644 --- a/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java @@ -47,7 +47,7 @@ public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher { private final Map amountOfDamageReceivedThisTurn = new HashMap<>(); public AmountOfDamageAPlayerReceivedThisTurnWatcher() { - super("AmountOfDamageReceivedThisTurn", WatcherScope.GAME); + super(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public AmountOfDamageAPlayerReceivedThisTurnWatcher(final AmountOfDamageAPlayerReceivedThisTurnWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/AttackedOrBlockedThisCombatWatcher.java b/Mage/src/main/java/mage/watchers/common/AttackedOrBlockedThisCombatWatcher.java index e54875d681..f4e36b11e4 100644 --- a/Mage/src/main/java/mage/watchers/common/AttackedOrBlockedThisCombatWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/AttackedOrBlockedThisCombatWatcher.java @@ -23,7 +23,7 @@ public class AttackedOrBlockedThisCombatWatcher extends Watcher { public final Set blockedThisTurnCreatures = new HashSet<>(); public AttackedOrBlockedThisCombatWatcher() { - super(AttackedOrBlockedThisCombatWatcher.class.getName(), WatcherScope.GAME); + super(AttackedOrBlockedThisCombatWatcher.class.getSimpleName(), WatcherScope.GAME); } public AttackedOrBlockedThisCombatWatcher(final AttackedOrBlockedThisCombatWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/AttackedThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/AttackedThisTurnWatcher.java index e3e6635dfe..a05882de46 100644 --- a/Mage/src/main/java/mage/watchers/common/AttackedThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/AttackedThisTurnWatcher.java @@ -43,7 +43,7 @@ public class AttackedThisTurnWatcher extends Watcher { public final Set attackedThisTurnCreatures = new HashSet<>(); public AttackedThisTurnWatcher() { - super(AttackedThisTurnWatcher.class.getName(), WatcherScope.GAME); + super(AttackedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/BlockedAttackerWatcher.java b/Mage/src/main/java/mage/watchers/common/BlockedAttackerWatcher.java index 1a9aaccc35..23a15d10cd 100644 --- a/Mage/src/main/java/mage/watchers/common/BlockedAttackerWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/BlockedAttackerWatcher.java @@ -47,7 +47,7 @@ public class BlockedAttackerWatcher extends Watcher { public final HashMap> blockData = new HashMap<>(); public BlockedAttackerWatcher() { - super("BlockedAttackerWatcher", WatcherScope.GAME); + super(BlockedAttackerWatcher.class.getSimpleName(), WatcherScope.GAME); } public BlockedAttackerWatcher(final BlockedAttackerWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/BlockedThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/BlockedThisTurnWatcher.java index fd7a1a2583..26d876f5d9 100644 --- a/Mage/src/main/java/mage/watchers/common/BlockedThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/BlockedThisTurnWatcher.java @@ -45,7 +45,7 @@ public class BlockedThisTurnWatcher extends Watcher { private final Set blockedThisTurnCreatures; public BlockedThisTurnWatcher() { - super("BlockedThisTurn", WatcherScope.GAME); + super(BlockedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); blockedThisTurnCreatures = new HashSet<>(); } diff --git a/Mage/src/main/java/mage/watchers/common/BloodthirstWatcher.java b/Mage/src/main/java/mage/watchers/common/BloodthirstWatcher.java index b49a62f629..b15cb2cfdd 100644 --- a/Mage/src/main/java/mage/watchers/common/BloodthirstWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/BloodthirstWatcher.java @@ -37,11 +37,12 @@ import java.util.UUID; /** * Must be installed to player for proper Bloodthirst work + * * @author Loki */ public class BloodthirstWatcher extends Watcher { public BloodthirstWatcher(UUID controllerId) { - super("DamagedOpponents", WatcherScope.PLAYER); + super(BloodthirstWatcher.class.getSimpleName(), WatcherScope.PLAYER); this.controllerId = controllerId; } @@ -55,7 +56,7 @@ public class BloodthirstWatcher extends Watcher { return; } if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { - DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event; + DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; if (game.getPlayer(this.getControllerId()).hasOpponent(damageEvent.getPlayerId(), game)) { condition = true; } diff --git a/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java index 39fc825179..3a3bd0d56d 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java @@ -44,12 +44,11 @@ import java.util.UUID; */ public class CardsAmountDrawnThisTurnWatcher extends Watcher { - public final static String BASIC_KEY = "CardsAmountDrawnThisTurnWatcher"; private final Map amountOfCardsDrawnThisTurn = new HashMap<>(); public CardsAmountDrawnThisTurnWatcher() { - super(BASIC_KEY, WatcherScope.GAME); + super(CardsAmountDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public CardsAmountDrawnThisTurnWatcher(final CardsAmountDrawnThisTurnWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java index 975ff72157..cdee6623c1 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; + import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; @@ -49,7 +50,7 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher { private final Map cycledOrDiscardedCardsThisTurn = new HashMap<>(); public CardsCycledOrDiscardedThisTurnWatcher() { - super(CardsCycledOrDiscardedThisTurnWatcher.class.getName(), WatcherScope.GAME); + super(CardsCycledOrDiscardedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public CardsCycledOrDiscardedThisTurnWatcher(final CardsCycledOrDiscardedThisTurnWatcher watcher) { @@ -61,12 +62,14 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.CYCLED_CARD + if (event.getType() == GameEvent.EventType.PAY_CYCLE_COST || event.getType() == GameEvent.EventType.DISCARDED_CARD) { if (event.getPlayerId() != null) { Card card = game.getCard(event.getTargetId()); if (card != null) { - getCardsCycledOrDiscardedThisTurn(event.getPlayerId()).add(card); + Cards c = getCardsCycledOrDiscardedThisTurn(event.getPlayerId()); + c.add(card); + cycledOrDiscardedCardsThisTurn.put(event.getPlayerId(), c); } } } diff --git a/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java index 59e9a91b77..33d421fe32 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java @@ -50,7 +50,7 @@ public class CardsDrawnDuringDrawStepWatcher extends Watcher { private final Map amountOfCardsDrawnThisTurn = new HashMap<>(); public CardsDrawnDuringDrawStepWatcher() { - super("CardsDrawnDuringDrawStep", WatcherScope.GAME); + super(CardsDrawnDuringDrawStepWatcher.class.getSimpleName(), WatcherScope.GAME); } public CardsDrawnDuringDrawStepWatcher(final CardsDrawnDuringDrawStepWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CardsPutIntoGraveyardWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsPutIntoGraveyardWatcher.java index 24957848cf..4371d4a5ea 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsPutIntoGraveyardWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsPutIntoGraveyardWatcher.java @@ -55,7 +55,7 @@ public class CardsPutIntoGraveyardWatcher extends Watcher { private final Set cardsPutToGraveyardFromBattlefield = new HashSet<>(); public CardsPutIntoGraveyardWatcher() { - super("CardsPutIntoGraveyardWatcher", WatcherScope.GAME); + super(CardsPutIntoGraveyardWatcher.class.getSimpleName(), WatcherScope.GAME); } public CardsPutIntoGraveyardWatcher(final CardsPutIntoGraveyardWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CastFromGraveyardWatcher.java b/Mage/src/main/java/mage/watchers/common/CastFromGraveyardWatcher.java index 7913fd121a..cb3418baf3 100644 --- a/Mage/src/main/java/mage/watchers/common/CastFromGraveyardWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CastFromGraveyardWatcher.java @@ -49,7 +49,7 @@ public class CastFromGraveyardWatcher extends Watcher { private final Map> spellsCastFromGraveyard = new HashMap<>(); public CastFromGraveyardWatcher() { - super(CastFromGraveyardWatcher.class.getName(), WatcherScope.GAME); + super(CastFromGraveyardWatcher.class.getSimpleName(), WatcherScope.GAME); } public CastFromGraveyardWatcher(final CastFromGraveyardWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java b/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java index b52afa6ce8..7d79471dc1 100644 --- a/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java @@ -19,7 +19,7 @@ public class CastFromHandWatcher extends Watcher { private Step step; public CastFromHandWatcher() { - super(CastFromHandWatcher.class.getName(), WatcherScope.GAME); + super(CastFromHandWatcher.class.getSimpleName(), WatcherScope.GAME); } public CastFromHandWatcher(final CastFromHandWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java index 27193a9dda..5caf5a5d17 100644 --- a/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java @@ -46,7 +46,7 @@ public class CastSpellLastTurnWatcher extends Watcher { private final List spellsCastThisTurnInOrder = new ArrayList<>(); public CastSpellLastTurnWatcher() { - super(CastSpellLastTurnWatcher.class.getName(), WatcherScope.GAME); + super(CastSpellLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public CastSpellLastTurnWatcher(final CastSpellLastTurnWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java b/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java index f6784b84c9..95ddc869d0 100644 --- a/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java @@ -54,7 +54,7 @@ public class CommanderInfoWatcher extends Watcher { public final boolean checkCommanderDamage; public CommanderInfoWatcher(UUID commander, boolean checkCommanderDamage) { - super("CommanderCombatDamageWatcher", WatcherScope.CARD); + super(CommanderInfoWatcher.class.getSimpleName(), WatcherScope.CARD); this.sourceId = commander; this.checkCommanderDamage = checkCommanderDamage; } diff --git a/Mage/src/main/java/mage/watchers/common/CreatureWasCastWatcher.java b/Mage/src/main/java/mage/watchers/common/CreatureWasCastWatcher.java index e42d17a714..493d88495d 100644 --- a/Mage/src/main/java/mage/watchers/common/CreatureWasCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CreatureWasCastWatcher.java @@ -49,7 +49,7 @@ public class CreatureWasCastWatcher extends Watcher { private final Set creaturesCasted = new HashSet<>(); public CreatureWasCastWatcher() { - super("CreatureWasCast", WatcherScope.GAME); + super(CreatureWasCastWatcher.class.getSimpleName(), WatcherScope.GAME); } public CreatureWasCastWatcher(final CreatureWasCastWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/CreaturesDiedWatcher.java b/Mage/src/main/java/mage/watchers/common/CreaturesDiedWatcher.java index 5905a625dd..c3537ac1e7 100644 --- a/Mage/src/main/java/mage/watchers/common/CreaturesDiedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CreaturesDiedWatcher.java @@ -45,7 +45,7 @@ public class CreaturesDiedWatcher extends Watcher { private final HashMap amountOfCreaturesThatDiedByController = new HashMap<>(); public CreaturesDiedWatcher() { - super("CreaturesDiedWatcher", WatcherScope.GAME); + super(CreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME); } public CreaturesDiedWatcher(final CreaturesDiedWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java b/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java index d9df669f88..3247f2ed1d 100644 --- a/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java @@ -27,7 +27,7 @@ public class DamageDoneWatcher extends Watcher { public final Map damagedObjects; public DamageDoneWatcher() { - super("DamageDone", WatcherScope.GAME); + super(DamageDoneWatcher.class.getSimpleName(), WatcherScope.GAME); this.damagingObjects = new HashMap<>(); this.damagedObjects = new HashMap<>(); } diff --git a/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java b/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java index 00816564e9..712d76d781 100644 --- a/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java @@ -54,7 +54,7 @@ public class DamagedByWatcher extends Watcher { } public DamagedByWatcher(boolean watchPlaneswalkers) { - super("DamagedByWatcher", WatcherScope.CARD); + super(DamagedByWatcher.class.getSimpleName(), WatcherScope.CARD); this.watchPlaneswalkers = watchPlaneswalkers; } diff --git a/Mage/src/main/java/mage/watchers/common/DragonOnTheBattlefieldWhileSpellWasCastWatcher.java b/Mage/src/main/java/mage/watchers/common/DragonOnTheBattlefieldWhileSpellWasCastWatcher.java index 51110c72ca..ec06e94af3 100644 --- a/Mage/src/main/java/mage/watchers/common/DragonOnTheBattlefieldWhileSpellWasCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DragonOnTheBattlefieldWhileSpellWasCastWatcher.java @@ -51,7 +51,7 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher { private final Set castWithDragonOnTheBattlefield = new HashSet<>(); public DragonOnTheBattlefieldWhileSpellWasCastWatcher() { - super("DragonOnTheBattlefieldWhileSpellWasCastWatcher", WatcherScope.GAME); + super(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName(), WatcherScope.GAME); } public DragonOnTheBattlefieldWhileSpellWasCastWatcher(final DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/FirstSpellCastThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/FirstSpellCastThisTurnWatcher.java index 5fb2de58c2..db98da2824 100644 --- a/Mage/src/main/java/mage/watchers/common/FirstSpellCastThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/FirstSpellCastThisTurnWatcher.java @@ -19,7 +19,7 @@ public class FirstSpellCastThisTurnWatcher extends Watcher { private final Map playerFirstCastSpell = new HashMap<>(); public FirstSpellCastThisTurnWatcher() { - super("FirstSpellCastThisTurn", WatcherScope.GAME); + super(FirstSpellCastThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public FirstSpellCastThisTurnWatcher(final FirstSpellCastThisTurnWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/FirstTimeStepWatcher.java b/Mage/src/main/java/mage/watchers/common/FirstTimeStepWatcher.java index 303f4586a2..7fb74921a1 100644 --- a/Mage/src/main/java/mage/watchers/common/FirstTimeStepWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/FirstTimeStepWatcher.java @@ -44,7 +44,7 @@ public class FirstTimeStepWatcher extends Watcher { private final EventType eventType; public FirstTimeStepWatcher(EventType eventType) { - super(eventType.toString() + FirstTimeStepWatcher.class.getName(), WatcherScope.GAME); + super(eventType.toString() + FirstTimeStepWatcher.class.getSimpleName(), WatcherScope.GAME); this.eventType = eventType; } diff --git a/Mage/src/main/java/mage/watchers/common/GravestormWatcher.java b/Mage/src/main/java/mage/watchers/common/GravestormWatcher.java index 5d8d101421..a18e185a7c 100644 --- a/Mage/src/main/java/mage/watchers/common/GravestormWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/GravestormWatcher.java @@ -45,7 +45,7 @@ public class GravestormWatcher extends Watcher { private int gravestormCount = 0; public GravestormWatcher() { - super("GravestormWatcher", WatcherScope.GAME); + super(GravestormWatcher.class.getSimpleName(), WatcherScope.GAME); } public GravestormWatcher(final GravestormWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/LandfallWatcher.java b/Mage/src/main/java/mage/watchers/common/LandfallWatcher.java index 51748037c6..f006cef8a8 100644 --- a/Mage/src/main/java/mage/watchers/common/LandfallWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/LandfallWatcher.java @@ -19,7 +19,7 @@ public class LandfallWatcher extends Watcher { final Set playerPlayedLand = new HashSet<>(); public LandfallWatcher() { - super("LandPlayed", WatcherScope.GAME); + super(LandfallWatcher.class.getSimpleName(), WatcherScope.GAME); } public LandfallWatcher(final LandfallWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/LifeLossOtherFromCombatWatcher.java b/Mage/src/main/java/mage/watchers/common/LifeLossOtherFromCombatWatcher.java index ebf698bdd4..0418c8592c 100644 --- a/Mage/src/main/java/mage/watchers/common/LifeLossOtherFromCombatWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/LifeLossOtherFromCombatWatcher.java @@ -45,7 +45,7 @@ public class LifeLossOtherFromCombatWatcher extends Watcher { private final Set players = new HashSet<>(); public LifeLossOtherFromCombatWatcher() { - super(LifeLossOtherFromCombatWatcher.class.getName(), WatcherScope.GAME); + super(LifeLossOtherFromCombatWatcher.class.getSimpleName(), WatcherScope.GAME); } public LifeLossOtherFromCombatWatcher(final LifeLossOtherFromCombatWatcher watcher) { @@ -66,7 +66,7 @@ public class LifeLossOtherFromCombatWatcher extends Watcher { public boolean opponentLostLifeOtherFromCombat(UUID playerId, Game game) { Player player = game.getPlayer(playerId); if (player != null) { - if (players.stream().anyMatch((damagedPlayerId) -> (player.hasOpponent(damagedPlayerId, game)))) { + if (players.stream().anyMatch(damagedPlayerId -> player.hasOpponent(damagedPlayerId, game))) { return true; } } diff --git a/Mage/src/main/java/mage/watchers/common/ManaSpentToCastWatcher.java b/Mage/src/main/java/mage/watchers/common/ManaSpentToCastWatcher.java index d00e66597c..917ecbe737 100644 --- a/Mage/src/main/java/mage/watchers/common/ManaSpentToCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ManaSpentToCastWatcher.java @@ -46,7 +46,7 @@ public class ManaSpentToCastWatcher extends Watcher { Mana payment = null; public ManaSpentToCastWatcher() { - super("ManaSpentToCast", WatcherScope.CARD); + super(ManaSpentToCastWatcher.class.getSimpleName(), WatcherScope.CARD); } public ManaSpentToCastWatcher(final ManaSpentToCastWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java b/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java index a3a966bd78..b4272671cb 100644 --- a/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java @@ -55,7 +55,7 @@ public class MiracleWatcher extends Watcher { private final Map amountOfCardsDrawnThisTurn = new HashMap<>(); public MiracleWatcher() { - super("MiracleWatcher", WatcherScope.GAME); + super(MiracleWatcher.class.getSimpleName(), WatcherScope.GAME); } public MiracleWatcher(final MiracleWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/MorbidWatcher.java b/Mage/src/main/java/mage/watchers/common/MorbidWatcher.java index e1df966f92..d69521a799 100644 --- a/Mage/src/main/java/mage/watchers/common/MorbidWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/MorbidWatcher.java @@ -44,7 +44,7 @@ import mage.watchers.Watcher; public class MorbidWatcher extends Watcher { public MorbidWatcher() { - super("Morbid", WatcherScope.GAME); + super(MorbidWatcher.class.getSimpleName(), WatcherScope.GAME); } public MorbidWatcher(final MorbidWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/NumberOfTimesPermanentTargetedATurnWatcher.java b/Mage/src/main/java/mage/watchers/common/NumberOfTimesPermanentTargetedATurnWatcher.java index b2ba609b06..3bb0f5770e 100644 --- a/Mage/src/main/java/mage/watchers/common/NumberOfTimesPermanentTargetedATurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/NumberOfTimesPermanentTargetedATurnWatcher.java @@ -46,12 +46,12 @@ public class NumberOfTimesPermanentTargetedATurnWatcher extends Watcher { private final Map permanentsTargeted = new HashMap<>(); public NumberOfTimesPermanentTargetedATurnWatcher() { - super(NumberOfTimesPermanentTargetedATurnWatcher.class.getName(), WatcherScope.GAME); + super(NumberOfTimesPermanentTargetedATurnWatcher.class.getSimpleName(), WatcherScope.GAME); } public NumberOfTimesPermanentTargetedATurnWatcher(final NumberOfTimesPermanentTargetedATurnWatcher watcher) { super(watcher); - this.permanentsTargeted.putAll(permanentsTargeted); + this.permanentsTargeted.putAll(watcher.permanentsTargeted); } @Override diff --git a/Mage/src/main/java/mage/watchers/common/PermanentsEnteredBattlefieldWatcher.java b/Mage/src/main/java/mage/watchers/common/PermanentsEnteredBattlefieldWatcher.java index f73cd79471..7fdefbe7cb 100644 --- a/Mage/src/main/java/mage/watchers/common/PermanentsEnteredBattlefieldWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PermanentsEnteredBattlefieldWatcher.java @@ -25,7 +25,7 @@ public class PermanentsEnteredBattlefieldWatcher extends Watcher { private final HashMap> enteringBattlefieldLastTurn = new HashMap<>(); public PermanentsEnteredBattlefieldWatcher() { - super(PermanentsEnteredBattlefieldWatcher.class.getName(), WatcherScope.GAME); + super(PermanentsEnteredBattlefieldWatcher.class.getSimpleName(), WatcherScope.GAME); } public PermanentsEnteredBattlefieldWatcher(final PermanentsEnteredBattlefieldWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/PermanentsSacrificedWatcher.java b/Mage/src/main/java/mage/watchers/common/PermanentsSacrificedWatcher.java index e5cb931e49..9e8119c4db 100644 --- a/Mage/src/main/java/mage/watchers/common/PermanentsSacrificedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PermanentsSacrificedWatcher.java @@ -24,7 +24,7 @@ public class PermanentsSacrificedWatcher extends Watcher { private final HashMap> sacrificedPermanents = new HashMap<>(); public PermanentsSacrificedWatcher() { - super(PermanentsSacrificedWatcher.class.getName(), WatcherScope.GAME); + super(PermanentsSacrificedWatcher.class.getSimpleName(), WatcherScope.GAME); } public PermanentsSacrificedWatcher(final PermanentsSacrificedWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java index 434cbb2dc9..8937f34fb4 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java @@ -47,7 +47,7 @@ public class PlayerAttackedWatcher extends Watcher { private final Map playerAttacked = new HashMap<>(); public PlayerAttackedWatcher() { - super("PlayerAttackedWatcher", WatcherScope.GAME); + super(PlayerAttackedWatcher.class.getSimpleName(), WatcherScope.GAME); } public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/PlayerCastCreatureWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerCastCreatureWatcher.java index d5fc443f1c..e452076b71 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerCastCreatureWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerCastCreatureWatcher.java @@ -46,7 +46,7 @@ public class PlayerCastCreatureWatcher extends Watcher { final Set playerIds = new HashSet<>(); public PlayerCastCreatureWatcher() { - super("PlayerCastCreature", WatcherScope.GAME); + super(PlayerCastCreatureWatcher.class.getSimpleName(), WatcherScope.GAME); } public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/PlayerDamagedBySourceWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerDamagedBySourceWatcher.java index 73020e7a5d..3f9349359a 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerDamagedBySourceWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerDamagedBySourceWatcher.java @@ -47,7 +47,7 @@ public class PlayerDamagedBySourceWatcher extends Watcher { private final Set damageSourceIds = new HashSet<>(); public PlayerDamagedBySourceWatcher(UUID playerId) { - super("PlayerDamagedBySource", WatcherScope.PLAYER); + super(PlayerLostLifeWatcher.class.getSimpleName(), WatcherScope.PLAYER); setControllerId(playerId); } diff --git a/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java index 8e9839e3fa..c6a7d28ceb 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java @@ -47,7 +47,7 @@ public class PlayerGainedLifeWatcher extends Watcher { private final Map amountOfLifeGainedThisTurn = new HashMap<>(); public PlayerGainedLifeWatcher() { - super(PlayerGainedLifeWatcher.class.getName(), WatcherScope.GAME); + super(PlayerGainedLifeWatcher.class.getSimpleName(), WatcherScope.GAME); } public PlayerGainedLifeWatcher(final PlayerGainedLifeWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java index 44db03d8bb..c0fd33b991 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java @@ -48,7 +48,7 @@ public class PlayerLostLifeWatcher extends Watcher { private final Map amountOfLifeLostLastTurn = new HashMap<>(); public PlayerLostLifeWatcher() { - super("PlayerLostLifeWatcher", WatcherScope.GAME); + super(PlayerLostLifeWatcher.class.getSimpleName(), WatcherScope.GAME); } public PlayerLostLifeWatcher(final PlayerLostLifeWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/ProwlWatcher.java b/Mage/src/main/java/mage/watchers/common/ProwlWatcher.java index 7f6d5f86f8..e61ea01bb0 100644 --- a/Mage/src/main/java/mage/watchers/common/ProwlWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ProwlWatcher.java @@ -55,7 +55,7 @@ public class ProwlWatcher extends Watcher { private final Set allSubtypes = new HashSet<>(); public ProwlWatcher() { - super("Prowl", WatcherScope.GAME); + super(ProwlWatcher.class.getSimpleName(), WatcherScope.GAME); } public ProwlWatcher(final ProwlWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/RevoltWatcher.java b/Mage/src/main/java/mage/watchers/common/RevoltWatcher.java index 63f9d33717..a7a4824d47 100644 --- a/Mage/src/main/java/mage/watchers/common/RevoltWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/RevoltWatcher.java @@ -48,7 +48,7 @@ public class RevoltWatcher extends Watcher { private final Set revoltActivePlayerIds = new HashSet<>(0); public RevoltWatcher() { - super(RevoltWatcher.class.getName(), WatcherScope.GAME); + super(RevoltWatcher.class.getSimpleName(), WatcherScope.GAME); } public RevoltWatcher(final RevoltWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java b/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java index 4c5ee497b5..6c0c810799 100644 --- a/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java @@ -45,7 +45,7 @@ public class SourceDidDamageWatcher extends Watcher { public final Set damageSources = new HashSet<>(); public SourceDidDamageWatcher() { - super("SourceDidDamageWatcher", WatcherScope.GAME); + super(SourceDidDamageWatcher.class.getSimpleName(), WatcherScope.GAME); } public SourceDidDamageWatcher(final SourceDidDamageWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java b/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java index e0de2c9c8f..34c2fcd1ae 100644 --- a/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java @@ -27,7 +27,7 @@ public class SpellsCastWatcher extends Watcher { private final HashMap> spellsCast = new HashMap<>(); public SpellsCastWatcher() { - super(SpellsCastWatcher.class.getName(), WatcherScope.GAME); + super(SpellsCastWatcher.class.getSimpleName(), WatcherScope.GAME); } public SpellsCastWatcher(final SpellsCastWatcher watcher) { diff --git a/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java b/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java index b82811661c..b3e3bcfea9 100644 --- a/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java @@ -16,7 +16,7 @@ public class ZuberasDiedWatcher extends Watcher { public int zuberasDiedThisTurn = 0; public ZuberasDiedWatcher() { - super("ZuberasDied", WatcherScope.GAME); + super(ZuberasDiedWatcher.class.getSimpleName(), WatcherScope.GAME); } public ZuberasDiedWatcher(final ZuberasDiedWatcher watcher) {