mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Integrating the zone restriction check as a mandatory part of SpellAbility#canTarget.
This commit is contained in:
@@ -63,7 +63,7 @@ public class ChangeTargetsAi extends SpellAbilityAi {
|
||||
// make sure not to redirect our own abilities
|
||||
return false;
|
||||
}
|
||||
if (!topSa.canTarget(sa.getHostCard(), true)) {
|
||||
if (!topSa.canTarget(sa.getHostCard())) {
|
||||
// don't try targeting it if we can't legally target the host card with it in the first place
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
// 3. test if updated choices would be correct.
|
||||
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa), null);
|
||||
|
||||
if (replaceIn.getSpellAbility(true).canTarget(newTarget, true)) {
|
||||
if (replaceIn.getSpellAbility(true).canTarget(newTarget)) {
|
||||
newTargetBlock.add(newTarget);
|
||||
replaceIn.updateTarget(newTargetBlock, oldTarget, newTarget);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
}
|
||||
else if (sa.hasParam("DefinedMagnet")){
|
||||
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
|
||||
if (newTarget != null && changingTgtSA.canTarget(newTarget, true)) {
|
||||
if (newTarget != null && changingTgtSA.canTarget(newTarget)) {
|
||||
changingTgtSA.resetTargets();
|
||||
changingTgtSA.getTargets().add(newTarget);
|
||||
changingTgtSI.updateTarget(changingTgtSA.getTargets(), null, newTarget);
|
||||
|
||||
@@ -973,27 +973,19 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof Card) {
|
||||
final Card c = (Card) entity;
|
||||
if (!tr.getZone().contains(c.getZone().getZoneType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restrictions coming from target
|
||||
return entity.canBeTargetedBy(this);
|
||||
}
|
||||
|
||||
public final boolean canTarget(final GameObject object, final boolean zoneCheck) {
|
||||
// TODO: the zone check should most likely be integrated as a part of the
|
||||
// regular canTarget call, but that needs testing.
|
||||
boolean zoneTestPassed = true;
|
||||
if (object instanceof Card && zoneCheck) {
|
||||
final TargetRestrictions tr = getTargetRestrictions();
|
||||
final Card c = (Card)object;
|
||||
if (!tr.getZone().contains(c.getZone().getZoneType())) {
|
||||
zoneTestPassed = false;
|
||||
}
|
||||
}
|
||||
|
||||
return zoneTestPassed && canTarget(object);
|
||||
}
|
||||
|
||||
// is this a wrapping ability (used by trigger abilities)
|
||||
public boolean isWrapper() {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user