From c1595b0358a38058f1609e0b3a010c4a40d3606a Mon Sep 17 00:00:00 2001 From: DeepCrimson <98864333+DeepCrimson@users.noreply.github.com> Date: Mon, 23 May 2022 07:29:21 -0700 Subject: [PATCH] Fix Unlicensed Hearse (#8985) Co-authored-by: DeepCrimson --- .../src/mage/cards/u/UnlicensedHearse.java | 119 +++++++++--------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/Mage.Sets/src/mage/cards/u/UnlicensedHearse.java b/Mage.Sets/src/mage/cards/u/UnlicensedHearse.java index 948f3c11a3..b203a2ea49 100644 --- a/Mage.Sets/src/mage/cards/u/UnlicensedHearse.java +++ b/Mage.Sets/src/mage/cards/u/UnlicensedHearse.java @@ -19,81 +19,80 @@ import mage.constants.Duration; import mage.constants.SubType; import mage.constants.Zone; import mage.filter.StaticFilters; +import mage.game.ExileZone; import mage.game.Game; import mage.target.common.TargetCardInASingleGraveyard; import mage.util.CardUtil; -import java.util.HashSet; -import java.util.Objects; -import java.util.Optional; import java.util.UUID; /** * @author TheElk801 */ -public final class UnlicensedHearse extends CardImpl { +enum UnlicensedHearseValue implements DynamicValue { + instance; - private static final Hint hint = new ValueHint("Cards exiled", UnlicensedHearseValue.instance); - - public UnlicensedHearse(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); - - this.subtype.add(SubType.VEHICLE); - this.power = new MageInt(0); - this.toughness = new MageInt(0); - - // {T}: Exile up to two target cards from a single graveyard. - Ability ability = new SimpleActivatedAbility(new ExileTargetForSourceEffect(), new TapSourceCost()); - ability.addTarget(new TargetCardInASingleGraveyard( - 0, 2, StaticFilters.FILTER_CARD_CARDS - )); - this.addAbility(ability); - - // Unlicensed Hearse's power and toughness are each equal to the number of cards exiled with it. - this.addAbility(new SimpleStaticAbility( - Zone.ALL, - new SetPowerToughnessSourceEffect( - UnlicensedHearseValue.instance, Duration.Custom - ) - ).addHint(hint)); - - // Crew 2 - this.addAbility(new CrewAbility(2)); + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + ExileZone cardsExiledWithUnlicensedHearse = + game.getExile() + .getExileZone( + CardUtil.getExileZoneId( + game, + sourceAbility.getSourceId(), + game.getState().getZoneChangeCounter(sourceAbility.getSourceId()))); + if (cardsExiledWithUnlicensedHearse == null) { + return 0; } - private UnlicensedHearse(final UnlicensedHearse card) { - super(card); - } + return cardsExiledWithUnlicensedHearse.size(); + } - @Override - public UnlicensedHearse copy() { - return new UnlicensedHearse(this); - } + @Override + public UnlicensedHearseValue copy() { + return this; + } + + @Override + public String getMessage() { + return "cards exiled with it"; + } } -enum UnlicensedHearseValue implements DynamicValue { - instance; +public final class UnlicensedHearse extends CardImpl { - @Override - public int calculate(Game game, Ability sourceAbility, Effect effect) { - return Optional.of(game - .getExile() - .getExileZone(CardUtil.getExileZoneId( - game, sourceAbility.getSourceId(), - game.getState().getZoneChangeCounter(sourceAbility.getSourceId()) - ))) - .filter(Objects::nonNull) - .map(HashSet::size) - .orElse(0); - } + private static final Hint hint = new ValueHint("Cards exiled", UnlicensedHearseValue.instance); - @Override - public UnlicensedHearseValue copy() { - return this; - } + public UnlicensedHearse(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[] {CardType.ARTIFACT}, "{2}"); - @Override - public String getMessage() { - return "cards exiled with it"; - } -} \ No newline at end of file + this.subtype.add(SubType.VEHICLE); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // {T}: Exile up to two target cards from a single graveyard. + Ability ability = + new SimpleActivatedAbility(new ExileTargetForSourceEffect(), new TapSourceCost()); + ability.addTarget(new TargetCardInASingleGraveyard(0, 2, StaticFilters.FILTER_CARD_CARDS)); + this.addAbility(ability); + + // Unlicensed Hearse's power and toughness are each equal to the number of cards exiled with it. + this.addAbility( + new SimpleStaticAbility( + Zone.ALL, + new SetPowerToughnessSourceEffect(UnlicensedHearseValue.instance, Duration.Custom)) + .addHint(hint)); + + // Crew 2 + this.addAbility(new CrewAbility(2)); + } + + private UnlicensedHearse(final UnlicensedHearse card) { + super(card); + } + + @Override + public UnlicensedHearse copy() { + return new UnlicensedHearse(this); + } +}