mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 12:52:06 -08:00
Fixed effects using library.removeFromTop()
This commit is contained in:
parent
24c4b3d6c8
commit
d0dbb93f8f
19 changed files with 114 additions and 128 deletions
|
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
package mage.sets.invasion;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
|
|
@ -44,10 +47,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
|
@ -113,17 +112,16 @@ class FactOrFictionEffect extends OneShotEffect<FactOrFictionEffect> {
|
|||
TargetCard target = new TargetCard(0, cards.size(), Zone.PICK, new FilterCard("cards to put in the first pile"));
|
||||
|
||||
Cards pile1 = new CardsImpl();
|
||||
|
||||
while (opponent.choose(Outcome.Neutral, cards, target, game));
|
||||
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = cards.get(targetId, game);
|
||||
if (card != null) {
|
||||
pile1.add(card);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
if (opponent.choose(Outcome.Neutral, cards, target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = cards.get(targetId, game);
|
||||
if (card != null) {
|
||||
pile1.add(card);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.revealCards("Pile 1 (Fact or Fiction)", pile1, game);
|
||||
player.revealCards("Pile 2 (Fact or Fiction)", cards, game);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ class SageOwlEffect extends OneShotEffect<SageOwlEffect> {
|
|||
}
|
||||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 4);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.sets.magic2011;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
|
|
@ -94,19 +93,20 @@ class ConundrumSphinxEffect extends OneShotEffect<ConundrumSphinxEffect> {
|
|||
Choice cardChoice = new ChoiceImpl();
|
||||
cardChoice.setChoices(Sets.getCardNames());
|
||||
for (Player player: game.getPlayers().values()) {
|
||||
cardChoice.clearChoice();
|
||||
player.choose(Outcome.DrawCard, cardChoice, game);
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Conundrum Sphinx", cards, game);
|
||||
if (card.getName().equals(cardChoice.getChoice())) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, true);
|
||||
if(player.getLibrary().size() > 0){
|
||||
cardChoice.clearChoice();
|
||||
player.choose(Outcome.DrawCard, cardChoice, game);
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Conundrum Sphinx", cards, game);
|
||||
if (card.getName().equals(cardChoice.getChoice())) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, true);
|
||||
}
|
||||
else {
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,20 +79,22 @@ class DarkTutelageEffect extends OneShotEffect<DarkTutelageEffect> {
|
|||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
player.loseLife(card.getManaCost().convertedManaCost(), game);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Dark Tutelage", cards, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && player.getLibrary().size() > 0) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
player.loseLife(card.getManaCost().convertedManaCost(), game);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Dark Tutelage", cards, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DarkTutelageEffect copy() {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class SphinxOfUthuunEffect extends OneShotEffect<SphinxOfUthuunEffect> {
|
|||
}
|
||||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
int count = Math.min(player.getLibrary().size(), 5);
|
||||
int count = Math.min(player.getLibrary().size(), 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
|
|
@ -119,19 +119,18 @@ class SphinxOfUthuunEffect extends OneShotEffect<SphinxOfUthuunEffect> {
|
|||
TargetCard target = new TargetCard(0, cards.size(), Zone.PICK, new FilterCard("cards to put in the first pile"));
|
||||
|
||||
Cards pile1 = new CardsImpl();
|
||||
if (opponent.choose(Outcome.Neutral, cards, target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = cards.get(targetId, game);
|
||||
if (card != null) {
|
||||
pile1.add(card);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (opponent.choose(Outcome.Neutral, cards, target, game));
|
||||
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = cards.get(targetId, game);
|
||||
if (card != null) {
|
||||
pile1.add(card);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
player.revealCards("Pile 1 (Sphinx of Uthuun)", pile1, game);
|
||||
player.revealCards("Pile 1 (Sphinx of Uthuun)", pile1, game);
|
||||
player.revealCards("Pile 2 (Sphinx of Uthuun)", cards, game);
|
||||
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
|
|
|
|||
|
|
@ -32,17 +32,14 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ class LeadTheStampedeEffect extends OneShotEffect<LeadTheStampedeEffect> {
|
|||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
int creatureCardsFound = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@ class MitoticManipulationEffect extends OneShotEffect<MitoticManipulationEffect>
|
|||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
Cards cardsFound = new CardsImpl(Zone.PICK);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 7);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ class TezzeretAgentOfBolasEffect1 extends OneShotEffect<TezzeretAgentOfBolasEffe
|
|||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
boolean artifactFound = false;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ class ShrineOfPiercingVisionEffect extends OneShotEffect<ShrineOfPiercingVisionE
|
|||
int count = permanent.getCounters().getCount(CounterType.CHARGE);
|
||||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
count = Math.min(player.getLibrary().size(), count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@
|
|||
*/
|
||||
package mage.sets.newphyrexia;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
|
|
@ -117,43 +114,34 @@ class SurgicalExtractionEffect extends OneShotEffect<SurgicalExtractionEffect> {
|
|||
if (cardsCount > 0) {
|
||||
filter.setMessage("card named " + card.getName() + " in the graveyard of " + targetPlayer.getName());
|
||||
TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filter);
|
||||
|
||||
while (target.canChoose(player.getId(), game)) {
|
||||
if (!player.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Card targetCard = targetPlayer.getGraveyard().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetPlayer.getGraveyard().remove(targetCard);
|
||||
targetCard.moveToZone(Zone.EXILED, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getGraveyard().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetPlayer.getGraveyard().remove(targetCard);
|
||||
targetCard.moveToZone(Zone.EXILED, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cards in Hand
|
||||
cardsCount = targetPlayer.getHand().count(filter, game);
|
||||
if (cardsCount > 0) {
|
||||
filter.setMessage("card named " + card.getName() + " in the hand of " + targetPlayer.getName());
|
||||
TargetCardInHand target = new TargetCardInHand(0, cardsCount, filter);
|
||||
|
||||
while (target.canChoose(player.getId(), game)) {
|
||||
if (!player.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Card targetCard = targetPlayer.getHand().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetPlayer.getHand().remove(targetCard);
|
||||
targetCard.moveToZone(Zone.EXILED, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (player.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getHand().get(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetPlayer.getHand().remove(targetCard);
|
||||
targetCard.moveToZone(Zone.EXILED, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.lookAtCards(targetPlayer.getName() + " hand", targetPlayer.getHand(), game);
|
||||
}
|
||||
|
||||
|
|
@ -162,19 +150,15 @@ class SurgicalExtractionEffect extends OneShotEffect<SurgicalExtractionEffect> {
|
|||
if (cardsCount > 0) {
|
||||
filter.setMessage("card named " + card.getName() + " in the library of " + targetPlayer.getName());
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter);
|
||||
|
||||
while (target.canChoose(player.getId(), game)) {
|
||||
if (!player.choose(Outcome.Exile, cardsInLibrary, target, game)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Card targetCard = targetPlayer.getLibrary().remove(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetCard.moveToZone(Zone.EXILED, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
if (player.choose(Outcome.Exile, cardsInLibrary, target, game)) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card targetCard = targetPlayer.getLibrary().remove(targetId, game);
|
||||
if (targetCard != null) {
|
||||
targetCard.moveToZone(Zone.EXILED, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.lookAtCards(targetPlayer.getName() + " library", cardsInLibrary, game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,15 +104,17 @@ class SarkhanTheMadRevealAndDrawEffect extends OneShotEffect<SarkhanTheMadReveal
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
permanent.damage(card.getManaCost().convertedManaCost(), this.getId(), game, false, false);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Sarkhan the Mad", cards, game);
|
||||
return true;
|
||||
if (player != null && player.getLibrary().size() > 0) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
permanent.damage(card.getManaCost().convertedManaCost(), this.getId(), game, false, false);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Sarkhan the Mad", cards, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class GenesisWaveEffect extends OneShotEffect<GenesisWaveEffect> {
|
|||
Player player = game.getPlayer(source.getControllerId());
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
int count = source.getManaCostsToPay().getX();
|
||||
count = Math.min(player.getLibrary().size(), count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.sets.scarsofmirrodin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
|
|
@ -41,11 +40,8 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
|
|
@ -55,7 +51,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class ShapeAnew extends CardImpl<ShapeAnew> {
|
||||
|
||||
private static FilterPermanent filter = new FilterPermanent("an artifact");
|
||||
private static final FilterPermanent filter = new FilterPermanent("an artifact");
|
||||
|
||||
static {
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class Traumatize extends CardImpl<Traumatize> {
|
|||
class TraumatizeEffect extends OneShotEffect<TraumatizeEffect> {
|
||||
|
||||
public TraumatizeEffect() {
|
||||
super(Outcome.GainLife);
|
||||
super(Outcome.Detriment);
|
||||
staticText = "Target player puts the top half of his or her library, rounded down, into his or her graveyard";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ class HalimarDepthsEffect extends OneShotEffect<HalimarDepthsEffect> {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 3);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
cards.add(card);
|
||||
game.setZone(card.getId(), Zone.PICK);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ class BeastHuntEffect extends OneShotEffect<BeastHuntEffect> {
|
|||
}
|
||||
|
||||
Cards cards = new CardsImpl();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 3);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,8 @@ class MerfolkWayfinderEffect extends OneShotEffect<MerfolkWayfinderEffect> {
|
|||
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
Cards cardsToReveal = new CardsImpl();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int count = Math.min(player.getLibrary().size(), 3);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
cardsToReveal.add(card);
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import java.util.*;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.TriggeredAbilities;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue