[CLB] Implement Lae'zel's Acrobatics. Changed similar cards to use common logic (#9856)

This commit is contained in:
Rowan Gudmundsson 2023-03-01 10:50:14 -08:00 committed by GitHub
parent 049dd48d0a
commit d5e74dd710
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 188 additions and 43 deletions

View file

@ -0,0 +1,34 @@
package mage.util;
import java.util.Set;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.MeldCard;
import mage.game.Game;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentMeld;
public class ExileUtil {
public static Cards returnCardsFromExile(Set<Card> cards, Game game) {
Cards cardsToReturn = new CardsImpl();
for (Card exiled : cards) {
if (exiled instanceof PermanentMeld) {
MeldCard meldCard = (MeldCard) ((PermanentCard) exiled).getCard();
Card topCard = meldCard.getTopHalfCard();
Card bottomCard = meldCard.getBottomHalfCard();
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter()) {
cardsToReturn.add(topCard);
}
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter()) {
cardsToReturn.add(bottomCard);
}
} else if (exiled.getZoneChangeCounter(game) == game.getState().getZoneChangeCounter(exiled.getId()) - 1) {
cardsToReturn.add(exiled);
}
}
return cardsToReturn;
}
}