mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Fixed some problems with blocking requirements (fixes #355).
This commit is contained in:
parent
2dd26a9075
commit
db1521d30c
8 changed files with 24 additions and 12 deletions
|
@ -91,7 +91,7 @@ class RevengeOfTheHuntedEffect extends RequirementEffect<RevengeOfTheHuntedEffec
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return true;
|
||||
return permanent.canBlock(source.getFirstTarget(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -93,9 +93,8 @@ class FeralContestEffect extends RequirementEffect<FeralContestEffect> {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (creature != null) {
|
||||
return true;
|
||||
if (permanent.getId().equals(source.getTargets().get(1).getFirstTarget())) {
|
||||
return permanent.canBlock(source.getFirstTarget(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,10 @@ class GrapplingHookEffect extends RequirementEffect<GrapplingHookEffect> {
|
|||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getId().equals(source.getFirstTarget())) {
|
||||
return true;
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
return permanent.canBlock(equipment.getAttachedTo(), game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,10 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect<MustBeBl
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
return permanent.canBlock(attachment.getAttachedTo(), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MustBeBlockedByAllSourceEffect extends RequirementEffect<MustBeBloc
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return true;
|
||||
return permanent.canBlock(source.getSourceId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,10 +56,12 @@ public class MustBeBlockedByTargetSourceEffect extends RequirementEffect<MustBeB
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Permanent creature = game.getPermanent(source.getFirstTarget());
|
||||
if (creature != null && creature.getId().equals(permanent.getId())) {
|
||||
if (permanent.getId().equals(source.getFirstTarget())) {
|
||||
Permanent blocker = game.getPermanent(source.getFirstTarget());
|
||||
if (blocker != null && blocker.canBlock(source.getSourceId(), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -400,7 +400,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
|
||||
public boolean checkBlockRequirementsAfter(Player player, Player controller, Game game) {
|
||||
// Get one time a list of all opponents in range
|
||||
// Get once a list of all opponents in range
|
||||
Set<UUID> opponents = game.getOpponents(attackerId);
|
||||
//20101001 - 509.1c
|
||||
// map with attackers (UUID) that must be blocked by at least one blocker and a set of all creatures that can block it and don't block yet
|
||||
|
|
|
@ -869,6 +869,10 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
return false;
|
||||
}
|
||||
Permanent attacker = game.getPermanent(attackerId);
|
||||
// controller of attacking permanent must be an opponent
|
||||
if (!game.getOpponents(this.getControllerId()).contains(attacker.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
//20101001 - 509.1b
|
||||
for (Map.Entry entry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||
RestrictionEffect effect = (RestrictionEffect)entry.getKey();
|
||||
|
|
Loading…
Reference in a new issue