* Mind's Desire - improved exile windows;

This commit is contained in:
Oleg Agafonov 2019-04-20 09:00:04 +04:00
parent ba1c6de2cd
commit 08616b6ec9
4 changed files with 46 additions and 25 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
@ -19,8 +17,9 @@ import mage.players.Player;
import mage.target.targetpointer.FixedTargets;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class MindsDesire extends CardImpl {
@ -68,12 +67,15 @@ class MindsDesireEffect extends OneShotEffect {
controller.shuffleLibrary(source, game);
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
UUID exileId = UUID.randomUUID();
controller.moveCardsToExile(card, source, game, true, exileId, CardUtil.createObjectRealtedWindowTitle(source, game, null));
UUID exileId = CardUtil.getExileZoneId(controller.getId().toString() + "-" + game.getState().getTurnNum() + "-" + MindsDesire.class.toString(), game);
String exileName = "Mind's Desire free cast on " + game.getState().getTurnNum() + " turn for " + controller.getName();
game.getExile().createZone(exileId, exileName).setCleanupOnEndTurn(true);
if (controller.moveCardsToExile(card, source, game, true, exileId, exileName)) {
ContinuousEffect effect = new MindsDesireCastFromExileEffect();
effect.setTargetPointer(new FixedTargets(game.getExile().getExileZone(exileId).getCards(game), game));
game.addEffect(effect, source);
}
}
return true;
}
return false;

View file

@ -1,22 +1,15 @@
package mage.game;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.stream.Collectors;
import mage.cards.Card;
import mage.filter.FilterCard;
import mage.util.Copyable;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Exile implements Serializable, Copyable<Exile> {
@ -114,4 +107,17 @@ public class Exile implements Serializable, Copyable<Exile> {
exile.clear();
}
}
public void cleanupEndOfTurnZones(Game game) {
// moves cards from outdated zone to main exile zone
ExileZone mainZone = getExileZone(PERMANENT);
for (ExileZone zone : exileZones.values()) {
if (zone.isCleanupOnEndTurn()) {
for (Card card : zone.getCards(game)) {
mainZone.add(card);
zone.remove(card);
}
}
}
}
}

View file

@ -1,13 +1,10 @@
package mage.game;
import java.util.UUID;
import mage.cards.CardsImpl;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class ExileZone extends CardsImpl {
@ -15,16 +12,22 @@ public class ExileZone extends CardsImpl {
private UUID id;
private String name;
private boolean hidden;
private boolean cleanupOnEndTurn = false; // moved cards from that zone to default on end of turn (to cleanup exile windows)
public ExileZone(UUID id, String name) {
this(id, name, false);
}
public ExileZone(UUID id, String name, boolean hidden) {
this(id, name, false, false);
}
public ExileZone(UUID id, String name, boolean hidden, boolean cleanupOnEndTurn) {
super();
this.id = id;
this.name = name;
this.hidden = hidden;
this.cleanupOnEndTurn = cleanupOnEndTurn;
}
public ExileZone(final ExileZone zone) {
@ -32,6 +35,7 @@ public class ExileZone extends CardsImpl {
this.id = zone.id;
this.name = zone.name;
this.hidden = zone.hidden;
this.cleanupOnEndTurn = zone.cleanupOnEndTurn;
}
public UUID getId() {
@ -46,6 +50,14 @@ public class ExileZone extends CardsImpl {
return hidden;
}
public boolean isCleanupOnEndTurn() {
return cleanupOnEndTurn;
}
public void setCleanupOnEndTurn(boolean cleanupOnEndTurn) {
this.cleanupOnEndTurn = cleanupOnEndTurn;
}
@Override
public ExileZone copy() {
return new ExileZone(this);

View file

@ -579,6 +579,7 @@ public class GameState implements Serializable, Copyable<GameState> {
public void removeEotEffects(Game game) {
effects.removeEndOfTurnEffects();
delayed.removeEndOfTurnAbilities();
exile.cleanupEndOfTurnZones(game);
game.applyEffects();
}