2020-03-03 04:18:07 +01:00
|
|
|
package inf112.fiasko.roborally.objects;
|
|
|
|
|
2020-03-03 14:13:11 +01:00
|
|
|
import java.util.List;
|
2020-03-03 04:18:07 +01:00
|
|
|
|
2020-03-03 04:46:03 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Describes a deck
|
|
|
|
*
|
|
|
|
* <p>Any card stored in the deck is assumed to be immutable. If it's not, the integrity of the deck cannot be
|
|
|
|
* guaranteed.</p>
|
2020-03-03 04:46:03 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
public interface Deck<T> {
|
2020-03-03 04:18:07 +01:00
|
|
|
|
2020-03-03 04:46:03 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Shuffles the order of the cards in the deck
|
2020-03-03 04:46:03 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
void shuffle();
|
2020-03-03 04:18:07 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Draws one card from the top of another deck
|
|
|
|
*
|
2020-03-12 11:24:04 +01:00
|
|
|
* @param other The deck to draw the card from
|
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
void draw(Deck<T> other);
|
2020-03-03 04:46:03 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Draws n cards from the top of another deck
|
|
|
|
*
|
2020-03-12 11:24:04 +01:00
|
|
|
* @param other The other deck to draw from
|
2020-04-20 13:13:04 +02:00
|
|
|
* @param n The number of cards to draw
|
2020-03-12 11:24:04 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
void draw(Deck<T> other, int n);
|
2020-03-03 04:18:07 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Moves all cards in this deck into another deck
|
|
|
|
*
|
2020-03-12 11:24:04 +01:00
|
|
|
* @param other The deck to move this deck's cards into
|
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
void emptyInto(Deck<T> other);
|
2020-03-03 04:18:07 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Whether this deck is empty
|
|
|
|
*
|
|
|
|
* @return True if this deck is currently empty
|
2020-03-12 11:24:04 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
boolean isEmpty();
|
2020-03-03 04:46:03 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Gets the number of cards currently in this deck
|
|
|
|
*
|
|
|
|
* @return The number of cards in this deck
|
2020-03-12 11:24:04 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
int size();
|
2020-03-03 04:18:07 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Takes a peek at the card currently at the top of the deck
|
|
|
|
*
|
|
|
|
* @return The card at the top of the deck
|
2020-03-12 11:24:04 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
T peekTop();
|
2020-03-03 17:57:27 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Takes a peek at the card currently at the bottom of the deck
|
|
|
|
*
|
|
|
|
* @return The card at the bottom of the deck
|
2020-03-12 11:24:04 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
T peekBottom();
|
2020-03-09 13:21:52 +01:00
|
|
|
|
2020-03-12 11:24:04 +01:00
|
|
|
/**
|
2020-04-20 13:13:04 +02:00
|
|
|
* Gets a list of all cards in this deck
|
|
|
|
*
|
|
|
|
* <p>The list should have the correct order according to the actual order within the deck.</p>
|
|
|
|
*
|
|
|
|
* @return A list of all cards in this deck
|
2020-03-12 11:24:04 +01:00
|
|
|
*/
|
2020-04-20 13:13:04 +02:00
|
|
|
List<T> getCards();
|
2020-03-03 04:18:07 +01:00
|
|
|
}
|