[LTC] Implement Treebeard, Gracious Host

This commit is contained in:
theelk801 2023-06-19 19:24:35 -04:00
parent 2e9eb7fb33
commit 536c0ddb21
2 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,98 @@
package mage.cards.t;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.GainLifeControllerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.WardAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.FoodToken;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class TreebeardGraciousHost extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("Halfling or Treefolk");
static {
filter.add(Predicates.or(
SubType.HALFLING.getPredicate(),
SubType.TREEFOLK.getPredicate()
));
}
public TreebeardGraciousHost(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.TREEFOLK);
this.power = new MageInt(0);
this.toughness = new MageInt(5);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Ward {2}
this.addAbility(new WardAbility(new ManaCostsImpl<>("{2}")));
// When Treebeard, Gracious Host enters the battlefield, create two Food tokens.
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new FoodToken(), 2)));
// Whenever you gain life, put that many +1/+1 counters on target Halfling or Treefolk.
Ability ability = new GainLifeControllerTriggeredAbility(new TreebeardGraciousHostEffect());
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);
}
private TreebeardGraciousHost(final TreebeardGraciousHost card) {
super(card);
}
@Override
public TreebeardGraciousHost copy() {
return new TreebeardGraciousHost(this);
}
}
class TreebeardGraciousHostEffect extends OneShotEffect {
TreebeardGraciousHostEffect() {
super(Outcome.Benefit);
staticText = "put that many +1/+1 counters on target Halfling or Treefolk";
}
private TreebeardGraciousHostEffect(final TreebeardGraciousHostEffect effect) {
super(effect);
}
@Override
public TreebeardGraciousHostEffect copy() {
return new TreebeardGraciousHostEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
int amount = (Integer) getValue("gainedLife");
return permanent != null && amount > 0
&& permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
}
}

View file

@ -244,6 +244,7 @@ public final class TalesOfMiddleEarthCommander extends ExpansionSet {
cards.add(new SetCardInfo("Trap the Trespassers", 25, Rarity.RARE, mage.cards.t.TrapTheTrespassers.class));
cards.add(new SetCardInfo("Travel Through Caradhras", 44, Rarity.RARE, mage.cards.t.TravelThroughCaradhras.class));
cards.add(new SetCardInfo("Treasure Nabber", 230, Rarity.RARE, mage.cards.t.TreasureNabber.class));
cards.add(new SetCardInfo("Treebeard, Gracious Host", 73, Rarity.RARE, mage.cards.t.TreebeardGraciousHost.class));
cards.add(new SetCardInfo("Unbreakable Formation", 179, Rarity.RARE, mage.cards.u.UnbreakableFormation.class));
cards.add(new SetCardInfo("Underground River", 342, Rarity.RARE, mage.cards.u.UndergroundRiver.class));
cards.add(new SetCardInfo("Urborg, Tomb of Yawgmoth", 375, Rarity.MYTHIC, mage.cards.u.UrborgTombOfYawgmoth.class));