-
Notifications
You must be signed in to change notification settings - Fork 783
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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}"); | ||
|
||
// 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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
//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 |
---|---|---|
@@ -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(); | ||
} | ||
} |
There was a problem hiding this comment.
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