diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index bb6845df11..4ed604330e 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -260,13 +260,10 @@ public class MageServerImpl implements MageServer { @Override public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException { execute("removeTable", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); TableManager.instance.removeTable(userId, tableId); - } + }); }); } @@ -277,7 +274,6 @@ public class MageServerImpl implements MageServer { public Boolean execute() throws MageException { Optional session = SessionManager.instance.getSession(sessionId); if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); return false; } UUID userId = session.get().getUserId(); @@ -288,7 +284,6 @@ public class MageServerImpl implements MageServer { } Optional room = GamesRoomManager.instance.getRoom(roomId); if (!room.isPresent()) { - logger.error("room not found : " + roomId); return false; } return room.get().joinTable(userId, tableId, name, playerType, skill, deckList, password); @@ -304,7 +299,6 @@ public class MageServerImpl implements MageServer { public Boolean execute() throws MageException { Optional session = SessionManager.instance.getSession(sessionId); if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); return false; } UUID userId = session.get().getUserId(); @@ -333,7 +327,6 @@ public class MageServerImpl implements MageServer { public Boolean execute() throws MageException { Optional session = SessionManager.instance.getSession(sessionId); if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); return false; } else { UUID userId = session.get().getUserId(); @@ -380,12 +373,7 @@ public class MageServerImpl implements MageServer { //FIXME: why no sessionId here??? public List getFinishedMatches(UUID roomId) throws MageException { try { - Optional room = GamesRoomManager.instance.getRoom(roomId); - if (room.isPresent()) { - return room.get().getFinished(); - } else { - return new ArrayList<>(); - } + return GamesRoomManager.instance.getRoom(roomId).map(GamesRoom::getFinished).orElse(new ArrayList<>()); } catch (Exception ex) { handleException(ex); } @@ -515,13 +503,11 @@ public class MageServerImpl implements MageServer { @Override public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException { execute("joinChat", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + + UUID userId = session.getUserId(); ChatManager.instance.joinChat(chatId, userId); - } + }); }); } @@ -529,13 +515,10 @@ public class MageServerImpl implements MageServer { public void leaveChat(final UUID chatId, final String sessionId) throws MageException { execute("leaveChat", sessionId, () -> { if (chatId != null) { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); ChatManager.instance.leaveChat(chatId, userId); - } + }); } }); } @@ -574,7 +557,6 @@ public class MageServerImpl implements MageServer { public Boolean execute() { Optional session = SessionManager.instance.getSession(sessionId); if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); return false; } else { UUID userId = session.get().getUserId(); @@ -587,13 +569,10 @@ public class MageServerImpl implements MageServer { @Override public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException { execute("swapSeats", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); TableManager.instance.swapSeats(tableId, userId, seatNum1, seatNum2); - } + }); }); } @@ -607,19 +586,12 @@ public class MageServerImpl implements MageServer { return false; } execute("leaveTable", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); - Optional room = GamesRoomManager.instance.getRoom(roomId); - if (!room.isPresent()) { - logger.error("room not found : " + roomId); - } else { + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); + GamesRoomManager.instance.getRoom(roomId).ifPresent(room -> + room.leaveTable(userId, tableId)); - room.get().leaveTable(userId, tableId); - } - } + }); }); } else { // this can happen if a game ends and a player quits XMage or a match nearly at the same time as the game ends @@ -642,26 +614,20 @@ public class MageServerImpl implements MageServer { @Override public void joinGame(final UUID gameId, final String sessionId) throws MageException { execute("joinGame", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); GameManager.instance.joinGame(gameId, userId); - } + }); }); } @Override public void joinDraft(final UUID draftId, final String sessionId) throws MageException { execute("joinDraft", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); DraftManager.instance.joinDraft(draftId, userId); - } + }); }); } @@ -769,13 +735,10 @@ public class MageServerImpl implements MageServer { @Override public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException { execute("sendCardMark", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); DraftManager.instance.sendCardMark(draftId, userId, cardPick); - } + }); }); } @@ -785,14 +748,10 @@ public class MageServerImpl implements MageServer { try { callExecutor.execute( () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); GameManager.instance.quitMatch(gameId, userId); - } - + }); } ); } catch (Exception ex) { @@ -807,14 +766,11 @@ public class MageServerImpl implements MageServer { try { callExecutor.execute( () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); TournamentManager.instance.quit(tournamentId, userId); - } + }); } ); } catch (Exception ex) { @@ -830,18 +786,16 @@ public class MageServerImpl implements MageServer { try { callExecutor.execute( () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); - UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId(); - Table table = TableManager.instance.getTable(tableId); - if (table.isTournament()) { - UUID tournamentId = table.getTournament().getId(); - TournamentManager.instance.quit(tournamentId, userId); - } - } + SessionManager.instance.getSession(sessionId).ifPresent( + session -> { + UUID userId = session.getUserId(); + UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId(); + Table table = TableManager.instance.getTable(tableId); + if (table.isTournament()) { + UUID tournamentId = table.getTournament().getId(); + TournamentManager.instance.quit(tournamentId, userId); + } + }); } ); } catch (Exception ex) { @@ -854,13 +808,10 @@ public class MageServerImpl implements MageServer { @Override public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId, final Object data) throws MageException { execute("sendPlayerAction", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); GameManager.instance.sendPlayerAction(playerAction, gameId, userId, data); - } + }); }); } @@ -895,14 +846,11 @@ public class MageServerImpl implements MageServer { return executeWithResult("watchGame", sessionId, new ActionWithResult() { @Override public Boolean execute() throws MageException { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - return false; - } else { - UUID userId = session.get().getUserId(); - return GameManager.instance.watchGame(gameId, userId); - } + return SessionManager.instance.getSession(sessionId) + .map(session -> { + UUID userId = session.getUserId(); + return GameManager.instance.watchGame(gameId, userId); + }).orElse(false); } @Override @@ -915,16 +863,13 @@ public class MageServerImpl implements MageServer { @Override public void stopWatching(final UUID gameId, final String sessionId) throws MageException { execute("stopWatching", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); UserManager.instance.getUser(userId).ifPresent(user -> { GameManager.instance.stopWatching(gameId, userId); user.removeGameWatchInfo(gameId); }); - } + }); }); } @@ -932,26 +877,20 @@ public class MageServerImpl implements MageServer { @Override public void replayGame(final UUID gameId, final String sessionId) throws MageException { execute("replayGame", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); ReplayManager.instance.replayGame(gameId, userId); - } + }); }); } @Override public void startReplay(final UUID gameId, final String sessionId) throws MageException { execute("startReplay", sessionId, () -> { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); ReplayManager.instance.startReplay(gameId, userId); - } + }); }); } @@ -1032,13 +971,10 @@ public class MageServerImpl implements MageServer { public void cheat(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException { execute("cheat", sessionId, () -> { if (testMode) { - Optional session = SessionManager.instance.getSession(sessionId); - if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); - } else { - UUID userId = session.get().getUserId(); + SessionManager.instance.getSession(sessionId).ifPresent(session -> { + UUID userId = session.getUserId(); GameManager.instance.cheat(gameId, userId, playerId, deckList); - } + }); } }); } @@ -1327,7 +1263,6 @@ public class MageServerImpl implements MageServer { public Boolean execute() throws MageException { Optional session = SessionManager.instance.getSession(sessionId); if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); return false; } else { UUID userId = session.get().getUserId(); @@ -1378,7 +1313,6 @@ public class MageServerImpl implements MageServer { public TableView execute() throws MageException { Optional session = SessionManager.instance.getSession(sessionId); if (!session.isPresent()) { - logger.error("Session not found : " + sessionId); return null; } UUID userId = session.get().getUserId(); diff --git a/Mage.Server/src/main/java/mage/server/game/GamesRoomManager.java b/Mage.Server/src/main/java/mage/server/game/GamesRoomManager.java index 1472a40c1b..83e78ed57e 100644 --- a/Mage.Server/src/main/java/mage/server/game/GamesRoomManager.java +++ b/Mage.Server/src/main/java/mage/server/game/GamesRoomManager.java @@ -2,6 +2,8 @@ package mage.server.game; +import org.apache.log4j.Logger; + import java.util.Optional; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -14,6 +16,7 @@ public enum GamesRoomManager { private final ConcurrentHashMap rooms = new ConcurrentHashMap<>(); private final UUID mainRoomId; + private static final Logger logger = Logger.getLogger(GamesRoomManager.class); GamesRoomManager() { @@ -36,6 +39,7 @@ public enum GamesRoomManager { if(rooms.containsKey(roomId)) { return Optional.of(rooms.get(roomId)); } + logger.error("room not found : " + roomId); return Optional.empty(); } diff --git a/Mage.Sets/src/mage/cards/a/AetherworksMarvel.java b/Mage.Sets/src/mage/cards/a/AetherworksMarvel.java index 2cca7a8b91..9fdf02cfa5 100644 --- a/Mage.Sets/src/mage/cards/a/AetherworksMarvel.java +++ b/Mage.Sets/src/mage/cards/a/AetherworksMarvel.java @@ -73,10 +73,7 @@ class AetherworksMarvelEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Set cardsSet = controller.getLibrary().getTopCards(game, 6); - Cards cards = new CardsImpl(); - for (Card card : cardsSet) { - cards.add(card); - } + Cards cards = new CardsImpl(cardsSet); TargetCard target = new TargetCardInLibrary(0, 1, new FilterNonlandCard("card to cast without paying its mana cost")); if (controller.choose(Outcome.PlayForFree, cards, target, game)) { Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java b/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java index ee3bfbd111..c5a369e1a8 100644 --- a/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java +++ b/Mage.Sets/src/mage/cards/a/AnimalMagnetism.java @@ -60,8 +60,7 @@ class AnimalMagnetismEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); if (!cards.isEmpty()) { controller.revealCards(staticText, cards, game); Card cardToBattlefield; diff --git a/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java b/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java index 810e91e0aa..bc67e69a24 100644 --- a/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java +++ b/Mage.Sets/src/mage/cards/a/AshiokNightmareWeaver.java @@ -222,8 +222,7 @@ class AshiokNightmareWeaverExileAllEffect extends OneShotEffect { for (UUID opponentId : game.getOpponents(source.getControllerId())) { Player opponent = game.getPlayer(opponentId); if (opponent != null) { - Cards cards = new CardsImpl(); - cards.addAll(opponent.getHand()); + Cards cards = new CardsImpl(opponent.getHand()); for (UUID cardId : cards) { Card card = game.getCard(cardId); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java b/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java index 551df4191a..9c0d5ed7e9 100644 --- a/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java +++ b/Mage.Sets/src/mage/cards/a/AvenSoulgazer.java @@ -89,8 +89,7 @@ class AvenSoulgazerLookFaceDownEffect extends OneShotEffect { if (faceDownCreature != null) { Permanent copyFaceDown = faceDownCreature.copy(); copyFaceDown.setFaceDown(false, game); - Cards cards = new CardsImpl(); - cards.add(copyFaceDown); + Cards cards = new CardsImpl(copyFaceDown); player.lookAtCards("face down card - " + mageObject.getName(), cards, game); } else { return false; diff --git a/Mage.Sets/src/mage/cards/b/BanefulOmen.java b/Mage.Sets/src/mage/cards/b/BanefulOmen.java index 31d22c9a48..7fc1edbecf 100644 --- a/Mage.Sets/src/mage/cards/b/BanefulOmen.java +++ b/Mage.Sets/src/mage/cards/b/BanefulOmen.java @@ -88,13 +88,13 @@ public final class BanefulOmen extends CardImpl { return false; } Card card = player.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); - cards.add(card); - player.revealCards("Baneful Omen", cards, game); - if (card == null) { return false; } + Cards cards = new CardsImpl(card); + player.revealCards("Baneful Omen", cards, game); + + int loseLife = card.getConvertedManaCost(); Set opponents = game.getOpponents(source.getControllerId()); for (UUID opponentUuid : opponents) { diff --git a/Mage.Sets/src/mage/cards/b/Barishi.java b/Mage.Sets/src/mage/cards/b/Barishi.java index 41500213b9..41c85f15c7 100644 --- a/Mage.Sets/src/mage/cards/b/Barishi.java +++ b/Mage.Sets/src/mage/cards/b/Barishi.java @@ -67,8 +67,7 @@ class BarishiEffect extends OneShotEffect { if (controller == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)); controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.shuffleLibrary(source, game); return true; diff --git a/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java b/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java index c0a55c2a66..39cab57d3c 100644 --- a/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java +++ b/Mage.Sets/src/mage/cards/b/BenefactionOfRhonas.java @@ -63,8 +63,7 @@ class BenefactionOfRhonasEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); boolean creatureCardFound = false; boolean enchantmentCardFound = false; for (UUID cardId : cards) { diff --git a/Mage.Sets/src/mage/cards/b/BorderlandExplorer.java b/Mage.Sets/src/mage/cards/b/BorderlandExplorer.java index f68f3ba599..f0e1fdf00f 100644 --- a/Mage.Sets/src/mage/cards/b/BorderlandExplorer.java +++ b/Mage.Sets/src/mage/cards/b/BorderlandExplorer.java @@ -80,10 +80,9 @@ class BorderlandExplorerEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - Cards cards = new CardsImpl(); - Target target = new TargetDiscard(0, 1, new FilterCard(), playerId); + Target target = new TargetDiscard(0, 1, new FilterCard(), playerId); player.chooseTarget(outcome, target, source, game); - cards.addAll(target.getTargets()); + Cards cards = new CardsImpl(target.getTargets()); cardsToDiscard.put(playerId, cards); } } diff --git a/Mage.Sets/src/mage/cards/c/CallToTheKindred.java b/Mage.Sets/src/mage/cards/c/CallToTheKindred.java index 91f10556c6..3b6bf2e502 100644 --- a/Mage.Sets/src/mage/cards/c/CallToTheKindred.java +++ b/Mage.Sets/src/mage/cards/c/CallToTheKindred.java @@ -90,8 +90,7 @@ class CallToTheKindredEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); controller.lookAtCards(enchantment.getIdName(), cards, game); FilterCreatureCard filter = new FilterCreatureCard(); diff --git a/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java b/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java index 027213fdb3..57a53d3191 100644 --- a/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java +++ b/Mage.Sets/src/mage/cards/c/ChandraPyromaster.java @@ -212,8 +212,7 @@ class ChandraPyromasterEffect3 extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 10)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 10)); controller.moveCardsToExile(cards.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName()); if (!cards.getCards(new FilterInstantOrSorceryCard(), game).isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/c/CoralFighters.java b/Mage.Sets/src/mage/cards/c/CoralFighters.java index 2737c523a6..eaee988286 100644 --- a/Mage.Sets/src/mage/cards/c/CoralFighters.java +++ b/Mage.Sets/src/mage/cards/c/CoralFighters.java @@ -64,8 +64,7 @@ class CoralFightersEffect extends OneShotEffect { if(controller != null && defendingPlayer != null) { Card card = defendingPlayer.getLibrary().getFromTop(game); if(card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards("Coral Fighters", cards, game); if (controller.chooseUse(outcome, "Do you wish to put card on the bottom of player's library?", source, game)) { controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, false, false); diff --git a/Mage.Sets/src/mage/cards/d/DeathOrGlory.java b/Mage.Sets/src/mage/cards/d/DeathOrGlory.java index 1417f0bd85..85efe75cd0 100644 --- a/Mage.Sets/src/mage/cards/d/DeathOrGlory.java +++ b/Mage.Sets/src/mage/cards/d/DeathOrGlory.java @@ -68,8 +68,7 @@ class DeathOrGloryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), game)); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(new FilterCreatureCard(), game)); if (!cards.isEmpty()) { TargetCard targetCards = new TargetCard(0, cards.size(), Zone.EXILED, new FilterCard("cards to put in the first pile")); List pile1 = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/d/DelverOfSecrets.java b/Mage.Sets/src/mage/cards/d/DelverOfSecrets.java index 2b2ea06194..3e2faf4dae 100644 --- a/Mage.Sets/src/mage/cards/d/DelverOfSecrets.java +++ b/Mage.Sets/src/mage/cards/d/DelverOfSecrets.java @@ -76,6 +76,9 @@ class DelverOfSecretsEffect extends OneShotEffect { if (player != null && sourcePermanent != null) { if (player.getLibrary().hasCards()) { Card card = player.getLibrary().getFromTop(game); + if(card == null){ + return false; + } Cards cards = new CardsImpl(); cards.add(card); player.lookAtCards(sourcePermanent.getName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/e/EnduringRenewal.java b/Mage.Sets/src/mage/cards/e/EnduringRenewal.java index 9d8a4e6575..510d9cb83b 100644 --- a/Mage.Sets/src/mage/cards/e/EnduringRenewal.java +++ b/Mage.Sets/src/mage/cards/e/EnduringRenewal.java @@ -82,8 +82,7 @@ class EnduringRenewalReplacementEffect extends ReplacementEffectImpl { } Card card = controller.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.revealCards("Top card of " + controller.getName() + "'s library", cards, game); if (card.isCreature()) { controller.moveCards(card, Zone.GRAVEYARD, source, game); diff --git a/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java b/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java index cad05da246..e1b8c901ed 100644 --- a/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java +++ b/Mage.Sets/src/mage/cards/e/EpiphanyAtTheDrownyard.java @@ -68,8 +68,7 @@ class EpiphanyAtTheDrownyardEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX() + 1)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX() + 1)); controller.revealCards(sourceObject.getIdName(), cards, game); Player opponent; diff --git a/Mage.Sets/src/mage/cards/e/ExplorersScope.java b/Mage.Sets/src/mage/cards/e/ExplorersScope.java index b1df107409..fb211ca098 100644 --- a/Mage.Sets/src/mage/cards/e/ExplorersScope.java +++ b/Mage.Sets/src/mage/cards/e/ExplorersScope.java @@ -69,8 +69,7 @@ class ExplorersScopeEffect extends OneShotEffect { Card card = controller.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards(sourceObject.getIdName(), cards, game); if (card.isLand()) { String message = "Put " + card.getLogName() + " onto the battlefield tapped?"; diff --git a/Mage.Sets/src/mage/cards/f/FactOrFiction.java b/Mage.Sets/src/mage/cards/f/FactOrFiction.java index 03c5806719..cfb2a3158c 100644 --- a/Mage.Sets/src/mage/cards/f/FactOrFiction.java +++ b/Mage.Sets/src/mage/cards/f/FactOrFiction.java @@ -65,8 +65,7 @@ class FactOrFictionEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); controller.revealCards(sourceObject.getName(), cards, game); Set opponents = game.getOpponents(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/f/FeralDeceiver.java b/Mage.Sets/src/mage/cards/f/FeralDeceiver.java index 32aa366413..f04e3ecb81 100644 --- a/Mage.Sets/src/mage/cards/f/FeralDeceiver.java +++ b/Mage.Sets/src/mage/cards/f/FeralDeceiver.java @@ -78,10 +78,9 @@ class FeralDeceiverEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { - Cards cards = new CardsImpl(); Card card = controller.getLibrary().getFromTop(game); if (card != null) { - cards.add(card); + Cards cards = new CardsImpl(card); controller.revealCards(sourceObject.getIdName(), cards, game); if (card.isLand()) { game.addEffect(new BoostSourceEffect(2, 2, Duration.EndOfTurn), source); diff --git a/Mage.Sets/src/mage/cards/f/FertileThicket.java b/Mage.Sets/src/mage/cards/f/FertileThicket.java index 1e6f8f9cc1..8ec4913fdd 100644 --- a/Mage.Sets/src/mage/cards/f/FertileThicket.java +++ b/Mage.Sets/src/mage/cards/f/FertileThicket.java @@ -71,8 +71,7 @@ class FertileThicketEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); controller.lookAtCards(sourceObject.getIdName(), cards, game); TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, StaticFilters.FILTER_CARD_BASIC_LAND); controller.chooseTarget(outcome, cards, target, source, game); diff --git a/Mage.Sets/src/mage/cards/f/FlashOfInsight.java b/Mage.Sets/src/mage/cards/f/FlashOfInsight.java index 7303d86cc3..2ea61b3c83 100644 --- a/Mage.Sets/src/mage/cards/f/FlashOfInsight.java +++ b/Mage.Sets/src/mage/cards/f/FlashOfInsight.java @@ -87,8 +87,7 @@ class FlashOfInsightEffect extends OneShotEffect { } } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, xValue)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue)); controller.lookAtCards(sourceObject.getIdName(), cards, game); TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand")); diff --git a/Mage.Sets/src/mage/cards/f/FortunesFavor.java b/Mage.Sets/src/mage/cards/f/FortunesFavor.java index 2ebbfbc103..2ff7942be0 100644 --- a/Mage.Sets/src/mage/cards/f/FortunesFavor.java +++ b/Mage.Sets/src/mage/cards/f/FortunesFavor.java @@ -64,13 +64,11 @@ class FortunesFavorEffect extends OneShotEffect { Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source)); MageObject sourceObject = source.getSourceObject(game); if (controller != null && targetOpponent != null && sourceObject != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 4)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards for the face-down pile")); targetOpponent.choose(outcome, cards, target, game); - Cards faceDownPile = new CardsImpl(); - faceDownPile.addAll(target.getTargets()); + Cards faceDownPile = new CardsImpl(target.getTargets()); cards.removeAll(target.getTargets()); controller.revealCards(sourceObject.getIdName() + " - cards in face-up pile", cards, game); game.informPlayers(targetOpponent.getLogName() + " puts " + faceDownPile.size() + " card(s) into the face-down pile"); diff --git a/Mage.Sets/src/mage/cards/f/FriendlyFire.java b/Mage.Sets/src/mage/cards/f/FriendlyFire.java index 61212e644a..ca6ebfc24d 100644 --- a/Mage.Sets/src/mage/cards/f/FriendlyFire.java +++ b/Mage.Sets/src/mage/cards/f/FriendlyFire.java @@ -64,10 +64,9 @@ class FriendlyFireEffect extends OneShotEffect { Player controllerOfTargetCreature = game.getPlayer(targetCreature.getControllerId()); if (controllerOfTargetCreature != null) { if (!controllerOfTargetCreature.getHand().isEmpty()) { - Cards cards = new CardsImpl(); Card card = controllerOfTargetCreature.getHand().getRandom(game); if (card != null) { - cards.add(card); + Cards cards = new CardsImpl(card); controllerOfTargetCreature.revealCards(sourceObject.getName(), cards, game); int damage = card.getConvertedManaCost(); targetCreature.damage(damage, source.getSourceId(), game, false, true); diff --git a/Mage.Sets/src/mage/cards/g/GatherThePack.java b/Mage.Sets/src/mage/cards/g/GatherThePack.java index 9569692e94..7f51389ac7 100644 --- a/Mage.Sets/src/mage/cards/g/GatherThePack.java +++ b/Mage.Sets/src/mage/cards/g/GatherThePack.java @@ -61,8 +61,7 @@ class GatherThePackEffect extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); int creatures = cards.count(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game); diff --git a/Mage.Sets/src/mage/cards/g/GoblinGuide.java b/Mage.Sets/src/mage/cards/g/GoblinGuide.java index 78376fc3e6..836177e58d 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinGuide.java +++ b/Mage.Sets/src/mage/cards/g/GoblinGuide.java @@ -126,10 +126,9 @@ class GoblinGuideEffect extends OneShotEffect { Player defender = game.getPlayer(getTargetPointer().getFirst(game, source)); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && defender != null) { - Cards cards = new CardsImpl(); Card card = defender.getLibrary().getFromTop(game); if (card != null) { - cards.add(card); + Cards cards = new CardsImpl(card); defender.revealCards(sourceObject.getName(), cards, game); if (card.isLand()) { defender.moveCards(card, Zone.HAND, source, game); diff --git a/Mage.Sets/src/mage/cards/h/HarshDeceiver.java b/Mage.Sets/src/mage/cards/h/HarshDeceiver.java index 28b06ac89f..b078a5b6ef 100644 --- a/Mage.Sets/src/mage/cards/h/HarshDeceiver.java +++ b/Mage.Sets/src/mage/cards/h/HarshDeceiver.java @@ -77,10 +77,9 @@ class HarshDeceiverEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { - Cards cards = new CardsImpl(); Card card = controller.getLibrary().getFromTop(game); if (card != null) { - cards.add(card); + Cards cards = new CardsImpl(card); controller.revealCards(sourceObject.getIdName(), cards, game); if (card.isLand()) { new UntapSourceEffect().apply(game, source); diff --git a/Mage.Sets/src/mage/cards/h/HeroesPodium.java b/Mage.Sets/src/mage/cards/h/HeroesPodium.java index f3c89f0f54..0c77aab946 100644 --- a/Mage.Sets/src/mage/cards/h/HeroesPodium.java +++ b/Mage.Sets/src/mage/cards/h/HeroesPodium.java @@ -123,8 +123,7 @@ class HeroesPodiumEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX())); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX())); boolean legendaryIncluded = cards.count(filter, game) > 0; controller.lookAtCards(sourceObject.getIdName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java b/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java index abb7e8a6e0..07f90385a1 100644 --- a/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java +++ b/Mage.Sets/src/mage/cards/i/ImpromptuRaid.java @@ -82,8 +82,8 @@ class ImpromptuRaidEffect extends OneShotEffect { MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && controller != null) { Card card = controller.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); if (card != null) { + Cards cards = new CardsImpl(); cards.add(card); controller.revealCards(sourceObject.getName(), cards, game); if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/j/JaceTheMindSculptor.java b/Mage.Sets/src/mage/cards/j/JaceTheMindSculptor.java index a823f6d030..0476ec9d8a 100644 --- a/Mage.Sets/src/mage/cards/j/JaceTheMindSculptor.java +++ b/Mage.Sets/src/mage/cards/j/JaceTheMindSculptor.java @@ -90,8 +90,7 @@ class JaceTheMindSculptorEffect1 extends OneShotEffect { if (controller != null && player != null) { Card card = player.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards("Jace, the Mind Sculptor", cards, game); if (controller.chooseUse(outcome, "Do you wish to put card on the bottom of player's library?", source, game)) { controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, false, false); diff --git a/Mage.Sets/src/mage/cards/k/KarnLiberated.java b/Mage.Sets/src/mage/cards/k/KarnLiberated.java index 5d96927395..1c3779d9e4 100644 --- a/Mage.Sets/src/mage/cards/k/KarnLiberated.java +++ b/Mage.Sets/src/mage/cards/k/KarnLiberated.java @@ -191,8 +191,7 @@ class KarnLiberatedDelayedEffect extends OneShotEffect { if (exile != null) { // Creatures put onto the battlefield due to Karn's ability will have been under their controller's control continuously // since the beginning of the first turn. They can attack and their activated abilities with {T} in the cost can be activated. - Cards cards = new CardsImpl(); // needed because putOntoTheBattlefield removes from exile - cards.addAll(exile); + Cards cards = new CardsImpl(exile); // needed because putOntoTheBattlefield removes from exile if (!cards.isEmpty()) { controller.moveCards(cards, Zone.BATTLEFIELD, source, game); for (Card card : cards.getCards(game)) { diff --git a/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java b/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java index c0a7719c65..c013d9e03f 100644 --- a/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java +++ b/Mage.Sets/src/mage/cards/k/KarnScionOfUrza.java @@ -89,8 +89,7 @@ class KarnPlus1Effect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 2)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2)); if (!cards.isEmpty()) { controller.revealCards(staticText, cards, game); diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java index 87ec804db3..dde0b01b32 100644 --- a/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheLens.java @@ -101,8 +101,7 @@ class KeeperOfTheLensLookFaceDownEffect extends OneShotEffect { if (faceDownCreature != null) { Permanent copyFaceDown = faceDownCreature.copy(); copyFaceDown.setFaceDown(false, game); - Cards cards = new CardsImpl(); - cards.add(copyFaceDown); + Cards cards = new CardsImpl(copyFaceDown); Player player = game.getPlayer(faceDownCreature.getControllerId()); controller.lookAtCards("face down card - " + mageObject.getName(), cards, game); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/k/KheruLichLord.java b/Mage.Sets/src/mage/cards/k/KheruLichLord.java index 3e0a7a49fb..b0c9890804 100644 --- a/Mage.Sets/src/mage/cards/k/KheruLichLord.java +++ b/Mage.Sets/src/mage/cards/k/KheruLichLord.java @@ -85,8 +85,7 @@ class KheruLichLordEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game)); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game)); Card card = cards.getRandom(game); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java b/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java index d42bd45c4a..2c4b8060eb 100644 --- a/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java +++ b/Mage.Sets/src/mage/cards/k/KioraMasterOfTheDepths.java @@ -124,8 +124,7 @@ class KioraRevealEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 4)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); boolean creatureCardFound = false; boolean landCardFound = false; for (UUID cardId : cards) { diff --git a/Mage.Sets/src/mage/cards/l/LensOfClarity.java b/Mage.Sets/src/mage/cards/l/LensOfClarity.java index cbf6afb818..1f0ac79046 100644 --- a/Mage.Sets/src/mage/cards/l/LensOfClarity.java +++ b/Mage.Sets/src/mage/cards/l/LensOfClarity.java @@ -93,8 +93,7 @@ class LensOfClarityLookLibraryEffect extends OneShotEffect { Card card = controller.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards("top card of library - " + controller.getName(), cards, game); game.informPlayers(controller.getLogName() + " looks at the top card of their library"); } else { @@ -158,8 +157,7 @@ class LensOfClarityLookFaceDownEffect extends OneShotEffect { if (faceDownCreature != null) { Permanent copyFaceDown = faceDownCreature.copy(); copyFaceDown.setFaceDown(false, game); - Cards cards = new CardsImpl(); - cards.add(copyFaceDown); + Cards cards = new CardsImpl(copyFaceDown); Player player = game.getPlayer(faceDownCreature.getControllerId()); controller.lookAtCards("face down card - " + mageObject.getName(), cards, game); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/l/Leveler.java b/Mage.Sets/src/mage/cards/l/Leveler.java index c1bd153050..4fe4a55d2e 100644 --- a/Mage.Sets/src/mage/cards/l/Leveler.java +++ b/Mage.Sets/src/mage/cards/l/Leveler.java @@ -60,8 +60,7 @@ class LevelerExileLibraryEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int count = controller.getLibrary().size(); - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, count)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count)); controller.moveCards(cards, Zone.EXILED, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java b/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java index e4544ab727..6cf148a651 100644 --- a/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java +++ b/Mage.Sets/src/mage/cards/l/LlanowarEmpath.java @@ -73,9 +73,9 @@ class LlanowarEmpathEffect extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - Cards cards = new CardsImpl(); Card card = controller.getLibrary().getFromTop(game); if (card != null) { + Cards cards = new CardsImpl(); cards.add(card); controller.revealCards(sourceObject.getName(), cards, game); if (card.isCreature()) { diff --git a/Mage.Sets/src/mage/cards/l/LordOfTheVoid.java b/Mage.Sets/src/mage/cards/l/LordOfTheVoid.java index be1fe956e5..85b62e4715 100644 --- a/Mage.Sets/src/mage/cards/l/LordOfTheVoid.java +++ b/Mage.Sets/src/mage/cards/l/LordOfTheVoid.java @@ -74,8 +74,7 @@ class LordOfTheVoidEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(player.getLibrary().getTopCards(game, 7)); + Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7)); controller.moveCards(cards, Zone.EXILED, source, game); if (!cards.getCards(new FilterCreatureCard(), game).isEmpty()) { TargetCard target = new TargetCard(Zone.EXILED, new FilterCreatureCard()); diff --git a/Mage.Sets/src/mage/cards/l/LostInTheWoods.java b/Mage.Sets/src/mage/cards/l/LostInTheWoods.java index 63edddda06..05f3076189 100644 --- a/Mage.Sets/src/mage/cards/l/LostInTheWoods.java +++ b/Mage.Sets/src/mage/cards/l/LostInTheWoods.java @@ -57,8 +57,7 @@ class LostInTheWoodsEffect extends OneShotEffect { } if (controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.revealCards(sourceObject.getName(), cards, game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java b/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java index d63af5b129..6c160eca91 100644 --- a/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java +++ b/Mage.Sets/src/mage/cards/m/MerchantsDockhand.java @@ -93,8 +93,7 @@ class MerchantsDockhandEffect extends OneShotEffect { } } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, xValue)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue)); controller.lookAtCards(sourceObject.getIdName(), cards, game); TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand")); diff --git a/Mage.Sets/src/mage/cards/m/MnemonicBetrayal.java b/Mage.Sets/src/mage/cards/m/MnemonicBetrayal.java index ab23ae3bd3..3de1f5f802 100644 --- a/Mage.Sets/src/mage/cards/m/MnemonicBetrayal.java +++ b/Mage.Sets/src/mage/cards/m/MnemonicBetrayal.java @@ -69,7 +69,7 @@ class MnemonicBetrayalExileEffect extends OneShotEffect { return false; } Cards cards = new CardsImpl(); - Map cardMap = new HashMap(); + Map cardMap = new HashMap<>(); game.getOpponents(source.getControllerId()).stream().map((playerId) -> game.getPlayer(playerId)).filter((player) -> (player != null)).forEachOrdered((player) -> { cards.addAll(player.getGraveyard()); }); diff --git a/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java b/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java index 8d829a6831..5018a530ce 100644 --- a/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java +++ b/Mage.Sets/src/mage/cards/m/MurmursFromBeyond.java @@ -64,8 +64,7 @@ class MurmursFromBeyondEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 3)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3)); if (!cards.isEmpty()) { controller.revealCards(staticText, cards, game); Card cardToGraveyard; diff --git a/Mage.Sets/src/mage/cards/n/NessianGameWarden.java b/Mage.Sets/src/mage/cards/n/NessianGameWarden.java index 1869cf5538..4a44a2b6b7 100644 --- a/Mage.Sets/src/mage/cards/n/NessianGameWarden.java +++ b/Mage.Sets/src/mage/cards/n/NessianGameWarden.java @@ -81,8 +81,8 @@ class NessianGameWardenEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); int count = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this); + Cards cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, count)); controller.lookAtCards(sourcePermanent.getIdName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java b/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java index ce50458307..e1ba5660e1 100644 --- a/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java +++ b/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java @@ -101,12 +101,11 @@ class NicolBolasGodPharaohPlusOneEffect extends OneShotEffect { } int numberOfCardsToExile = Math.min(2, player.getHand().size()); - Cards cards = new CardsImpl(); Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard()); + Cards cards = new CardsImpl(target.getTargets()); player.chooseTarget(Outcome.Exile, target, source, game); - cards.addAll(target.getTargets()); cardsToExile.put(playerId, cards); } // Exile all choosen cards diff --git a/Mage.Sets/src/mage/cards/n/NightDealings.java b/Mage.Sets/src/mage/cards/n/NightDealings.java index 6032b45792..033f544c21 100644 --- a/Mage.Sets/src/mage/cards/n/NightDealings.java +++ b/Mage.Sets/src/mage/cards/n/NightDealings.java @@ -161,8 +161,7 @@ public final class NightDealings extends CardImpl { card.moveToZone(Zone.HAND, source.getSourceId(), game, false); String name = "Reveal"; - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard != null) { name = sourceCard.getName(); diff --git a/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java b/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java index 375be16f43..9403be8418 100644 --- a/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java +++ b/Mage.Sets/src/mage/cards/n/NissaNaturesArtisan.java @@ -84,8 +84,7 @@ class NissaNaturesArtisanEffect extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 2)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2)); if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); Set toBattlefield = new LinkedHashSet<>(); diff --git a/Mage.Sets/src/mage/cards/n/NissasRevelation.java b/Mage.Sets/src/mage/cards/n/NissasRevelation.java index df4d2e4992..220dd0fe86 100644 --- a/Mage.Sets/src/mage/cards/n/NissasRevelation.java +++ b/Mage.Sets/src/mage/cards/n/NissasRevelation.java @@ -62,10 +62,10 @@ class NissasRevelationEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { - Cards cards = new CardsImpl(); Card card = controller.getLibrary().getFromTop(game); if (card != null) { + Cards cards = new CardsImpl(); cards.add(card); controller.revealCards(sourceObject.getIdName(), cards, game); if (card.isCreature()) { diff --git a/Mage.Sets/src/mage/cards/p/PainSeer.java b/Mage.Sets/src/mage/cards/p/PainSeer.java index a8871cb6a1..f575815218 100644 --- a/Mage.Sets/src/mage/cards/p/PainSeer.java +++ b/Mage.Sets/src/mage/cards/p/PainSeer.java @@ -1,31 +1,27 @@ package mage.cards.p; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.InspiredAbility; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class PainSeer extends CardImpl { public PainSeer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WIZARD); @@ -71,14 +67,14 @@ class PainSeerEffect extends OneShotEffect { if (player.getLibrary().hasCards()) { Card card = player.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); - cards.add(card); - player.revealCards("Pain Seer", cards, game); - if (card != null && - card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { - player.loseLife(card.getConvertedManaCost(), game, false); - return true; + if (card != null) { + Cards cards = new CardsImpl(card); + player.revealCards("Pain Seer", cards, game); + if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { + player.loseLife(card.getConvertedManaCost(), game, false); + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/p/ParadigmShift.java b/Mage.Sets/src/mage/cards/p/ParadigmShift.java index 7b60dfaa49..5ae7c00fb7 100644 --- a/Mage.Sets/src/mage/cards/p/ParadigmShift.java +++ b/Mage.Sets/src/mage/cards/p/ParadigmShift.java @@ -55,8 +55,7 @@ class ExileLibraryEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int count = controller.getLibrary().size(); - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, count)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count)); controller.moveCards(cards, Zone.EXILED, source, game); for (Card card: controller.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/cards/p/Paroxysm.java b/Mage.Sets/src/mage/cards/p/Paroxysm.java index d24b2e9b27..cd9a98a532 100644 --- a/Mage.Sets/src/mage/cards/p/Paroxysm.java +++ b/Mage.Sets/src/mage/cards/p/Paroxysm.java @@ -91,8 +91,7 @@ class ParoxysmEffect extends OneShotEffect { if (controllerOfCreature != null) { Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game); if (revealCardFromTop != null) { - Cards cards = new CardsImpl(); - cards.add(revealCardFromTop); + Cards cards = new CardsImpl(revealCardFromTop); controllerOfCreature.revealCards(source, cards, game); if (revealCardFromTop.isLand()) { creatureAttachedTo.destroy(source.getSourceId(), game, false); diff --git a/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java b/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java index 26b90f09b9..e331b79599 100644 --- a/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java +++ b/Mage.Sets/src/mage/cards/p/PetalsOfInsight.java @@ -61,8 +61,7 @@ class PetalsOfInsightEffect extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 3)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3)); controller.lookAtCards(sourceObject.getIdName(), cards, game); if (controller.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java b/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java index 9b044c1a68..6201578c0f 100644 --- a/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java +++ b/Mage.Sets/src/mage/cards/p/PhosphorescentFeast.java @@ -67,10 +67,11 @@ class PhosphorescentFeastEffect extends OneShotEffect { if (player == null) { return false; } - Cards cards = new CardsImpl(); if (player.getHand().count(new FilterCard(), game) > 0) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCard()); if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { + + Cards cards = new CardsImpl(); for (UUID uuid : target.getTargets()) { cards.add(player.getHand().get(uuid, game)); } diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianPortal.java b/Mage.Sets/src/mage/cards/p/PhyrexianPortal.java index c31886dd5b..b0cccd8a0a 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianPortal.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianPortal.java @@ -69,8 +69,7 @@ class PhyrexianPortalEffect extends OneShotEffect { Player opponent = game.getPlayer(source.getFirstTarget()); if (controller != null && opponent != null) { if (controller.getLibrary().size() >= 10) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 10)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 10)); TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile")); List pile1 = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java b/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java index 01493437e3..7ff16984da 100644 --- a/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java +++ b/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java @@ -82,8 +82,7 @@ class PlaneswalkersMischiefEffect extends OneShotEffect { if (revealedCard == null) { return false; } - Cards cards = new CardsImpl(); - cards.add(revealedCard); + Cards cards = new CardsImpl(revealedCard); opponent.revealCards("Planeswalker's Mischief Reveal", cards, game); if (revealedCard.isInstant() || revealedCard.isSorcery()) { diff --git a/Mage.Sets/src/mage/cards/p/Precognition.java b/Mage.Sets/src/mage/cards/p/Precognition.java index 2efda6c498..34a82e70a7 100644 --- a/Mage.Sets/src/mage/cards/p/Precognition.java +++ b/Mage.Sets/src/mage/cards/p/Precognition.java @@ -68,8 +68,7 @@ class PrecognitionEffect extends OneShotEffect { if (controller != null && player != null) { Card card = player.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards("Precognition", cards, game); if (controller.chooseUse(outcome, "Do you wish to put card on the bottom of player's library?", source, game)) { controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, false, false); diff --git a/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java b/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java index 17fc88ca5b..c13b1000e7 100644 --- a/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java +++ b/Mage.Sets/src/mage/cards/p/PriestOfTheWakeningSun.java @@ -100,8 +100,7 @@ class PriestOfTheWakeningSunEffect extends OneShotEffect { if (controller.chooseUse(outcome, "Reveal a Dinosaur card?", source, game)) { TargetCardInHand target = new TargetCardInHand(0, 1, filter); if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) { - Cards cards = new CardsImpl(); - cards.addAll(target.getTargets()); + Cards cards = new CardsImpl(target.getTargets()); controller.revealCards(sourceObject.getIdName(), cards, game); controller.gainLife(2, game, source); return true; diff --git a/Mage.Sets/src/mage/cards/p/PuresightMerrow.java b/Mage.Sets/src/mage/cards/p/PuresightMerrow.java index 6e9a4c7048..e8df9abeae 100644 --- a/Mage.Sets/src/mage/cards/p/PuresightMerrow.java +++ b/Mage.Sets/src/mage/cards/p/PuresightMerrow.java @@ -75,8 +75,7 @@ class PuresightMerrowEffect extends OneShotEffect { if (controller != null && sourceObject != null) { Card card = controller.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards("Puresight Merrow", cards, game); if (controller.chooseUse(Outcome.Removal, "Do you wish to exile the card from the top of your library?", source, game)) { controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); diff --git a/Mage.Sets/src/mage/cards/r/RevealingWind.java b/Mage.Sets/src/mage/cards/r/RevealingWind.java index 053ddac0b1..c977cd9ddd 100644 --- a/Mage.Sets/src/mage/cards/r/RevealingWind.java +++ b/Mage.Sets/src/mage/cards/r/RevealingWind.java @@ -82,8 +82,7 @@ class RevealingWindEffect extends OneShotEffect { if (controller.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards(sourceObject.getName(), cards, game); game.informPlayers(controller.getLogName() + " look at a face-down attacking creature"); } diff --git a/Mage.Sets/src/mage/cards/r/RevivingVapors.java b/Mage.Sets/src/mage/cards/r/RevivingVapors.java index e64c2fef63..0c90f22883 100644 --- a/Mage.Sets/src/mage/cards/r/RevivingVapors.java +++ b/Mage.Sets/src/mage/cards/r/RevivingVapors.java @@ -60,8 +60,7 @@ class RevivingVaporsEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 3)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3)); if (!cards.isEmpty()) { controller.revealCards(sourceObject.getName(), cards, game); Card card = null; diff --git a/Mage.Sets/src/mage/cards/r/RiseFall.java b/Mage.Sets/src/mage/cards/r/RiseFall.java index d636a11e8e..b3042b9902 100644 --- a/Mage.Sets/src/mage/cards/r/RiseFall.java +++ b/Mage.Sets/src/mage/cards/r/RiseFall.java @@ -113,12 +113,11 @@ class FallEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { if (!targetPlayer.getHand().isEmpty()) { - Cards cards = new CardsImpl(); Card card = targetPlayer.getHand().getRandom(game); if (card == null) { return false; } - cards.add(card); + Cards cards = new CardsImpl(card); if (targetPlayer.getHand().size() > 1) { do { card = targetPlayer.getHand().getRandom(game); diff --git a/Mage.Sets/src/mage/cards/r/RootingKavu.java b/Mage.Sets/src/mage/cards/r/RootingKavu.java index b70328f358..7e0fc263db 100644 --- a/Mage.Sets/src/mage/cards/r/RootingKavu.java +++ b/Mage.Sets/src/mage/cards/r/RootingKavu.java @@ -65,8 +65,7 @@ class RootingKavuEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)); controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.shuffleLibrary(source, game); return true; diff --git a/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java b/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java index a913ed326f..c08d606f57 100644 --- a/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java +++ b/Mage.Sets/src/mage/cards/s/SatyrWayfinder.java @@ -71,8 +71,7 @@ class SatyrWayfinderEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 4)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0; if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/s/SearchForSurvivors.java b/Mage.Sets/src/mage/cards/s/SearchForSurvivors.java index d961db7e4a..06e24dc5c1 100644 --- a/Mage.Sets/src/mage/cards/s/SearchForSurvivors.java +++ b/Mage.Sets/src/mage/cards/s/SearchForSurvivors.java @@ -82,10 +82,7 @@ class SearchForSurvivorsEffect extends OneShotEffect { controller.getGraveyard().clear(); controller.getGraveyard().addAll(Arrays.asList(shuffled)); // end of randomize - Cards cards = new CardsImpl(); - controller.getGraveyard().getCards(game).forEach((card) -> { - cards.add(card); - }); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(game)); if (!cards.isEmpty()) { Card card = cards.getRandom(game); cards.clear(); diff --git a/Mage.Sets/src/mage/cards/s/SerumPowder.java b/Mage.Sets/src/mage/cards/s/SerumPowder.java index 955f9a5bf6..b30d9caf37 100644 --- a/Mage.Sets/src/mage/cards/s/SerumPowder.java +++ b/Mage.Sets/src/mage/cards/s/SerumPowder.java @@ -65,10 +65,7 @@ class SerumPowderReplaceEffect extends ReplacementEffectImpl { } int cardsHand = controller.getHand().size(); if (cardsHand > 0){ - Cards cards = new CardsImpl(); - for (UUID cardId: controller.getHand()) { - cards.add(game.getCard(cardId)); - } + Cards cards = new CardsImpl(controller.getHand()); for (Card card: cards.getCards(game)) { card.moveToExile(null, null, source.getSourceId(), game); } diff --git a/Mage.Sets/src/mage/cards/s/SifterWurm.java b/Mage.Sets/src/mage/cards/s/SifterWurm.java index 27d1fe73d1..da4a909703 100644 --- a/Mage.Sets/src/mage/cards/s/SifterWurm.java +++ b/Mage.Sets/src/mage/cards/s/SifterWurm.java @@ -73,10 +73,10 @@ class SifterWurmEffect extends OneShotEffect { if (controller != null && sourceObject != null) { controller.scry(3, source, game); - Cards cards = new CardsImpl(); Card card = controller.getLibrary().getFromTop(game); if (card != null) { + Cards cards = new CardsImpl(); cards.add(card); controller.revealCards(sourceObject.getIdName(), cards, game); controller.gainLife(card.getConvertedManaCost(), game, source); diff --git a/Mage.Sets/src/mage/cards/s/SmokeTeller.java b/Mage.Sets/src/mage/cards/s/SmokeTeller.java index 5994a8d247..3d3f74865f 100644 --- a/Mage.Sets/src/mage/cards/s/SmokeTeller.java +++ b/Mage.Sets/src/mage/cards/s/SmokeTeller.java @@ -86,8 +86,7 @@ class SmokeTellerLookFaceDownEffect extends OneShotEffect { if (faceDownCreature != null) { Permanent copyFaceDown = faceDownCreature.copy(); copyFaceDown.setFaceDown(false, game); - Cards cards = new CardsImpl(); - cards.add(copyFaceDown); + Cards cards = new CardsImpl(copyFaceDown); player.lookAtCards("face down card - " + mageObject.getName(), cards, game); } else { return false; diff --git a/Mage.Sets/src/mage/cards/s/SorinGrimNemesis.java b/Mage.Sets/src/mage/cards/s/SorinGrimNemesis.java index a4d363f8bf..639a1cb10c 100644 --- a/Mage.Sets/src/mage/cards/s/SorinGrimNemesis.java +++ b/Mage.Sets/src/mage/cards/s/SorinGrimNemesis.java @@ -1,7 +1,6 @@ package mage.cards.s; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; @@ -13,24 +12,17 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.GainLifeEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Outcome; -import mage.constants.SuperType; -import mage.constants.Zone; +import mage.cards.*; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.token.VampireKnightToken; import mage.players.Player; import mage.players.PlayerList; import mage.target.common.TargetCreatureOrPlaneswalker; +import java.util.UUID; + /** - * * @author fireshoes */ public final class SorinGrimNemesis extends CardImpl { @@ -90,90 +82,91 @@ class SorinGrimNemesisRevealEffect extends OneShotEffect { if (player.getLibrary().hasCards()) { Card card = player.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); - cards.add(card); - player.revealCards("Sorin, Grim Nemesis", cards, game); + if (card != null) { + Cards cards = new CardsImpl(); + cards.add(card); + player.revealCards("Sorin, Grim Nemesis", cards, game); - if (card != null - && card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { - for (UUID playerId : game.getOpponents(source.getControllerId())) { - if (card.getConvertedManaCost() > 0) { - Player opponent = game.getPlayer(playerId); - if (opponent != null) { - opponent.loseLife(card.getConvertedManaCost(), game, false); + if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { + for (UUID playerId : game.getOpponents(source.getControllerId())) { + if (card.getConvertedManaCost() > 0) { + Player opponent = game.getPlayer(playerId); + if (opponent != null) { + opponent.loseLife(card.getConvertedManaCost(), game, false); + } } } + return true; } - return true; } } return false; } } -class SorinXValue implements DynamicValue { + class SorinXValue implements DynamicValue { - private static final SorinXValue defaultValue = new SorinXValue(); + private static final SorinXValue defaultValue = new SorinXValue(); - @Override - public int calculate(Game game, Ability sourceAbility, Effect effect) { - for (Cost cost : sourceAbility.getCosts()) { - if (cost instanceof PayVariableLoyaltyCost) { - return ((PayVariableLoyaltyCost) cost).getAmount(); - } - } - return 0; - } - - @Override - public DynamicValue copy() { - return defaultValue; - } - - @Override - public String getMessage() { - return ""; - } - - @Override - public String toString() { - return "X"; - } - - public static SorinXValue getDefault() { - return defaultValue; - } -} - -class SorinTokenEffect extends OneShotEffect { - - SorinTokenEffect() { - super(Outcome.GainLife); - staticText = "Create a number of 1/1 black Vampire Knight creature tokens with lifelink equal to the highest life total among all players"; - } - - SorinTokenEffect(final SorinTokenEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - int maxLife = 0; - PlayerList playerList = game.getState().getPlayersInRange(source.getControllerId(), game); - for (UUID pid : playerList) { - Player p = game.getPlayer(pid); - if (p != null) { - if (maxLife < p.getLife()) { - maxLife = p.getLife(); + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + for (Cost cost : sourceAbility.getCosts()) { + if (cost instanceof PayVariableLoyaltyCost) { + return ((PayVariableLoyaltyCost) cost).getAmount(); } } + return 0; + } + + @Override + public DynamicValue copy() { + return defaultValue; + } + + @Override + public String getMessage() { + return ""; + } + + @Override + public String toString() { + return "X"; + } + + public static SorinXValue getDefault() { + return defaultValue; } - new CreateTokenEffect(new VampireKnightToken(), maxLife).apply(game, source); - return true; } - @Override - public SorinTokenEffect copy() { - return new SorinTokenEffect(this); + class SorinTokenEffect extends OneShotEffect { + + SorinTokenEffect() { + super(Outcome.GainLife); + staticText = "Create a number of 1/1 black Vampire Knight creature tokens with lifelink equal to the highest life total among all players"; + } + + SorinTokenEffect(final SorinTokenEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + int maxLife = 0; + PlayerList playerList = game.getState().getPlayersInRange(source.getControllerId(), game); + for (UUID pid : playerList) { + Player p = game.getPlayer(pid); + if (p != null) { + if (maxLife < p.getLife()) { + maxLife = p.getLife(); + } + } + } + new CreateTokenEffect(new VampireKnightToken(), maxLife).apply(game, source); + return true; + } + + @Override + public SorinTokenEffect copy() { + return new SorinTokenEffect(this); + } } -} diff --git a/Mage.Sets/src/mage/cards/s/SphinxOfJwarIsle.java b/Mage.Sets/src/mage/cards/s/SphinxOfJwarIsle.java index 49b8e776e4..ca70c11ed4 100644 --- a/Mage.Sets/src/mage/cards/s/SphinxOfJwarIsle.java +++ b/Mage.Sets/src/mage/cards/s/SphinxOfJwarIsle.java @@ -94,8 +94,7 @@ class SphinxOfJwarIsleEffect extends OneShotEffect { Card card = player.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); player.lookAtCards("Sphinx of Jwar Isle", cards, game); } else { return false; diff --git a/Mage.Sets/src/mage/cards/s/SpyNetwork.java b/Mage.Sets/src/mage/cards/s/SpyNetwork.java index 4daf571ac0..c325541b6c 100644 --- a/Mage.Sets/src/mage/cards/s/SpyNetwork.java +++ b/Mage.Sets/src/mage/cards/s/SpyNetwork.java @@ -116,8 +116,7 @@ class SpyNetworkFaceDownEffect extends OneShotEffect { if (faceDownCreature != null) { Permanent copyFaceDown = faceDownCreature.copy(); copyFaceDown.setFaceDown(false, game); - Cards cards = new CardsImpl(); - cards.add(copyFaceDown); + Cards cards = new CardsImpl(copyFaceDown); controller.lookAtCards("face down card - " + mageObject.getName(), cards, game); game.informPlayers(controller.getLogName() + " looks at a face down creature controlled by " + player.getLogName()); } diff --git a/Mage.Sets/src/mage/cards/s/SteamAugury.java b/Mage.Sets/src/mage/cards/s/SteamAugury.java index ae6183b7a8..54dd837bfd 100644 --- a/Mage.Sets/src/mage/cards/s/SteamAugury.java +++ b/Mage.Sets/src/mage/cards/s/SteamAugury.java @@ -71,8 +71,7 @@ class SteamAuguryEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); controller.revealCards(sourceObject.getIdName(), cards, game); Player opponent; diff --git a/Mage.Sets/src/mage/cards/s/StompingSlabs.java b/Mage.Sets/src/mage/cards/s/StompingSlabs.java index a843ecf37b..2990e7bdb4 100644 --- a/Mage.Sets/src/mage/cards/s/StompingSlabs.java +++ b/Mage.Sets/src/mage/cards/s/StompingSlabs.java @@ -62,8 +62,7 @@ class StompingSlabsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 7)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7)); if (!cards.isEmpty()) { controller.revealCards("Stomping Slabs", cards, game); boolean stompingSlabsFound = false; diff --git a/Mage.Sets/src/mage/cards/s/StrongarmTactics.java b/Mage.Sets/src/mage/cards/s/StrongarmTactics.java index b0acc08d9b..62676daaf8 100644 --- a/Mage.Sets/src/mage/cards/s/StrongarmTactics.java +++ b/Mage.Sets/src/mage/cards/s/StrongarmTactics.java @@ -68,9 +68,9 @@ class StrongarmTacticsEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { int numberOfCardsToDiscard = Math.min(1, player.getHand().size()); - Cards cards = new CardsImpl(); Target target = new TargetDiscard(numberOfCardsToDiscard, numberOfCardsToDiscard, new FilterCard(), playerId); player.chooseTarget(outcome, target, source, game); + Cards cards = new CardsImpl(); cards.addAll(target.getTargets()); cardsToDiscard.put(playerId, cards); } diff --git a/Mage.Sets/src/mage/cards/s/SummoningTrap.java b/Mage.Sets/src/mage/cards/s/SummoningTrap.java index b8dd0e4593..0337caf7af 100644 --- a/Mage.Sets/src/mage/cards/s/SummoningTrap.java +++ b/Mage.Sets/src/mage/cards/s/SummoningTrap.java @@ -133,8 +133,7 @@ class SummoningTrapEffect extends OneShotEffect { if (controller == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 7)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7)); if (!cards.isEmpty()) { TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard( diff --git a/Mage.Sets/src/mage/cards/s/SunbirdsInvocation.java b/Mage.Sets/src/mage/cards/s/SunbirdsInvocation.java index 10dcad1ec4..0d5e1540dc 100644 --- a/Mage.Sets/src/mage/cards/s/SunbirdsInvocation.java +++ b/Mage.Sets/src/mage/cards/s/SunbirdsInvocation.java @@ -117,8 +117,7 @@ class SunbirdsInvocationEffect extends OneShotEffect { return false; } int xValue = spell.getConvertedManaCost(); - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, xValue)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue)); if (!cards.isEmpty()) { controller.revealCards(sourceObject.getIdName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/t/TalentOfTheTelepath.java b/Mage.Sets/src/mage/cards/t/TalentOfTheTelepath.java index 03a409cb8d..5751791d2e 100644 --- a/Mage.Sets/src/mage/cards/t/TalentOfTheTelepath.java +++ b/Mage.Sets/src/mage/cards/t/TalentOfTheTelepath.java @@ -75,10 +75,7 @@ class TalentOfTheTelepathEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (targetOpponent != null && sourceObject != null) { Set allCards = targetOpponent.getLibrary().getTopCards(game, 7); - Cards cards = new CardsImpl(); - for (Card card : allCards) { - cards.add(card); - } + Cards cards = new CardsImpl(allCards); targetOpponent.revealCards(sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards", cards, game); for (Card card : allCards) { if (filter.match(card, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TellingTime.java b/Mage.Sets/src/mage/cards/t/TellingTime.java index 0e4c928f0a..d73b1b5918 100644 --- a/Mage.Sets/src/mage/cards/t/TellingTime.java +++ b/Mage.Sets/src/mage/cards/t/TellingTime.java @@ -66,8 +66,7 @@ class TellingTimeEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 3)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3)); controller.lookAtCards(sourceObject.getIdName(), cards, game); if (cards.isEmpty()) { return true; diff --git a/Mage.Sets/src/mage/cards/t/TemporalAperture.java b/Mage.Sets/src/mage/cards/t/TemporalAperture.java index 3cb817280d..7cedc4b5f7 100644 --- a/Mage.Sets/src/mage/cards/t/TemporalAperture.java +++ b/Mage.Sets/src/mage/cards/t/TemporalAperture.java @@ -65,9 +65,8 @@ class TemporalApertureEffect extends OneShotEffect { if (controller != null) { controller.shuffleLibrary(source, game); Card topCard = controller.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); if (topCard != null) { - cards.add(topCard); + Cards cards = new CardsImpl(topCard); controller.revealCards("Top card of " + controller.getName() + "'s library revealed", cards, game); ContinuousEffect effect = new TemporalApertureTopCardCastEffect(topCard); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/t/ThoughtLash.java b/Mage.Sets/src/mage/cards/t/ThoughtLash.java index f8e53fb8f9..46663adb7c 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtLash.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtLash.java @@ -102,8 +102,7 @@ class ThoughtLashExileLibraryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, controller.getLibrary().size())); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, controller.getLibrary().size())); controller.moveCards(cards, Zone.EXILED, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/t/ThoughtpickerWitch.java b/Mage.Sets/src/mage/cards/t/ThoughtpickerWitch.java index 1cbef42ad6..6ee29633cf 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtpickerWitch.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtpickerWitch.java @@ -78,8 +78,7 @@ class ThoughtpickerWitchEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (controller != null && opponent != null) { - Cards cards = new CardsImpl(); - cards.addAll(opponent.getLibrary().getTopCards(game, 2)); + Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, 2)); if (!cards.isEmpty()) { TargetCard target = new TargetCardInLibrary(new FilterCard("card to exile")); if (controller.choose(Outcome.Exile, cards, target, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TruthOrTale.java b/Mage.Sets/src/mage/cards/t/TruthOrTale.java index f76c7eed66..ebf295088d 100644 --- a/Mage.Sets/src/mage/cards/t/TruthOrTale.java +++ b/Mage.Sets/src/mage/cards/t/TruthOrTale.java @@ -66,8 +66,7 @@ class TruthOrTaleEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 5)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5)); controller.revealCards(sourceObject.getIdName(), cards, game); Player opponent; diff --git a/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java b/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java index de1230006a..c30f25ae5b 100644 --- a/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java +++ b/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java @@ -141,8 +141,7 @@ class UneshCriosphinxSovereignEffect extends OneShotEffect { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 4)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); controller.revealCards(sourceObject.getName(), cards, game); Set opponents = game.getOpponents(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/v/VesselOfNascency.java b/Mage.Sets/src/mage/cards/v/VesselOfNascency.java index 68591eb695..8113992126 100644 --- a/Mage.Sets/src/mage/cards/v/VesselOfNascency.java +++ b/Mage.Sets/src/mage/cards/v/VesselOfNascency.java @@ -81,8 +81,7 @@ class VesselOfNascencyEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 4)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4)); boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0; if (!cards.isEmpty()) { controller.revealCards(sourceObject.getName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/v/ViviensInvocation.java b/Mage.Sets/src/mage/cards/v/ViviensInvocation.java index dec4018466..7eacc7e747 100644 --- a/Mage.Sets/src/mage/cards/v/ViviensInvocation.java +++ b/Mage.Sets/src/mage/cards/v/ViviensInvocation.java @@ -67,8 +67,7 @@ class ViviensInvocationEffect extends OneShotEffect { if (controller == null) { return false; } - Cards cards = new CardsImpl(); - cards.addAll(controller.getLibrary().getTopCards(game, 7)); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7)); if (!cards.isEmpty()) { TargetCard target = new TargetCard( Zone.LIBRARY, diff --git a/Mage.Sets/src/mage/cards/w/WildEvocation.java b/Mage.Sets/src/mage/cards/w/WildEvocation.java index 3278c01842..76ece70c23 100644 --- a/Mage.Sets/src/mage/cards/w/WildEvocation.java +++ b/Mage.Sets/src/mage/cards/w/WildEvocation.java @@ -64,8 +64,7 @@ class WildEvocationEffect extends OneShotEffect { if (player != null && sourceObject != null) { Card card = player.getHand().getRandom(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); player.revealCards(sourceObject.getIdName() + " Turn: " + game.getTurnNum(), cards, game); if (card.isLand()) { player.moveCards(card, Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/cards/w/WildResearch.java b/Mage.Sets/src/mage/cards/w/WildResearch.java index 44a6450c41..b4d7d9e6b5 100644 --- a/Mage.Sets/src/mage/cards/w/WildResearch.java +++ b/Mage.Sets/src/mage/cards/w/WildResearch.java @@ -87,8 +87,7 @@ class WildResearchEffect extends OneShotEffect { Card card = controller.getLibrary().remove(target.getFirstTarget(), game); if (card != null) { controller.moveCards(card, Zone.HAND, source, game); - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.revealCards(sourceObject.getIdName(), cards, game, true); } } diff --git a/Mage.Sets/src/mage/cards/w/WuSpy.java b/Mage.Sets/src/mage/cards/w/WuSpy.java index ce091d87d9..a1edf88cf5 100644 --- a/Mage.Sets/src/mage/cards/w/WuSpy.java +++ b/Mage.Sets/src/mage/cards/w/WuSpy.java @@ -74,8 +74,7 @@ class WuSpyEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (controller != null && opponent != null) { - Cards cards = new CardsImpl(); - cards.addAll(opponent.getLibrary().getTopCards(game, 2)); + Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, 2)); if (!cards.isEmpty()) { TargetCard target = new TargetCardInLibrary(new FilterCard("card to put into graveyard")); controller.choose(Outcome.Benefit, cards, target, game); diff --git a/Mage.Sets/src/mage/cards/z/ZombieMob.java b/Mage.Sets/src/mage/cards/z/ZombieMob.java index 7b2477ceaf..c37b4a18a7 100644 --- a/Mage.Sets/src/mage/cards/z/ZombieMob.java +++ b/Mage.Sets/src/mage/cards/z/ZombieMob.java @@ -73,8 +73,7 @@ class ZombieMobEffect extends OneShotEffect { if (amount > 0) { permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } - Cards cards = new CardsImpl(); - cards.addAll(controller.getGraveyard().getCards(filter, game)); + Cards cards = new CardsImpl(controller.getGraveyard().getCards(filter, game)); controller.moveCards(cards, Zone.EXILED, source, game); return true; } diff --git a/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java b/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java index 697ec9ab9c..e553478a63 100644 --- a/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java @@ -65,8 +65,7 @@ public class MiracleWatcher extends Watcher { if (ability instanceof MiracleAbility) { Player controller = game.getPlayer(ability.getControllerId()); if (controller != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); controller.lookAtCards("Miracle", cards, game); if (controller.chooseUse(Outcome.Benefit, "Reveal " + card.getLogName() + " to be able to use Miracle?", ability, game)) { controller.revealCards("Miracle", cards, game);