-
Notifications
You must be signed in to change notification settings - Fork 895
[SOC] Implement Zimone, Infinite Analyst #14861
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
Closed
+139
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| package mage.cards.z; | ||
|
|
||
| import mage.MageInt; | ||
| import mage.abilities.Ability; | ||
| import mage.abilities.SpellAbility; | ||
| import mage.abilities.common.SimpleStaticAbility; | ||
| import mage.abilities.common.SpellCastControllerTriggeredAbility; | ||
| import mage.abilities.effects.common.counter.AddCountersSourceEffect; | ||
| import mage.abilities.effects.common.cost.CostModificationEffectImpl; | ||
| import mage.cards.Card; | ||
| import mage.cards.CardImpl; | ||
| import mage.cards.CardSetInfo; | ||
| import mage.constants.*; | ||
| import mage.counters.CounterType; | ||
| import mage.filter.FilterSpell; | ||
| import mage.filter.predicate.mageobject.VariableManaCostPredicate; | ||
| import mage.game.Game; | ||
| import mage.game.events.GameEvent; | ||
| import mage.game.permanent.Permanent; | ||
| import mage.game.stack.Spell; | ||
| import mage.util.CardUtil; | ||
| import mage.watchers.Watcher; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author muz | ||
| */ | ||
| public final class ZimoneInfiniteAnalyst extends CardImpl { | ||
|
|
||
| private static final FilterSpell filter = new FilterSpell("spell with {X} in its mana cost"); | ||
|
|
||
| static { | ||
| filter.add(VariableManaCostPredicate.instance); | ||
| } | ||
|
|
||
| public ZimoneInfiniteAnalyst(UUID ownerId, CardSetInfo setInfo) { | ||
| super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{U}"); | ||
|
|
||
| this.supertype.add(SuperType.LEGENDARY); | ||
| this.subtype.add(SubType.HUMAN); | ||
| this.subtype.add(SubType.WIZARD); | ||
| this.power = new MageInt(0); | ||
| this.toughness = new MageInt(4); | ||
|
|
||
| // The first spell you cast with {X} in its mana cost each turn costs {1} less to cast for each +1/+1 counter on Zimone. | ||
| this.addAbility(new SimpleStaticAbility(new ZimoneCostReductionEffect()), new ZimoneInfiniteAnalystWatcher()); | ||
|
|
||
| // Whenever you cast your first spell with {X} in its mana cost each turn, put two +1/+1 counters on Zimone. | ||
| this.addAbility(new SpellCastControllerTriggeredAbility( | ||
| new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), filter, false | ||
| ).setTriggersLimitEachTurn(1)); | ||
| } | ||
|
|
||
| private ZimoneInfiniteAnalyst(final ZimoneInfiniteAnalyst card) { | ||
| super(card); | ||
| } | ||
|
|
||
| @Override | ||
| public ZimoneInfiniteAnalyst copy() { | ||
| return new ZimoneInfiniteAnalyst(this); | ||
| } | ||
| } | ||
|
|
||
| class ZimoneCostReductionEffect extends CostModificationEffectImpl { | ||
|
|
||
| ZimoneCostReductionEffect() { | ||
| super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); | ||
| staticText = "The first spell you cast with {X} in its mana cost each turn costs {1} less to cast for each +1/+1 counter on {this}"; | ||
| } | ||
|
|
||
| private ZimoneCostReductionEffect(final ZimoneCostReductionEffect effect) { | ||
| super(effect); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean apply(Game game, Ability source, Ability abilityToModify) { | ||
| Permanent sourcePermanent = game.getPermanent(source.getSourceId()); | ||
|
Contributor
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. source.getSourcePermanentIfItStillExists(game) |
||
| if (sourcePermanent != null) { | ||
| int counters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); | ||
| if (counters > 0) { | ||
| CardUtil.reduceCost(abilityToModify, counters); | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean applies(Ability abilityToModify, Ability source, Game game) { | ||
| if (!(abilityToModify instanceof SpellAbility) | ||
| || !abilityToModify.isControlledBy(source.getControllerId())) { | ||
| return false; | ||
| } | ||
| Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); | ||
| if (spellCard == null || !spellCard.getManaCost().containsX()) { | ||
| return false; | ||
| } | ||
| ZimoneInfiniteAnalystWatcher watcher = game.getState().getWatcher(ZimoneInfiniteAnalystWatcher.class); | ||
| return watcher != null && watcher.getFirstXSpell(source.getControllerId()) == null; | ||
| } | ||
|
|
||
| @Override | ||
| public ZimoneCostReductionEffect copy() { | ||
| return new ZimoneCostReductionEffect(this); | ||
| } | ||
| } | ||
|
|
||
| class ZimoneInfiniteAnalystWatcher extends Watcher { | ||
|
|
||
| private final Map<UUID, UUID> firstXSpellPerPlayer = new HashMap<>(); | ||
|
|
||
| ZimoneInfiniteAnalystWatcher() { | ||
| super(WatcherScope.GAME); | ||
| } | ||
|
|
||
| @Override | ||
| public void watch(GameEvent event, Game game) { | ||
| if (event.getType() != GameEvent.EventType.SPELL_CAST) { | ||
| return; | ||
| } | ||
| Spell spell = game.getStack().getSpell(event.getTargetId()); | ||
| if (spell != null && spell.getSpellAbility().getManaCostsToPay().containsX()) { | ||
| firstXSpellPerPlayer.putIfAbsent(event.getPlayerId(), spell.getId()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void reset() { | ||
| super.reset(); | ||
| firstXSpellPerPlayer.clear(); | ||
| } | ||
|
|
||
| UUID getFirstXSpell(UUID playerId) { | ||
| return firstXSpellPerPlayer.get(playerId); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this correct? Shouldn't it also be checking the watcher? Example, you cast a spell with {X} in mana cost, then you cast Zimone, then you cast another. Ability hasn't triggered yet but it still shouldn't.
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.
Ah good point, I had this using the watcher previously and thought "oh, can't we just do this to limit it". Turns out that sequence of events was why it made sense to go with the prior implementation I had 🤦