mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Quarry Colossus / Unexpectedly Absent - Fixed that card was not moved to the correct position inlibrary.
This commit is contained in:
parent
0a5bb7329e
commit
b93cafe707
2 changed files with 43 additions and 31 deletions
|
@ -28,6 +28,8 @@
|
|||
package mage.sets.commander2013;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.UUID;
|
||||
|
@ -100,31 +102,38 @@ class UnexpectedlyAbsentEffect extends OneShotEffect<UnexpectedlyAbsentEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
Player owner = game.getPlayer(permanent.getOwnerId());
|
||||
if (owner != null) {
|
||||
int xValue = Math.min(source.getManaCostsToPay().getX(), owner.getLibrary().size());
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
List<UUID> cardIds = new ArrayList<>();
|
||||
for (int i = 0; i < xValue; i++) {
|
||||
Card card = owner.getLibrary().getFromTop(game);
|
||||
cards.add(card);
|
||||
cardIds.add(card.getId());
|
||||
}
|
||||
// return cards back to library
|
||||
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
ListIterator<UUID> l = cardIds.listIterator();
|
||||
while(l.hasPrevious()) {
|
||||
UUID cardId = l.previous();
|
||||
Card card = cards.get(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
Player owner = game.getPlayer(permanent.getOwnerId());
|
||||
if (owner != null) {
|
||||
int xValue = Math.min(source.getManaCostsToPay().getX(), owner.getLibrary().size());
|
||||
Cards cards = new CardsImpl(Zone.PICK);
|
||||
Deque<UUID> cardIds = new LinkedList<>();
|
||||
for (int i = 0; i < xValue; i++) {
|
||||
Card card = owner.getLibrary().removeFromTop(game);
|
||||
cards.add(card);
|
||||
cardIds.push(card.getId());
|
||||
}
|
||||
// return cards back to library
|
||||
game.informPlayers(new StringBuilder(controller.getName())
|
||||
.append(" puts ").append(permanent.getName())
|
||||
.append(" beneath the top ").append(xValue)
|
||||
.append(" cards of ").append(owner.getName()).append("'s library").toString());
|
||||
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
while(!cardIds.isEmpty()) {
|
||||
UUID cardId = cardIds.poll();
|
||||
Card card = cards.get(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
*/
|
||||
package mage.sets.journeyintonyx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
|
@ -106,17 +106,20 @@ class QuarryColossusReturnLibraryEffect extends OneShotEffect<QuarryColossusRetu
|
|||
int plains = game.getBattlefield().countAll(new FilterPermanent("Plains", "Plains you control"), source.getControllerId(), game);
|
||||
int xValue = Math.min(plains, owner.getLibrary().size());
|
||||
Cards cards = new CardsImpl();
|
||||
List<UUID> cardIds = new ArrayList<>();
|
||||
Deque<UUID> cardIds = new LinkedList<>();
|
||||
for (int i = 0; i < xValue; i++) {
|
||||
Card card = owner.getLibrary().getFromTop(game);
|
||||
Card card = owner.getLibrary().removeFromTop(game);
|
||||
cards.add(card);
|
||||
cardIds.add(card.getId());
|
||||
cardIds.push(card.getId());
|
||||
}
|
||||
// return cards back to library
|
||||
controller.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
ListIterator<UUID> libraryCards = cardIds.listIterator();
|
||||
while(libraryCards.hasPrevious()) {
|
||||
UUID cardId = libraryCards.previous();
|
||||
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
game.informPlayers(new StringBuilder(controller.getName())
|
||||
.append(" puts ").append(permanent.getName())
|
||||
.append(" beneath the top ").append(xValue)
|
||||
.append(" cards of ").append(owner.getName()).append("'s library").toString());
|
||||
while(!cardIds.isEmpty()) {
|
||||
UUID cardId = cardIds.poll();
|
||||
Card card = cards.get(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
|
|
Loading…
Reference in a new issue