* Turntimber Basilisk - Fix a bug when a creature that must be blocked is not attacking

This commit is contained in:
Quercitron 2015-11-29 00:19:21 +03:00
parent d94a2712ba
commit b9add2e041
2 changed files with 34 additions and 0 deletions

View file

@ -298,4 +298,33 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Walking Corpse", 1);
assertPermanentCount(playerB, "Llanowar Elves", 1);
}
/**
* Reproduces a bug when a creature that must be blocked is not attacking
*/
@Test
public void testTurntimberBasilisk() {
addCard(Zone.BATTLEFIELD, playerA, "Turntimber Basilisk");
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
addCard(Zone.HAND, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerB, "Storm Crow");
playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Forest");
addTarget(playerA, "Storm Crow");
attack(3, playerA, "Grizzly Bears");
block(3, playerB, "Storm Crow", "Grizzly Bears");
setStopAt(3, PhaseStep.END_TURN);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Turntimber Basilisk", 1);
assertPermanentCount(playerA, "Grizzly Bears", 1);
assertPermanentCount(playerB, "Storm Crow", 0);
}
}

View file

@ -538,6 +538,11 @@ public class Combat implements Serializable, Copyable<Combat> {
UUID attackingCreatureId = requirementEntry.getKey().mustBlockAttacker(ability, game);
Player defender = game.getPlayer(possibleBlocker.getControllerId());
if (attackingCreatureId != null && defender != null && possibleBlocker.canBlock(attackingCreatureId, game)) {
Permanent attackingCreature = game.getPermanent(attackingCreatureId);
if (attackingCreature == null || !attackingCreature.isAttacking()) {
// creature that must be blocked is not attacking
continue;
}
// check if the possible blocker has to pay cost to block, if so don't force
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKER, attackingCreatureId, possibleBlocker.getId(), possibleBlocker.getControllerId()), game)) {