Title: | Play Casino Games |
---|---|
Description: | Play casino games in the R console, including poker, blackjack, and a slot machine. Try to build your fortune before you succumb to the gambler's ruin! |
Authors: | Anthony Pileggi [aut, cre] |
Maintainer: | Anthony Pileggi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2025-03-11 05:47:43 UTC |
Source: | https://github.com/anthonypileggi/casino |
Blackjack R6 Class
Blackjack
Blackjack
An object of class R6ClassGenerator
of length 24.
set.seed(101315) setup() # sit at the blackjack table x <- Blackjack$new(who = "Player 1", bet = 10) # play a hand x$play() x$hit() x$stand() # play a hand blind w/out drawing x$play()$stand() # clean-up delete()
set.seed(101315) setup() # sit at the blackjack table x <- Blackjack$new(who = "Player 1", bet = 10) # play a hand x$play() x$hit() x$stand() # play a hand blind w/out drawing x$play()$stand() # clean-up delete()
Deck R6 Class
Deck
Deck
An object of class R6ClassGenerator
of length 24.
# create a new deck x <- Deck$new() x # draw a card x$draw(1) x # draw 10 cards x$draw(10) # check how many cards are left x$cards_left() # reset the deck x$shuffle() x # create a deck composed of 5 decks x <- Deck$new(decks = 5) x
# create a new deck x <- Deck$new() x # draw a card x$draw(1) x # draw 10 cards x$draw(10) # check how many cards are left x$cards_left() # reset the deck x$shuffle() x # create a deck composed of 5 decks x <- Deck$new(decks = 5) x
Delete all player history and re-lock the casino
delete()
delete()
Play blackjack
play_blackjack(name)
play_blackjack(name)
name |
player name |
Play poker
play_poker(name, type)
play_poker(name, type)
name |
player name |
type |
game type ('draw' or 'stud') |
Play the slot machine
play_slots(name)
play_slots(name)
name |
player name |
Play a sound (if possible)
play_sound(sound = "fanfare")
play_sound(sound = "fanfare")
sound |
character string or number specifying the sound (see |
requires the 'beepr' package
Player R6 Class
Player
Player
An object of class R6ClassGenerator
of length 24.
setup("my_profile") Player$new("Player 1") Player$new("Player 2") delete()
setup("my_profile") Player$new("Player 1") Player$new("Player 2") delete()
List all player profiles
players(file = Sys.getenv("CASINO_FILE"))
players(file = Sys.getenv("CASINO_FILE"))
file |
full path to file containing player profiles |
Poker R6 Class
Poker
Poker
An object of class R6ClassGenerator
of length 24.
set.seed(101315) setup() # draw poker x <- Poker$new(who = "Player 1", type = "draw", bet = 10) x$play() x$hold(1, 2, 5) x$draw() # stud poker (bet 20) x <- Poker$new(who = "Player 1", type = "stud", bet = 20) x$play() # clean-up delete()
set.seed(101315) setup() # draw poker x <- Poker$new(who = "Player 1", type = "draw", bet = 10) x$play() x$hold(1, 2, 5) x$draw() # stud poker (bet 20) x <- Poker$new(who = "Player 1", type = "stud", bet = 20) x$play() # clean-up delete()
Allow casino to store player profiles in a local file
setup(file = file.path(getwd(), ".casino"))
setup(file = file.path(getwd(), ".casino"))
file |
full path to file |
Slots R6 Class
Slots
Slots
An object of class R6ClassGenerator
of length 24.
set.seed(101315) setup() # start the slot machine x <- Slots$new(who = "Player 1", bet = 10) # play 1 game x$play() # play >1 game at a time x$play(spins = 3) # clean-up delete()
set.seed(101315) setup() # start the slot machine x <- Slots$new(who = "Player 1", bet = 10) # play 1 game x$play() # play >1 game at a time x$play(spins = 3) # clean-up delete()