mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 04:12:14 -08:00
* Fixed missing check for restricting effects of activated abilities of permanents (fixes #6657). I guess that got lost by refactoring get playable abilities.
This commit is contained in:
parent
3beaec4525
commit
c41fc0284d
4 changed files with 67 additions and 5 deletions
|
|
@ -18,6 +18,8 @@ public final class SolRing extends CardImpl {
|
|||
|
||||
public SolRing(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
|
||||
|
||||
// Tap: Add {C}{C}
|
||||
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(2), new TapSourceCost()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package org.mage.test.cards.restriction;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class CantUseActivatedAbilitiesTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* I can activate artifacts despite my opponent having Collector Ouphe or
|
||||
* Karn, the Great Creator in play. The artifact says it can't be activated, but that's a lie.
|
||||
*/
|
||||
@Test
|
||||
public void testCantActivateManaAbility() {
|
||||
// Activated abilities of artifacts can't be activated.
|
||||
addCard(Zone.HAND, playerA, "Collector Ouphe"); // Creature {1}{G} 2/2
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
|
||||
// {T}: Add {C}{C}
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Sol Ring"); // Artifact
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Collector Ouphe");
|
||||
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
// Sol Ring can't produce mana
|
||||
Assert.assertTrue("PlayerB may not be able to produce any mana but he he can produce " + playerB.getManaAvailable(currentGame).toString(), playerB.getManaAvailable(currentGame).toString().equals("[]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCantActivateActivatedAbility() {
|
||||
// Activated abilities of artifacts can't be activated.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Collector Ouphe"); // Creature {1}{G} 2/2
|
||||
|
||||
// {1}: Adarkar Sentinel gets +0/+1 until end of turn.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Adarkar Sentinel"); // Artifact Creature — Soldier (3/3)
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{1}: ");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
|
||||
execute();
|
||||
|
||||
assertPowerToughness(playerB, "Adarkar Sentinel", 3, 3);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1165,9 +1165,9 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
|
||||
if (mustHave) {
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have ability " + abilityClass, true, founded);
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have the ability " + abilityClass, true, founded);
|
||||
} else {
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have not ability " + abilityClass, false, founded);
|
||||
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must not have the ability " + abilityClass, false, founded);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3365,11 +3365,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// activated abilities from battlefield objects
|
||||
if (fromAll || fromZone == Zone.BATTLEFIELD) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
boolean canUseActivated = permanent.canUseActivatedAbilities(game);
|
||||
List<ActivatedAbility> battlePlayable = new ArrayList<>();
|
||||
getPlayableFromCardAll(game, Zone.BATTLEFIELD, permanent, availableMana, battlePlayable);
|
||||
for (ActivatedAbility ability : battlePlayable) {
|
||||
activatedUnique.putIfAbsent(ability.toString(), ability);
|
||||
activatedAll.add(ability);
|
||||
if (ability instanceof SpecialAction || canUseActivated) {
|
||||
activatedUnique.putIfAbsent(ability.toString(), ability);
|
||||
activatedAll.add(ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4272,7 +4275,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
cards.addAll(getLibrary().getTopCards(game, value));
|
||||
if (!cards.isEmpty()) {
|
||||
TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY,
|
||||
new FilterCard("card" + (cards.size() == 1 ? "":"s")
|
||||
new FilterCard("card" + (cards.size() == 1 ? "" : "s")
|
||||
+ " to PUT on the BOTTOM of your library (Scry)"));
|
||||
chooseTarget(Outcome.Benefit, cards, target, source, game);
|
||||
putCardsOnBottomOfLibrary(new CardsImpl(target.getTargets()), game, source, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue