mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Started to rework player.moveCard methods to handle multiple cards.
This commit is contained in:
parent
e68bd0e876
commit
467a11b4cd
48 changed files with 241 additions and 359 deletions
|
@ -129,7 +129,7 @@ class TransmuteArtifactEffect extends SearchEffect {
|
|||
}
|
||||
else{
|
||||
//If you don't, put it into its owner's graveyard. Then shuffle your library
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class HeedTheMists extends CardImpl {
|
|||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
int cmc = card.getManaCost().convertedManaCost();
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
controller.drawCards(cmc, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,19 +119,14 @@ class GiftsUngivenEffect extends OneShotEffect {
|
|||
} else {
|
||||
opponent = game.getPlayer(game.getOpponents(player.getId()).iterator().next());
|
||||
}
|
||||
TargetCard targetDiscard = new TargetCard(2, Zone.PICK, new FilterCard("cards to put in graveyard"));
|
||||
TargetCard targetDiscard = new TargetCard(2, Zone.LIBRARY, new FilterCard("cards to put in graveyard"));
|
||||
if (opponent != null && opponent.choose(Outcome.Discard, cards, targetDiscard, game)) {
|
||||
cardsToKeep.removeAll(targetDiscard.getTargets());
|
||||
cards.removeAll(cardsToKeep);
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
for (UUID cardId : cardsToKeep) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
|
|
|
@ -105,15 +105,10 @@ class StitcherGeralfEffect extends OneShotEffect {
|
|||
for (UUID playerId: controller.getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (int i = 0; i < Math.min(3, player.getLibrary().size()); i++) {
|
||||
Card card = player.getLibrary().getFromTop(game);
|
||||
if (player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY)) {
|
||||
// add card only if it goes to graveyard
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
cards.addAll(player.getLibrary().getTopCards(game, 3));
|
||||
}
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
TargetCard target = new TargetCard(0,2,Zone.GRAVEYARD, new FilterCreatureCard("creature cards to exile"));
|
||||
controller.chooseTarget(outcome, cards, target, source, game);
|
||||
int power = 0;
|
||||
|
|
|
@ -117,7 +117,7 @@ class GrenzoDungeonWardenEffect extends OneShotEffect {
|
|||
|
||||
GrenzoDungeonWardenEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Put the bottom card of your library into your graveyard. If it's a creature card with power less than or equal to Grenzo's power, put it onto the battlefield";
|
||||
this.staticText = "Put the bottom card of your library into your graveyard. If it's a creature card with power less than or equal to {this}'s power, put it onto the battlefield";
|
||||
}
|
||||
|
||||
GrenzoDungeonWardenEffect(final GrenzoDungeonWardenEffect effect) {
|
||||
|
@ -131,16 +131,16 @@ class GrenzoDungeonWardenEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
if (player.getLibrary().size() > 0) {
|
||||
Card card = player.getLibrary().removeFromBottom(game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller.getLibrary().size() > 0) {
|
||||
Card card = controller.getLibrary().removeFromBottom(game);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (sourcePermanent != null && card.getPower().getValue() <= sourcePermanent.getPower().getValue()) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,22 +101,17 @@ class GurmagDrownerEffect extends OneShotEffect {
|
|||
if (controller != null && sourceObject != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 4));
|
||||
|
||||
if (cards.size() > 0) {
|
||||
controller.lookAtCards(sourceObject.getName(), cards, game);
|
||||
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
|
||||
if (controller.choose(Outcome.Benefit, cards, target, game)) {
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
for (Card card : cards.getCards(game)) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ class SkirkDrillSergeantEffect extends OneShotEffect {
|
|||
if (filter.match(card, game)) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
} else {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,12 +161,7 @@ class OathOfDruidsEffect extends OneShotEffect {
|
|||
player.putOntoBattlefieldWithInfo(creatureCard, game, Zone.LIBRARY, source.getSourceId());
|
||||
}
|
||||
// and all other cards revealed this way into his or her graveyard
|
||||
for (UUID uuid : nonCreatureCards) {
|
||||
Card card = game.getCard(uuid);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
player.moveCards(nonCreatureCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,13 +94,7 @@ class PsychicStrikeEffect extends OneShotEffect {
|
|||
if (stackObject != null) {
|
||||
Player controller = game.getPlayer(stackObject.getControllerId());
|
||||
if (controller != null) {
|
||||
int cardsCount = Math.min(2, controller.getLibrary().size());
|
||||
for (int i = 0; i < cardsCount; i++) {
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
controller.moveCards(controller.getLibrary().getTopCards(game, 2), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
return countered;
|
||||
|
|
|
@ -112,26 +112,19 @@ class EnduringRenewalReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you == null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
} else if (you.getLibrary().size() > 0){
|
||||
|
||||
Card top = you.getLibrary().getFromTop(game);
|
||||
|
||||
}
|
||||
Card card = controller.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
|
||||
cards.add(top);
|
||||
|
||||
you.revealCards("Top card of " + you.getName() + "'s library", cards, game);
|
||||
|
||||
if (top.getCardType().contains(CardType.CREATURE)) {
|
||||
you.moveCardToGraveyardWithInfo(top, source.getSourceId(), game, Zone.LIBRARY);
|
||||
} else {
|
||||
you.moveCardToHandWithInfo(top, source.getSourceId(), game, Zone.LIBRARY);
|
||||
cards.add(card);
|
||||
controller.revealCards("Top card of " + controller.getName() + "'s library", cards, game);
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -114,10 +114,8 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
currentPlayer.getLife() >= 2 &&
|
||||
currentPlayer.chooseUse(Outcome.Benefit, message, game)) {
|
||||
currentPlayer.loseLife(2, game);
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
|
||||
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
game.getState().getRevealed().reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,18 +89,21 @@ class MulchEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
int count = Math.min(controller.getLibrary().size(), 4);
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, count));
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 4));
|
||||
if (!cards.isEmpty()) {
|
||||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
Cards landCards = new CardsImpl();
|
||||
Cards otherCards = new CardsImpl();
|
||||
for (Card card: cards.getCards(game)) {
|
||||
cards.add(card);
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
landCards.add(card);
|
||||
} else {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
otherCards.add(card);
|
||||
}
|
||||
}
|
||||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
controller.moveCards(landCards, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
controller.moveCards(otherCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -115,15 +115,14 @@ class TrepanationBladeDiscardEffect extends OneShotEffect {
|
|||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
landFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
if (!cards.isEmpty()) {
|
||||
player.revealCards("Trepanation Blade", cards, game);
|
||||
player.revealCards(equipment.getName(), cards, game);
|
||||
game.getState().setValue(source.getSourceId().toString() + "_TrepanationBlade", cards.size());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -98,16 +98,19 @@ class UndeadAlchemistTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return new UndeadAlchemistTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Zone.LIBRARY && zEvent.getToZone() == Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId()));
|
||||
return true;
|
||||
}
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Zone.LIBRARY && zEvent.getToZone() == Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -134,30 +137,23 @@ class UndeadAlchemistEffect extends ReplacementEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player player = game.getPlayer(event.getTargetId());
|
||||
if (player != null) {
|
||||
int cardsCount = Math.min(event.getAmount(), player.getLibrary().size());
|
||||
for (int i = 0; i < cardsCount; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return player.moveCards(player.getLibrary().getTopCards(game, event.getAmount()), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGE_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event instanceof DamagePlayerEvent) {
|
||||
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
|
||||
if (damageEvent.isCombatDamage()) {
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent != null && permanent.hasSubtype("Zombie")) {
|
||||
return true;
|
||||
}
|
||||
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
|
||||
if (damageEvent.isCombatDamage()) {
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent != null && permanent.hasSubtype("Zombie")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -112,12 +112,9 @@ class RevivingVaporsEffect extends OneShotEffect {
|
|||
}
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
|
||||
for (Card moveCard: cards.getCards(game)) {
|
||||
controller.moveCardToGraveyardWithInfo(moveCard, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -93,13 +93,7 @@ class CountermandEffect extends OneShotEffect {
|
|||
if (stackObject != null) {
|
||||
Player controller = game.getPlayer(stackObject.getControllerId());
|
||||
if (controller != null) {
|
||||
int cardsCount = Math.min(4, controller.getLibrary().size());
|
||||
for (int i = 0; i < cardsCount; i++) {
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
controller.moveCards(controller.getLibrary().getTopCards(game, 4), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
return countered;
|
||||
|
|
|
@ -105,9 +105,9 @@ class DakraMysticEffect extends OneShotEffect {
|
|||
}
|
||||
if (controller.chooseUse(outcome, "Put revealed cards into graveyard?", game)) {
|
||||
for(UUID playerId: controller.getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.getLibrary().size() > 0) {
|
||||
controller.moveCardToGraveyardWithInfo(player.getLibrary().getFromTop(game), source.getSourceId(), game, Zone.LIBRARY);
|
||||
player.moveCards(player.getLibrary().getFromTop(game), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -99,20 +99,20 @@ class BitterRevelationEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (cards.size() > 0) {
|
||||
Cards cardsToHand = new CardsImpl();
|
||||
player.lookAtCards("Bitter Revelation", cards, game);
|
||||
TargetCard target = new TargetCard(Math.min(2, cards.size()), Zone.PICK, new FilterCard("two cards to put in your hand"));
|
||||
if (player.choose(Outcome.DrawCard, cards, target, game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Card card = cards.get(targetId, game);
|
||||
if (card != null) {
|
||||
player.putInHand(card, game);
|
||||
cardsToHand.add(card);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Card card : cards.getCards(game)) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
player.moveCards(cardsToHand, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -117,18 +117,12 @@ class ScoutTheBordersEffect extends OneShotEffect {
|
|||
if (properCardFound && controller.choose(Outcome.DrawCard, cards, target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
cards.remove(card);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -106,15 +106,15 @@ class SeeTheUnwrittenEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (player != null && sourceObject != null) {
|
||||
if (controller != null && sourceObject != null) {
|
||||
Cards cards = new CardsImpl(Zone.LIBRARY);
|
||||
|
||||
int creatureCardsFound = 0;
|
||||
int count = Math.min(player.getLibrary().size(), 8);
|
||||
int count = Math.min(controller.getLibrary().size(), 8);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) {
|
||||
|
@ -124,27 +124,22 @@ class SeeTheUnwrittenEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
if (!cards.isEmpty()) {
|
||||
player.revealCards(sourceObject.getName(), cards, game);
|
||||
if (creatureCardsFound > 0 && player.chooseUse(outcome, "Put creature(s) into play?", game)) {
|
||||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
if (creatureCardsFound > 0 && controller.chooseUse(outcome, "Put creature(s) into play?", game)) {
|
||||
int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound);
|
||||
TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, filter);
|
||||
if (player.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
|
||||
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
|
||||
for(UUID creatureId: target.getTargets()) {
|
||||
Card card = game.getCard(creatureId);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -98,22 +98,17 @@ class SultaiSoothsayerEffect extends OneShotEffect {
|
|||
if (controller != null && sourceObject != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 4));
|
||||
|
||||
if (cards.size() > 0) {
|
||||
controller.lookAtCards(sourceObject.getName(), cards, game);
|
||||
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
|
||||
if (controller.choose(Outcome.Benefit, cards, target, game)) {
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
for (Card card : cards.getCards(game)) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -95,38 +95,20 @@ class TaigamsSchemingEffect extends OneShotEffect {
|
|||
controller.setTopCardRevealed(false);
|
||||
// get cards from top
|
||||
Cards cards = new CardsImpl();
|
||||
int count = Math.min(controller.getLibrary().size(), 5);
|
||||
if (count > 0) {
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, count));
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 5));
|
||||
if (!cards.isEmpty()) {
|
||||
controller.lookAtCards(sourceObject.getName(), cards, game);
|
||||
// pick cards going to graveyard
|
||||
TargetCard target = new TargetCard(0,5, Zone.LIBRARY, new FilterCard("cards to put into your graveyard"));
|
||||
TargetCard target = new TargetCard(0,cards.size(), Zone.LIBRARY, new FilterCard("cards to put into your graveyard"));
|
||||
if (controller.choose(Outcome.Detriment, cards, target, game)) {
|
||||
for (UUID cardId : (List<UUID>)target.getTargets()) {
|
||||
Card card = cards.get(cardId, game);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
Cards cardsToGraveyard = new CardsImpl();
|
||||
cards.removeAll(target.getTargets());
|
||||
cardsToGraveyard.addAll(target.getTargets());
|
||||
controller.moveCards(cardsToGraveyard, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
// The rest goes back to library in any order
|
||||
if (cards.size() > 0) {
|
||||
game.informPlayers(controller.getLogName() + " puts " + cards.size() + " card" + (cards.size() ==1 ? "":"s") + " back to his or her library");
|
||||
target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on your library (last chosen will be on top)"));
|
||||
while (controller.isInGame() && cards.size() > 1) {
|
||||
controller.choose(Outcome.Neutral, cards, target, game);
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
if (cards.size() == 1) {
|
||||
Card card = cards.get(cards.iterator().next(), game);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
}
|
||||
controller.putCardsOnTopOfLibrary(cards, game, source, true);
|
||||
}
|
||||
}
|
||||
controller.setTopCardRevealed(topCardRevealed);
|
||||
|
|
|
@ -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;
|
||||
|
@ -98,13 +100,7 @@ class LifesFinaleEffect extends OneShotEffect {
|
|||
if (player != null && opponent != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCreatureCard("creature cards from his library to put in his graveyard"));
|
||||
if (player.searchLibrary(target, game, opponent.getId())) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
player.moveCards(new CardsImpl(target.getTargets()), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
opponent.shuffleLibrary(game);
|
||||
return true;
|
||||
|
|
|
@ -54,7 +54,6 @@ public class Entomb extends CardImpl {
|
|||
super(ownerId, 132, "Entomb", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}");
|
||||
this.expansionSetCode = "ODY";
|
||||
|
||||
|
||||
// Search your library for a card and put that card into your graveyard. Then shuffle your library.
|
||||
this.getSpellAbility().addEffect(new SearchLibraryPutInGraveyard());
|
||||
}
|
||||
|
@ -92,20 +91,11 @@ class SearchLibraryPutInGraveyard extends SearchEffect {
|
|||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
boolean result = false;
|
||||
if (controller.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = controller.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
result = true;
|
||||
controller.moveCards(game.getCard(target.getFirstTarget()), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
controller.shuffleLibrary(game);
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,15 +97,12 @@ class PredictEffect extends OneShotEffect {
|
|||
int amount = 1;
|
||||
Card card = targetPlayer.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
if (targetPlayer.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY)) {
|
||||
if (card.getName().equals(cardName)) {
|
||||
amount = 2;
|
||||
}
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
if (card.getName().equals(cardName)) {
|
||||
amount = 2;
|
||||
}
|
||||
}
|
||||
|
||||
controller.drawCards(amount, game);
|
||||
|
||||
}
|
||||
controller.drawCards(amount, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -109,7 +109,7 @@ class ZoologistEffect extends OneShotEffect {
|
|||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
} else {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,13 +112,11 @@ class GrislySalvageEffect extends OneShotEffect {
|
|||
if (properCardFound && controller.choose(Outcome.DrawCard, cards, target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
for (Card card : cards.getCards(game)) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class RealmsUnchartedEffect extends OneShotEffect {
|
|||
if (controller.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 = controller.getLibrary().getCard(cardId, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
|
@ -129,19 +129,8 @@ class RealmsUnchartedEffect extends OneShotEffect {
|
|||
cards.removeAll(cardsToKeep);
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
for (UUID cardId : cardsToKeep) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
controller.moveCards(cardsToKeep, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
}
|
||||
controller.shuffleLibrary(game);
|
||||
return true;
|
||||
|
|
|
@ -97,8 +97,9 @@ class MurmursFromBeyondEffect extends OneShotEffect {
|
|||
cards.addAll(controller.getLibrary().getTopCards(game, 3));
|
||||
if (!cards.isEmpty()) {
|
||||
controller.revealCards(staticText, cards, game);
|
||||
Card cardToGraveyard;
|
||||
if (cards.size() == 1) {
|
||||
controller.moveCardToGraveyardWithInfo(cards.getRandom(game), source.getSourceId(), game, Zone.LIBRARY);
|
||||
cardToGraveyard = cards.getRandom(game);
|
||||
} else {
|
||||
Player opponent;
|
||||
Set<UUID> opponents = game.getOpponents(controller.getId());
|
||||
|
@ -111,15 +112,13 @@ class MurmursFromBeyondEffect extends OneShotEffect {
|
|||
}
|
||||
TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard());
|
||||
opponent.chooseTarget(outcome, cards, target, source, game);
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(cards.getRandom(game), source.getSourceId(), game, Zone.LIBRARY);
|
||||
cards.remove(card);
|
||||
}
|
||||
for (Card cardToHand: cards.getCards(game)) {
|
||||
controller.moveCardToHandWithInfo(cardToHand, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
cardToGraveyard = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
if (cardToGraveyard != null) {
|
||||
controller.moveCards(cardToGraveyard,Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
cards.remove(cardToGraveyard);
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -123,11 +123,7 @@ class GenesisWaveEffect extends OneShotEffect {
|
|||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
}
|
||||
}
|
||||
while (cards.size() > 0) {
|
||||
Card card = cards.get(cards.iterator().next(), game);
|
||||
cards.remove(card);
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ class ImpromptuRaidEffect extends OneShotEffect {
|
|||
cards.add(card);
|
||||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
return true;
|
||||
}
|
||||
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId())) {
|
||||
|
|
|
@ -42,7 +42,6 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.common.FilterBasicLandCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Library;
|
||||
|
@ -67,8 +66,6 @@ public class HermitDruid extends CardImpl {
|
|||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HermitDruidEffect(), new ManaCostsImpl("{G}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public HermitDruid(final HermitDruid card) {
|
||||
|
@ -109,13 +106,13 @@ class HermitDruidEffect extends OneShotEffect {
|
|||
}
|
||||
CardsImpl cards = new CardsImpl();
|
||||
Card card;
|
||||
Filter filter = new FilterBasicLandCard();
|
||||
FilterBasicLandCard filter = new FilterBasicLandCard();
|
||||
do {
|
||||
card = library.removeFromTop(game);
|
||||
if (card != null) {
|
||||
|
||||
if (filter.match(card, game)) {
|
||||
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
player.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
} else {
|
||||
cards.add(card);
|
||||
}
|
||||
|
@ -123,9 +120,7 @@ class HermitDruidEffect extends OneShotEffect {
|
|||
} while (library.size() > 0 && card != null && !filter.match(card, game));
|
||||
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card cardToGrave: cards.getCards(game)) {
|
||||
player.moveCardToGraveyardWithInfo(cardToGrave, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class MoxDiamondReplacementEffect extends ReplacementEffectImpl {
|
|||
else{
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, null);
|
||||
player.moveCards(card, Zone.STACK, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
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;
|
||||
|
@ -106,23 +108,18 @@ class GrindstoneEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
colorShared = false;
|
||||
Card card1 = null;
|
||||
Card card2 = null;
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
card1 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(targetPlayer.getLibrary().getTopCards(game, 2));
|
||||
if (!cards.isEmpty()) {
|
||||
Card card1 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (targetPlayer.getLibrary().size() > 0) {
|
||||
card2 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
Card card2 = targetPlayer.getLibrary().removeFromTop(game);
|
||||
if (card1.getColor().hasColor() && card2.getColor().hasColor()) {
|
||||
colorShared = card1.getColor().shares(card2.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (card1 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card1, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
if (card2 != null) {
|
||||
targetPlayer.moveCardToGraveyardWithInfo(card2, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
targetPlayer.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
} while (colorShared && targetPlayer.isInGame());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -119,17 +119,11 @@ class CommuneWithTheGodsEffect extends OneShotEffect {
|
|||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (UUID cardId : cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -237,10 +237,7 @@ class GrinningTotemPutIntoGraveyardEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
if (controller != null && zone != null) {
|
||||
for (Card card : zone.getCards(game)) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED);
|
||||
}
|
||||
return true;
|
||||
return controller.moveCards(zone, Zone.EXILED, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class PullFromEternityEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED);
|
||||
controller.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -98,9 +98,9 @@ class WandOfDenialEffect extends OneShotEffect {
|
|||
if (!card.getCardType().contains(CardType.LAND)
|
||||
&& controller.canPayLifeCost()
|
||||
&& controller.getLife() >= 2
|
||||
&& controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getName() + " into graveyard?", game)) {
|
||||
&& controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", game)) {
|
||||
controller.loseLife(2, game);
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public class CallOfTheWild extends CardImpl {
|
|||
super(ownerId, 64, "Call of the Wild", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}");
|
||||
this.expansionSetCode = "WTH";
|
||||
|
||||
|
||||
// {2}{G}{G}: Reveal the top card of your library. If it's a creature card, put it onto the battlefield. Otherwise, put it into your graveyard.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CallOfTheWildEffect(), new ManaCostsImpl("{2}{G}{G}")));
|
||||
}
|
||||
|
@ -103,10 +102,10 @@ class CallOfTheWildEffect extends OneShotEffect {
|
|||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
} else {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,25 +86,19 @@ class BeastHuntEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
Cards cards = new CardsImpl();
|
||||
int count = Math.min(controller.getLibrary().size(), 3);
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
} else {
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Cards cardsToHand = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 3));
|
||||
if (!cards.isEmpty()) {
|
||||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
for (Card card: cards.getCards(game)) {
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
cardsToHand.add(card);
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
controller.moveCards(cardsToHand, Zone.LIBRARY, Zone.HAND, source, game);
|
||||
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class EnterBattlefieldPayCostOrPutGraveyardEffect extends ReplacementEffe
|
|||
if (replace) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, game.getState().getZone(event.getTargetId()));
|
||||
player.moveCards(card, game.getState().getZone(event.getTargetId()), Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -38,11 +38,9 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
@ -156,7 +154,7 @@ public class LookLibraryControllerEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
/**
|
||||
* Put the rest of the cards back to library
|
||||
* Put the rest of the cards back to defined zone
|
||||
*
|
||||
* @param source
|
||||
* @param player
|
||||
|
@ -166,27 +164,14 @@ public class LookLibraryControllerEffect extends OneShotEffect {
|
|||
protected void putCardsBack(Ability source, Player player, Cards cards, Game game) {
|
||||
switch(targetZoneLookedCards) {
|
||||
case LIBRARY:
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard(this.getPutBackText()));
|
||||
while (player.isInGame() && cards.size() > 1) {
|
||||
player.choose(Outcome.Neutral, cards, target, game);
|
||||
Card card = cards.get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
cards.remove(card);
|
||||
player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, putOnTop, false);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
if (cards.size() == 1) {
|
||||
Card card = cards.get(cards.iterator().next(), game);
|
||||
player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, putOnTop, false);
|
||||
if (putOnTop) {
|
||||
player.putCardsOnTopOfLibrary(cards, game, source, true);
|
||||
} else {
|
||||
player.putCardsOnBottomOfLibrary(cards, game, source, true);
|
||||
}
|
||||
break;
|
||||
case GRAVEYARD:
|
||||
for (Card card : cards.getCards(game)) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
|
||||
}
|
||||
player.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
break;
|
||||
default:
|
||||
// not supported yet
|
||||
|
@ -205,16 +190,6 @@ public class LookLibraryControllerEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
|
||||
protected String getPutBackText() {
|
||||
StringBuilder sb = new StringBuilder("card to put ");
|
||||
if (putOnTop) {
|
||||
sb.append("on your library (last chosen will be on top)");
|
||||
} else {
|
||||
sb.append("on bottom of your library (last chosen will be mostbottom)");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return setText(mode, "");
|
||||
|
|
|
@ -33,6 +33,7 @@ import mage.abilities.dynamicvalue.DynamicValue;
|
|||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
@ -70,14 +71,7 @@ public class PutTopCardOfLibraryIntoGraveTargetEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
int cardsCount = Math.min(numberCards.calculate(game, source, this), player.getLibrary().size());
|
||||
for (int i = 0; i < cardsCount; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return player.moveCards(player.getLibrary().getTopCards(game, numberCards.calculate(game, source, this)), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -84,36 +84,37 @@ public class ReturnFromExileEffect extends OneShotEffect {
|
|||
ExileZone exile = game.getExile().getExileZone(exileId);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && exile != null) {
|
||||
exile = exile.copy();
|
||||
for (UUID cardId : exile) {
|
||||
Card card = game.getCard(cardId);
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
switch (zone) {
|
||||
case BATTLEFIELD:
|
||||
card.moveToZone(zone, source.getSourceId(), game, tapped);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
|
||||
}
|
||||
break;
|
||||
case HAND:
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
|
||||
break;
|
||||
case GRAVEYARD:
|
||||
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED);
|
||||
break;
|
||||
case LIBRARY:
|
||||
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, true);
|
||||
break;
|
||||
default:
|
||||
card.moveToZone(zone, source.getSourceId(), game, tapped);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
|
||||
}
|
||||
if (zone == Zone.GRAVEYARD) {
|
||||
controller.moveCards(exile, zone, Zone.EXILED, source, game);
|
||||
} else {
|
||||
exile = exile.copy();
|
||||
for (UUID cardId : exile) {
|
||||
Card card = game.getCard(cardId);
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
switch (zone) {
|
||||
case BATTLEFIELD:
|
||||
card.moveToZone(zone, source.getSourceId(), game, tapped);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
|
||||
}
|
||||
break;
|
||||
case HAND:
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
|
||||
break;
|
||||
case LIBRARY:
|
||||
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, true);
|
||||
break;
|
||||
default:
|
||||
card.moveToZone(zone, source.getSourceId(), game, tapped);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
game.getExile().getExileZone(exileId).clear();
|
||||
}
|
||||
game.getExile().getExileZone(exileId).clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -150,7 +150,7 @@ class MadnessTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
// if cast was not successfull, the card is moved to graveyard
|
||||
owner.moveCardToGraveyardWithInfo(card, getSourceId(), game, Zone.EXILED);
|
||||
owner.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, this, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -64,13 +64,21 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
public CardsImpl() { }
|
||||
|
||||
public CardsImpl(Card card) {
|
||||
this.add(card.getId());
|
||||
if (card != null) {
|
||||
this.add(card.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public CardsImpl(Collection<UUID> cardIds) {
|
||||
if (cardIds != null) {
|
||||
this.addAll(cardIds);
|
||||
}
|
||||
}
|
||||
|
||||
public CardsImpl(Zone zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
|
||||
public CardsImpl(Zone zone, Collection<Card> cards) {
|
||||
this(zone);
|
||||
for (Card card: cards) {
|
||||
|
|
|
@ -438,6 +438,20 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
*/
|
||||
UUID getCommanderId();
|
||||
|
||||
/**
|
||||
* Moves cards from one zone to another
|
||||
*
|
||||
* @param cards
|
||||
* @param fromZone
|
||||
* @param toZone
|
||||
* @param source
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||
|
||||
/**
|
||||
* Uses card.moveToZone and posts a inform message about moving the card
|
||||
* into the game log
|
||||
|
|
|
@ -2821,13 +2821,42 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.commanderId = commanderId;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public UUID getCommanderId() {
|
||||
return this.commanderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||
ArrayList<Card> cardList = new ArrayList<>();
|
||||
cardList.addAll(cards.getCards(game));
|
||||
return moveCards(cardList, fromZone, toZone, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||
ArrayList<Card> cardList = new ArrayList<>();
|
||||
if (card != null) {
|
||||
cardList.add(card);
|
||||
}
|
||||
return moveCards(cardList, fromZone, toZone, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||
switch(toZone) {
|
||||
case GRAVEYARD:
|
||||
return moveCardsToGraveyardWithInfo(cards, source, game, fromZone);
|
||||
case HAND:
|
||||
for(Card card: cards) {
|
||||
moveCardToHandWithInfo(card, playerId, game, fromZone);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
throw new UnsupportedOperationException("to Zone not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
|
||||
return this.moveCardToHandWithInfo(card, sourceId, game, fromZone, true);
|
||||
|
|
Loading…
Reference in a new issue