Fixed blocking change for AI player not locking the game.

This commit is contained in:
LevelX2 2013-05-29 21:02:00 +02:00
parent 7bb6fabfef
commit 6f8ee8e3de
2 changed files with 16 additions and 3 deletions

View file

@ -49,6 +49,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
/**
*
@ -99,7 +100,7 @@ class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl<Cant
super(duration, Outcome.Benefit);
this.amount = amount;
this.attachmentType = attachmentType;
staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted" : "Equipped") + " creature can't be blocked by more than " + amount + " creature" + (amount==1 ?"":"s");
staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted" : "Equipped") + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s");
}
public CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) {

View file

@ -257,8 +257,14 @@ public class Combat implements Serializable, Copyable<Combat> {
if (game.isPaused() || game.isGameOver()) {
return;
}
choose = !checkBlockRestrictions(game.getPlayer(defenderId), game);
choose |= !checkBlockRequirementsAfter(defender, defender, game);
if (!checkBlockRestrictions(game.getPlayer(defenderId), game)) {
// only human player can decide to do the block in another way
if (player.isHuman()) {
continue;
}
}
choose = !checkBlockRequirementsAfter(defender, defender, game);
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defenderId, defenderId));
}
@ -266,6 +272,12 @@ public class Combat implements Serializable, Copyable<Combat> {
}
}
/**
* Check the block restrictions
* @param player
* @param game
* @return false - if block restrictions were not complied
*/
public boolean checkBlockRestrictions(Player player, Game game) {
int count = 0;
boolean blockWasLegal = true;