mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Fixed a problem with creatures forced to block while not able to do because the attacker has restrictions (e.g. menace).
This commit is contained in:
parent
672ac28931
commit
916836d0c9
2 changed files with 40 additions and 17 deletions
|
@ -29,7 +29,6 @@ package org.mage.test.cards.requirement;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
@ -158,7 +157,8 @@ public class BlockRequirementTest extends CardTestPlayerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Okk is red creature that can't block unless a creature with greater power also blocks.
|
||||
* Okk is red creature that can't block unless a creature with greater power
|
||||
* also blocks.
|
||||
*/
|
||||
@Test
|
||||
public void testOkkBlocking() {
|
||||
|
@ -167,7 +167,7 @@ public class BlockRequirementTest extends CardTestPlayerBase {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Hill Giant", 1);
|
||||
|
||||
// 4/4 Goblin:
|
||||
// Okk can't attack unless a creature with greater power also attacks.
|
||||
// Okk can't attack unless a creature with greater power also attacks.
|
||||
// Okk can't block unless a creature with greater power also blocks.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Okk", 1); //
|
||||
|
||||
|
@ -183,32 +183,31 @@ public class BlockRequirementTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Hill Giant", 1);
|
||||
assertLife(playerB, 17);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reported bug:
|
||||
* When Breaker of Armies is granted Menace and there is only 1 valid blocker, the game enters a state
|
||||
* that cannot be continued. He must be blocked by all creatures that are able, however, with menace
|
||||
* the only valid blocks would be by more than one creature, so the expected behavior is no blocks can be made.
|
||||
* Reported bug: When Breaker of Armies is granted Menace and there is only
|
||||
* 1 valid blocker, the game enters a state that cannot be continued. He
|
||||
* must be blocked by all creatures that are able, however, with menace the
|
||||
* only valid blocks would be by more than one creature, so the expected
|
||||
* behavior is no blocks can be made.
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBreakerOfArmiesWithMenace() {
|
||||
|
||||
// {8}
|
||||
// All creatures able to block Breaker of Armies do so.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Breaker of Armies", 1); // 10/8
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Breaker of Armies", 1); // 10/8
|
||||
|
||||
// 3/3 Vanilla creature
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Hill Giant", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Hill Giant", 1);
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 8);
|
||||
// {2}{B} Enchanted creature gets +2/+1 and has menace.
|
||||
// {2}{B} Enchanted creature gets +2/+1 and has menace.
|
||||
addCard(Zone.HAND, playerA, "Untamed Hunger", 1);
|
||||
castSpell(1,PhaseStep.PRECOMBAT_MAIN, playerA, "Untamed Hunger", "Breaker of Armies");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Untamed Hunger", "Breaker of Armies");
|
||||
|
||||
attack(1, playerA, "Breaker of Armies");
|
||||
|
||||
|
||||
// not allowed due to Breaker of Armies having menace
|
||||
block(1, playerB, "Hill Giant", "Breaker of Armies");
|
||||
|
||||
|
@ -216,8 +215,8 @@ public class BlockRequirementTest extends CardTestPlayerBase {
|
|||
execute();
|
||||
|
||||
// Hill giant is still alive
|
||||
assertPermanentCount(playerA, "Hill Giant", 1);
|
||||
assertPermanentCount(playerB, "Hill Giant", 1);
|
||||
// Player B was unable to block, so goes down to 10 life
|
||||
assertLife(playerB, 10);
|
||||
assertLife(playerB, 8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -801,6 +801,30 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Check if blocker is really able to block one or more attackers (maybe not if the attacker has menace) - if not continue with the next forced blocker
|
||||
// TODO: Probably there is some potential to abuse the check if forced blockers are assigned to differnt attackers with e.g. menace.
|
||||
// While if assigned all to one the block is possible
|
||||
if (creatureForcedToBlock.getBlocking() == 0) {
|
||||
boolean validBlockPossible = false;
|
||||
for (UUID possibleAttackerId : entry.getValue()) {
|
||||
CombatGroup attackersGroup = findGroup(possibleAttackerId);
|
||||
if (attackersGroup.getBlockers().contains(creatureForcedToBlock.getId())) {
|
||||
// forcedBlocker blocks a valid blocker, so no problem break check if valid block option exists
|
||||
validBlockPossible = true;
|
||||
break;
|
||||
}
|
||||
Permanent attackingCreature = game.getPermanent(possibleAttackerId);
|
||||
if (attackingCreature.getMinBlockedBy() > 1) { // e.g. Menace
|
||||
if (attackersGroup.getBlockers().size() + 1 >= attackingCreature.getMinBlockedBy()) {
|
||||
validBlockPossible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!validBlockPossible) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// // check if creature has to pay a cost to block so it's not mandatory to block
|
||||
// boolean removedAttacker = false;
|
||||
// for (Iterator<UUID> iterator = entry.getValue().iterator(); iterator.hasNext();) {
|
||||
|
|
Loading…
Reference in a new issue