mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
[CLB] Fix Myrkul's Edict not sacrificing creatures on 1-9. For #9381.
This commit is contained in:
parent
473ecc3292
commit
9d54aee3ba
2 changed files with 100 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.RollDieWithResultTableEffect;
|
||||
import mage.abilities.effects.common.SacrificeEffect;
|
||||
|
@ -16,6 +17,7 @@ import mage.filter.predicate.permanent.GreatestPowerControlledPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -78,16 +80,19 @@ class MyrkulsEdictEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
if (!target.choose(outcome, source.getControllerId(), source.getId(), source, game)) {
|
||||
return false;
|
||||
}
|
||||
TargetOpponent target = new TargetOpponent();
|
||||
target.setNotTarget(true);
|
||||
player.choose(outcome, target, source, game);
|
||||
return game.getPlayer(target.getFirstTarget()) != null
|
||||
&& new SacrificeEffect(
|
||||
StaticFilters.FILTER_PERMANENT_CREATURE, 1, ""
|
||||
).apply(game, source);
|
||||
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
if (opponent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Effect sacrificeEffect = new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "");
|
||||
sacrificeEffect.setTargetPointer(new FixedTarget(opponent.getId()));
|
||||
|
||||
return sacrificeEffect.apply(game, source);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
package org.mage.test.cards.single.clb;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* {@link mage.cards.m.MyrkulsEdict Myrkul's Edict}
|
||||
* Sorcery
|
||||
* {1}{B}
|
||||
*
|
||||
* Roll a d20.
|
||||
* 1—9 | Choose an opponent. That player sacrifices a creature.
|
||||
* 10—19 | Each opponent sacrifices a creature.
|
||||
* 20 | Each opponent sacrifices a creature with the greatest power among creatures that player controls.
|
||||
*
|
||||
* @author Alex-Vasile
|
||||
*/
|
||||
public class MyrkulsEdictTest extends CardTestPlayerBase {
|
||||
private static final String myrkulsEdict = "Myrkul's Edict";
|
||||
|
||||
/**
|
||||
* Reported bug: https://github.com/magefree/mage/issues/9381
|
||||
* AI doesn't sacrifice a creature on a roll of 1-9
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void opponentSacrificesLevel1() {
|
||||
addCard(Zone.HAND, playerA, myrkulsEdict);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
|
||||
setDieRollResult(playerA, 1);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, myrkulsEdict);
|
||||
addTarget(playerA, playerB);
|
||||
addTarget(playerB, "Silvercoat Lion");
|
||||
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerB, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void opponentSacrificesLevel2() {
|
||||
addCard(Zone.HAND, playerA, myrkulsEdict);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
|
||||
setDieRollResult(playerA, 11);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, myrkulsEdict);
|
||||
addTarget(playerB, "Silvercoat Lion");
|
||||
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerB, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void opponentSacrificesLevel3() {
|
||||
addCard(Zone.HAND, playerA, myrkulsEdict);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Aesi, Tyrant of Gyre Strait"); // 5/5
|
||||
|
||||
setStrictChooseMode(true);
|
||||
|
||||
setDieRollResult(playerA, 20);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, myrkulsEdict);
|
||||
addTarget(playerB, "Aesi, Tyrant of Gyre Strait");
|
||||
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerB, "Silvercoat Lion", 1);
|
||||
assertPermanentCount(playerB, "Aesi, Tyrant of Gyre Strait", 0);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue