* Author of Shadows - added window with exiled and castable cards;

This commit is contained in:
Oleg Agafonov 2021-08-18 11:02:30 +04:00
parent 1d60c2039b
commit 3da525520c
2 changed files with 35 additions and 6 deletions

View file

@ -7,6 +7,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.ExileZone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
@ -63,8 +64,8 @@ class AuthorOfShadowsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
@ -78,18 +79,27 @@ class AuthorOfShadowsEffect extends OneShotEffect {
if (cards.isEmpty()) {
return false;
}
player.moveCards(cards, Zone.EXILED, source, game);
controller.moveCards(cards, Zone.EXILED, source, game);
cards.retainZone(Zone.EXILED, game);
if (cards.isEmpty()) {
return false;
}
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD_A_NON_LAND);
target.setNotTarget(true);
player.choose(outcome, cards, target, game);
controller.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
return true;
}
// use same player's zone for all Author of Shadows instances
String exileZoneName = controller.getName() + " - Author of Shadows - cast with any color";
UUID exileZoneId = CardUtil.getExileZoneId(exileZoneName, game);
ExileZone exileZone = game.getExile().createZone(exileZoneId, exileZoneName);
game.getExile().moveToAnotherZone(card, game, exileZone);
CardUtil.makeCardPlayable(game, source, card, Duration.Custom, true);
return true;
}

View file

@ -16,7 +16,7 @@ public class Exile implements Serializable, Copyable<Exile> {
private static final UUID PERMANENT = UUID.randomUUID();
private Map<UUID, ExileZone> exileZones = new HashMap<>();
private final Map<UUID, ExileZone> exileZones = new HashMap<>();
public Exile() {
createZone(PERMANENT, "Permanent");
@ -88,6 +88,25 @@ public class Exile implements Serializable, Copyable<Exile> {
return false;
}
/**
* Move card from one exile zone to another. Use case example: create special zone for exiled and castable card.
*
* @param card
* @param game
* @param toZoneId
*/
public void moveToAnotherZone(Card card, Game game, ExileZone exileZone) {
if (getCard(card.getId(), game) == null) {
throw new IllegalArgumentException("Card must be in exile zone: " + card.getIdName());
}
if (exileZone == null) {
throw new IllegalArgumentException("Exile zone must exists: " + card.getIdName());
}
removeCard(card, game);
exileZone.add(card);
}
@Override
public Exile copy() {
return new Exile(this);