mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
Added a mode to allow TargetCardInExile in all exile zones.
This commit is contained in:
parent
0ab055c0f8
commit
3e1b0f5fce
1 changed files with 46 additions and 3 deletions
|
|
@ -27,15 +27,17 @@
|
|||
*/
|
||||
package mage.target.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -44,26 +46,67 @@ import java.util.UUID;
|
|||
public class TargetCardInExile extends TargetCard<TargetCardInExile> {
|
||||
|
||||
private UUID zoneId;
|
||||
private boolean allExileZones;
|
||||
|
||||
public TargetCardInExile(FilterCard filter, UUID zoneId) {
|
||||
this(1, 1, filter, zoneId);
|
||||
}
|
||||
|
||||
public TargetCardInExile(int minNumTargets, int maxNumTargets, FilterCard filter, UUID zoneId) {
|
||||
this(minNumTargets, maxNumTargets, filter, zoneId, false);
|
||||
}
|
||||
|
||||
public TargetCardInExile(int minNumTargets, int maxNumTargets, FilterCard filter, UUID zoneId, boolean allExileZones) {
|
||||
super(minNumTargets, maxNumTargets, Zone.EXILED, filter);
|
||||
this.zoneId = zoneId;
|
||||
this.allExileZones = allExileZones;
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
public TargetCardInExile(final TargetCardInExile target) {
|
||||
super(target);
|
||||
this.zoneId = target.zoneId;
|
||||
this.allExileZones = target.allExileZones;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
if (allExileZones) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (filter.match(card, sourceControllerId, game)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
} else {
|
||||
return super.possibleTargets(sourceId, sourceControllerId, game);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
if (allExileZones) {
|
||||
int numberTargets = 0;
|
||||
for(ExileZone exileZone : game.getExile().getExileZones()) {
|
||||
numberTargets += exileZone.count(filter, sourceId, sourceControllerId, game);
|
||||
if (numberTargets >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return super.canChoose(sourceControllerId, game);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.EXILED) {
|
||||
if (allExileZones) {
|
||||
return filter.match(card, source.getControllerId(), game);
|
||||
}
|
||||
ExileZone exile;
|
||||
if (zoneId != null) {
|
||||
exile = game.getExile().getExileZone(zoneId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue