The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Persistent Player Profiles

Anthony Pileggi

2019-01-10

Introduction

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

Multiple Players

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

Multiple Profile Files

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

Delete Profiles

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

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.