mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 05:09:16 -08: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;
|
package mage.sets.commander2013;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Deque;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -100,31 +102,38 @@ class UnexpectedlyAbsentEffect extends OneShotEffect<UnexpectedlyAbsentEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (permanent != null) {
|
if (controller != null) {
|
||||||
Player owner = game.getPlayer(permanent.getOwnerId());
|
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||||
if (owner != null) {
|
if (permanent != null) {
|
||||||
int xValue = Math.min(source.getManaCostsToPay().getX(), owner.getLibrary().size());
|
Player owner = game.getPlayer(permanent.getOwnerId());
|
||||||
Cards cards = new CardsImpl(Zone.PICK);
|
if (owner != null) {
|
||||||
List<UUID> cardIds = new ArrayList<>();
|
int xValue = Math.min(source.getManaCostsToPay().getX(), owner.getLibrary().size());
|
||||||
for (int i = 0; i < xValue; i++) {
|
Cards cards = new CardsImpl(Zone.PICK);
|
||||||
Card card = owner.getLibrary().getFromTop(game);
|
Deque<UUID> cardIds = new LinkedList<>();
|
||||||
cards.add(card);
|
for (int i = 0; i < xValue; i++) {
|
||||||
cardIds.add(card.getId());
|
Card card = owner.getLibrary().removeFromTop(game);
|
||||||
}
|
cards.add(card);
|
||||||
// return cards back to library
|
cardIds.push(card.getId());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.journeyintonyx;
|
package mage.sets.journeyintonyx;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Deque;
|
||||||
import java.util.List;
|
import java.util.LinkedList;
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
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 plains = game.getBattlefield().countAll(new FilterPermanent("Plains", "Plains you control"), source.getControllerId(), game);
|
||||||
int xValue = Math.min(plains, owner.getLibrary().size());
|
int xValue = Math.min(plains, owner.getLibrary().size());
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
List<UUID> cardIds = new ArrayList<>();
|
Deque<UUID> cardIds = new LinkedList<>();
|
||||||
for (int i = 0; i < xValue; i++) {
|
for (int i = 0; i < xValue; i++) {
|
||||||
Card card = owner.getLibrary().getFromTop(game);
|
Card card = owner.getLibrary().removeFromTop(game);
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
cardIds.add(card.getId());
|
cardIds.push(card.getId());
|
||||||
}
|
}
|
||||||
// return cards back to library
|
// return cards back to library
|
||||||
controller.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||||
ListIterator<UUID> libraryCards = cardIds.listIterator();
|
game.informPlayers(new StringBuilder(controller.getName())
|
||||||
while(libraryCards.hasPrevious()) {
|
.append(" puts ").append(permanent.getName())
|
||||||
UUID cardId = libraryCards.previous();
|
.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);
|
Card card = cards.get(cardId, game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue