mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Fixed search library handling of Surgical Extraction.
This commit is contained in:
parent
ddbd3c3fa5
commit
a24067473a
8 changed files with 49 additions and 60 deletions
|
@ -92,15 +92,15 @@ class TransmuteArtifactEffect extends SearchEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
//Sacrifice an artifact.
|
||||
int convertedManaCost = 0;
|
||||
boolean sacrifice = false;
|
||||
TargetControlledPermanent targetArtifact = new TargetControlledPermanent(new FilterControlledArtifactPermanent());
|
||||
if(player.chooseTarget(Outcome.Sacrifice, targetArtifact, source, game)){
|
||||
if(controller.chooseTarget(Outcome.Sacrifice, targetArtifact, source, game)){
|
||||
Permanent permanent = game.getPermanent(targetArtifact.getFirstTarget());
|
||||
if(permanent != null){
|
||||
convertedManaCost = permanent.getManaCost().convertedManaCost();
|
||||
|
@ -112,34 +112,34 @@ class TransmuteArtifactEffect extends SearchEffect {
|
|||
return true;
|
||||
}
|
||||
//If you do, search your library for an artifact card.
|
||||
if (sacrifice && player.searchLibrary(target, game)) {
|
||||
if (sacrifice && controller.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = controller.getLibrary().getCard(cardId, game);
|
||||
if (card != null) {
|
||||
//If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield.
|
||||
if(card.getManaCost().convertedManaCost() <= convertedManaCost){
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId(), false);
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
//If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield.
|
||||
GenericManaCost cost = new GenericManaCost(card.getManaCost().convertedManaCost() - convertedManaCost);
|
||||
if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId(), false);
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
}
|
||||
else{
|
||||
//If you don't, put it into its owner's graveyard. Then shuffle your library
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
controller.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
controller.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ class PeregrinationEffect extends OneShotEffect {
|
|||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
revealed.add(card);
|
||||
}
|
||||
|
@ -113,23 +113,14 @@ class PeregrinationEffect extends OneShotEffect {
|
|||
player.choose(Outcome.Benefit, revealed, target2, game);
|
||||
Card card = revealed.get(target2.getFirstTarget(), game);
|
||||
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
|
||||
revealed.remove(card);
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setTapped(true);
|
||||
}
|
||||
card = revealed.getCards(game).iterator().next();
|
||||
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
else if (target.getTargets().size() == 1) {
|
||||
Card card = revealed.getCards(game).iterator().next();
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setTapped(true);
|
||||
}
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class GiftsUngivenEffect extends OneShotEffect {
|
|||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId : (List<UUID>) target.getTargets()) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
|
|
@ -92,7 +92,7 @@ class BuriedAliveEffect extends SearchEffect {
|
|||
if (player != null) {
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
|
|
|
@ -98,7 +98,7 @@ class KodamasReachEffect extends OneShotEffect {
|
|||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
revealed.add(card);
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ class ReapIntellectEffect extends OneShotEffect {
|
|||
TargetCard target = new TargetCard(0, xCost, Zone.PICK, filter);
|
||||
target.setNotTarget(true);
|
||||
if (you.choose(Outcome.Benefit, targetPlayer.getHand(), target, game)) {
|
||||
for (UUID cardId : (List<UUID>) target.getTargets()) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card chosenCard = game.getCard(cardId);
|
||||
if (chosenCard != null) {
|
||||
if (chosenCard.moveToExile(source.getSourceId(), "Reap Intellect", source.getSourceId(), game)) {
|
||||
|
@ -116,7 +116,6 @@ class ReapIntellectEffect extends OneShotEffect {
|
|||
}
|
||||
for (UUID cardId : exiledCards) {
|
||||
if (cardId != null) {
|
||||
if (targetPlayer != null) {
|
||||
Card card = game.getCard(cardId);
|
||||
|
||||
// cards in Graveyard
|
||||
|
@ -154,7 +153,6 @@ class ReapIntellectEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetPlayer.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ class SurgicalExtractionEffect extends OneShotEffect {
|
|||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getGraveyard().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetCard.moveToExile(null, null, source.getSourceId(), game);
|
||||
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ class SurgicalExtractionEffect extends OneShotEffect {
|
|||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getHand().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetCard.moveToExile(null, null, source.getSourceId(), game);
|
||||
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,12 +153,12 @@ class SurgicalExtractionEffect extends OneShotEffect {
|
|||
if (cardsCount > 0) {
|
||||
filter.setMessage("card named " + card.getName() + " in the library of " + targetPlayer.getName());
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter);
|
||||
if (player.choose(Outcome.Exile, cardsInLibrary, target, game)) {
|
||||
if (player.searchLibrary(target, game, targetPlayer.getId())) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getLibrary().getCard(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetCard.moveToExile(null, null, source.getSourceId(), game);
|
||||
player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class FiremindsForesightSearchEffect extends OneShotEffect {
|
|||
if (cardsCount > 0) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
|
|
Loading…
Reference in a new issue