[AFR] Implemented Ochre Jelly

This commit is contained in:
Evan Kranzler 2021-07-15 20:24:46 -04:00
parent f9bf84e6f6
commit d42fd2e505
4 changed files with 121 additions and 1 deletions

View file

@ -0,0 +1,107 @@
package mage.cards.o;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.keyword.TrampleAbility;
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.game.Game;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class OchreJelly extends CardImpl {
public OchreJelly(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}");
this.subtype.add(SubType.OOZE);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Ochre Jelly enters the battlefield with X +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance())));
// Split When Ochre Jelly dies, if it had two or more +1/+1 counters on it, create a token that's a copy of it at the beginning of the next end step. That token enters the battlefield with half that many +1/+1 counters on it, rounded down.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new DiesSourceTriggeredAbility(new CreateDelayedTriggeredAbilityEffect(
new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OchreJellyEffect())
)), OchreJellyCondition.instance, CardUtil.italicizeWithEmDash("Split")
+ "When {this} dies, if it had two or more +1/+1 counters on it, " +
"create a token that's a copy of it at the beginning of the next end step. " +
"That token enters the battlefield with half that many +1/+1 counters on it, rounded down."
));
}
private OchreJelly(final OchreJelly card) {
super(card);
}
@Override
public OchreJelly copy() {
return new OchreJelly(this);
}
}
enum OchreJellyCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) source.getEffects().get(0).getValue("permanentLeftBattlefield");
return permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) >= 2;
}
}
class OchreJellyEffect extends OneShotEffect {
OchreJellyEffect() {
super(Outcome.Benefit);
staticText = "create a token that's a copy of {this}";
}
private OchreJellyEffect(final OchreJellyEffect effect) {
super(effect);
}
@Override
public OchreJellyEffect copy() {
return new OchreJellyEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) getValue("permanentLeftBattlefield");
if (permanent == null) {
return false;
}
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
effect.setSavedPermanent(permanent);
effect.apply(game, source);
int counters = permanent.getCounters(game).getCount(CounterType.P1P1) / 2;
for (Permanent token : effect.getAddedPermanent()) {
permanent.addCounters(CounterType.P1P1.createInstance(counters), source.getControllerId(), source, game);
}
return true;
}
}

View file

@ -170,6 +170,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Mountain", 274, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Nadaar, Selfless Paladin", 27, Rarity.RARE, mage.cards.n.NadaarSelflessPaladin.class));
cards.add(new SetCardInfo("Neverwinter Dryad", 195, Rarity.COMMON, mage.cards.n.NeverwinterDryad.class));
cards.add(new SetCardInfo("Ochre Jelly", 196, Rarity.RARE, mage.cards.o.OchreJelly.class));
cards.add(new SetCardInfo("Old Gnawbone", 197, Rarity.MYTHIC, mage.cards.o.OldGnawbone.class));
cards.add(new SetCardInfo("Orb of Dragonkind", 157, Rarity.RARE, mage.cards.o.OrbOfDragonkind.class));
cards.add(new SetCardInfo("Orcus, Prince of Undeath", 229, Rarity.RARE, mage.cards.o.OrcusPrinceOfUndeath.class));

View file

@ -77,4 +77,9 @@ public class CreateDelayedTriggeredAbilityEffect extends OneShotEffect {
}
}
@Override
public void setValue(String key, Object value) {
ability.getEffects().setValue(key, value);
super.setValue(key, value);
}
}

View file

@ -49,6 +49,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
private boolean isntLegendary = false;
private int startingLoyalty = -1;
private final List<Ability> additionalAbilities = new ArrayList();
private Permanent savedPermanent = null;
public CreateTokenCopyTargetEffect(boolean useLKI) {
this();
@ -133,7 +134,9 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
targetId = getTargetPointer().getFirst(game, source);
}
Permanent permanent;
if (useLKI) {
if (savedPermanent != null) {
permanent = savedPermanent;
} else if (useLKI) {
permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
} else {
permanent = game.getPermanentOrLKIBattlefield(targetId);
@ -319,4 +322,8 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
public void addAdditionalAbilities(Ability... abilities) {
Arrays.stream(abilities).forEach(this.additionalAbilities::add);
}
public void setSavedPermanent(Permanent savedPermanent) {
this.savedPermanent = savedPermanent;
}
}