[CLB] Implemented Greatsword of Tyr

This commit is contained in:
Evan Kranzler 2022-05-25 09:00:47 -04:00
parent 79b8aece5c
commit d45cb1b705
2 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,82 @@
package mage.cards.g;
import mage.abilities.Ability;
import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.effects.common.counter.AddCountersAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class GreatswordOfTyr extends CardImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent("creature defending player controls");
static {
filter.add(GreatswordOfTyrPredicate.instance);
}
public GreatswordOfTyr(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{W}");
this.subtype.add(SubType.EQUIPMENT);
// Whenever equipped creature attacks, put a +1/+1 counter on it and tap up to one target creature defending player controls.
Ability ability = new AttacksAttachedTriggeredAbility(
new AddCountersAttachedEffect(CounterType.P1P1.createInstance(), "it")
);
ability.addEffect(new TapTargetEffect().concatBy("and"));
ability.addTarget(new TargetPermanent(0, 1, filter));
this.addAbility(ability);
// Equip {W}
this.addAbility(new EquipAbility(Outcome.AddAbility, new ManaCostsImpl<>("{W}")));
}
private GreatswordOfTyr(final GreatswordOfTyr card) {
super(card);
}
@Override
public GreatswordOfTyr copy() {
return new GreatswordOfTyr(this);
}
}
enum GreatswordOfTyrPredicate implements ObjectSourcePlayerPredicate<Permanent> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
return Optional.of(input.getSource().getSourcePermanentOrLKI(game))
.filter(Objects::nonNull)
.map(Permanent::getAttachedTo)
.map(uuid -> game.getCombat().getDefendingPlayerId(uuid, game))
.map(input.getObject()::isControlledBy)
.orElse(false);
}
@Override
public String toString() {
return "";
}
}

View file

@ -90,6 +90,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
cards.add(new SetCardInfo("Ghost Lantern", 128, Rarity.UNCOMMON, mage.cards.g.GhostLantern.class));
cards.add(new SetCardInfo("Goggles of Night", 74, Rarity.COMMON, mage.cards.g.GogglesOfNight.class));
cards.add(new SetCardInfo("Gorion, Wise Mentor", 276, Rarity.RARE, mage.cards.g.GorionWiseMentor.class));
cards.add(new SetCardInfo("Greatsword of Tyr", 22, Rarity.COMMON, mage.cards.g.GreatswordOfTyr.class));
cards.add(new SetCardInfo("Gut, True Soul Zealot", 180, Rarity.UNCOMMON, mage.cards.g.GutTrueSoulZealot.class));
cards.add(new SetCardInfo("Hammers of Moradin", 25, Rarity.UNCOMMON, mage.cards.h.HammersOfMoradin.class));
cards.add(new SetCardInfo("Hardy Outlander", 235, Rarity.UNCOMMON, mage.cards.h.HardyOutlander.class));