Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DSC] Add Zimone's Hypothesis #13181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions Mage.Sets/src/mage/cards/z/ZimonesHypothesis.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package mage.cards.z;

import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerParityPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;

import java.util.UUID;
import java.util.stream.Collectors;

/**
* @author werhsdnas
*/
public final class ZimonesHypothesis extends CardImpl {

public ZimonesHypothesis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason for the verify failure - this card is an Instant, not a Sorcery


// You may put a +1/+1 counter on a creature.
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this construction doesn't work as you might hope. Despite the not-target param, it's still asking for a target on cast. Since it's not targeting, that must happen only on resolution.

What I typically see for this is a custom effect - see Titan of Industry as a reference and add a player.chooseUse to account for the "you may"


//Then choose odd or even. Return each creature with power of the chosen quality to its owner’s hand.
this.getSpellAbility().addEffect(new ZimonesHypothesisBounceEffect());
}

private ZimonesHypothesis(final ZimonesHypothesis card) {
super(card);
}

@Override
public ZimonesHypothesis copy() {
return new ZimonesHypothesis(this);
}
}

class ZimonesHypothesisBounceEffect extends OneShotEffect {

private static final FilterPermanent evenFilter = new FilterCreaturePermanent();
private static final FilterPermanent oddFilter = new FilterCreaturePermanent();

static {
evenFilter.add(PowerParityPredicate.EVEN);
oddFilter.add(PowerParityPredicate.ODD);
}

ZimonesHypothesisBounceEffect() {
super(Outcome.Benefit);
staticText = "Choose odd or even. Return each creature with power of the chosen quality to its owner's hand. <i>(Zero is even.)</i>";
}

private ZimonesHypothesisBounceEffect(final ZimonesHypothesisBounceEffect effect) {
super(effect);
}

@Override
public ZimonesHypothesisBounceEffect copy() {
return new ZimonesHypothesisBounceEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
FilterPermanent filter = player.chooseUse(
outcome, "Odd or even?", null,
"Odd", "Even", source, game
) ? oddFilter : evenFilter;

return player.moveCards(
game.getBattlefield().getActivePermanents(
filter, source.getControllerId(), source, game
).stream().collect(Collectors.toSet()), Zone.HAND, source, game
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,6 @@ private DuskmournHouseOfHorrorCommander() {
cards.add(new SetCardInfo("Yavimaya Elder", 208, Rarity.COMMON, mage.cards.y.YavimayaElder.class));
cards.add(new SetCardInfo("Yedora, Grave Gardener", 209, Rarity.UNCOMMON, mage.cards.y.YedoraGraveGardener.class));
cards.add(new SetCardInfo("Zimone, Mystery Unraveler", 8, Rarity.MYTHIC, mage.cards.z.ZimoneMysteryUnraveler.class));
cards.add(new SetCardInfo("Zimone's Hypothesis", 15, Rarity.RARE, mage.cards.z.ZimonesHypothesis.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mage.filter.predicate.mageobject;

import mage.MageObject;
import mage.filter.predicate.Predicate;
import mage.game.Game;

/**
* @author werhsdnas
*/
public enum PowerParityPredicate implements Predicate<MageObject> {
EVEN(0),
ODD(1);
private final int parity;

PowerParityPredicate(int parity) {
this.parity = parity;
}

@Override
public boolean apply(MageObject input, Game game) {
return input.getPower().getValue() % 2 == parity;
}

@Override
public String toString() {
return "PowerParity" + super.toString();
}
}
Loading