mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Some fixed to card movement.
This commit is contained in:
parent
21437efe84
commit
2da4fdf72a
4 changed files with 8 additions and 34 deletions
|
@ -27,13 +27,12 @@
|
|||
*/
|
||||
package mage.abilities.common.delayed;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
@ -50,9 +49,9 @@ import mage.util.CardUtil;
|
|||
* Returns the exiled cards/permanents as source leaves battlefield
|
||||
*
|
||||
* Uses no stack
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class OnLeaveReturnExiledToBattlefieldAbility extends DelayedTriggeredAbility {
|
||||
|
||||
public OnLeaveReturnExiledToBattlefieldAbility() {
|
||||
|
@ -108,22 +107,12 @@ class ReturnExiledPermanentsEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null && controller != null) {
|
||||
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1;
|
||||
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
|
||||
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter);
|
||||
if (exileZone != null) {
|
||||
ExileZone exile = game.getExile().getExileZone(exileZone);
|
||||
if (exile != null) {
|
||||
LinkedList<UUID> cards = new LinkedList<>(exile);
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null && owner.isInGame()) {
|
||||
owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
exile.clear();
|
||||
controller.moveCards(new LinkedHashSet<>(exile.getCards(game)), Zone.EXILED, source, game, false, false, true, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ package mage.abilities.effects.common;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import static mage.constants.Zone.BATTLEFIELD;
|
||||
|
@ -102,16 +101,7 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
|||
}
|
||||
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
|
||||
if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved
|
||||
if (returnToZone.equals(Zone.BATTLEFIELD)) {
|
||||
for (Card card : exile.getCards(game)) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
controller.moveCards(exile, Zone.EXILED, returnToZone, source, game);
|
||||
}
|
||||
controller.moveCards(exile, null, returnToZone, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -644,7 +644,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param tapped tha cards are tapped on the battlefield
|
||||
* @param faceDown the cards are face down in the to zone
|
||||
* @param byOwner the card is moved (or put onto battlefield) by the owner
|
||||
* of the card (instead of the controller of the source)
|
||||
* of the card and if target zone is battlefield controlls the permanent
|
||||
* (instead of the controller of the source)
|
||||
* @return
|
||||
*/
|
||||
boolean moveCards(Set<Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList<UUID> appliedEffects);
|
||||
|
|
|
@ -3015,13 +3015,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
break;
|
||||
case BATTLEFIELD:
|
||||
for (Card card : cards) {
|
||||
fromZone = game.getState().getZone(card.getId());
|
||||
if (putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, card.isFaceDown(game))) {
|
||||
successfulMovedCards.add(card);
|
||||
}
|
||||
}
|
||||
break;
|
||||
return moveCards(cards, toZone, source, game, false, false, false, null);
|
||||
case LIBRARY:
|
||||
for (Card card : cards) {
|
||||
fromZone = game.getState().getZone(card.getId());
|
||||
|
|
Loading…
Reference in a new issue