From 9c0dfd1bbecae4a975830b227fd2b2cdeaf4636e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 19 Sep 2022 20:27:52 -0400 Subject: [PATCH] [DMC] Implemented Tetsuo, Imperial Champion --- .../mage/cards/t/TetsuoImperialChampion.java | 131 ++++++++++++++++++ .../mage/sets/DominariaUnitedCommander.java | 1 + 2 files changed, 132 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TetsuoImperialChampion.java diff --git a/Mage.Sets/src/mage/cards/t/TetsuoImperialChampion.java b/Mage.Sets/src/mage/cards/t/TetsuoImperialChampion.java new file mode 100644 index 00000000000..f8473ff145f --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TetsuoImperialChampion.java @@ -0,0 +1,131 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.condition.common.EquippedSourceCondition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.cost.CastFromHandForFreeEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterCard; +import mage.filter.common.FilterInstantOrSorceryCard; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetAnyTarget; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TetsuoImperialChampion extends CardImpl { + + private static final Hint hint = new ValueHint( + "Greatest mana value of attached equipment", TetsuoImperialChampionValue.instance + ); + private static final FilterCard filter = new FilterInstantOrSorceryCard( + "an instant or sorcery spell from your hand with mana value " + + "less than or equal to the highest mana value among Equipment attached to {this}" + ); + + static { + filter.add(TetsuoImperialChampionPredicate.instance); + } + + public TetsuoImperialChampion(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{B}{R}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SAMURAI); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Whenever Tetsuo, Imperial Champion attacks, if it's equipped, choose one -- + // * Tetsuo deals damage equal to the highest mana value among Equipment attached to it to any target. + Ability ability = new ConditionalInterveningIfTriggeredAbility( + new AttacksTriggeredAbility(new DamageTargetEffect( + TetsuoImperialChampionValue.instance, "it" + ).setText("{this} deals damage equal to the highest mana value " + + "among Equipment attached to it to any target") + ).setTriggerPhrase("Whenever {this} attacks, if it's equipped, "), + EquippedSourceCondition.instance, null + ); + ability.addTarget(new TargetAnyTarget()); + + // * You may cast an instant or sorcery spell from your hand with mana value less than or equal to the highest mana value among Equipment attached to Tetsuo without paying its mana cost. + ability.addMode(new Mode(new CastFromHandForFreeEffect(filter))); + this.addAbility(ability); + } + + private TetsuoImperialChampion(final TetsuoImperialChampion card) { + super(card); + } + + @Override + public TetsuoImperialChampion copy() { + return new TetsuoImperialChampion(this); + } +} + +enum TetsuoImperialChampionPredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + return input + .getObject() + .getManaValue() + <= TetsuoImperialChampionValue + .instance + .calculate(game, input.getSource(), null); + } +} + +enum TetsuoImperialChampionValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + Permanent permanent = sourceAbility.getSourcePermanentOrLKI(game); + return permanent == null ? 0 : permanent + .getAttachments() + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .filter(p -> p.hasSubtype(SubType.EQUIPMENT, game)) + .mapToInt(MageObject::getManaValue) + .max() + .orElse(0); + } + + @Override + public TetsuoImperialChampionValue copy() { + return this; + } + + @Override + public String getMessage() { + return ""; + } + + @Override + public String toString() { + return "1"; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java index a1058de9530..02b27bf88d0 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java +++ b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java @@ -186,6 +186,7 @@ public final class DominariaUnitedCommander extends ExpansionSet { cards.add(new SetCardInfo("Terminate", 172, Rarity.COMMON, mage.cards.t.Terminate.class)); cards.add(new SetCardInfo("Terramorphic Expanse", 239, Rarity.COMMON, mage.cards.t.TerramorphicExpanse.class)); cards.add(new SetCardInfo("Teshar, Ancestor's Apostle", 105, Rarity.RARE, mage.cards.t.TesharAncestorsApostle.class)); + cards.add(new SetCardInfo("Tetsuo, Imperial Champion", 44, Rarity.MYTHIC, mage.cards.t.TetsuoImperialChampion.class)); cards.add(new SetCardInfo("The Circle of Loyalty", 98, Rarity.MYTHIC, mage.cards.t.TheCircleOfLoyalty.class)); cards.add(new SetCardInfo("The Ever-Changing 'Dane", 30, Rarity.RARE, mage.cards.t.TheEverChangingDane.class)); cards.add(new SetCardInfo("The Mana Rig", 28, Rarity.MYTHIC, mage.cards.t.TheManaRig.class, NON_FULL_USE_VARIOUS));