mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
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:
parent
81af372bc1
commit
cc7b7ec2a2
6 changed files with 307 additions and 3 deletions
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue