mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
fix #11626 (Runadi, Behemoth Caller)
This commit is contained in:
parent
2232b9b90c
commit
7d821ef922
2 changed files with 82 additions and 54 deletions
|
|
@ -2,8 +2,8 @@ package mage.cards.r;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
|
|
@ -13,12 +13,13 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
|
|
@ -32,8 +33,12 @@ public final class RunadiBehemothCaller extends CardImpl {
|
|||
|
||||
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("creatures with three or more +1/+1 counters on them");
|
||||
|
||||
private static final FilterSpell filterSpell = new FilterSpell("a creature spell with mana value 5 or greater");
|
||||
|
||||
static {
|
||||
filter.add(RunadiBehemothCallerPredicate.instance);
|
||||
filterSpell.add(CardType.CREATURE.getPredicate());
|
||||
filterSpell.add(new ManaValuePredicate(ComparisonType.OR_GREATER, 5));
|
||||
}
|
||||
|
||||
public RunadiBehemothCaller(UUID ownerId, CardSetInfo setInfo) {
|
||||
|
|
@ -46,7 +51,8 @@ public final class RunadiBehemothCaller extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// Whenever you cast a creature spell with mana value 5 or greater, that creature enters the battlefield with X additional +1/+1 counters on it, where X is its mana value minus 4.
|
||||
this.addAbility(new RunadiBehemothCallerTriggeredAbility());
|
||||
this.addAbility(new SpellCastControllerTriggeredAbility(new RunadiBehemothCallerCounterEffect(), filterSpell,
|
||||
false, SetTargetPointer.SPELL));
|
||||
|
||||
// Creature you control with three or more +1/+1 counters on them have haste.
|
||||
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
|
||||
|
|
@ -68,61 +74,14 @@ public final class RunadiBehemothCaller extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class RunadiBehemothCallerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
RunadiBehemothCallerTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, null, false);
|
||||
}
|
||||
|
||||
private RunadiBehemothCallerTriggeredAbility(final RunadiBehemothCallerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunadiBehemothCallerTriggeredAbility copy() {
|
||||
return new RunadiBehemothCallerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.CAST_SPELL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.isCreature(game)) {
|
||||
int manaValue = spell.getManaValue();
|
||||
if (manaValue >= 5) {
|
||||
this.addEffect(new RunadiBehemothCallerCounterEffect(spell.getSourceId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you cast a creature spell with mana value 5 or greater," +
|
||||
" that creature enters the battlefield with X additional +1/+1 counters on it," +
|
||||
" where X is its mana value minus 4.";
|
||||
}
|
||||
}
|
||||
|
||||
class RunadiBehemothCallerCounterEffect extends ReplacementEffectImpl {
|
||||
|
||||
private final UUID spellCastId;
|
||||
|
||||
RunadiBehemothCallerCounterEffect(UUID spellCastId) {
|
||||
RunadiBehemothCallerCounterEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.BoostCreature);
|
||||
this.spellCastId = spellCastId;
|
||||
}
|
||||
|
||||
private RunadiBehemothCallerCounterEffect(final RunadiBehemothCallerCounterEffect effect) {
|
||||
super(effect);
|
||||
this.spellCastId = effect.spellCastId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -137,16 +96,21 @@ class RunadiBehemothCallerCounterEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return spellCastId.equals(event.getTargetId());
|
||||
Spell spell = game.getSpellOrLKIStack(getTargetPointer().getFirst(game, source));
|
||||
return spell != null && event.getTargetId().equals(spell.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
if (creature != null) {
|
||||
creature.addCounters(CounterType.P1P1.createInstance(creature.getManaValue() - 4),
|
||||
Spell spell = game.getSpellOrLKIStack(creature.getId());
|
||||
if (spell != null) {
|
||||
int countersToAdd = spell.getManaValue() - 4;
|
||||
creature.addCounters(CounterType.P1P1.createInstance(countersToAdd),
|
||||
source.getControllerId(), source, game, event.getAppliedEffects());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package org.mage.test.cards.single.j22;
|
||||
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class RunadiBehemothCallerTest extends CardTestPlayerBase {
|
||||
|
||||
private static final String runadi = "Runadi, Behemoth Caller";
|
||||
// Whenever you cast a creature spell with mana value 5 or greater, that creature enters the battlefield with
|
||||
// X additional +1/+1 counters on it, where X is its mana value minus 4.
|
||||
// Creatures you control with three or more +1/+1 counters on them have haste.
|
||||
private static final String endlessOne = "Endless One"; // 0/0 for {X}, ETB with X +1/+1 counters
|
||||
private static final String kurgadon = "Kurgadon";
|
||||
// Whenever you cast a creature spell with mana value 6 or greater, put three +1/+1 counters on Kurgadon.
|
||||
|
||||
@Test
|
||||
public void testXEnters() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, runadi);
|
||||
addCard(Zone.HAND, playerA, endlessOne);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Wastes", 6);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, endlessOne);
|
||||
setChoice(playerA, "X=6");
|
||||
// should enter with two additional counters to be an 8/8
|
||||
setChoice(playerA, "Endless One"); // order replacement effects
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
assertPowerToughness(playerA, endlessOne, 8, 8);
|
||||
assertAbility(playerA, endlessOne, HasteAbility.getInstance(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpellXChecked() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, kurgadon);
|
||||
addCard(Zone.HAND, playerA, endlessOne);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Wastes", 6);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, endlessOne);
|
||||
setChoice(playerA, "X=6");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
assertCounterCount(playerA, kurgadon, CounterType.P1P1, 3);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue