mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
[CMR] fixed Hellkite Courser - missing command zone support in target (#7198);
This commit is contained in:
parent
2b78388eab
commit
c548b3fd1d
5 changed files with 82 additions and 7 deletions
|
|
@ -12,6 +12,8 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Works with cards only. For objects like commanders you must override your canTarget method.
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author North
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -158,7 +156,7 @@ public class TargetCard extends TargetObject {
|
|||
case LIBRARY:
|
||||
for (Card card : player.getLibrary().getUniqueCards(game)) {
|
||||
if (sourceId == null || isNotTarget() || !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.TARGET, card.getId(), sourceId, sourceControllerId))) {
|
||||
if (filter.match(card, game)) {
|
||||
if (filter.match(card, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -167,12 +165,25 @@ public class TargetCard extends TargetObject {
|
|||
case EXILED:
|
||||
for (Card card : game.getExile().getPermanentExile().getCards(game)) {
|
||||
if (sourceId == null || isNotTarget() || !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.TARGET, card.getId(), sourceId, sourceControllerId))) {
|
||||
if (filter.match(card, player.getId(), game)) {
|
||||
if (filter.match(card, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COMMAND:
|
||||
List<Card> possibleCards = game.getCommandersIds(player).stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(card -> game.getState().getZone(card.getId()).equals(Zone.COMMAND))
|
||||
.filter(card -> filter.match(card, sourceId, sourceControllerId, game))
|
||||
.collect(Collectors.toList());
|
||||
for (Card card : possibleCards) {
|
||||
if (sourceId == null || isNotTarget() || !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.TARGET, card.getId(), sourceId, sourceControllerId))) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +203,11 @@ public class TargetCard extends TargetObject {
|
|||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
return super.canTarget(id, game);
|
||||
// copy-pasted from super but with card instead object
|
||||
Card card = game.getCard(id);
|
||||
return card != null
|
||||
&& zone != null && zone.match(game.getState().getZone(id))
|
||||
&& getFilter() != null && getFilter().match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -47,6 +47,14 @@ public abstract class TargetObject extends TargetImpl {
|
|||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning, don't use with non card objects here like commanders/emblems/etc. If you want it then
|
||||
* override canTarget in your own target.
|
||||
*
|
||||
* @param id
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
MageObject object = game.getObject(id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue