forked from External/mage
Rework drawing cards and associated replacement effects; implement [WHO] River Song (#12700)
* remove unused scoring system code * add test for Alms Collector replacement effect * flatten draw cards into single method in PlayerImpl * remove outdated MageAction framework * clarify game event for drawing two or more cards * clarify methods for getting cards from library * implement [WHO] River Song * fix error * adjust library methods * add lots of test cases for draw replacement effects * fix #12616 * track cards drawn this way through multi draw replacement as well * add test for River Song * remove redundant comment
This commit is contained in:
parent
34ae226130
commit
9fcbfdeac6
22 changed files with 645 additions and 345 deletions
|
|
@ -47,57 +47,51 @@ public class Library implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the top card of the Library and returns it
|
||||
*
|
||||
* @param game
|
||||
* @return Card
|
||||
* @see Card
|
||||
* Draws a card from the top of the library, removing it from the library.
|
||||
* If library is empty, returns null and sets flag for drawing from an empty library.
|
||||
*/
|
||||
public Card drawFromTop(Game game) {
|
||||
Card card = game.getCard(library.pollFirst());
|
||||
if (card == null) {
|
||||
emptyDraw = true;
|
||||
}
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a card from the bottom of the library, removing it from the library.
|
||||
* If library is empty, returns null and sets flag for drawing from an empty library.
|
||||
*/
|
||||
public Card drawFromBottom(Game game) {
|
||||
Card card = game.getCard(library.pollLast());
|
||||
if (card == null) {
|
||||
emptyDraw = true;
|
||||
}
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the top card from the Library and returns it (can be null if library is empty).
|
||||
*/
|
||||
@Deprecated // recommend refactoring methods that re-order library to not require this explicit removal
|
||||
public Card removeFromTop(Game game) {
|
||||
UUID cardId = library.pollFirst();
|
||||
Card card = game.getCard(cardId);
|
||||
if (card == null) {
|
||||
emptyDraw = true;
|
||||
}
|
||||
return card;
|
||||
return game.getCard(library.pollFirst());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the bottom card of the Library and returns it
|
||||
*
|
||||
* @param game
|
||||
* @return Card
|
||||
* @see Card
|
||||
*/
|
||||
public Card removeFromBottom(Game game) {
|
||||
UUID cardId = library.pollLast();
|
||||
Card card = game.getCard(cardId);
|
||||
if (card == null) {
|
||||
emptyDraw = true;
|
||||
}
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the top card of the Library without removing it
|
||||
*
|
||||
* @param game
|
||||
* @return Card
|
||||
* @see Card
|
||||
* Returns the top card of the Library (can be null if library is empty).
|
||||
* The card is still in the library, until/unless some zone-handling code moves it
|
||||
*/
|
||||
public Card getFromTop(Game game) {
|
||||
return game.getCard(library.peekFirst());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bottommost card of the Library without removing it
|
||||
*
|
||||
* @param game
|
||||
* @return Card
|
||||
* @see Card
|
||||
* Returns the bottom card of the library (can be null if library is empty)
|
||||
* The card is still in the library, until/unless some zone-handling code moves it
|
||||
*/
|
||||
public Card getFromBottom(Game game) {
|
||||
return game.getCard(library.pollLast());
|
||||
return game.getCard(library.peekLast());
|
||||
}
|
||||
|
||||
public void putOnTop(Card card, Game game) {
|
||||
|
|
@ -152,10 +146,7 @@ public class Library implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the cards of the library in a list ordered from top to buttom
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
* Returns the cards of the library in a list ordered from top to bottom
|
||||
*/
|
||||
public List<Card> getCards(Game game) {
|
||||
return library.stream().map(game::getCard).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
|
|
@ -235,9 +226,6 @@ public class Library implements Serializable {
|
|||
|
||||
/**
|
||||
* Tests only -- find card position in library
|
||||
*
|
||||
* @param cardId
|
||||
* @return
|
||||
*/
|
||||
public int getCardPosition(UUID cardId) {
|
||||
UUID[] list = library.toArray(new UUID[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue