This commit is contained in:
Jeff 2019-04-08 16:36:43 -05:00
parent 53fbe7e502
commit 9f70a0ea85

View file

@ -19,10 +19,11 @@ import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.other.OwnerIdPredicate;
import mage.filter.predicate.other.OwnerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.target.common.TargetOpponent;
/**
@ -86,41 +87,55 @@ class DawnbreakReclaimerEffect extends OneShotEffect {
*/
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
TargetCardInOpponentsGraveyard targetOpponentGraveyard = new TargetCardInOpponentsGraveyard(new FilterCreatureCard("a creature card in an opponent's graveyard"));
targetOpponentGraveyard.setNotTarget(true);
if (controller != null
&& sourceObject != null) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card in an opponent's graveyard");
filter.add(new OwnerPredicate(TargetController.OPPONENT));
TargetCard chosenCreatureOpponentGraveyard = new TargetCard(Zone.GRAVEYARD, filter);
Player opponent = null;
Card cardOpponentGraveyard = null;
targetOpponentGraveyard.setNotTarget(true);
if (targetOpponentGraveyard.canChoose(source.getSourceId(), source.getControllerId(), game)) {
controller.choose(Outcome.Detriment, targetOpponentGraveyard, source.getSourceId(), game);
cardOpponentGraveyard = game.getCard(targetOpponentGraveyard.getFirstTarget());
chosenCreatureOpponentGraveyard.setNotTarget(true);
if (chosenCreatureOpponentGraveyard.canChoose(source.getSourceId(), source.getControllerId(), game)) {
controller.choose(Outcome.Detriment, chosenCreatureOpponentGraveyard, source.getSourceId(), game);
cardOpponentGraveyard = game.getCard(chosenCreatureOpponentGraveyard.getFirstTarget());
if (cardOpponentGraveyard != null) {
opponent = game.getPlayer(cardOpponentGraveyard.getOwnerId());
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + cardOpponentGraveyard.getIdName() + " of " + opponent.getLogName());
game.informPlayers(sourceObject.getLogName()
+ ": " + controller.getLogName()
+ " has chosen "
+ cardOpponentGraveyard.getIdName()
+ " of " + opponent.getLogName());
}
}
if (opponent == null) {
// if no card from opponent was available controller has to chose an opponent to select a creature card in controllers graveyard
TargetOpponent targetOpponent = new TargetOpponent(true);
targetOpponent.setNotTarget(true);
controller.choose(outcome, targetOpponent, source.getSourceId(), game);
opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent != null) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName() + " to select a creature card from their graveyard");
game.informPlayers(sourceObject.getLogName()
+ ": " + controller.getLogName()
+ " has chosen "
+ opponent.getLogName()
+ " to select a creature card from their graveyard");
}
}
if (opponent != null) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card in " + controller.getName() + "'s the graveyard");
filter.add(new OwnerIdPredicate(controller.getId()));
TargetCardInGraveyard targetControllerGaveyard = new TargetCardInGraveyard(filter);
FilterCreatureCard filterCreatureCard =
new FilterCreatureCard("a creature card in " + controller.getName() + "'s the graveyard");
filterCreatureCard.add(new OwnerIdPredicate(controller.getId()));
TargetCardInGraveyard targetControllerGaveyard = new TargetCardInGraveyard(filterCreatureCard);
targetControllerGaveyard.setNotTarget(true);
Card controllerCreatureCard = null;
if (targetControllerGaveyard.canChoose(source.getSourceId(), opponent.getId(), game)
&& opponent.choose(outcome, targetControllerGaveyard, source.getSourceId(), game)) {
controllerCreatureCard = game.getCard(targetControllerGaveyard.getFirstTarget());
if (controllerCreatureCard != null) {
game.informPlayers(sourceObject.getLogName() + ": " + opponent.getLogName() + " has chosen " + controllerCreatureCard.getIdName() + " of " + controller.getLogName());
game.informPlayers(sourceObject.getLogName()
+ ": " + opponent.getLogName()
+ " has chosen "
+ controllerCreatureCard.getIdName()
+ " of " + controller.getLogName());
}
}
Set<Card> cards = new HashSet<>();
@ -134,7 +149,11 @@ class DawnbreakReclaimerEffect extends OneShotEffect {
if (controller.chooseUse(
outcome,
"Return those cards to the battlefield under their owners' control?",
"Opponent's creature card: " + (cardOpponentGraveyard == null ? "none" : cardOpponentGraveyard.getLogName()) + ", your creature card: " + (controllerCreatureCard == null ? "none" : controllerCreatureCard.getLogName()),
"Opponent's creature card: "
+ (cardOpponentGraveyard == null
? "none" : cardOpponentGraveyard.getLogName())
+ ", your creature card: " + (controllerCreatureCard == null
? "none" : controllerCreatureCard.getLogName()),
null,
null,
source,