Package 'casino'

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

Help Index


Blackjack R6 Class

Description

Blackjack R6 Class

Usage

Blackjack

Format

An object of class R6ClassGenerator of length 24.

Examples

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

Description

Deck R6 Class

Usage

Deck

Format

An object of class R6ClassGenerator of length 24.

Examples

# 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

Description

Delete all player history and re-lock the casino

Usage

delete()

Play in the casino

Description

Play in the casino

Usage

play()

Play blackjack

Description

Play blackjack

Usage

play_blackjack(name)

Arguments

name

player name


Play poker

Description

Play poker

Usage

play_poker(name, type)

Arguments

name

player name

type

game type ('draw' or 'stud')


Play the slot machine

Description

Play the slot machine

Usage

play_slots(name)

Arguments

name

player name


Play a sound (if possible)

Description

Play a sound (if possible)

Usage

play_sound(sound = "fanfare")

Arguments

sound

character string or number specifying the sound (see beep)

Note

requires the 'beepr' package


Player R6 Class

Description

Player R6 Class

Usage

Player

Format

An object of class R6ClassGenerator of length 24.

Examples

setup("my_profile")
Player$new("Player 1")
Player$new("Player 2")
delete()

List all player profiles

Description

List all player profiles

Usage

players(file = Sys.getenv("CASINO_FILE"))

Arguments

file

full path to file containing player profiles


Poker R6 Class

Description

Poker R6 Class

Usage

Poker

Format

An object of class R6ClassGenerator of length 24.

Examples

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

Description

Allow casino to store player profiles in a local file

Usage

setup(file = file.path(getwd(), ".casino"))

Arguments

file

full path to file


Slots R6 Class

Description

Slots R6 Class

Usage

Slots

Format

An object of class R6ClassGenerator of length 24.

Examples

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()