mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Permanent.canAttack() check for restriction effects more improvements and fix in CanAttackControllerAttachedEffect.
This commit is contained in:
parent
cbb6117b8e
commit
4e2c8dbe02
2 changed files with 31 additions and 9 deletions
|
@ -68,7 +68,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect {
|
|||
return false;
|
||||
}
|
||||
Permanent plainswalker = game.getPermanent(defenderId);
|
||||
return plainswalker == null || !plainswalker.getControllerId().equals(source.getSourceId());
|
||||
return plainswalker == null || !plainswalker.getControllerId().equals(source.getControllerId());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -872,23 +873,44 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
if (hasSummoningSickness()) {
|
||||
return false;
|
||||
}
|
||||
//20101001 - 508.1c
|
||||
if (defenderId == null) {
|
||||
boolean oneCanBeAttacked = false;
|
||||
for (UUID defenderToCheckId: game.getCombat().getDefenders()) {
|
||||
if (canAttackCheckRestrictionEffects(defenderToCheckId, game)) {
|
||||
oneCanBeAttacked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!oneCanBeAttacked) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!canAttackCheckRestrictionEffects(defenderId, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !abilities.containsKey(DefenderAbility.getInstance().getId())
|
||||
|| game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, this.getControllerId(), game);
|
||||
}
|
||||
|
||||
|
||||
private boolean canAttackCheckRestrictionEffects(UUID defenderId, Game game) {
|
||||
//20101001 - 508.1c
|
||||
for (Map.Entry<RestrictionEffect, HashSet<Ability>> effectEntry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||
if (!effectEntry.getKey().canAttack(game)) {
|
||||
return false;
|
||||
}
|
||||
if (defenderId != null) {
|
||||
for (Ability ability :effectEntry.getValue()) {
|
||||
if (!effectEntry.getKey().canAttack(defenderId, ability, game)) {
|
||||
return false;
|
||||
}
|
||||
for (Ability ability :effectEntry.getValue()) {
|
||||
if (!effectEntry.getKey().canAttack(defenderId, ability, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !abilities.containsKey(DefenderAbility.getInstance().getId())
|
||||
|| game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, this.getControllerId(), game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canBlock(UUID attackerId, Game game) {
|
||||
if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(), AsThoughEffectType.BLOCK_TAPPED, this.getControllerId(), game)) {
|
||||
|
|
Loading…
Reference in a new issue