sonar 220219, criticals

This commit is contained in:
Ingmar Goudt 2019-02-22 12:05:44 +01:00
parent 4504ad5e6f
commit 3359c1f3f1
23 changed files with 153 additions and 280 deletions

View file

@ -805,7 +805,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
insertArrow = new JLabel();
insertArrow.setSize(20, 20);
insertArrow.setVisible(false);
cardContent.add(insertArrow, new Integer(1000));
cardContent.add(insertArrow, 1000);
// Selection panel
selectionPanel = new SelectionBox();

View file

@ -14,6 +14,9 @@ import java.util.UUID;
public final class LocalCommands {
private LocalCommands(){}
/**
* Handler for commands that do not require server interaction, i.e settings etc
* @param chatId

View file

@ -26,7 +26,7 @@ public class MageRoundPane extends JPanel {
private int Y_OFFSET = 30;
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
private Color backgroundColor = defaultBackgroundColor;
private static final int alpha = 0;
private static final int ALPHA = 0;
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final Map<Key, BufferedImage> IMAGE_CACHE;
@ -163,8 +163,8 @@ public class MageRoundPane extends JPanel {
/**
* Add white translucent substrate
*/
/*if (alpha != 0) {
g2.setColor(new Color(255, 255, 255, alpha));
/*if (ALPHA != 0) {
g2.setColor(new Color(255, 255, 255, ALPHA));
g2.fillRoundRect(x, y, w, h, arc, arc);
}*/
g2.setColor(key.backgroundColor);

View file

@ -16,7 +16,7 @@ public class BackgroundPainter extends AbstractPainter {
private final Color bgColor = Color.black;
static final float bgalpha = 0.6f;
static final float BACKGROUND_ALPHA = 0.6f;
public BackgroundPainter() {
super();
@ -25,7 +25,7 @@ public class BackgroundPainter extends AbstractPainter {
@Override
protected void doPaint(Graphics2D g2, Object o, int i, int i1) {
float alpha = bgalpha;
float alpha = BACKGROUND_ALPHA;
Component c = (Component)o;
Composite composite = g2.getComposite();
if (composite instanceof AlphaComposite) {

View file

@ -0,0 +1,8 @@
package mage.client.components.ext;
public enum MessageDialogType {
INFO,
WARNING,
ERROR,
FLASH_INFO
}

View file

@ -1,13 +0,0 @@
package mage.client.components.ext;
/**
* @author mw, noxx
*/
public class MessageDlg {
MessageDlg() {}
public enum Types {
Info, Warning, Error, FlashInfo
}
}

View file

@ -1,6 +1,6 @@
package mage.client.components.ext.dlg;
import mage.client.components.ext.MessageDlg;
import mage.client.components.ext.MessageDialogType;
import mage.client.components.ext.dlg.impl.ChoiceDialog;
import mage.client.components.ext.dlg.impl.StackDialog;
@ -37,146 +37,99 @@ public class DialogContainer extends JPanel {
setLayout(null);
drawContainer = true;
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
//backgroundColor = new Color(0, 255, 255, 60);
if (params.type == MessageDlg.Types.Warning) {
backgroundColor = new Color(255, 0, 0, 90);
} else {
backgroundColor = new Color(0, 0, 0, 90);
switch (dialogType) {
case MESSAGE:
//backgroundColor = new Color(0, 255, 255, 60);
if (params.type == MessageDialogType.WARNING) {
backgroundColor = new Color(255, 0, 0, 90);
} else {
backgroundColor = new Color(0, 0, 0, 90);
}
alpha = 0;
//MessageDlg dlg = new MessageDlg(params);
//add(dlg);
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
//dlg.updateSize(params.rect.width, params.rect.height);
break;
case STACK: {
//backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(0, 0, 0, 50);
alpha = 0;
StackDialog dlg = new StackDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
//int width = Math.min(params.rect.width - 80, 600);
int width = params.rect.width;
int height = params.rect.height - 80;
dlg.updateSize(width, height);
break;
}
alpha = 0;
//MessageDlg dlg = new MessageDlg(params);
//add(dlg);
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
//dlg.updateSize(params.rect.width, params.rect.height);
} else if (dialogType == DialogManager.MTGDialogs.StackDialog) {
//backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(0, 0, 0, 50);
alpha = 0;
StackDialog dlg = new StackDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
//int width = Math.min(params.rect.width - 80, 600);
int width = params.rect.width;
int height = params.rect.height - 80;
dlg.updateSize(width, height);
}
/*
else if (dialogType == DialogManager.MTGDialogs.CombatDialog) {
else if (dialogType == DialogManager.MTGDialogs.COMBAT) {
backgroundColor = new Color(0, 0, 0, 60);
alpha = 0;
CombatDialog dlg = new CombatDialog(params);
COMBAT dlg = new COMBAT(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
}*/ else if (dialogType == DialogManager.MTGDialogs.ChoiceDialog) {
}*/
case CHOICE: {
//backgroundColor = new Color(200, 200, 172, 120);
//backgroundColor = new Color(180, 150, 200, 120);
//backgroundColor = new Color(0, 255, 0, 60);
//backgroundColor = new Color(200, 200, 172, 120);
//backgroundColor = new Color(180, 150, 200, 120);
//backgroundColor = new Color(0, 255, 0, 60);
//backgroundColor = new Color(139, 46, 173, 20);
backgroundColor = new Color(0, 0, 0, 110);
//backgroundColor = new Color(139, 46, 173, 0);
//backgroundColor = new Color(139, 46, 173, 20);
backgroundColor = new Color(0, 0, 0, 110);
//backgroundColor = new Color(139, 46, 173, 0);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
add(dlg);
//GameManager.getManager().setCurrentChoiceDlg(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
add(dlg);
//GameManager.getManager().setCurrentChoiceDlg(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
backgroundColor = new Color(0, 0, 0, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.ExileDialog) {
backgroundColor = new Color(250, 250, 250, 50);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.EmblemsDialog) {
backgroundColor = new Color(0, 0, 50, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} /*else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
backgroundColor = new Color(20, 20, 20, 120);
alpha = 0;
GraveDialog dlg = new GraveDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.RevealDialog) {
backgroundColor = new Color(90, 135, 190, 80);
alpha = 0;
RevealDialog dlg = new RevealDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.AssignDamageDialog) {
backgroundColor = new Color(255, 255, 255, 130);
alpha = 0;
AssignDamageDialog dlg = new AssignDamageDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.ManaChoiceDialog) {
backgroundColor = new Color(0, 255, 255, 60);
alpha = 20;
ManaChoiceDialog dlg = new ManaChoiceDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
//isGradient = true;
gradient = ImageManager.getGradientImage();
if (gradient != null) {
b = ImageToBufferedImage.toBufferedImage(gradient);
b = Transparency.makeImageTranslucent(b, 0.35);
Rectangle2D tr = new Rectangle2D.Double(0, 0, params.rect.width, params.rect.height);
//gradient = gradient.getScaledInstance(w, h, Image.SCALE_SMOOTH);
tp = new TexturePaint(b, tr);
break;
}
case GRAVEYARD: {
backgroundColor = new Color(0, 0, 0, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
break;
}
case EXILE: {
backgroundColor = new Color(250, 250, 250, 50);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
break;
}
case EMBLEMS: {
backgroundColor = new Color(0, 0, 50, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
break;
}
} else if (dialogType == DialogManager.MTGDialogs.ChooseDeckDialog) {
MWDeckPanel deckPanel = new MWDeckPanel(params.getDeckList(), params.isAI);
deckPanel.setVisible(true);
deckPanel.setBounds(0,0,480,320);
add(deckPanel);
drawContainer = false;
} else if (dialogType == DialogManager.MTGDialogs.ChooseCommonDialog) {
MWChoosePanel choosePanel = new MWChoosePanel(params.getObjectList(), params.getTitle());
choosePanel.setVisible(true);
choosePanel.setBounds(0,0,440,240);
add(choosePanel);
drawContainer = false;
} else if (dialogType == DialogManager.MTGDialogs.AboutDialog) {
backgroundColor = new Color(255, 255, 255, 120);
alpha = 0;
AboutDialog dlg = new AboutDialog();
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
}
*/
}
public void cleanUp() {

View file

@ -39,8 +39,8 @@ public class DialogManager extends JComponent implements MouseListener,
}
public enum MTGDialogs {
none, AboutDialog, MessageDialog, StackDialog, AssignDamageDialog, ManaChoiceDialog, ChoiceDialog, EmblemsDialog, GraveDialog, DialogContainer, CombatDialog,
ChooseDeckDialog, ChooseCommonDialog, RevealDialog, ExileDialog
NONE, ABOUT, MESSAGE, STACK, ASSIGN_DAMAGE, MANA_CHOICE, CHOICE, EMBLEMS, GRAVEYARD, DialogContainer, COMBAT,
CHOOSE_DECK, CHOOSE_COMMON, REVEAL, EXILE
}
/**
@ -58,7 +58,7 @@ public class DialogManager extends JComponent implements MouseListener,
}
}
private MTGDialogs currentDialog = MTGDialogs.none;
private MTGDialogs currentDialog = MTGDialogs.NONE;
private DialogContainer dialogContainer = null;
@ -133,7 +133,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId;
params.feedbackPanel = feedbackPanel;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.StackDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.STACK, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -163,7 +163,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId;
//params.feedbackPanel = feedbackPanel;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.GraveDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.GRAVEYARD, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -192,7 +192,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.bigCard = bigCard;
params.gameId = gameId;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.ExileDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.EXILE, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -222,7 +222,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId;
//params.feedbackPanel = feedbackPanel;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.EmblemsDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.EMBLEMS, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -248,7 +248,7 @@ public class DialogManager extends JComponent implements MouseListener,
removeAll();
}
this.currentDialog = MTGDialogs.none;
this.currentDialog = MTGDialogs.NONE;
setVisible(false);
@ -312,6 +312,7 @@ public class DialogManager extends JComponent implements MouseListener,
@Override
public void mouseExited(MouseEvent e) {
}
@Override
@ -360,7 +361,7 @@ public class DialogManager extends JComponent implements MouseListener,
public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
// System.out.println("outx:"+notches);
// if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) {
// if (currentDialog != null && currentDialog.equals(MTGDialogs.CHOOSE_COMMON)) {
// System.out.println("out:"+1);
// }
}

View file

@ -1,7 +1,7 @@
package mage.client.components.ext.dlg;
import mage.client.cards.BigCard;
import mage.client.components.ext.MessageDlg;
import mage.client.components.ext.MessageDialogType;
import mage.client.game.FeedbackPanel;
import mage.view.CardsView;
@ -19,7 +19,7 @@ import java.util.UUID;
public class DlgParams {
public Rectangle rect;
public MessageDlg.Types type;
public MessageDialogType type;
public BigCard bigCard;
public FeedbackPanel feedbackPanel;
public UUID gameId;
@ -33,13 +33,13 @@ public class DlgParams {
private String title;
private int opponentID;
boolean isOptional = false;
boolean isChooseAbility = false;
boolean isCancelStopsPlaying = true;
private boolean isOptional = false;
private boolean isChooseAbility = false;
private boolean isCancelStopsPlaying = true;
boolean isAI = false;
private boolean isAI = false;
public Set<String> manaChoices = new HashSet<>();
private Set<String> manaChoices = new HashSet<>();
public int getPlayerID() {
return playerID;

View file

@ -1,7 +1,7 @@
/*
* CombatDialog.java
* COMBAT.java
*
* Created on Feb 10, 2010, 3:35:02 PM
*/
@ -33,7 +33,7 @@ public class CombatDialog extends MageDialog {
private int lastX = 500;
private int lastY = 300;
/** Creates new form CombatDialog */
/** Creates new form COMBAT */
public CombatDialog() {
JPanel contentPane = new JPanel() {

View file

@ -164,10 +164,7 @@ public final class DeckBuilder {
}
}
if (count > 0) {
Integer typeCount = colorCount.get(symbol);
if (typeCount == null) {
typeCount = 0;
}
Integer typeCount = colorCount.getOrDefault(symbol, 0);
typeCount += 1;
colorCount.put(symbol, typeCount);
}
@ -243,9 +240,9 @@ public final class DeckBuilder {
int type;
if (card.isCreature()) {
type = 10;
} else if (card.getSubtype(null).contains(SubType.EQUIPMENT)) {
} else if (card.hasSubtype(SubType.EQUIPMENT, null)) {
type = 8;
} else if (card.getSubtype(null).contains(SubType.AURA)) {
} else if (card.hasSubtype(SubType.AURA, null)) {
type = 5;
} else if (card.isInstant()) {
type = 7;
@ -283,10 +280,7 @@ public final class DeckBuilder {
multicolor += 1;
colors.add(symbol);
}
Integer typeCount = singleCount.get(symbol);
if (typeCount == null) {
typeCount = 0;
}
Integer typeCount = singleCount.getOrDefault(symbol, 0);
typeCount += 1;
singleCount.put(symbol, typeCount);
maxSingleCount = Math.max(maxSingleCount, typeCount);

View file

@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
import java.io.File;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
public enum TableRecordRepository {
@ -63,7 +64,7 @@ public enum TableRecordRepository {
} catch (SQLException ex) {
Logger.getLogger(TableRecordRepository.class).error("Error getting table_records from DB - ", ex);
}
return null;
return Collections.emptyList();
}
public void closeDB() {

View file

@ -16,10 +16,7 @@ import org.apache.log4j.Logger;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
public enum UserStatsRepository {
@ -89,7 +86,7 @@ public enum UserStatsRepository {
} catch (SQLException ex) {
Logger.getLogger(UserStatsRepository.class).error("Error getting all users from DB - ", ex);
}
return null;
return Collections.emptyList();
}
public long getLatestEndTimeMs() {

View file

@ -12,6 +12,8 @@ import org.apache.log4j.Logger;
*/
public final class Config {
private Config(){}
private static final Logger logger = Logger.getLogger(Config.class);
static {

View file

@ -8,6 +8,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.Executors;
@ -52,7 +53,6 @@ public enum ServerMessagesUtil {
}
public List<String> getMessages() {
lock.readLock().lock();
try {
@ -66,9 +66,7 @@ public enum ServerMessagesUtil {
log.debug("Reading server messages...");
List<String> motdMessages = readFromFile();
List<String> newMessages = new ArrayList<>();
if (motdMessages != null) {
newMessages.addAll(motdMessages);
}
newMessages.addAll(motdMessages);
newMessages.add(getServerStatistics());
newMessages.add(getServerStatistics2());
@ -83,7 +81,7 @@ public enum ServerMessagesUtil {
private List<String> readFromFile() {
if (ignore) {
return null;
return Collections.emptyList();
}
File externalFile = null;
if (pathToExternalMessages != null) {
@ -120,7 +118,7 @@ public enum ServerMessagesUtil {
}
if (is == null) {
log.warn("Couldn't find server.msg");
return null;
return Collections.emptyList();
}
Scanner scanner = null;
@ -133,8 +131,8 @@ public enum ServerMessagesUtil {
newMessages.add(message.trim());
}
}
} catch(Exception e) {
log.error(e,e);
} catch (Exception e) {
log.error(e, e);
} finally {
StreamUtils.closeQuietly(scanner);
StreamUtils.closeQuietly(is);
@ -168,7 +166,7 @@ public enum ServerMessagesUtil {
return statistics.toString();
}
// private Timer timer = new Timer(1000 * 60, new ActionListener() {
// private Timer timer = new Timer(1000 * 60, new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// reloadMessages();
// }

View file

@ -11,6 +11,8 @@ import mage.players.Player;
*/
public final class Splitter {
private Splitter(){}
public static List<UUID> split(Game game, UUID playerId) {
List<UUID> players = new ArrayList<>();
//players.add(playerId); // add original player

View file

@ -31,6 +31,8 @@ import java.util.stream.Collectors;
*/
public final class SystemUtil {
private SystemUtil(){}
public static final DateFormat dateFormat = new SimpleDateFormat("yy-M-dd HH:mm:ss");
private static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
@ -120,7 +122,7 @@ public final class SystemUtil {
String cardInfo = card.getName() + " - " + card.getExpansionSetCode();
// optional info
ArrayList<String> resInfo = new ArrayList<>();
List<String> resInfo = new ArrayList<>();
for (String param : commandParams) {
switch (param) {
case PARAM_COLOR_COST:
@ -147,7 +149,7 @@ public final class SystemUtil {
}
}
if (resInfo.size() > 0) {
if (!resInfo.isEmpty()) {
cardInfo += ": " + resInfo.stream().collect(Collectors.joining("; "));
}
@ -555,12 +557,9 @@ public final class SystemUtil {
* @return
*/
private static Optional<Player> findPlayer(Game game, String name) {
for (Player player : game.getPlayers().values()) {
if (player.getName().equals(name)) {
return Optional.of(player);
}
}
return Optional.empty();
return game.getPlayers().values().stream()
.filter(player -> player.getName().equals(name)).findFirst();
}
public static String sanitize(String input) {

View file

@ -19,12 +19,12 @@ import mage.watchers.common.BloodthirstWatcher;
*/
public final class Antagonism extends CardImpl {
private static final String rule = "{this} deals 2 damage to that player unless one of his or her opponents was dealt damage this turn";
private static final String rule = "{this} deals 2 damage to that player unless one of their opponents was dealt damage this turn";
public Antagonism(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
// At the beginning of each player's end step, Antagonism deals 2 damage to that player unless one of his or her opponents was dealt damage this turn.
// At the beginning of each player's end step, Antagonism deals 2 damage to that player unless one of their opponents was dealt damage this turn.
this.addAbility(new BeginningOfEndStepTriggeredAbility(new ConditionalOneShotEffect(new DamageTargetEffect(2),
new OpponentWasNotDealtDamageCondition(), rule), TargetController.ANY, false));

View file

@ -53,78 +53,6 @@ public final class NullChamber extends CardImpl {
}
}
class NullChamberChooseACardNameEffect extends OneShotEffect {
public static String INFO_KEY = "NAMED_CARD";
public enum TypeOfName {
NOT_BASIC_LAND_NAME,
}
private final TypeOfName typeOfName;
public NullChamberChooseACardNameEffect(TypeOfName typeOfName) {
super(Outcome.Detriment);
this.typeOfName = typeOfName;
staticText = setText();
}
public NullChamberChooseACardNameEffect(final NullChamberChooseACardNameEffect effect) {
super(effect);
this.typeOfName = effect.typeOfName;
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(source.getFirstTarget());
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
if (sourceObject == null) {
sourceObject = game.getObject(source.getSourceId());
}
if (controller != null
&& opponent != null
&& sourceObject != null) {
Choice cardChoice = new ChoiceImpl();
switch (typeOfName) {
case NOT_BASIC_LAND_NAME:
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
cardChoice.setMessage("Choose a card name other than a basic land card name");
break;
}
cardChoice.clearChoice();
if (controller.choose(Outcome.Detriment, cardChoice, game)) {
String cardName = cardChoice.getChoice();
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + ']');
}
game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
if (sourceObject instanceof Permanent) {
((Permanent) sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName), game);
}
return true;
}
}
return false;
}
@Override
public NullChamberChooseACardNameEffect copy() {
return new NullChamberChooseACardNameEffect(this);
}
private String setText() {
StringBuilder sb = new StringBuilder("choose a ");
switch (typeOfName) {
case NOT_BASIC_LAND_NAME:
sb.append("card name other than a basic land card");
break;
}
sb.append(" name");
return sb.toString();
}
}
class NullChamberReplacementEffect extends ContinuousRuleModifyingEffectImpl {

View file

@ -71,7 +71,7 @@ class VenarianGoldValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
MageObject mageObject = game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.STACK);
if (mageObject != null && mageObject instanceof StackObject) {
if (mageObject instanceof StackObject) {
return ((StackObject) mageObject).getStackAbility().getManaCostsToPay().getX();
}
return 0;

View file

@ -111,7 +111,7 @@ class CanTargetOnlyWallsPredicate implements Predicate<MageObject> {
for (Mode mode : stackObject.getStackAbility().getModes().values()) {
for (Target target : mode.getTargets()) {
Filter filter = target.getFilter();
if (filter != null && filter instanceof FilterPermanent) {
if (filter instanceof FilterPermanent) {
for (Object predicate : filter.getPredicates()) {
if (predicate instanceof SubtypePredicate) {
if (predicate.toString().equals("Subtype(Wall)")) {

View file

@ -21,7 +21,7 @@ public class SkipNextDrawStepTargetEffect extends ReplacementEffectImpl {
public SkipNextDrawStepTargetEffect() {
super(Duration.OneUse, Outcome.Detriment);
staticText = "Target player skips his or her next draw step";
staticText = "Target player skips their next draw step";
}
public SkipNextDrawStepTargetEffect(final SkipNextDrawStepTargetEffect effect) {

View file

@ -19,23 +19,23 @@ import mage.filter.predicate.permanent.CounterPredicate;
*/
public class BountyAbility extends DiesCreatureTriggeredAbility {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls with a bounty counter on it");
private static final FilterCreaturePermanent bountyCounterFilter = new FilterCreaturePermanent("creature an opponent controls with a bounty counter on it");
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
filter.add(new CounterPredicate(CounterType.BOUNTY));
bountyCounterFilter.add(new ControllerPredicate(TargetController.OPPONENT));
bountyCounterFilter.add(new CounterPredicate(CounterType.BOUNTY));
}
public BountyAbility(Effect effect) {
super(effect, false, filter);
super(effect, false, bountyCounterFilter);
}
public BountyAbility(Effect effect, boolean optional) {
super(effect, optional, filter);
super(effect, optional, bountyCounterFilter);
}
public BountyAbility(Effect effect, boolean optional, boolean setTargetPointer) {
super(effect, optional, filter, setTargetPointer);
super(effect, optional, bountyCounterFilter, setTargetPointer);
}
public BountyAbility(final BountyAbility ability) {