This commit is contained in:
Jeff Wadsworth 2021-11-11 16:35:15 -06:00
parent 24fab24440
commit 0600c0e7d5
2 changed files with 23 additions and 12 deletions

View file

@ -47,9 +47,9 @@ public final class OchreJelly extends CardImpl {
new DiesSourceTriggeredAbility(new CreateDelayedTriggeredAbilityEffect( new DiesSourceTriggeredAbility(new CreateDelayedTriggeredAbilityEffect(
new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OchreJellyEffect()) new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OchreJellyEffect())
)), OchreJellyCondition.instance, CardUtil.italicizeWithEmDash("Split") )), OchreJellyCondition.instance, CardUtil.italicizeWithEmDash("Split")
+ "When {this} dies, if it had two or more +1/+1 counters on it, " + + "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. " + + "create a token that's a copy of it at the beginning of the next end step. "
"The token enters the battlefield with half that many +1/+1 counters on it, rounded down." + "The token enters the battlefield with half that many +1/+1 counters on it, rounded down."
)); ));
} }
@ -95,13 +95,10 @@ class OchreJellyEffect extends OneShotEffect {
if (permanent == null) { if (permanent == null) {
return false; return false;
} }
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(); final int counters = permanent.getCounters(game).getCount(CounterType.P1P1) / 2;
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(CounterType.P1P1, counters);
effect.setSavedPermanent(permanent); effect.setSavedPermanent(permanent);
effect.apply(game, source); 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; return true;
} }
} }

View file

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.counters.CounterType;
/** /**
* @author LevelX2 * @author LevelX2
@ -50,6 +51,8 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
private int startingLoyalty = -1; private int startingLoyalty = -1;
private final List<Ability> additionalAbilities = new ArrayList(); private final List<Ability> additionalAbilities = new ArrayList();
private Permanent savedPermanent = null; private Permanent savedPermanent = null;
private CounterType counter;
private int numberOfCounters;
public CreateTokenCopyTargetEffect(boolean useLKI) { public CreateTokenCopyTargetEffect(boolean useLKI) {
this(); this();
@ -60,6 +63,12 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
this((UUID) null); this((UUID) null);
} }
public CreateTokenCopyTargetEffect(CounterType counter, int numberOfCounters) {
this((UUID) null);
this.counter = counter;
this.numberOfCounters = numberOfCounters;
}
public CreateTokenCopyTargetEffect(UUID playerId) { public CreateTokenCopyTargetEffect(UUID playerId) {
this(playerId, null, false); this(playerId, null, false);
} }
@ -73,11 +82,11 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
} }
/** /**
* @param playerId null the token is controlled/owned by the * @param playerId null the token is controlled/owned by the controller of
* controller of the source ability * the source ability
* @param additionalCardType the token gains this card type in addition * @param additionalCardType the token gains this card type in addition
* @param hasHaste the token gains haste * @param hasHaste the token gains haste
* @param number number of tokens to put into play * @param number number of tokens to put into play
* @param tapped * @param tapped
* @param attacking * @param attacking
*/ */
@ -220,6 +229,11 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
Permanent tokenPermanent = game.getPermanent(tokenId); Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) { if (tokenPermanent != null) {
addedTokenPermanents.add(tokenPermanent); addedTokenPermanents.add(tokenPermanent);
// add counters if necessary ie Ochre Jelly
if (counter != null
&& numberOfCounters > 0) {
tokenPermanent.addCounters(counter.createInstance(numberOfCounters), source.getControllerId(), source, game);
}
} }
} }
return true; return true;