Last active
August 29, 2015 14:15
-
-
Save JefClaes/fb1a37ae1ca7b3d71bb5 to your computer and use it in GitHub Desktop.
Playthrough Bonus I
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Bonus = { Amount : decimal; Balance : decimal; Bets : decimal; Playthrough: decimal; } | |
with | |
static member Create amount playthrough = | |
{ Amount = amount; Balance = amount; Bets = 0M; Playthrough = playthrough } | |
member x.Win amount = | |
{ x with Balance = x.Balance + amount } | |
member x.AcceptsBet amount = | |
x.Balance - amount >= 0M | |
member x.Cleared = | |
( x.Playthrough * x.Amount ) - x.Bets <= 0M | |
member x.Bet amount = | |
match x.AcceptsBet amount with | |
| true -> { x with Bets = x.Bets + amount; Balance = x.Balance - amount } | |
| false -> invalidOp "Bonus can't accept bet" | |
type GameSettings = { Payout : decimal; Stake : decimal; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment