From 06f5fe0cffba51bae93bcecd645913e754da8ff2 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 28 May 2025 22:03:11 -0400 Subject: [PATCH] [FIN] Implement Excalibur II --- Mage.Sets/src/mage/cards/e/ExcaliburII.java | 52 +++++++++++++++++++ Mage.Sets/src/mage/sets/FinalFantasy.java | 2 + .../continuous/BoostEquippedEffect.java | 36 +++++++------ 3 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/e/ExcaliburII.java diff --git a/Mage.Sets/src/mage/cards/e/ExcaliburII.java b/Mage.Sets/src/mage/cards/e/ExcaliburII.java new file mode 100644 index 00000000000..c37c86a9e82 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ExcaliburII.java @@ -0,0 +1,52 @@ +package mage.cards.e; + +import mage.abilities.common.GainLifeControllerTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.CountersSourceCount; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.EquipAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.counters.CounterType; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ExcaliburII extends CardImpl { + + private static final DynamicValue xValue = new CountersSourceCount(CounterType.CHARGE); + + public ExcaliburII(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.EQUIPMENT); + + // Whenever you gain life, put a charge counter on Excalibur II. + this.addAbility(new GainLifeControllerTriggeredAbility( + new AddCountersSourceEffect(CounterType.CHARGE.createInstance()) + )); + + // Equipped creature gets +1/+1 for each charge counter on Excalibur II. + this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(xValue, xValue))); + + // Equip {3} + this.addAbility(new EquipAbility(3)); + } + + private ExcaliburII(final ExcaliburII card) { + super(card); + } + + @Override + public ExcaliburII copy() { + return new ExcaliburII(this); + } +} diff --git a/Mage.Sets/src/mage/sets/FinalFantasy.java b/Mage.Sets/src/mage/sets/FinalFantasy.java index 30a8db61f4f..a5941459139 100644 --- a/Mage.Sets/src/mage/sets/FinalFantasy.java +++ b/Mage.Sets/src/mage/sets/FinalFantasy.java @@ -188,6 +188,8 @@ public final class FinalFantasy extends ExpansionSet { cards.add(new SetCardInfo("Esper Terra", 511, Rarity.MYTHIC, mage.cards.e.EsperTerra.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Ether", 53, Rarity.UNCOMMON, mage.cards.e.Ether.class)); cards.add(new SetCardInfo("Evil Reawakened", 98, Rarity.UNCOMMON, mage.cards.e.EvilReawakened.class)); + cards.add(new SetCardInfo("Excalibur II", 257, Rarity.RARE, mage.cards.e.ExcaliburII.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Excalibur II", 352, Rarity.RARE, mage.cards.e.ExcaliburII.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Fang, Fearless l'Cie", 381, Rarity.UNCOMMON, mage.cards.f.FangFearlessLCie.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Fang, Fearless l'Cie", 446, Rarity.UNCOMMON, mage.cards.f.FangFearlessLCie.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Fang, Fearless l'Cie", 526, Rarity.UNCOMMON, mage.cards.f.FangFearlessLCie.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostEquippedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostEquippedEffect.java index 2cc3ce3b1bb..70e9badbd92 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostEquippedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostEquippedEffect.java @@ -1,19 +1,20 @@ - package mage.abilities.effects.common.continuous; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; import mage.util.CardUtil; +import java.util.Optional; + /** * @author BetaSteward_at_googlemail.com */ @@ -31,14 +32,14 @@ public class BoostEquippedEffect extends ContinuousEffectImpl { this(StaticValue.get(power), StaticValue.get(toughness), duration); } - public BoostEquippedEffect(DynamicValue powerDynamicValue, DynamicValue toughnessDynamicValue) { - this(powerDynamicValue, toughnessDynamicValue, Duration.WhileOnBattlefield); + public BoostEquippedEffect(DynamicValue power, DynamicValue toughness) { + this(power, toughness, Duration.WhileOnBattlefield); } - public BoostEquippedEffect(DynamicValue powerDynamicValue, DynamicValue toughnessDynamicValue, Duration duration) { + public BoostEquippedEffect(DynamicValue power, DynamicValue toughness, Duration duration) { super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); - this.power = powerDynamicValue; - this.toughness = toughnessDynamicValue; + this.power = power; + this.toughness = toughness; if (duration == Duration.EndOfTurn) { fixedTarget = true; } @@ -70,21 +71,22 @@ public class BoostEquippedEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - Permanent creature = null; + Permanent creature; if (fixedTarget) { creature = game.getPermanent(getTargetPointer().getFirst(game, source)); } else { - Permanent equipment = game.getPermanent(source.getSourceId()); - if (equipment != null && equipment.getAttachedTo() != null) { - creature = game.getPermanent(equipment.getAttachedTo()); - } + creature = Optional + .ofNullable(source) + .map(Ability::getSourceId) + .map(game::getPermanent) + .map(Permanent::getAttachedTo) + .map(game::getPermanent) + .orElse(null); } - if (creature != null) { creature.addPower(power.calculate(game, source, this)); creature.addToughness(toughness.calculate(game, source, this)); } - return true; } }