* Orzhov Advokist - Fixed that the attack preventing effect did not work correctly.

This commit is contained in:
LevelX2 2016-12-11 16:25:08 +01:00
parent 3d9b51bec3
commit 4b4aef8ed5
3 changed files with 39 additions and 5 deletions

View file

@ -121,9 +121,11 @@ class OrzhovAdvokistEffect extends OneShotEffect {
}
}
for (UUID playerId : players) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId));
game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter, true), source);
if (playerId != source.getControllerId()) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId));
game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter, true), source);
}
}
return true;
}

View file

@ -140,4 +140,31 @@ public class CantAttackTest extends CardTestPlayerBase {
assertTapped("Battle-Mad Ronin", false);
}
// Orzhov Advokist's ability does not work. Your opponents get the counters but they can still attack you.
@Test
public void testOrzhovAdvokist() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
// At the beginning of your upkeep, each player may put two +1/+1 counters on a creature he or she controls.
// If a player does, creatures that player controls can't attack you or a planeswalker you control until your next turn.
addCard(Zone.HAND, playerA, "Orzhov Advokist"); // Creature {2}{W} 1/4
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Orzhov Advokist");
setChoice(playerA, "Yes");
setChoice(playerB, "Yes");
attack(2, playerB, "Silvercoat Lion");
attack(4, playerB, "Silvercoat Lion");
setStopAt(4, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Orzhov Advokist", 1);
assertPowerToughness(playerA, "Orzhov Advokist", 3, 6);
assertLife(playerA, 18);
assertTapped("Silvercoat Lion", false);
assertPowerToughness(playerB, "Silvercoat Lion", 4, 4);
}
}

View file

@ -75,8 +75,13 @@ public class CantAttackYouAllEffect extends RestrictionEffect {
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
return (!alsoPlaneswalker && !defenderId.equals(source.getControllerId()))
|| (alsoPlaneswalker && !(source.getControllerId().equals(game.getCombat().getDefendingPlayerId(attacker.getId(), game))));
if (alsoPlaneswalker) {
Permanent planeswalker = game.getPermanent(defenderId);
if (planeswalker != null) {
defenderId = planeswalker.getControllerId();
}
}
return !defenderId.equals(source.getControllerId());
}
@Override