Hardly.Games.PlayerPointManager.ReserveBet C# (CSharp) Method

ReserveBet() public method

public ReserveBet ( ulong bet, bool allOrNothing = false ) : ulong
bet ulong
allOrNothing bool
return ulong
        public ulong ReserveBet(ulong bet, bool allOrNothing = false)
        {
            if(!allOrNothing) {
                bet = Math.Min(Points, bet);
            } else {
                if(bet > Points) {
                    bet = 0;
                }
            }
            Debug.Assert(bet + reservedPoints <= TotalPointsInAccount);

            reservedPoints += bet;

            return bet;
        }

Usage Example

Example #1
0
        public ulong PlaceBet(ulong amount, bool allOrNothing)
        {
            amount = pointManager?.ReserveBet(amount, allOrNothing) ?? amount;
            if (pointManager != null && amount > 0)
            {
                bet += amount;
                return(amount);
            }

            return(0);
        }