fix #11456 (Become Brutes)

CreateRoleAttachedTargetEffect changed to use all targets, not just first
This commit is contained in:
xenohedron 2023-11-25 02:20:11 -05:00
parent 9f3777a82f
commit 867a8f54b0
2 changed files with 36 additions and 6 deletions

View file

@ -150,4 +150,29 @@ public class RoleTest extends CardTestPlayerBase {
assertLife(playerA, 20);
}
@Test
public void testBecomeBrutes() {
String bear = "Runeclaw Bear"; // 2/2
String become = "Become Brutes";
// One or two target creatures each gain haste until end of turn.
// For each of those creatures, create a Monster Role token attached to it.
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.BATTLEFIELD, playerA, wardens);
addCard(Zone.HAND, playerA, become);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addTarget(playerA, bear + "^" + wardens);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, become);
setChoice(playerA, ""); // order triggers
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, become, 1);
assertPowerToughness(playerA, bear, 3, 3);
assertPowerToughness(playerA, wardens, 2, 5);
assertLife(playerA, 20 + 2 + 2);
}
}

View file

@ -9,6 +9,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
* @author TheElk801
*/
@ -33,13 +35,16 @@ public class CreateRoleAttachedTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
boolean result = false;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
Token token = roleType.createToken(permanent, game, source);
// The token may not be created, for instance if the creature has protection from enchantments.
result |= !token.getLastAddedTokenIds().isEmpty();
}
}
Token token = roleType.createToken(permanent, game, source);
// The token may not be created, for instance if the creature has protection from enchantments.
return !token.getLastAddedTokenIds().isEmpty();
return result;
}
@Override