mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +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.
|
||||
*/
|
||||
public final boolean canTarget(final ITargetable entity) {
|
||||
final TargetRestrictions tr = this.getTargetRestrictions();
|
||||
|
||||
// Restriction related to this ability
|
||||
if (this.getTargetRestrictions() != null) {
|
||||
if (this.getTargetRestrictions().isUniqueTargets() && this.getUniqueTargets().contains(entity))
|
||||
if (tr != null) {
|
||||
if (tr.isUniqueTargets() && this.getUniqueTargets().contains(entity))
|
||||
return false;
|
||||
|
||||
// If the cards must have a specific controller
|
||||
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 = this.getTargetRestrictions().getValidTgts();
|
||||
if (entity instanceof GameEntity && !((GameEntity)entity).isValid(validTgt, this.getActivatingPlayer(), this.getSourceCard()))
|
||||
String[] validTgt = tr.getValidTgts();
|
||||
if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getSourceCard()))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.ITargetable;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user