Added card Okk. Incluedes a new restriction effect called "canBlockCheckAfter", an update to the combat sequence where this restriction is taken into considiration and a new test which assert the behaviour of the effect.

This commit is contained in:
icetc 2016-02-01 13:30:08 +01:00
parent 81af372bc1
commit cc7b7ec2a2
6 changed files with 307 additions and 3 deletions

View file

@ -77,10 +77,14 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
return true;
}
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
public boolean canBlockCheckAfter(Ability source, Game game) {
return true;
}
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return true;
}
/**
* Called for all attackers after all blocking decisions are made
*

View file

@ -910,6 +910,27 @@ public class Combat implements Serializable, Copyable<Combat> {
* @return
*/
public boolean checkBlockRestrictionsAfter(Player player, Player controller, Game game) {
// Restrictions applied to blocking creatures
for (UUID blockingCreatureId : this.getBlockers()) {
Permanent blockingCreature = game.getPermanent(blockingCreatureId);
if (blockingCreature != null) {
for (Map.Entry<RestrictionEffect, HashSet<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(blockingCreature, game).entrySet()) {
RestrictionEffect effect = entry.getKey();
for (Ability ability : entry.getValue()) {
if (!effect.canBlockCheckAfter(ability, game)) {
if (controller.isHuman()) {
game.informPlayer(controller, new StringBuilder(blockingCreature.getLogName()).append(" can't block this way.").toString());
return false;
} else {
// remove blocking creatures for AI
removeBlocker(blockingCreatureId, game);
}
}
}
}
}
}
// Restrictions applied because of attacking creatures
for (UUID attackingCreatureId : this.getAttackers()) {
Permanent attackingCreature = game.getPermanent(attackingCreatureId);
if (attackingCreature != null) {
@ -929,7 +950,6 @@ public class Combat implements Serializable, Copyable<Combat> {
}
}
}
}
}
}