mirror of
https://github.com/correl/mage.git
synced 2025-03-16 09:16:26 -09: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;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent plainswalker = game.getPermanent(defenderId);
|
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.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -872,23 +873,44 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
if (hasSummoningSickness()) {
|
if (hasSummoningSickness()) {
|
||||||
return false;
|
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
|
//20101001 - 508.1c
|
||||||
for (Map.Entry<RestrictionEffect, HashSet<Ability>> effectEntry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
for (Map.Entry<RestrictionEffect, HashSet<Ability>> effectEntry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||||
if (!effectEntry.getKey().canAttack(game)) {
|
if (!effectEntry.getKey().canAttack(game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (defenderId != null) {
|
for (Ability ability :effectEntry.getValue()) {
|
||||||
for (Ability ability :effectEntry.getValue()) {
|
if (!effectEntry.getKey().canAttack(defenderId, ability, game)) {
|
||||||
if (!effectEntry.getKey().canAttack(defenderId, ability, game)) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !abilities.containsKey(DefenderAbility.getInstance().getId())
|
return true;
|
||||||
|| game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, this.getControllerId(), game);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBlock(UUID attackerId, Game game) {
|
public boolean canBlock(UUID attackerId, Game game) {
|
||||||
if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(), AsThoughEffectType.BLOCK_TAPPED, this.getControllerId(), game)) {
|
if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(), AsThoughEffectType.BLOCK_TAPPED, this.getControllerId(), game)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue