Kotlin Library providing an Implementation of Playing Cards. Could be used to jump-start a card game or anything that uses playing cards.
To create a deck of cards, instantiate of the Deck class provided.
A standard deck of playing cards has 52 cards. Creating one is easy:
val deck = Deck.Builder().addCompleteDeck().build()Some games need more than one deck. Just add any number of standard decks just like this:
val deck = Deck.Builder()
.addCompleteDeck()
.addCompleteDeck()
.build()Some games are not using all cards of a standard deck. Deck with a subset of ranks can be created like this:
val deck = Deck.Builder()
.addRank(Rank.TWO)
.addRank(Rank.ACE)
.addRank(Rank.KING)
.build()You can build a deck with only a subset of suites like this
var deck = Deck.Builder()
.addSuite(Suite.SPADES)
.addSuite(Suite.CLUBS)
.build()Simply extend the CardHolder abstract class to create any entity that holds cards (players, table, discarded piles etc.)
Card games
Can be CLUBS, DIAMONDS, HEARTS or SPADES
Can be ACE, ONE ... TEN, JACK, QUEEN OR KING
Has a Suite and a Rank. Can not be changed after creation (immutable)
Any entity that holds cards (decks, players etc.) can be created by extending CardHolder abstract class.
CardHolder provides storage for holding cards and functions to manipulate them (add, remove, shuffle, exchange with other CardHoders).