1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-30 01:03:57 -09:00

fixed some issues with targets that require different names

This commit is contained in:
Evan Kranzler 2020-07-01 21:07:57 -04:00
parent fbfb55f99c
commit 1c4e8db236
2 changed files with 26 additions and 20 deletions

View file

@ -17,7 +17,10 @@ import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author TheElk801
@ -90,18 +93,18 @@ class EerieUltimatumTarget extends TargetCardInYourGraveyard {
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
if (!super.canTarget(controllerId, id, source, game)) {
return false;
}
Card card = game.getCard(id);
if (card == null) {
return false;
}
return this.getTargets()
public Set<UUID> possibleTargets(UUID sourceId, UUID playerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, playerId, game);
Set<String> names = this.getTargets()
.stream()
.map(game::getCard)
.map(MageObject::getName)
.noneMatch(card.getName()::equals);
.filter(Objects::nonNull)
.collect(Collectors.toSet());
possibleTargets.removeIf(uuid -> {
Card card = game.getCard(uuid);
return card != null && names.contains(card.getName());
});
return possibleTargets;
}
}

View file

@ -22,7 +22,10 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author TheElk801
@ -127,18 +130,18 @@ class OrmosArchiveKeeperTarget extends TargetCardInHand {
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
if (!super.canTarget(controllerId, id, source, game)) {
return false;
}
Card card = game.getCard(id);
if (card == null) {
return false;
}
return this.getTargets()
public Set<UUID> possibleTargets(UUID sourceId, UUID playerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, playerId, game);
Set<String> names = this.getTargets()
.stream()
.map(game::getCard)
.map(MageObject::getName)
.noneMatch(card.getName()::equals);
.filter(Objects::nonNull)
.collect(Collectors.toSet());
possibleTargets.removeIf(uuid -> {
Card card = game.getCard(uuid);
return card != null && names.contains(card.getName());
});
return possibleTargets;
}
}