mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
* Extirpate - Fixed that the hand and library of target card owner could not be serached.
This commit is contained in:
parent
7d863c25a2
commit
fa709bfd5e
3 changed files with 53 additions and 57 deletions
|
@ -102,73 +102,63 @@ class SurgicalExtractionEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Card card = game.getCard(source.getFirstTarget());
|
Card chosenCard = game.getCard(source.getFirstTarget());
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
|
||||||
// 6/1/2011 "Any number of cards" means just that. If you wish, you can choose to
|
// 6/1/2011 "Any number of cards" means just that. If you wish, you can choose to
|
||||||
// leave some or all of the cards with the same name as the targeted card,
|
// leave some or all of the cards with the same name as the targeted card,
|
||||||
// including that card, in the zone they're in.
|
// including that card, in the zone they're in.
|
||||||
if (card != null && player != null) {
|
if (chosenCard != null && controller != null) {
|
||||||
Player targetPlayer = game.getPlayer(card.getOwnerId());
|
Player owner = game.getPlayer(chosenCard.getOwnerId());
|
||||||
if (targetPlayer != null) {
|
if (owner != null) {
|
||||||
FilterCard filter = new FilterCard("card named " + card.getName());
|
FilterCard filterNamedCard = new FilterCard("card named " + chosenCard.getName());
|
||||||
filter.add(new NamePredicate(card.getName()));
|
filterNamedCard.add(new NamePredicate(chosenCard.getName()));
|
||||||
|
|
||||||
Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY);
|
Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY);
|
||||||
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
|
cardsInLibrary.addAll(owner.getLibrary().getCards(game));
|
||||||
|
|
||||||
// cards in Graveyard
|
// cards in Graveyard
|
||||||
int cardsCount = targetPlayer.getGraveyard().count(filter, game);
|
int cardsCount = owner.getGraveyard().count(filterNamedCard, game);
|
||||||
if (cardsCount > 0) {
|
if (cardsCount > 0) {
|
||||||
filter.setMessage("card named " + card.getName() + " in the graveyard of " + targetPlayer.getName());
|
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the graveyard of " + owner.getName());
|
||||||
TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filter);
|
TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filterNamedCard);
|
||||||
if (player.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
|
if (controller.choose(Outcome.Exile, owner.getGraveyard(), target, game)) {
|
||||||
List<UUID> targets = target.getTargets();
|
List<UUID> targets = target.getTargets();
|
||||||
for (UUID targetId : targets) {
|
for (UUID targetId : targets) {
|
||||||
Card targetCard = targetPlayer.getGraveyard().get(targetId, game);
|
Card targetCard = owner.getGraveyard().get(targetId, game);
|
||||||
if (targetCard != null) {
|
if (targetCard != null) {
|
||||||
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD);
|
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cards in Hand
|
// cards in Hand
|
||||||
cardsCount = targetPlayer.getHand().count(filter, game);
|
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the hand of " + owner.getName());
|
||||||
if (cardsCount > 0) {
|
TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCard);
|
||||||
filter.setMessage("card named " + card.getName() + " in the hand of " + targetPlayer.getName());
|
if (controller.choose(Outcome.Exile, owner.getHand(), targetCardInHand, game)) {
|
||||||
TargetCardInHand target = new TargetCardInHand(0, cardsCount, filter);
|
List<UUID> targets = targetCardInHand.getTargets();
|
||||||
if (player.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
|
for (UUID targetId : targets) {
|
||||||
List<UUID> targets = target.getTargets();
|
Card targetCard = owner.getHand().get(targetId, game);
|
||||||
for (UUID targetId : targets) {
|
if (targetCard != null) {
|
||||||
Card targetCard = targetPlayer.getHand().get(targetId, game);
|
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND);
|
||||||
if (targetCard != null) {
|
|
||||||
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
player.lookAtCards(targetPlayer.getName() + " hand", targetPlayer.getHand(), game);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cards in Library
|
// cards in Library
|
||||||
cardsCount = cardsInLibrary.count(filter, game);
|
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the library of " + owner.getName());
|
||||||
if (cardsCount > 0) {
|
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard);
|
||||||
filter.setMessage("card named " + card.getName() + " in the library of " + targetPlayer.getName());
|
if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) {
|
||||||
TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter);
|
List<UUID> targets = targetCardInLibrary.getTargets();
|
||||||
if (player.searchLibrary(target, game, targetPlayer.getId())) {
|
for (UUID targetId : targets) {
|
||||||
List<UUID> targets = target.getTargets();
|
Card targetCard = owner.getLibrary().getCard(targetId, game);
|
||||||
for (UUID targetId : targets) {
|
if (targetCard != null) {
|
||||||
Card targetCard = targetPlayer.getLibrary().getCard(targetId, game);
|
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY);
|
||||||
if (targetCard != null) {
|
|
||||||
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
player.lookAtCards(targetPlayer.getName() + " library", cardsInLibrary, game);
|
|
||||||
}
|
}
|
||||||
targetPlayer.shuffleLibrary(game);
|
owner.shuffleLibrary(game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ class ExtirpateEffect extends OneShotEffect {
|
||||||
|
|
||||||
// Exile all cards with the same name
|
// Exile all cards with the same name
|
||||||
// Building a card filter with the name
|
// Building a card filter with the name
|
||||||
FilterCard filterNamedCards = new FilterCard();
|
FilterCard filterNamedCard = new FilterCard();
|
||||||
filterNamedCards.add(new NamePredicate(chosenCard.getName()));
|
filterNamedCard.add(new NamePredicate(chosenCard.getName()));
|
||||||
|
|
||||||
// The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone.
|
// 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).
|
// Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).
|
||||||
|
@ -129,22 +129,28 @@ class ExtirpateEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
// search cards in hand
|
// search cards in hand
|
||||||
TargetCardInHand targetCardsHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards);
|
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the hand of " + owner.getName());
|
||||||
controller.chooseTarget(outcome, owner.getGraveyard(), targetCardsHand, source, game);
|
TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCard);
|
||||||
for(UUID cardId: targetCardsHand.getTargets()) {
|
if (controller.choose(Outcome.Exile, owner.getHand(), targetCardInHand, game)) {
|
||||||
Card card = game.getCard(cardId);
|
List<UUID> targets = targetCardInHand.getTargets();
|
||||||
if (card != null) {
|
for (UUID targetId : targets) {
|
||||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND);
|
Card targetCard = owner.getHand().get(targetId, game);
|
||||||
|
if (targetCard != null) {
|
||||||
|
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// search cards in Library
|
// search cards in Library
|
||||||
TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards);
|
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the library of " + owner.getName());
|
||||||
controller.searchLibrary(targetCardsLibrary, game, owner.getId());
|
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard);
|
||||||
for(UUID cardId: targetCardsLibrary.getTargets()) {
|
if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) {
|
||||||
Card card = game.getCard(cardId);
|
List<UUID> targets = targetCardInLibrary.getTargets();
|
||||||
if (card != null) {
|
for (UUID targetId : targets) {
|
||||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY);
|
Card targetCard = owner.getLibrary().getCard(targetId, game);
|
||||||
|
if (targetCard != null) {
|
||||||
|
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
owner.shuffleLibrary(game);
|
owner.shuffleLibrary(game);
|
||||||
|
|
|
@ -371,7 +371,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
boolean isInUseableZone(Game game, MageObject source, boolean checkLKI);
|
boolean isInUseableZone(Game game, MageObject source, boolean checkLKI);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this ability has to be shown on top of the card.
|
* Returns true if this ability has to be shown as topmost of all the rules of the object
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue