fn create_deck<T>(cards []T) Deck<T>
Creates a deck from the provided set of cards.
fn create_standard_deck() Deck<.Card>
Creates a deck of 52 cards (2 through 10, Jock, Queen, King and Ace) of the 4 standard suits - Clubs, Diamonds, Hearts and Spades.
fn create_uno_deck() Deck<.UnoCard>
Creates a standard deck of 108 Uno cards, including one 0
of each color, four 1
- 9
of each color, four skip
, reverse
and draw two
of each color, and four change color
and draw four
(each) wild cards.
fn (mut deck Deck<T>) shuffle(times ...int)
Shuffles the deck. Optionally specify how many times to shuffle it. deck.shuffle()
- shuffles the deck once. deck.shuffle(3)
- shuffles the deck 3 times.
fn (deck Deck<T>) peek() T
Peeks the card at the top of the deck. Does not draw/remove the card from the deck.
fn (deck Deck<T>) peekn(amount int) []T
Peeks a specified amount of cards from the top of the deck. Does not draw/remove the cards from the deck.
fn (deck Deck<T>) peek_middle() T
Peeks the card at the middle of the deck. Does not draw/remove the card from the deck.
fn (deck Deck<T>) peek_bottom() T
Peeks the card at the bottom of the deck. Does not draw/remove the card from the deck.
fn (deck Deck<T>) peek_bottomn(amount int) []T
Peeks a specified amount of cards from the bottom of the deck. Does not draw/remove the cards from the deck.
fn (deck Deck<T>) peek_random() T
Peeks a card from a random position in the deck. Does not draw/remove the card from the deck.
fn (deck Deck<T>) peek_randomn(amount int) []T
Peeks a specified amount of cards from random, non-repeating positions in the deck. Does not draw/remove the cards from the deck.
fn (deck Deck<T>) peek_at(position int) T
Peeks the card at the specified position in the deck. Does not draw/remove the card from the deck.
fn (mut deck Deck<T>) draw() T
Draws a card from the top of the deck. The card is then removed from the deck.
fn (mut deck Deck<T>) drawn(amount int) []T
Draws a specified amount of cards from the top of the deck. The cards are then removed from the deck.
fn (mut deck Deck<T>) draw_middle() T
Draws the card at the middle of the deck. The card is then removed from the deck.
fn (mut deck Deck<T>) draw_bottom() T
Draws a single cards from the bottom of the deck. The card is then removed from the deck.
fn (mut deck Deck<T>) draw_bottomn(amount int) []T
Draws a specified amount of cards from the bottom of the deck. The cards are then removed from the deck.
fn (mut deck Deck<T>) draw_random() T
Draws a card from a random position in the deck. The card is then removed from the deck.
fn (mut deck Deck<T>) draw_randomn(amount int) []T
Draws a specified amount of cards from random positions in the deck. The cards are then removed from the deck.
fn (mut deck Deck<T>) draw_at(position int) T
Draws the card from the specified position in the deck. The card is then removed from the deck.
fn (mut deck Deck<T>) add(card T)
Adds the specified card to the top of the deck.
fn (mut deck Deck<T>) add_middle(card T)
Adds the specified card to the middle of the deck.
fn (mut deck Deck<T>) add_bottom(card T)
Adds the specified card to the bottom of the deck.
fn (mut deck Deck<T>) add_at(position int, card T)
Adds the specified card at the specified position in the deck.
fn (mut deck Deck<T>) add_random(card T)
Adds the specified card at a random position in the deck.
fn (deck Deck<T>) get_cards() []T
Returns the cards currently in the deck.
fn (deck Deck<T>) count_cards() int
Returns the current amount of cards in the deck.
fn (deck Deck<T>) has_cards() bool
Returns a boolean indicating whether there is atleast 1 card in the deck.
fn (deck Deck<T>) contains(card T) bool
Checks whether the specified card is contained in the deck.
fn (deck Deck<T>) index_of(card T) int
Returns the index of the specified card in the deck. Returns -1
if the card is not contained in the deck.
type UnoCard = UnoActionCard | UnoNumberCard | UnoWildCard
enum Suit {
@none
diamond
club
heart
spade
}
enum UnoColor {
red
yellow
green
blue
}
enum UnoAction {
skip
reverse
draw_two
}
enum UnoWildAction {
change_color
draw_four
}
struct Deck<T> {
mut:
cards []T
}
Represents a deck of cards.
struct UnoNumberCard {
color UnoColor
number int
}
struct Card {
suit Suit
rank CardRank
}
Represents a standard playing card with a rank and a suit.
struct UnoActionCard {
color UnoColor
action UnoAction
}
struct UnoWildCard {
action UnoWildAction
}