mirror of
https://github.com/magefree/mage.git
synced 2025-12-30 07:22:03 -08:00
* Some more rework of card mobement handling.
This commit is contained in:
parent
55fe68d718
commit
48195629c9
1 changed files with 19 additions and 15 deletions
|
|
@ -33,6 +33,8 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
|
|
@ -96,10 +98,10 @@ class LobotomyEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (targetPlayer != null && sourceObject != null && controller != null) {
|
||||
|
||||
// reveal hand of target player
|
||||
|
||||
// reveal hand of target player
|
||||
targetPlayer.revealCards(sourceObject.getName(), targetPlayer.getHand(), game);
|
||||
|
||||
|
||||
// You choose card other than a basic land card
|
||||
TargetCardInHand target = new TargetCardInHand(filter);
|
||||
target.setNotTarget(true);
|
||||
|
|
@ -107,51 +109,53 @@ class LobotomyEffect extends OneShotEffect {
|
|||
if (controller.choose(Outcome.Benefit, targetPlayer.getHand(), target, game)) {
|
||||
chosenCard = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Exile all cards with the same name
|
||||
// Building a card filter with the name
|
||||
FilterCard filterNamedCards = new FilterCard();
|
||||
if (chosenCard != null) {
|
||||
filterNamedCards.add(new NamePredicate(chosenCard.getName()));
|
||||
filterNamedCards.add(new NamePredicate(chosenCard.getName()));
|
||||
} else {
|
||||
filterNamedCards.add(new NamePredicate("----")); // so no card matches
|
||||
}
|
||||
|
||||
Cards cardsToExile = new CardsImpl();
|
||||
// The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone.
|
||||
// Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).
|
||||
// search cards in graveyard
|
||||
if (chosenCard != null) {
|
||||
for (Card checkCard : targetPlayer.getGraveyard().getCards(game)) {
|
||||
if (checkCard.getName().equals(chosenCard.getName())) {
|
||||
controller.moveCardToExileWithInfo(checkCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
cardsToExile.add(checkCard);
|
||||
}
|
||||
}
|
||||
|
||||
// search cards in hand
|
||||
TargetCardInHand targetCardsHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards);
|
||||
controller.chooseTarget(outcome, targetPlayer.getGraveyard(), targetCardsHand, source, game);
|
||||
for(UUID cardId: targetCardsHand.getTargets()) {
|
||||
for (UUID cardId : targetCardsHand.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
|
||||
cardsToExile.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// search cards in Library
|
||||
// If the player has no nonland cards in his or her hand, you can still search that player's library and have him or her shuffle it.
|
||||
if (chosenCard != null || controller.chooseUse(outcome, "Search library anyway?", source, game)) {
|
||||
TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards);
|
||||
controller.searchLibrary(targetCardsLibrary, game, targetPlayer.getId());
|
||||
for(UUID cardId: targetCardsLibrary.getTargets()) {
|
||||
for (UUID cardId : targetCardsLibrary.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
|
||||
cardsToExile.add(card);
|
||||
}
|
||||
}
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
|
||||
}
|
||||
if (!cardsToExile.isEmpty()) {
|
||||
controller.moveCards(cardsToExile, null, Zone.EXILED, source, game, true);
|
||||
}
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue