mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
[M21] Fix castability and selectability of EnthrallingHold (#6773)
This commit is contained in:
parent
b6b7a9c0f9
commit
91571df264
3 changed files with 74 additions and 77 deletions
|
|
@ -0,0 +1,60 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TargetTappedPermanentAsYouCast extends TargetPermanent {
|
||||
|
||||
public TargetTappedPermanentAsYouCast() {}
|
||||
|
||||
public TargetTappedPermanentAsYouCast(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
private TargetTappedPermanentAsYouCast(TargetTappedPermanentAsYouCast target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetTappedPermanentAsYouCast copy() {
|
||||
return new TargetTappedPermanentAsYouCast(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
return game.getBattlefield().getAllActivePermanents(getFilter(), game).stream()
|
||||
.filter(Permanent::isTapped)
|
||||
.map(Permanent::getId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
return game.getBattlefield().getAllActivePermanents(getFilter(), game).stream()
|
||||
.anyMatch(Permanent::isTapped);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent != null && permanent.isTapped();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// See ruling: https://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/253345-dream-leash
|
||||
@Override
|
||||
public boolean stillLegalTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent != null && getFilter().match(permanent, game);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue