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 @Override
public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException { public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
execute("removeTable", sessionId, () -> { execute("removeTable", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
TableManager.instance.removeTable(userId, tableId); TableManager.instance.removeTable(userId, tableId);
} });
}); });
} }
@ -277,7 +274,6 @@ public class MageServerImpl implements MageServer {
public Boolean execute() throws MageException { public Boolean execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId); Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) { if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return false; return false;
} }
UUID userId = session.get().getUserId(); UUID userId = session.get().getUserId();
@ -288,7 +284,6 @@ public class MageServerImpl implements MageServer {
} }
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId); Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
if (!room.isPresent()) { if (!room.isPresent()) {
logger.error("room not found : " + roomId);
return false; return false;
} }
return room.get().joinTable(userId, tableId, name, playerType, skill, deckList, password); 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 { public Boolean execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId); Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) { if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return false; return false;
} }
UUID userId = session.get().getUserId(); UUID userId = session.get().getUserId();
@ -333,7 +327,6 @@ public class MageServerImpl implements MageServer {
public Boolean execute() throws MageException { public Boolean execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId); Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) { if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return false; return false;
} else { } else {
UUID userId = session.get().getUserId(); UUID userId = session.get().getUserId();
@ -380,12 +373,7 @@ public class MageServerImpl implements MageServer {
//FIXME: why no sessionId here??? //FIXME: why no sessionId here???
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException { public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
try { try {
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId); return GamesRoomManager.instance.getRoom(roomId).map(GamesRoom::getFinished).orElse(new ArrayList<>());
if (room.isPresent()) {
return room.get().getFinished();
} else {
return new ArrayList<>();
}
} catch (Exception ex) { } catch (Exception ex) {
handleException(ex); handleException(ex);
} }
@ -515,13 +503,11 @@ public class MageServerImpl implements MageServer {
@Override @Override
public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException { public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException {
execute("joinChat", sessionId, () -> { execute("joinChat", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) {
logger.error("Session not found : " + sessionId); UUID userId = session.getUserId();
} else {
UUID userId = session.get().getUserId();
ChatManager.instance.joinChat(chatId, userId); 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 { public void leaveChat(final UUID chatId, final String sessionId) throws MageException {
execute("leaveChat", sessionId, () -> { execute("leaveChat", sessionId, () -> {
if (chatId != null) { if (chatId != null) {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
ChatManager.instance.leaveChat(chatId, userId); ChatManager.instance.leaveChat(chatId, userId);
} });
} }
}); });
} }
@ -574,7 +557,6 @@ public class MageServerImpl implements MageServer {
public Boolean execute() { public Boolean execute() {
Optional<Session> session = SessionManager.instance.getSession(sessionId); Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) { if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return false; return false;
} else { } else {
UUID userId = session.get().getUserId(); UUID userId = session.get().getUserId();
@ -587,13 +569,10 @@ public class MageServerImpl implements MageServer {
@Override @Override
public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException { public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
execute("swapSeats", sessionId, () -> { execute("swapSeats", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
TableManager.instance.swapSeats(tableId, userId, seatNum1, seatNum2); TableManager.instance.swapSeats(tableId, userId, seatNum1, seatNum2);
} });
}); });
} }
@ -607,19 +586,12 @@ public class MageServerImpl implements MageServer {
return false; return false;
} }
execute("leaveTable", sessionId, () -> { execute("leaveTable", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId); GamesRoomManager.instance.getRoom(roomId).ifPresent(room ->
} else { room.leaveTable(userId, tableId));
UUID userId = session.get().getUserId();
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
if (!room.isPresent()) {
logger.error("room not found : " + roomId);
} else {
room.get().leaveTable(userId, tableId); });
}
}
}); });
} else { } 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 // 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 @Override
public void joinGame(final UUID gameId, final String sessionId) throws MageException { public void joinGame(final UUID gameId, final String sessionId) throws MageException {
execute("joinGame", sessionId, () -> { execute("joinGame", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
GameManager.instance.joinGame(gameId, userId); GameManager.instance.joinGame(gameId, userId);
} });
}); });
} }
@Override @Override
public void joinDraft(final UUID draftId, final String sessionId) throws MageException { public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
execute("joinDraft", sessionId, () -> { execute("joinDraft", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
DraftManager.instance.joinDraft(draftId, userId); DraftManager.instance.joinDraft(draftId, userId);
} });
}); });
} }
@ -769,13 +735,10 @@ public class MageServerImpl implements MageServer {
@Override @Override
public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException { public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
execute("sendCardMark", sessionId, () -> { execute("sendCardMark", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
DraftManager.instance.sendCardMark(draftId, userId, cardPick); DraftManager.instance.sendCardMark(draftId, userId, cardPick);
} });
}); });
} }
@ -785,14 +748,10 @@ public class MageServerImpl implements MageServer {
try { try {
callExecutor.execute( callExecutor.execute(
() -> { () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
GameManager.instance.quitMatch(gameId, userId); GameManager.instance.quitMatch(gameId, userId);
} });
} }
); );
} catch (Exception ex) { } catch (Exception ex) {
@ -807,14 +766,11 @@ public class MageServerImpl implements MageServer {
try { try {
callExecutor.execute( callExecutor.execute(
() -> { () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
TournamentManager.instance.quit(tournamentId, userId); TournamentManager.instance.quit(tournamentId, userId);
} });
} }
); );
} catch (Exception ex) { } catch (Exception ex) {
@ -830,18 +786,16 @@ public class MageServerImpl implements MageServer {
try { try {
callExecutor.execute( callExecutor.execute(
() -> { () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(
if (!session.isPresent()) { session -> {
logger.error("Session not found : " + sessionId); UUID userId = session.getUserId();
} else { UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
UUID userId = session.get().getUserId(); Table table = TableManager.instance.getTable(tableId);
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId(); if (table.isTournament()) {
Table table = TableManager.instance.getTable(tableId); UUID tournamentId = table.getTournament().getId();
if (table.isTournament()) { TournamentManager.instance.quit(tournamentId, userId);
UUID tournamentId = table.getTournament().getId(); }
TournamentManager.instance.quit(tournamentId, userId); });
}
}
} }
); );
} catch (Exception ex) { } catch (Exception ex) {
@ -854,13 +808,10 @@ public class MageServerImpl implements MageServer {
@Override @Override
public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId, final Object data) throws MageException { public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId, final Object data) throws MageException {
execute("sendPlayerAction", sessionId, () -> { execute("sendPlayerAction", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
GameManager.instance.sendPlayerAction(playerAction, gameId, userId, data); GameManager.instance.sendPlayerAction(playerAction, gameId, userId, data);
} });
}); });
} }
@ -895,14 +846,11 @@ public class MageServerImpl implements MageServer {
return executeWithResult("watchGame", sessionId, new ActionWithResult<Boolean>() { return executeWithResult("watchGame", sessionId, new ActionWithResult<Boolean>() {
@Override @Override
public Boolean execute() throws MageException { public Boolean execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId); return SessionManager.instance.getSession(sessionId)
if (!session.isPresent()) { .map(session -> {
logger.error("Session not found : " + sessionId); UUID userId = session.getUserId();
return false; return GameManager.instance.watchGame(gameId, userId);
} else { }).orElse(false);
UUID userId = session.get().getUserId();
return GameManager.instance.watchGame(gameId, userId);
}
} }
@Override @Override
@ -915,16 +863,13 @@ public class MageServerImpl implements MageServer {
@Override @Override
public void stopWatching(final UUID gameId, final String sessionId) throws MageException { public void stopWatching(final UUID gameId, final String sessionId) throws MageException {
execute("stopWatching", sessionId, () -> { execute("stopWatching", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
UserManager.instance.getUser(userId).ifPresent(user -> { UserManager.instance.getUser(userId).ifPresent(user -> {
GameManager.instance.stopWatching(gameId, userId); GameManager.instance.stopWatching(gameId, userId);
user.removeGameWatchInfo(gameId); user.removeGameWatchInfo(gameId);
}); });
} });
}); });
} }
@ -932,26 +877,20 @@ public class MageServerImpl implements MageServer {
@Override @Override
public void replayGame(final UUID gameId, final String sessionId) throws MageException { public void replayGame(final UUID gameId, final String sessionId) throws MageException {
execute("replayGame", sessionId, () -> { execute("replayGame", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
ReplayManager.instance.replayGame(gameId, userId); ReplayManager.instance.replayGame(gameId, userId);
} });
}); });
} }
@Override @Override
public void startReplay(final UUID gameId, final String sessionId) throws MageException { public void startReplay(final UUID gameId, final String sessionId) throws MageException {
execute("startReplay", sessionId, () -> { execute("startReplay", sessionId, () -> {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
ReplayManager.instance.startReplay(gameId, userId); 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 { public void cheat(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException {
execute("cheat", sessionId, () -> { execute("cheat", sessionId, () -> {
if (testMode) { if (testMode) {
Optional<Session> session = SessionManager.instance.getSession(sessionId); SessionManager.instance.getSession(sessionId).ifPresent(session -> {
if (!session.isPresent()) { UUID userId = session.getUserId();
logger.error("Session not found : " + sessionId);
} else {
UUID userId = session.get().getUserId();
GameManager.instance.cheat(gameId, userId, playerId, deckList); GameManager.instance.cheat(gameId, userId, playerId, deckList);
} });
} }
}); });
} }
@ -1327,7 +1263,6 @@ public class MageServerImpl implements MageServer {
public Boolean execute() throws MageException { public Boolean execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId); Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) { if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return false; return false;
} else { } else {
UUID userId = session.get().getUserId(); UUID userId = session.get().getUserId();
@ -1378,7 +1313,6 @@ public class MageServerImpl implements MageServer {
public TableView execute() throws MageException { public TableView execute() throws MageException {
Optional<Session> session = SessionManager.instance.getSession(sessionId); Optional<Session> session = SessionManager.instance.getSession(sessionId);
if (!session.isPresent()) { if (!session.isPresent()) {
logger.error("Session not found : " + sessionId);
return null; return null;
} }
UUID userId = session.get().getUserId(); UUID userId = session.get().getUserId();

View file

@ -2,6 +2,8 @@
package mage.server.game; package mage.server.game;
import org.apache.log4j.Logger;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -14,6 +16,7 @@ public enum GamesRoomManager {
private final ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<>(); private final ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<>();
private final UUID mainRoomId; private final UUID mainRoomId;
private static final Logger logger = Logger.getLogger(GamesRoomManager.class);
GamesRoomManager() { GamesRoomManager() {
@ -36,6 +39,7 @@ public enum GamesRoomManager {
if(rooms.containsKey(roomId)) { if(rooms.containsKey(roomId)) {
return Optional.of(rooms.get(roomId)); return Optional.of(rooms.get(roomId));
} }
logger.error("room not found : " + roomId);
return Optional.empty(); return Optional.empty();
} }

View file

@ -73,10 +73,7 @@ class AetherworksMarvelEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Set<Card> cardsSet = controller.getLibrary().getTopCards(game, 6); Set<Card> cardsSet = controller.getLibrary().getTopCards(game, 6);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(cardsSet);
for (Card card : cardsSet) {
cards.add(card);
}
TargetCard target = new TargetCardInLibrary(0, 1, new FilterNonlandCard("card to cast without paying its mana cost")); TargetCard target = new TargetCardInLibrary(0, 1, new FilterNonlandCard("card to cast without paying its mana cost"));
if (controller.choose(Outcome.PlayForFree, cards, target, game)) { if (controller.choose(Outcome.PlayForFree, cards, target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), 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()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(staticText, cards, game); controller.revealCards(staticText, cards, game);
Card cardToBattlefield; Card cardToBattlefield;

View file

@ -222,8 +222,7 @@ class AshiokNightmareWeaverExileAllEffect extends OneShotEffect {
for (UUID opponentId : game.getOpponents(source.getControllerId())) { for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId); Player opponent = game.getPlayer(opponentId);
if (opponent != null) { if (opponent != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(opponent.getHand());
cards.addAll(opponent.getHand());
for (UUID cardId : cards) { for (UUID cardId : cards) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null) { if (card != null) {

View file

@ -89,8 +89,7 @@ class AvenSoulgazerLookFaceDownEffect extends OneShotEffect {
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false, game); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(copyFaceDown);
cards.add(copyFaceDown);
player.lookAtCards("face down card - " + mageObject.getName(), cards, game); player.lookAtCards("face down card - " + mageObject.getName(), cards, game);
} else { } else {
return false; return false;

View file

@ -88,13 +88,13 @@ public final class BanefulOmen extends CardImpl {
return false; return false;
} }
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("Baneful Omen", cards, game);
if (card == null) { if (card == null) {
return false; return false;
} }
Cards cards = new CardsImpl(card);
player.revealCards("Baneful Omen", cards, game);
int loseLife = card.getConvertedManaCost(); int loseLife = card.getConvertedManaCost();
Set<UUID> opponents = game.getOpponents(source.getControllerId()); Set<UUID> opponents = game.getOpponents(source.getControllerId());
for (UUID opponentUuid : opponents) { for (UUID opponentUuid : opponents) {

View file

@ -67,8 +67,7 @@ class BarishiEffect extends OneShotEffect {
if (controller == null) { if (controller == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
cards.addAll(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.putCardsOnTopOfLibrary(cards, game, source, false);
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);
return true; return true;

View file

@ -63,8 +63,7 @@ class BenefactionOfRhonasEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
boolean creatureCardFound = false; boolean creatureCardFound = false;
boolean enchantmentCardFound = false; boolean enchantmentCardFound = false;
for (UUID cardId : cards) { for (UUID cardId : cards) {

View file

@ -80,10 +80,9 @@ class BorderlandExplorerEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { 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); player.chooseTarget(outcome, target, source, game);
cards.addAll(target.getTargets()); Cards cards = new CardsImpl(target.getTargets());
cardsToDiscard.put(playerId, cards); cardsToDiscard.put(playerId, cards);
} }
} }

View file

@ -90,8 +90,7 @@ class CallToTheKindredEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
controller.lookAtCards(enchantment.getIdName(), cards, game); controller.lookAtCards(enchantment.getIdName(), cards, game);
FilterCreatureCard filter = new FilterCreatureCard(); FilterCreatureCard filter = new FilterCreatureCard();

View file

@ -212,8 +212,7 @@ class ChandraPyromasterEffect3 extends OneShotEffect {
if (controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 10));
cards.addAll(controller.getLibrary().getTopCards(game, 10));
controller.moveCardsToExile(cards.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName()); controller.moveCardsToExile(cards.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName());
if (!cards.getCards(new FilterInstantOrSorceryCard(), game).isEmpty()) { if (!cards.getCards(new FilterInstantOrSorceryCard(), game).isEmpty()) {

View file

@ -64,8 +64,7 @@ class CoralFightersEffect extends OneShotEffect {
if(controller != null && defendingPlayer != null) { if(controller != null && defendingPlayer != null) {
Card card = defendingPlayer.getLibrary().getFromTop(game); Card card = defendingPlayer.getLibrary().getFromTop(game);
if(card != null) { if(card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards("Coral Fighters", cards, game); 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)) { 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); 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) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getGraveyard().getCards(new FilterCreatureCard(), game));
cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), game));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
TargetCard targetCards = new TargetCard(0, cards.size(), Zone.EXILED, new FilterCard("cards to put in the first pile")); TargetCard targetCards = new TargetCard(0, cards.size(), Zone.EXILED, new FilterCard("cards to put in the first pile"));
List<Card> pile1 = new ArrayList<>(); List<Card> pile1 = new ArrayList<>();

View file

@ -76,6 +76,9 @@ class DelverOfSecretsEffect extends OneShotEffect {
if (player != null && sourcePermanent != null) { if (player != null && sourcePermanent != null) {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
if(card == null){
return false;
}
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.add(card); cards.add(card);
player.lookAtCards(sourcePermanent.getName(), cards, game); player.lookAtCards(sourcePermanent.getName(), cards, game);

View file

@ -82,8 +82,7 @@ class EnduringRenewalReplacementEffect extends ReplacementEffectImpl {
} }
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.revealCards("Top card of " + controller.getName() + "'s library", cards, game); controller.revealCards("Top card of " + controller.getName() + "'s library", cards, game);
if (card.isCreature()) { if (card.isCreature()) {
controller.moveCards(card, Zone.GRAVEYARD, source, game); controller.moveCards(card, Zone.GRAVEYARD, source, game);

View file

@ -68,8 +68,7 @@ class EpiphanyAtTheDrownyardEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX() + 1));
cards.addAll(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX() + 1));
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
Player opponent; Player opponent;

View file

@ -69,8 +69,7 @@ class ExplorersScopeEffect extends OneShotEffect {
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (card.isLand()) { if (card.isLand()) {
String message = "Put " + card.getLogName() + " onto the battlefield tapped?"; String message = "Put " + card.getLogName() + " onto the battlefield tapped?";

View file

@ -65,8 +65,7 @@ class FactOrFictionEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
Set<UUID> opponents = game.getOpponents(source.getControllerId()); Set<UUID> opponents = game.getOpponents(source.getControllerId());

View file

@ -78,10 +78,9 @@ class FeralDeceiverEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
cards.add(card); Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
if (card.isLand()) { if (card.isLand()) {
game.addEffect(new BoostSourceEffect(2, 2, Duration.EndOfTurn), source); 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()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, StaticFilters.FILTER_CARD_BASIC_LAND); TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, StaticFilters.FILTER_CARD_BASIC_LAND);
controller.chooseTarget(outcome, cards, target, source, game); controller.chooseTarget(outcome, cards, target, source, game);

View file

@ -87,8 +87,7 @@ class FlashOfInsightEffect extends OneShotEffect {
} }
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
cards.addAll(controller.getLibrary().getTopCards(game, xValue));
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand")); 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)); Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && targetOpponent != null && sourceObject != null) { if (controller != null && targetOpponent != null && sourceObject != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
cards.addAll(controller.getLibrary().getTopCards(game, 4));
TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards for the face-down pile")); TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards for the face-down pile"));
targetOpponent.choose(outcome, cards, target, game); targetOpponent.choose(outcome, cards, target, game);
Cards faceDownPile = new CardsImpl(); Cards faceDownPile = new CardsImpl(target.getTargets());
faceDownPile.addAll(target.getTargets());
cards.removeAll(target.getTargets()); cards.removeAll(target.getTargets());
controller.revealCards(sourceObject.getIdName() + " - cards in face-up pile", cards, game); 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"); 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()); Player controllerOfTargetCreature = game.getPlayer(targetCreature.getControllerId());
if (controllerOfTargetCreature != null) { if (controllerOfTargetCreature != null) {
if (!controllerOfTargetCreature.getHand().isEmpty()) { if (!controllerOfTargetCreature.getHand().isEmpty()) {
Cards cards = new CardsImpl();
Card card = controllerOfTargetCreature.getHand().getRandom(game); Card card = controllerOfTargetCreature.getHand().getRandom(game);
if (card != null) { if (card != null) {
cards.add(card); Cards cards = new CardsImpl(card);
controllerOfTargetCreature.revealCards(sourceObject.getName(), cards, game); controllerOfTargetCreature.revealCards(sourceObject.getName(), cards, game);
int damage = card.getConvertedManaCost(); int damage = card.getConvertedManaCost();
targetCreature.damage(damage, source.getSourceId(), game, false, true); targetCreature.damage(damage, source.getSourceId(), game, false, true);

View file

@ -61,8 +61,7 @@ class GatherThePackEffect extends OneShotEffect {
if (controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
int creatures = cards.count(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), 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)); Player defender = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && defender != null) { if (sourceObject != null && defender != null) {
Cards cards = new CardsImpl();
Card card = defender.getLibrary().getFromTop(game); Card card = defender.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
cards.add(card); Cards cards = new CardsImpl(card);
defender.revealCards(sourceObject.getName(), cards, game); defender.revealCards(sourceObject.getName(), cards, game);
if (card.isLand()) { if (card.isLand()) {
defender.moveCards(card, Zone.HAND, source, game); defender.moveCards(card, Zone.HAND, source, game);

View file

@ -77,10 +77,9 @@ class HarshDeceiverEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
cards.add(card); Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
if (card.isLand()) { if (card.isLand()) {
new UntapSourceEffect().apply(game, source); new UntapSourceEffect().apply(game, source);

View file

@ -123,8 +123,7 @@ class HeroesPodiumEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
cards.addAll(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
boolean legendaryIncluded = cards.count(filter, game) > 0; boolean legendaryIncluded = cards.count(filter, game) > 0;
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);

View file

@ -82,8 +82,8 @@ class ImpromptuRaidEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
if (card != null) { if (card != null) {
Cards cards = new CardsImpl();
cards.add(card); cards.add(card);
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), 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) { if (controller != null && player != null) {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards("Jace, the Mind Sculptor", cards, game); 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)) { 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); controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, false, false);

View file

@ -191,8 +191,7 @@ class KarnLiberatedDelayedEffect extends OneShotEffect {
if (exile != null) { if (exile != null) {
// Creatures put onto the battlefield due to Karn's ability will have been under their controller's control continuously // 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. // 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 cards = new CardsImpl(exile); // needed because putOntoTheBattlefield removes from exile
cards.addAll(exile);
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.moveCards(cards, Zone.BATTLEFIELD, source, game); controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
for (Card card : cards.getCards(game)) { for (Card card : cards.getCards(game)) {

View file

@ -89,8 +89,7 @@ class KarnPlus1Effect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2));
cards.addAll(controller.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(staticText, cards, game); controller.revealCards(staticText, cards, game);

View file

@ -101,8 +101,7 @@ class KeeperOfTheLensLookFaceDownEffect extends OneShotEffect {
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false, game); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(copyFaceDown);
cards.add(copyFaceDown);
Player player = game.getPlayer(faceDownCreature.getControllerId()); Player player = game.getPlayer(faceDownCreature.getControllerId());
controller.lookAtCards("face down card - " + mageObject.getName(), cards, game); controller.lookAtCards("face down card - " + mageObject.getName(), cards, game);
if (player != null) { if (player != null) {

View file

@ -85,8 +85,7 @@ class KheruLichLordEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game));
cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game));
Card card = cards.getRandom(game); Card card = cards.getRandom(game);
if (card != null) { if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game); controller.moveCards(card, Zone.BATTLEFIELD, source, game);

View file

@ -124,8 +124,7 @@ class KioraRevealEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
cards.addAll(controller.getLibrary().getTopCards(game, 4));
boolean creatureCardFound = false; boolean creatureCardFound = false;
boolean landCardFound = false; boolean landCardFound = false;
for (UUID cardId : cards) { for (UUID cardId : cards) {

View file

@ -93,8 +93,7 @@ class LensOfClarityLookLibraryEffect extends OneShotEffect {
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards("top card of library - " + controller.getName(), cards, game); controller.lookAtCards("top card of library - " + controller.getName(), cards, game);
game.informPlayers(controller.getLogName() + " looks at the top card of their library"); game.informPlayers(controller.getLogName() + " looks at the top card of their library");
} else { } else {
@ -158,8 +157,7 @@ class LensOfClarityLookFaceDownEffect extends OneShotEffect {
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false, game); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(copyFaceDown);
cards.add(copyFaceDown);
Player player = game.getPlayer(faceDownCreature.getControllerId()); Player player = game.getPlayer(faceDownCreature.getControllerId());
controller.lookAtCards("face down card - " + mageObject.getName(), cards, game); controller.lookAtCards("face down card - " + mageObject.getName(), cards, game);
if (player != null) { if (player != null) {

View file

@ -60,8 +60,7 @@ class LevelerExileLibraryEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
int count = controller.getLibrary().size(); int count = controller.getLibrary().size();
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
cards.addAll(controller.getLibrary().getTopCards(game, count));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
return true; return true;
} }

View file

@ -73,9 +73,9 @@ class LlanowarEmpathEffect extends OneShotEffect {
if (controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl();
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl();
cards.add(card); cards.add(card);
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
if (card.isCreature()) { if (card.isCreature()) {

View file

@ -74,8 +74,7 @@ class LordOfTheVoidEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
cards.addAll(player.getLibrary().getTopCards(game, 7));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
if (!cards.getCards(new FilterCreatureCard(), game).isEmpty()) { if (!cards.getCards(new FilterCreatureCard(), game).isEmpty()) {
TargetCard target = new TargetCard(Zone.EXILED, new FilterCreatureCard()); TargetCard target = new TargetCard(Zone.EXILED, new FilterCreatureCard());

View file

@ -57,8 +57,7 @@ class LostInTheWoodsEffect extends OneShotEffect {
} }
if (controller.getLibrary().hasCards()) { if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
if (card != null) { if (card != null) {

View file

@ -93,8 +93,7 @@ class MerchantsDockhandEffect extends OneShotEffect {
} }
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
cards.addAll(controller.getLibrary().getTopCards(game, xValue));
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand")); 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; return false;
} }
Cards cards = new CardsImpl(); 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) -> { game.getOpponents(source.getControllerId()).stream().map((playerId) -> game.getPlayer(playerId)).filter((player) -> (player != null)).forEachOrdered((player) -> {
cards.addAll(player.getGraveyard()); cards.addAll(player.getGraveyard());
}); });

View file

@ -64,8 +64,7 @@ class MurmursFromBeyondEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
cards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(staticText, cards, game); controller.revealCards(staticText, cards, game);
Card cardToGraveyard; Card cardToGraveyard;

View file

@ -81,8 +81,8 @@ class NessianGameWardenEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl();
int count = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this); int count = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, count)); cards.addAll(controller.getLibrary().getTopCards(game, count));
controller.lookAtCards(sourcePermanent.getIdName(), cards, game); controller.lookAtCards(sourcePermanent.getIdName(), cards, game);

View file

@ -101,12 +101,11 @@ class NicolBolasGodPharaohPlusOneEffect extends OneShotEffect {
} }
int numberOfCardsToExile = Math.min(2, player.getHand().size()); int numberOfCardsToExile = Math.min(2, player.getHand().size());
Cards cards = new CardsImpl();
Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard()); Target target = new TargetCardInHand(numberOfCardsToExile, new FilterCard());
Cards cards = new CardsImpl(target.getTargets());
player.chooseTarget(Outcome.Exile, target, source, game); player.chooseTarget(Outcome.Exile, target, source, game);
cards.addAll(target.getTargets());
cardsToExile.put(playerId, cards); cardsToExile.put(playerId, cards);
} }
// Exile all choosen 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); card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
String name = "Reveal"; String name = "Reveal";
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) { if (sourceCard != null) {
name = sourceCard.getName(); name = sourceCard.getName();

View file

@ -84,8 +84,7 @@ class NissaNaturesArtisanEffect extends OneShotEffect {
if (controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2));
cards.addAll(controller.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
Set<Card> toBattlefield = new LinkedHashSet<>(); Set<Card> toBattlefield = new LinkedHashSet<>();

View file

@ -62,10 +62,10 @@ class NissasRevelationEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl();
cards.add(card); cards.add(card);
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
if (card.isCreature()) { if (card.isCreature()) {

View file

@ -1,31 +1,27 @@
package mage.cards.p; package mage.cards.p;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.InspiredAbility; import mage.abilities.keyword.InspiredAbility;
import mage.cards.Card; import mage.cards.*;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class PainSeer extends CardImpl { public final class PainSeer extends CardImpl {
public PainSeer(UUID ownerId, CardSetInfo setInfo) { 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.HUMAN);
this.subtype.add(SubType.WIZARD); this.subtype.add(SubType.WIZARD);
@ -71,14 +67,14 @@ class PainSeerEffect extends OneShotEffect {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("Pain Seer", cards, game);
if (card != null && if (card != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { Cards cards = new CardsImpl(card);
player.loseLife(card.getConvertedManaCost(), game, false); player.revealCards("Pain Seer", cards, game);
return true; if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) {
player.loseLife(card.getConvertedManaCost(), game, false);
return true;
}
} }
} }
return false; return false;

View file

@ -55,8 +55,7 @@ class ExileLibraryEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
int count = controller.getLibrary().size(); int count = controller.getLibrary().size();
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
cards.addAll(controller.getLibrary().getTopCards(game, count));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
for (Card card: controller.getGraveyard().getCards(game)) { for (Card card: controller.getGraveyard().getCards(game)) {

View file

@ -91,8 +91,7 @@ class ParoxysmEffect extends OneShotEffect {
if (controllerOfCreature != null) { if (controllerOfCreature != null) {
Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game); Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game);
if (revealCardFromTop != null) { if (revealCardFromTop != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(revealCardFromTop);
cards.add(revealCardFromTop);
controllerOfCreature.revealCards(source, cards, game); controllerOfCreature.revealCards(source, cards, game);
if (revealCardFromTop.isLand()) { if (revealCardFromTop.isLand()) {
creatureAttachedTo.destroy(source.getSourceId(), game, false); creatureAttachedTo.destroy(source.getSourceId(), game, false);

View file

@ -61,8 +61,7 @@ class PetalsOfInsightEffect extends OneShotEffect {
if (controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
cards.addAll(controller.getLibrary().getTopCards(game, 3));
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (controller.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", source, 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) { if (player == null) {
return false; return false;
} }
Cards cards = new CardsImpl();
if (player.getHand().count(new FilterCard(), game) > 0) { if (player.getHand().count(new FilterCard(), game) > 0) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCard()); TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCard());
if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
Cards cards = new CardsImpl();
for (UUID uuid : target.getTargets()) { for (UUID uuid : target.getTargets()) {
cards.add(player.getHand().get(uuid, game)); cards.add(player.getHand().get(uuid, game));
} }

View file

@ -69,8 +69,7 @@ class PhyrexianPortalEffect extends OneShotEffect {
Player opponent = game.getPlayer(source.getFirstTarget()); Player opponent = game.getPlayer(source.getFirstTarget());
if (controller != null && opponent != null) { if (controller != null && opponent != null) {
if (controller.getLibrary().size() >= 10) { if (controller.getLibrary().size() >= 10) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 10));
cards.addAll(controller.getLibrary().getTopCards(game, 10));
TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile")); TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile"));
List<Card> pile1 = new ArrayList<>(); List<Card> pile1 = new ArrayList<>();

View file

@ -82,8 +82,7 @@ class PlaneswalkersMischiefEffect extends OneShotEffect {
if (revealedCard == null) { if (revealedCard == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(revealedCard);
cards.add(revealedCard);
opponent.revealCards("Planeswalker's Mischief Reveal", cards, game); opponent.revealCards("Planeswalker's Mischief Reveal", cards, game);
if (revealedCard.isInstant() if (revealedCard.isInstant()
|| revealedCard.isSorcery()) { || revealedCard.isSorcery()) {

View file

@ -68,8 +68,7 @@ class PrecognitionEffect extends OneShotEffect {
if (controller != null && player != null) { if (controller != null && player != null) {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards("Precognition", cards, game); controller.lookAtCards("Precognition", cards, game);
if (controller.chooseUse(outcome, "Do you wish to put card on the bottom of player's library?", source, 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); 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)) { if (controller.chooseUse(outcome, "Reveal a Dinosaur card?", source, game)) {
TargetCardInHand target = new TargetCardInHand(0, 1, filter); TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) { if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(target.getTargets());
cards.addAll(target.getTargets());
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
controller.gainLife(2, game, source); controller.gainLife(2, game, source);
return true; return true;

View file

@ -75,8 +75,7 @@ class PuresightMerrowEffect extends OneShotEffect {
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards("Puresight Merrow", cards, game); 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)) { 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); 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)) { if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards(sourceObject.getName(), cards, game); controller.lookAtCards(sourceObject.getName(), cards, game);
game.informPlayers(controller.getLogName() + " look at a face-down attacking creature"); game.informPlayers(controller.getLogName() + " look at a face-down attacking creature");
} }

View file

@ -60,8 +60,7 @@ class RevivingVaporsEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
cards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
Card card = null; Card card = null;

View file

@ -113,12 +113,11 @@ class FallEffect extends OneShotEffect {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) { if (targetPlayer != null) {
if (!targetPlayer.getHand().isEmpty()) { if (!targetPlayer.getHand().isEmpty()) {
Cards cards = new CardsImpl();
Card card = targetPlayer.getHand().getRandom(game); Card card = targetPlayer.getHand().getRandom(game);
if (card == null) { if (card == null) {
return false; return false;
} }
cards.add(card); Cards cards = new CardsImpl(card);
if (targetPlayer.getHand().size() > 1) { if (targetPlayer.getHand().size() > 1) {
do { do {
card = targetPlayer.getHand().getRandom(game); card = targetPlayer.getHand().getRandom(game);

View file

@ -65,8 +65,7 @@ class RootingKavuEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
cards.addAll(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.putCardsOnTopOfLibrary(cards, game, source, false);
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);
return true; return true;

View file

@ -71,8 +71,7 @@ class SatyrWayfinderEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
cards.addAll(controller.getLibrary().getTopCards(game, 4));
boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0; boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0;
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);

View file

@ -82,10 +82,7 @@ class SearchForSurvivorsEffect extends OneShotEffect {
controller.getGraveyard().clear(); controller.getGraveyard().clear();
controller.getGraveyard().addAll(Arrays.asList(shuffled)); controller.getGraveyard().addAll(Arrays.asList(shuffled));
// end of randomize // end of randomize
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getGraveyard().getCards(game));
controller.getGraveyard().getCards(game).forEach((card) -> {
cards.add(card);
});
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
Card card = cards.getRandom(game); Card card = cards.getRandom(game);
cards.clear(); cards.clear();

View file

@ -65,10 +65,7 @@ class SerumPowderReplaceEffect extends ReplacementEffectImpl {
} }
int cardsHand = controller.getHand().size(); int cardsHand = controller.getHand().size();
if (cardsHand > 0){ if (cardsHand > 0){
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getHand());
for (UUID cardId: controller.getHand()) {
cards.add(game.getCard(cardId));
}
for (Card card: cards.getCards(game)) { for (Card card: cards.getCards(game)) {
card.moveToExile(null, null, source.getSourceId(), game); card.moveToExile(null, null, source.getSourceId(), game);
} }

View file

@ -73,10 +73,10 @@ class SifterWurmEffect extends OneShotEffect {
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
controller.scry(3, source, game); controller.scry(3, source, game);
Cards cards = new CardsImpl();
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl();
cards.add(card); cards.add(card);
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
controller.gainLife(card.getConvertedManaCost(), game, source); controller.gainLife(card.getConvertedManaCost(), game, source);

View file

@ -86,8 +86,7 @@ class SmokeTellerLookFaceDownEffect extends OneShotEffect {
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false, game); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(copyFaceDown);
cards.add(copyFaceDown);
player.lookAtCards("face down card - " + mageObject.getName(), cards, game); player.lookAtCards("face down card - " + mageObject.getName(), cards, game);
} else { } else {
return false; return false;

View file

@ -1,7 +1,6 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; 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.CreateTokenEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.Card; import mage.cards.*;
import mage.cards.CardImpl; import mage.constants.*;
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.game.Game; import mage.game.Game;
import mage.game.permanent.token.VampireKnightToken; import mage.game.permanent.token.VampireKnightToken;
import mage.players.Player; import mage.players.Player;
import mage.players.PlayerList; import mage.players.PlayerList;
import mage.target.common.TargetCreatureOrPlaneswalker; import mage.target.common.TargetCreatureOrPlaneswalker;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class SorinGrimNemesis extends CardImpl { public final class SorinGrimNemesis extends CardImpl {
@ -90,90 +82,91 @@ class SorinGrimNemesisRevealEffect extends OneShotEffect {
if (player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(); if (card != null) {
cards.add(card); Cards cards = new CardsImpl();
player.revealCards("Sorin, Grim Nemesis", cards, game); cards.add(card);
player.revealCards("Sorin, Grim Nemesis", cards, game);
if (card != null if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) {
&& card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { for (UUID playerId : game.getOpponents(source.getControllerId())) {
for (UUID playerId : game.getOpponents(source.getControllerId())) { if (card.getConvertedManaCost() > 0) {
if (card.getConvertedManaCost() > 0) { Player opponent = game.getPlayer(playerId);
Player opponent = game.getPlayer(playerId); if (opponent != null) {
if (opponent != null) { opponent.loseLife(card.getConvertedManaCost(), game, false);
opponent.loseLife(card.getConvertedManaCost(), game, false); }
} }
} }
return true;
} }
return true;
} }
} }
return false; 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 @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost : sourceAbility.getCosts()) { for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof PayVariableLoyaltyCost) { if (cost instanceof PayVariableLoyaltyCost) {
return ((PayVariableLoyaltyCost) cost).getAmount(); 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();
} }
} }
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 class SorinTokenEffect extends OneShotEffect {
public SorinTokenEffect copy() {
return new SorinTokenEffect(this); 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);
}
} }
}

View file

@ -94,8 +94,7 @@ class SphinxOfJwarIsleEffect extends OneShotEffect {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
player.lookAtCards("Sphinx of Jwar Isle", cards, game); player.lookAtCards("Sphinx of Jwar Isle", cards, game);
} else { } else {
return false; return false;

View file

@ -116,8 +116,7 @@ class SpyNetworkFaceDownEffect extends OneShotEffect {
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false, game); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(copyFaceDown);
cards.add(copyFaceDown);
controller.lookAtCards("face down card - " + mageObject.getName(), cards, game); controller.lookAtCards("face down card - " + mageObject.getName(), cards, game);
game.informPlayers(controller.getLogName() + " looks at a face down creature controlled by " + player.getLogName()); 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; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
Player opponent; Player opponent;

View file

@ -62,8 +62,7 @@ class StompingSlabsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
cards.addAll(controller.getLibrary().getTopCards(game, 7));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards("Stomping Slabs", cards, game); controller.revealCards("Stomping Slabs", cards, game);
boolean stompingSlabsFound = false; boolean stompingSlabsFound = false;

View file

@ -68,9 +68,9 @@ class StrongarmTacticsEffect extends OneShotEffect {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
int numberOfCardsToDiscard = Math.min(1, player.getHand().size()); int numberOfCardsToDiscard = Math.min(1, player.getHand().size());
Cards cards = new CardsImpl();
Target target = new TargetDiscard(numberOfCardsToDiscard, numberOfCardsToDiscard, new FilterCard(), playerId); Target target = new TargetDiscard(numberOfCardsToDiscard, numberOfCardsToDiscard, new FilterCard(), playerId);
player.chooseTarget(outcome, target, source, game); player.chooseTarget(outcome, target, source, game);
Cards cards = new CardsImpl();
cards.addAll(target.getTargets()); cards.addAll(target.getTargets());
cardsToDiscard.put(playerId, cards); cardsToDiscard.put(playerId, cards);
} }

View file

@ -133,8 +133,7 @@ class SummoningTrapEffect extends OneShotEffect {
if (controller == null) { if (controller == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
cards.addAll(controller.getLibrary().getTopCards(game, 7));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, TargetCard target = new TargetCard(Zone.LIBRARY,
new FilterCreatureCard( new FilterCreatureCard(

View file

@ -117,8 +117,7 @@ class SunbirdsInvocationEffect extends OneShotEffect {
return false; return false;
} }
int xValue = spell.getConvertedManaCost(); int xValue = spell.getConvertedManaCost();
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
cards.addAll(controller.getLibrary().getTopCards(game, xValue));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);

View file

@ -75,10 +75,7 @@ class TalentOfTheTelepathEffect extends OneShotEffect {
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (targetOpponent != null && sourceObject != null) { if (targetOpponent != null && sourceObject != null) {
Set<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 7); Set<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 7);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(allCards);
for (Card card : allCards) {
cards.add(card);
}
targetOpponent.revealCards(sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards", cards, game); targetOpponent.revealCards(sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards", cards, game);
for (Card card : allCards) { for (Card card : allCards) {
if (filter.match(card, game)) { if (filter.match(card, game)) {

View file

@ -66,8 +66,7 @@ class TellingTimeEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
cards.addAll(controller.getLibrary().getTopCards(game, 3));
controller.lookAtCards(sourceObject.getIdName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (cards.isEmpty()) { if (cards.isEmpty()) {
return true; return true;

View file

@ -65,9 +65,8 @@ class TemporalApertureEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);
Card topCard = controller.getLibrary().getFromTop(game); Card topCard = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
if (topCard != null) { if (topCard != null) {
cards.add(topCard); Cards cards = new CardsImpl(topCard);
controller.revealCards("Top card of " + controller.getName() + "'s library revealed", cards, game); controller.revealCards("Top card of " + controller.getName() + "'s library revealed", cards, game);
ContinuousEffect effect = new TemporalApertureTopCardCastEffect(topCard); ContinuousEffect effect = new TemporalApertureTopCardCastEffect(topCard);
game.addEffect(effect, source); game.addEffect(effect, source);

View file

@ -102,8 +102,7 @@ class ThoughtLashExileLibraryEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, controller.getLibrary().size()));
cards.addAll(controller.getLibrary().getTopCards(game, controller.getLibrary().size()));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
return true; return true;
} }

View file

@ -78,8 +78,7 @@ class ThoughtpickerWitchEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller != null && opponent != null) { if (controller != null && opponent != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, 2));
cards.addAll(opponent.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
TargetCard target = new TargetCardInLibrary(new FilterCard("card to exile")); TargetCard target = new TargetCardInLibrary(new FilterCard("card to exile"));
if (controller.choose(Outcome.Exile, cards, target, game)) { if (controller.choose(Outcome.Exile, cards, target, game)) {

View file

@ -66,8 +66,7 @@ class TruthOrTaleEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
cards.addAll(controller.getLibrary().getTopCards(game, 5));
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
Player opponent; Player opponent;

View file

@ -141,8 +141,7 @@ class UneshCriosphinxSovereignEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
cards.addAll(controller.getLibrary().getTopCards(game, 4));
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
Set<UUID> opponents = game.getOpponents(source.getControllerId()); Set<UUID> opponents = game.getOpponents(source.getControllerId());

View file

@ -81,8 +81,7 @@ class VesselOfNascencyEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
cards.addAll(controller.getLibrary().getTopCards(game, 4));
boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0; boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0;
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);

View file

@ -67,8 +67,7 @@ class ViviensInvocationEffect extends OneShotEffect {
if (controller == null) { if (controller == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
cards.addAll(controller.getLibrary().getTopCards(game, 7));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
TargetCard target = new TargetCard( TargetCard target = new TargetCard(
Zone.LIBRARY, Zone.LIBRARY,

View file

@ -64,8 +64,7 @@ class WildEvocationEffect extends OneShotEffect {
if (player != null && sourceObject != null) { if (player != null && sourceObject != null) {
Card card = player.getHand().getRandom(game); Card card = player.getHand().getRandom(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
player.revealCards(sourceObject.getIdName() + " Turn: " + game.getTurnNum(), cards, game); player.revealCards(sourceObject.getIdName() + " Turn: " + game.getTurnNum(), cards, game);
if (card.isLand()) { if (card.isLand()) {
player.moveCards(card, Zone.BATTLEFIELD, source, game); 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); Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
controller.moveCards(card, Zone.HAND, source, game); controller.moveCards(card, Zone.HAND, source, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.revealCards(sourceObject.getIdName(), cards, game, true); controller.revealCards(sourceObject.getIdName(), cards, game, true);
} }
} }

View file

@ -74,8 +74,7 @@ class WuSpyEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller != null && opponent != null) { if (controller != null && opponent != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, 2));
cards.addAll(opponent.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
TargetCard target = new TargetCardInLibrary(new FilterCard("card to put into graveyard")); TargetCard target = new TargetCardInLibrary(new FilterCard("card to put into graveyard"));
controller.choose(Outcome.Benefit, cards, target, game); controller.choose(Outcome.Benefit, cards, target, game);

View file

@ -73,8 +73,7 @@ class ZombieMobEffect extends OneShotEffect {
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(controller.getGraveyard().getCards(filter, game));
cards.addAll(controller.getGraveyard().getCards(filter, game));
controller.moveCards(cards, Zone.EXILED, source, game); controller.moveCards(cards, Zone.EXILED, source, game);
return true; return true;
} }

View file

@ -65,8 +65,7 @@ public class MiracleWatcher extends Watcher {
if (ability instanceof MiracleAbility) { if (ability instanceof MiracleAbility) {
Player controller = game.getPlayer(ability.getControllerId()); Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) { if (controller != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card);
controller.lookAtCards("Miracle", cards, game); controller.lookAtCards("Miracle", cards, game);
if (controller.chooseUse(Outcome.Benefit, "Reveal " + card.getLogName() + " to be able to use Miracle?", ability, game)) { if (controller.chooseUse(Outcome.Benefit, "Reveal " + card.getLogName() + " to be able to use Miracle?", ability, game)) {
controller.revealCards("Miracle", cards, game); controller.revealCards("Miracle", cards, game);