[MH2] fixed Chatterfang, Squirrel General applying to opponent's tokens (fixes #7909)

This commit is contained in:
Evan Kranzler 2021-06-14 08:13:48 -04:00
parent d69180df97
commit ee0f35a2cd
2 changed files with 28 additions and 9 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.c;
import java.util.Map;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -12,10 +10,10 @@ import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.constants.*;
import mage.abilities.keyword.ForestwalkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.events.CreateTokenEvent;
@ -24,8 +22,10 @@ import mage.game.permanent.token.SquirrelToken;
import mage.game.permanent.token.Token;
import mage.target.common.TargetCreaturePermanent;
import java.util.Map;
import java.util.UUID;
/**
*
* @author weirddan455
*/
public final class ChatterfangSquirrelGeneral extends CardImpl {
@ -49,9 +49,8 @@ public final class ChatterfangSquirrelGeneral extends CardImpl {
// {B}, Sacrifice X Squirrels: Target creature gets +X/-X until end of turn.
Ability ability = new SimpleActivatedAbility(new BoostTargetEffect(
GetXValue.instance, new SignInversionDynamicValue(GetXValue.instance), Duration.EndOfTurn),
new ManaCostsImpl<>("{B}")
);
GetXValue.instance, new SignInversionDynamicValue(GetXValue.instance), Duration.EndOfTurn
), new ManaCostsImpl<>("{B}"));
ability.addCost(new SacrificeXTargetCost(filter));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
@ -90,7 +89,7 @@ class ChatterfangSquirrelGeneralReplacementEffect extends ReplacementEffectImpl
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return true;
return source.isControlledBy(event.getPlayerId());
}
@Override

View file

@ -27,6 +27,26 @@ public class ChatterfangSquirrelGeneralTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Squirrel", 2);
}
@Test
public void testChatterfangOpponent() {
addCard(Zone.BATTLEFIELD, playerB, chatterfang);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.HAND, playerA, "Raise the Alarm");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Raise the Alarm");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Plains", 2);
assertPermanentCount(playerB, chatterfang, 1);
assertPermanentCount(playerA, "Soldier", 2);
assertPermanentCount(playerA, "Squirrel", 0);
assertPermanentCount(playerB, "Soldier", 0);
assertPermanentCount(playerB, "Squirrel", 0);
}
@Test
public void testChatterfangPlusAcademyManufactor() {
addCard(Zone.BATTLEFIELD, playerA, chatterfang);
@ -48,7 +68,7 @@ public class ChatterfangSquirrelGeneralTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Academy Manufactor", 1);
assertPermanentCount(playerA, "Clue", 1);
assertPermanentCount(playerA, "Food", 1);
assertPermanentCount(playerA, "Treasure" ,1);
assertPermanentCount(playerA, "Treasure", 1);
assertPermanentCount(playerA, "Squirrel", 3);
}
}