Player information is stored in a local file. By default, this file is call .casino
and it is placed in the current working directory.
library(casino)
# create a new file to store player profiles
setup()
#> No records found.
#> Storing player records at '/private/var/folders/00/wqk2kgyj3klfdsyz_08693m40000gn/T/RtmpDj644l/Rbuild512c65891e92/casino/vignettes/.casino'
#> Updating value for environment variable 'CASINO_FILE'.
# create some players
Player$new("Player 1")
#> You have no money!
#> Player:
#> Name: Player 1
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
# check the available players
players()
#> # A tibble: 1 x 2
#> name balance
#> <chr> <chr>
#> 1 Player 1 100.000000
You can store multiple players in the same profile file.
# create more players
Player$new("Player 2")
#> You have no money!
#> Player:
#> Name: Player 2
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
Player$new("Player 3")
#> You have no money!
#> Player:
#> Name: Player 3
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
# check the available players
players()
#> # A tibble: 3 x 2
#> name balance
#> <chr> <chr>
#> 1 Player 1 100.000000
#> 2 Player 2 100.000000
#> 3 Player 3 100.000000
If you want to store multiple player profiles, you can specify the filename.
# first profile
setup(".bellagio")
#> No records found.
#> Storing player records at '.bellagio'
#> Updating value for environment variable 'CASINO_FILE'.
Player$new("Player 1")
#> You have no money!
#> Player:
#> Name: Player 1
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
Player$new("Player 2")
#> You have no money!
#> Player:
#> Name: Player 2
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
players()
#> # A tibble: 2 x 2
#> name balance
#> <chr> <chr>
#> 1 Player 1 100.000000
#> 2 Player 2 100.000000
# second profile
setup(".caesars")
#> No records found.
#> Storing player records at '.caesars'
#> Updating value for environment variable 'CASINO_FILE'.
Player$new("Player 3")
#> You have no money!
#> Player:
#> Name: Player 3
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
Player$new("Player 4")
#> You have no money!
#> Player:
#> Name: Player 4
#> Balance: 100
#> Level: 0
#> Played: 1
#> Debt: 100
players()
#> # A tibble: 2 x 2
#> name balance
#> <chr> <chr>
#> 1 Player 3 100.000000
#> 2 Player 4 100.000000
# now switch back to the first one
setup(".bellagio")
#> Found an existing record of players at '.bellagio'
#> Updating value for environment variable 'CASINO_FILE'.
players()
#> # A tibble: 2 x 2
#> name balance
#> <chr> <chr>
#> 1 Player 1 100.000000
#> 2 Player 2 100.000000
If you want to delete all players in the current profile and reset the casino
package, use the delete()
function.
# delete current profile (.bellagio)
delete()
# delete a different profile (.caesars)
setup(".caesars")
#> Found an existing record of players at '.caesars'
#> Updating value for environment variable 'CASINO_FILE'.
delete()
# delete the default profile (.casino)
setup()
#> Found an existing record of players at '/private/var/folders/00/wqk2kgyj3klfdsyz_08693m40000gn/T/RtmpDj644l/Rbuild512c65891e92/casino/vignettes/.casino'
#> Updating value for environment variable 'CASINO_FILE'.
delete()