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
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
return true;
|
return permanent.canBlock(source.getFirstTarget(), game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -92,10 +92,9 @@ class FeralContestEffect extends RequirementEffect<FeralContestEffect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
if (permanent.getId().equals(source.getTargets().get(1).getFirstTarget())) {
|
||||||
if (creature != null) {
|
return permanent.canBlock(source.getFirstTarget(), game);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,10 @@ class GrapplingHookEffect extends RequirementEffect<GrapplingHookEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
if (permanent.getId().equals(source.getFirstTarget())) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,10 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect<MustBeBl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class MustBeBlockedByAllSourceEffect extends RequirementEffect<MustBeBloc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
return true;
|
return permanent.canBlock(source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,9 +56,11 @@ public class MustBeBlockedByTargetSourceEffect extends RequirementEffect<MustBeB
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent creature = game.getPermanent(source.getFirstTarget());
|
if (permanent.getId().equals(source.getFirstTarget())) {
|
||||||
if (creature != null && creature.getId().equals(permanent.getId())) {
|
Permanent blocker = game.getPermanent(source.getFirstTarget());
|
||||||
return true;
|
if (blocker != null && blocker.canBlock(source.getSourceId(), game)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
* and the requirement, so that's the only option.
|
* and the requirement, so that's the only option.
|
||||||
*/
|
*/
|
||||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterBlockers, player.getId(), game)) {
|
for (Permanent creature : game.getBattlefield().getActivePermanents(filterBlockers, player.getId(), game)) {
|
||||||
if (game.getOpponents(attackerId).contains(creature.getControllerId())) {
|
if (game.getOpponents(attackerId).contains(creature.getControllerId())) {
|
||||||
for (Map.Entry entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) {
|
for (Map.Entry entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) {
|
||||||
RequirementEffect effect = (RequirementEffect)entry.getKey();
|
RequirementEffect effect = (RequirementEffect)entry.getKey();
|
||||||
if (effect.mustBlock(game)) {
|
if (effect.mustBlock(game)) {
|
||||||
|
@ -400,7 +400,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkBlockRequirementsAfter(Player player, Player controller, Game game) {
|
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);
|
Set<UUID> opponents = game.getOpponents(attackerId);
|
||||||
//20101001 - 509.1c
|
//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
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent attacker = game.getPermanent(attackerId);
|
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
|
//20101001 - 509.1b
|
||||||
for (Map.Entry entry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
for (Map.Entry entry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||||
RestrictionEffect effect = (RestrictionEffect)entry.getKey();
|
RestrictionEffect effect = (RestrictionEffect)entry.getKey();
|
||||||
|
|
Loading…
Reference in a new issue