[DMC] Implemented Tetsuo, Imperial Champion

This commit is contained in:
Evan Kranzler 2022-09-19 20:27:52 -04:00
parent 8af7758744
commit 9c0dfd1bbe
2 changed files with 132 additions and 0 deletions

View file

@ -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<Card> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Card> 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";
}
}

View file

@ -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));