better use of the CardsImpl constructor

This commit is contained in:
Ingmar Goudt 2019-02-03 21:08:31 +01:00
parent dc112215d4
commit 2cd9e25229
89 changed files with 248 additions and 402 deletions

View file

@ -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> 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> 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<GamesRoom> 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> 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> 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<MatchView> getFinishedMatches(UUID roomId) throws MageException {
try {
Optional<GamesRoom> 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> 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> 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> 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> 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> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
Optional<GamesRoom> 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> 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> 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> 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> 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> 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> 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();
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> 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<Boolean>() {
@Override
public Boolean execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return false;
} else {
UUID userId = session.get().getUserId();
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> 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> 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> 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> 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> 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> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return null;
}
UUID userId = session.get().getUserId();

View file

@ -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<UUID, GamesRoom> 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();
}

View file

@ -73,10 +73,7 @@ class AetherworksMarvelEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> 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);

View file

@ -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;

View file

@ -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) {

View file

@ -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;

View file

@ -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<UUID> opponents = game.getOpponents(source.getControllerId());
for (UUID opponentUuid : opponents) {

View file

@ -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;

View file

@ -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) {

View file

@ -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);
player.chooseTarget(outcome, target, source, game);
cards.addAll(target.getTargets());
Cards cards = new CardsImpl(target.getTargets());
cardsToDiscard.put(playerId, cards);
}
}

View file

@ -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();

View file

@ -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()) {

View file

@ -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);

View file

@ -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<Card> pile1 = new ArrayList<>();

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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?";

View file

@ -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<UUID> opponents = game.getOpponents(source.getControllerId());

View file

@ -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);

View file

@ -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);

View file

@ -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"));

View file

@ -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");

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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)) {

View file

@ -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);

View file

@ -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)) {

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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) {

View file

@ -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) {

View file

@ -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;
}

View file

@ -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()) {

View file

@ -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());

View file

@ -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) {

View file

@ -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"));

View file

@ -69,7 +69,7 @@ class MnemonicBetrayalExileEffect extends OneShotEffect {
return false;
}
Cards cards = new CardsImpl();
Map<UUID, Integer> cardMap = new HashMap();
Map<UUID, Integer> cardMap = new HashMap<>();
game.getOpponents(source.getControllerId()).stream().map((playerId) -> game.getPlayer(playerId)).filter((player) -> (player != null)).forEachOrdered((player) -> {
cards.addAll(player.getGraveyard());
});

View file

@ -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;

View file

@ -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);

View file

@ -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

View file

@ -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();

View file

@ -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<Card> toBattlefield = new LinkedHashSet<>();

View file

@ -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()) {

View file

@ -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,16 +67,16 @@ 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)) {
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;
}
}

View file

@ -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)) {

View file

@ -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);

View file

@ -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)) {

View file

@ -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));
}

View file

@ -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<Card> pile1 = new ArrayList<>();

View file

@ -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()) {

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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");
}

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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();

View file

@ -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);
}

View file

@ -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);

View file

@ -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;

View file

@ -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,12 +82,12 @@ class SorinGrimNemesisRevealEffect extends OneShotEffect {
if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().getFromTop(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)) {
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);
@ -107,11 +99,12 @@ class SorinGrimNemesisRevealEffect extends OneShotEffect {
return true;
}
}
}
return false;
}
}
class SorinXValue implements DynamicValue {
class SorinXValue implements DynamicValue {
private static final SorinXValue defaultValue = new SorinXValue();
@ -143,9 +136,9 @@ class SorinXValue implements DynamicValue {
public static SorinXValue getDefault() {
return defaultValue;
}
}
}
class SorinTokenEffect extends OneShotEffect {
class SorinTokenEffect extends OneShotEffect {
SorinTokenEffect() {
super(Outcome.GainLife);
@ -176,4 +169,4 @@ class SorinTokenEffect extends OneShotEffect {
public SorinTokenEffect copy() {
return new SorinTokenEffect(this);
}
}
}

View file

@ -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;

View file

@ -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());
}

View file

@ -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;

View file

@ -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;

View file

@ -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);
}

View file

@ -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(

View file

@ -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);

View file

@ -75,10 +75,7 @@ class TalentOfTheTelepathEffect extends OneShotEffect {
MageObject sourceObject = source.getSourceObject(game);
if (targetOpponent != null && sourceObject != null) {
Set<Card> 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)) {

View file

@ -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;

View file

@ -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);

View file

@ -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;
}

View file

@ -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)) {

View file

@ -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;

View file

@ -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<UUID> opponents = game.getOpponents(source.getControllerId());

View file

@ -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);

View file

@ -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,

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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);