Skip to content

Instantly share code, notes, and snippets.

@JefClaes
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JefClaes/fb1a37ae1ca7b3d71bb5 to your computer and use it in GitHub Desktop.
Save JefClaes/fb1a37ae1ca7b3d71bb5 to your computer and use it in GitHub Desktop.
Playthrough Bonus I
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