-
Notifications
You must be signed in to change notification settings - Fork 786
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
[ICE] Implement Kjeldoran Guard #11184
Changes from 2 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,149 @@ | ||
package mage.cards.k; | ||
|
||
import mage.MageInt; | ||
import mage.MageObjectReference; | ||
import mage.abilities.Ability; | ||
import mage.abilities.DelayedTriggeredAbility; | ||
import mage.abilities.condition.CompoundCondition; | ||
import mage.abilities.condition.InvertCondition; | ||
import mage.abilities.condition.common.DefendingPlayerControlsNoSourceCondition; | ||
import mage.abilities.condition.common.IsPhaseCondition; | ||
import mage.abilities.costs.common.TapSourceCost; | ||
import mage.abilities.decorator.ConditionalActivatedAbility; | ||
import mage.abilities.effects.OneShotEffect; | ||
import mage.abilities.effects.common.SacrificeSourceEffect; | ||
import mage.abilities.effects.common.continuous.BoostTargetEffect; | ||
import mage.cards.Card; | ||
import mage.cards.CardImpl; | ||
import mage.cards.CardSetInfo; | ||
import mage.constants.*; | ||
import mage.filter.common.FilterLandPermanent; | ||
import mage.game.Game; | ||
import mage.game.events.GameEvent; | ||
import mage.game.permanent.Permanent; | ||
import mage.target.common.TargetCreaturePermanent; | ||
import mage.target.targetpointer.FixedTarget; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author Alex-Vasile, Susucr | ||
*/ | ||
public final class KjeldoranGuard extends CardImpl { | ||
|
||
private static final FilterLandPermanent filter = new FilterLandPermanent(); | ||
|
||
static { | ||
filter.add(SuperType.SNOW.getPredicate()); | ||
} | ||
|
||
public KjeldoranGuard(UUID ownerId, CardSetInfo setInfo) { | ||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); | ||
|
||
this.subtype.add(SubType.HUMAN); | ||
this.subtype.add(SubType.SOLDIER); | ||
this.power = new MageInt(1); | ||
this.toughness = new MageInt(1); | ||
|
||
// {T}: Target creature gets +1/+1 until end of turn. When that creature leaves the battlefield this turn, sacrifice Kjeldoran Guard. Activate only during combat and only if defending player controls no snow lands. | ||
CompoundCondition condition = new CompoundCondition( | ||
new IsPhaseCondition(TurnPhase.COMBAT, false), // Only during combat | ||
new InvertCondition(new DefendingPlayerControlsNoSourceCondition(filter)) // Only if defending player controls no snow land | ||
); | ||
|
||
Ability ability = new ConditionalActivatedAbility( | ||
Zone.BATTLEFIELD, | ||
new KjeldoranGuardEffect(), | ||
new TapSourceCost(), | ||
condition, | ||
"{T}: Target creature gets +1/+1 until end of turn. " | ||
+ "When that creature leaves the battlefield this turn, sacrifice {this}. " | ||
+ "Activate only during combat and only if defending player controls no snow lands." | ||
); | ||
ability.addTarget(new TargetCreaturePermanent()); | ||
this.addAbility(ability); | ||
} | ||
|
||
private KjeldoranGuard(final KjeldoranGuard card) { super(card); } | ||
|
||
@Override | ||
public Card copy() { | ||
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. Covariant return |
||
return new KjeldoranGuard(this); | ||
} | ||
} | ||
|
||
class KjeldoranGuardEffect extends OneShotEffect { | ||
|
||
KjeldoranGuardEffect() { | ||
super(Outcome.BoostCreature); | ||
staticText = "Target creature gets +1/+1 until end of turn." | ||
+ "When that creature leaves the battlefield this turn, sacrifice {this}." | ||
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. Miss space |
||
+ "Activate only during combat and only if defending player controls no snow lands."; | ||
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. I don't think the activation restriction should be part of the effect text |
||
} | ||
|
||
private KjeldoranGuardEffect(KjeldoranGuardEffect effect) { | ||
super(effect); | ||
} | ||
|
||
@Override | ||
public KjeldoranGuardEffect copy() { | ||
return new KjeldoranGuardEffect(this); | ||
} | ||
|
||
@Override | ||
public boolean apply(Game game, Ability source) { | ||
UUID targetId = source.getFirstTarget(); | ||
Permanent targetPermanent = game.getPermanent(targetId); | ||
Susucre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (game.getPermanent(targetId) == null) { | ||
return false; | ||
} | ||
|
||
// Target creature gets +1/+1 until end of turn. | ||
BoostTargetEffect buffEffect = new BoostTargetEffect(1, 1, Duration.EndOfTurn); | ||
buffEffect.setTargetPointer(new FixedTarget(targetId, game)); | ||
game.addEffect(buffEffect, source); | ||
|
||
// When that creature leaves the battlefield this turn, sacrifice Kjeldoran Guard. | ||
game.addDelayedTriggeredAbility( | ||
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. Please test- if you flicker Kjeldoran Guard, shouldn't have to sacrifice it. 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. oh right that should be using MOR 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. Actually that was already correct. I did replace the UUID of the target to a MOR, but that should not really matter with
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. Oh nevermind, there is indeed an issue if you blink the Guard in response to tapping it. |
||
new KjeldoranGuardDelayedTriggeredAbility( | ||
new MageObjectReference(targetPermanent, game) | ||
), source | ||
); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
class KjeldoranGuardDelayedTriggeredAbility extends DelayedTriggeredAbility { | ||
|
||
private final MageObjectReference mor; | ||
|
||
KjeldoranGuardDelayedTriggeredAbility(MageObjectReference mor) { | ||
super(new SacrificeSourceEffect(), Duration.EndOfTurn, true); | ||
this.mor = mor; | ||
} | ||
|
||
private KjeldoranGuardDelayedTriggeredAbility(final KjeldoranGuardDelayedTriggeredAbility ability) { | ||
super(ability); | ||
this.mor = ability.mor; | ||
} | ||
|
||
@Override | ||
public KjeldoranGuardDelayedTriggeredAbility copy() { | ||
return new KjeldoranGuardDelayedTriggeredAbility(this); | ||
} | ||
|
||
@Override | ||
public boolean checkEventType(GameEvent event, Game game) { | ||
return event.getType() == GameEvent.EventType.ZONE_CHANGE; | ||
} | ||
|
||
@Override | ||
public boolean checkTrigger(GameEvent event, Game game) { | ||
Permanent permanentLeaving = game.getPermanentOrLKIBattlefield(event.getTargetId()); | ||
return permanentLeaving != null && mor.equals(new MageObjectReference(permanentLeaving, game)); | ||
} | ||
|
||
@Override | ||
public String getRule() { return "sacrifice {this}"; } | ||
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. Hm, this doesn't feel quite right but not sure why, can you check the delayed trigger displays with correct text on the stack? 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. 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. will capitalize 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. Yeah ideally the trigger phrase should be part of it (but for sure lots of these have wrong text all over the codebase). So not required to fix, just a nice to have. Also it doesn't get automatically capitalized which is a separate bug. 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. I can replace it with "When that creature leaves the battlefield, sacrifice Kjeldoran Guard"? 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. Should be "When that creature leaves the battlefield this turn, sacrifice {this}." 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. Just for a discussion point, got a comment from theelk801 last month that reflexive triggers can have their trigger left out. #10866 (comment) 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. That's a good question - my initial reaction is I disagree but I should double check how it works. 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. It's more important to have clarity on delayed, the reflexive at least occur in close proximity to their source |
||
} |
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.
Style