Implemented Yorvo, Lord of Garenbrig

This commit is contained in:
Evan Kranzler 2019-09-18 19:35:15 -04:00
parent 374827d717
commit 05f70e5320
2 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,101 @@
package mage.cards.y;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class YorvoLordOfGarenbrig extends CardImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent();
static {
filter.add(AnotherPredicate.instance);
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
public YorvoLordOfGarenbrig(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{G}{G}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.GIANT);
this.subtype.add(SubType.NOBLE);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
// Yorvo, Lord of Garenbrig enters the battlefield with four +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(
new AddCountersSourceEffect(CounterType.P1P1.createInstance(4)),
"{this} enters the battlefield with four +1/+1 counters on it"
));
// Whenever another green creature enters the battlefield under your control, put a +1/+1 counter on Yorvo. Then if that creature's power is greater than Yorvo's power, put another +1/+1 counter on Yorvo.
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(
Zone.BATTLEFIELD, new YorvoLordOfGarenbrigEffect(), filter, false, SetTargetPointer.PERMANENT,
"Whenever another green creature enters the battlefield under your control, " +
"put a +1/+1 counter on {this}. Then if that creature's power is greater than {this}'s power, " +
"put another +1/+1 counter on {this}."
));
}
private YorvoLordOfGarenbrig(final YorvoLordOfGarenbrig card) {
super(card);
}
@Override
public YorvoLordOfGarenbrig copy() {
return new YorvoLordOfGarenbrig(this);
}
}
class YorvoLordOfGarenbrigEffect extends OneShotEffect {
YorvoLordOfGarenbrigEffect() {
super(Outcome.Benefit);
}
private YorvoLordOfGarenbrigEffect(final YorvoLordOfGarenbrigEffect effect) {
super(effect);
}
@Override
public YorvoLordOfGarenbrigEffect copy() {
return new YorvoLordOfGarenbrigEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePerm = game.getPermanent(source.getSourceId());
if (sourcePerm == null) {
return false;
}
sourcePerm.addCounters(CounterType.P1P1.createInstance(), source, game);
Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source));
if (permanent == null) {
return true;
}
game.applyEffects();
if (permanent.getPower().getValue() > sourcePerm.getPower().getValue()) {
sourcePerm.addCounters(CounterType.P1P1.createInstance(), source, game);
}
return true;
}
}

View file

@ -249,6 +249,7 @@ public final class ThroneOfEldraine extends ExpansionSet {
cards.add(new SetCardInfo("Wolf's Quarry", 184, Rarity.COMMON, mage.cards.w.WolfsQuarry.class));
cards.add(new SetCardInfo("Workshop Elders", 318, Rarity.RARE, mage.cards.w.WorkshopElders.class));
cards.add(new SetCardInfo("Worthy Knight", 36, Rarity.RARE, mage.cards.w.WorthyKnight.class));
cards.add(new SetCardInfo("Yorvo, Lord of Garenbrig", 185, Rarity.RARE, mage.cards.y.YorvoLordOfGarenbrig.class));
// This is here to prevent the incomplete adventure implementation from causing problems and will be removed
cards.removeIf(setCardInfo -> AdventureCard.class.isAssignableFrom(setCardInfo.getCardClass()));