mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- Moved check for TargetsWithDefinedController to the right place.
This commit is contained in:
@@ -1021,13 +1021,24 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean canTarget(final ITargetable entity) {
|
public final boolean canTarget(final ITargetable entity) {
|
||||||
|
final TargetRestrictions tr = this.getTargetRestrictions();
|
||||||
|
|
||||||
// Restriction related to this ability
|
// Restriction related to this ability
|
||||||
if (this.getTargetRestrictions() != null) {
|
if (tr != null) {
|
||||||
if (this.getTargetRestrictions().isUniqueTargets() && this.getUniqueTargets().contains(entity))
|
if (tr.isUniqueTargets() && this.getUniqueTargets().contains(entity))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
String[] validTgt = this.getTargetRestrictions().getValidTgts();
|
// If the cards must have a specific controller
|
||||||
if (entity instanceof GameEntity && !((GameEntity)entity).isValid(validTgt, this.getActivatingPlayer(), this.getSourceCard()))
|
if (tr.getDefinedController() != null && entity instanceof Card) {
|
||||||
|
final Card c = (Card) entity;
|
||||||
|
List<Player> pl = AbilityUtils.getDefinedPlayers(this.getSourceCard(), tr.getDefinedController(), this);
|
||||||
|
if (pl == null || !pl.contains(c.getController()) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] validTgt = tr.getValidTgts();
|
||||||
|
if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getSourceCard()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.ITargetable;
|
import forge.ITargetable;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.ability.AbilityUtils;
|
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
@@ -241,16 +240,6 @@ public class TargetSelection {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// If the cards must have a specific controller
|
|
||||||
if (tgt.getDefinedController() != null) {
|
|
||||||
List<Player> pl = AbilityUtils.getDefinedPlayers(ability.getSourceCard(), tgt.getDefinedController(), this.ability);
|
|
||||||
if (pl != null && !pl.isEmpty()) {
|
|
||||||
Player controller = pl.get(0);
|
|
||||||
choices = CardLists.filterControlledBy(choices, controller);
|
|
||||||
} else {
|
|
||||||
choices.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return choices;
|
return choices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user