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.constants.Zone;
import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.other.OwnerIdPredicate; import mage.filter.predicate.other.OwnerIdPredicate;
import mage.filter.predicate.other.OwnerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
/** /**
@ -30,7 +31,7 @@ import mage.target.common.TargetOpponent;
* @author LevelX2 * @author LevelX2
*/ */
public final class DawnbreakReclaimer extends CardImpl { public final class DawnbreakReclaimer extends CardImpl {
public DawnbreakReclaimer(UUID ownerId, CardSetInfo setInfo) { public DawnbreakReclaimer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
this.subtype.add(SubType.ANGEL); this.subtype.add(SubType.ANGEL);
@ -43,11 +44,11 @@ public final class DawnbreakReclaimer extends CardImpl {
// You may return those cards to the battlefield under their owners' control. // You may return those cards to the battlefield under their owners' control.
this.addAbility(new BeginningOfEndStepTriggeredAbility(new DawnbreakReclaimerEffect(), TargetController.YOU, false)); this.addAbility(new BeginningOfEndStepTriggeredAbility(new DawnbreakReclaimerEffect(), TargetController.YOU, false));
} }
public DawnbreakReclaimer(final DawnbreakReclaimer card) { public DawnbreakReclaimer(final DawnbreakReclaimer card) {
super(card); super(card);
} }
@Override @Override
public DawnbreakReclaimer copy() { public DawnbreakReclaimer copy() {
return new DawnbreakReclaimer(this); return new DawnbreakReclaimer(this);
@ -55,21 +56,21 @@ public final class DawnbreakReclaimer extends CardImpl {
} }
class DawnbreakReclaimerEffect extends OneShotEffect { class DawnbreakReclaimerEffect extends OneShotEffect {
public DawnbreakReclaimerEffect() { public DawnbreakReclaimerEffect() {
super(Outcome.Detriment); super(Outcome.Detriment);
this.staticText = "choose a creature card in an opponent's graveyard, then that player chooses a creature card in your graveyard. You may return those cards to the battlefield under their owners' control"; this.staticText = "choose a creature card in an opponent's graveyard, then that player chooses a creature card in your graveyard. You may return those cards to the battlefield under their owners' control";
} }
public DawnbreakReclaimerEffect(final DawnbreakReclaimerEffect effect) { public DawnbreakReclaimerEffect(final DawnbreakReclaimerEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public DawnbreakReclaimerEffect copy() { public DawnbreakReclaimerEffect copy() {
return new DawnbreakReclaimerEffect(this); return new DawnbreakReclaimerEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
/** /**
@ -86,41 +87,55 @@ class DawnbreakReclaimerEffect 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
TargetCardInOpponentsGraveyard targetOpponentGraveyard = new TargetCardInOpponentsGraveyard(new FilterCreatureCard("a creature card in an opponent's graveyard")); && sourceObject != null) {
targetOpponentGraveyard.setNotTarget(true); 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; Player opponent = null;
Card cardOpponentGraveyard = null; Card cardOpponentGraveyard = null;
targetOpponentGraveyard.setNotTarget(true); chosenCreatureOpponentGraveyard.setNotTarget(true);
if (targetOpponentGraveyard.canChoose(source.getSourceId(), source.getControllerId(), game)) { if (chosenCreatureOpponentGraveyard.canChoose(source.getSourceId(), source.getControllerId(), game)) {
controller.choose(Outcome.Detriment, targetOpponentGraveyard, source.getSourceId(), game); controller.choose(Outcome.Detriment, chosenCreatureOpponentGraveyard, source.getSourceId(), game);
cardOpponentGraveyard = game.getCard(targetOpponentGraveyard.getFirstTarget()); cardOpponentGraveyard = game.getCard(chosenCreatureOpponentGraveyard.getFirstTarget());
if (cardOpponentGraveyard != null) { if (cardOpponentGraveyard != null) {
opponent = game.getPlayer(cardOpponentGraveyard.getOwnerId()); 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 (opponent == null) {
// if no card from opponent was available controller has to chose an opponent to select a creature card in controllers graveyard // 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 targetOpponent = new TargetOpponent(true);
targetOpponent.setNotTarget(true);
controller.choose(outcome, targetOpponent, source.getSourceId(), game); controller.choose(outcome, targetOpponent, source.getSourceId(), game);
opponent = game.getPlayer(targetOpponent.getFirstTarget()); opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent != null) { 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) { if (opponent != null) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card in " + controller.getName() + "'s the graveyard"); FilterCreatureCard filterCreatureCard =
filter.add(new OwnerIdPredicate(controller.getId())); new FilterCreatureCard("a creature card in " + controller.getName() + "'s the graveyard");
TargetCardInGraveyard targetControllerGaveyard = new TargetCardInGraveyard(filter); filterCreatureCard.add(new OwnerIdPredicate(controller.getId()));
TargetCardInGraveyard targetControllerGaveyard = new TargetCardInGraveyard(filterCreatureCard);
targetControllerGaveyard.setNotTarget(true); targetControllerGaveyard.setNotTarget(true);
Card controllerCreatureCard = null; Card controllerCreatureCard = null;
if (targetControllerGaveyard.canChoose(source.getSourceId(), opponent.getId(), game) if (targetControllerGaveyard.canChoose(source.getSourceId(), opponent.getId(), game)
&& opponent.choose(outcome, targetControllerGaveyard, source.getSourceId(), game)) { && opponent.choose(outcome, targetControllerGaveyard, source.getSourceId(), game)) {
controllerCreatureCard = game.getCard(targetControllerGaveyard.getFirstTarget()); controllerCreatureCard = game.getCard(targetControllerGaveyard.getFirstTarget());
if (controllerCreatureCard != null) { 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<>(); Set<Card> cards = new HashSet<>();
@ -134,7 +149,11 @@ class DawnbreakReclaimerEffect extends OneShotEffect {
if (controller.chooseUse( if (controller.chooseUse(
outcome, outcome,
"Return those cards to the battlefield under their owners' control?", "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,
null, null,
source, source,
@ -143,10 +162,10 @@ class DawnbreakReclaimerEffect extends OneShotEffect {
} }
} }
} }
return true; return true;
} }
return false; return false;
} }
} }