Esempio n. 1
0
        public long SellGate(Gate gate, long sessionId)
        {
            if (gate != Gate.Even && gate != Gate.Odd)
            {
                throw new SellGateException();
            }

            string money = _moneyType == MoneyType.GOLD ? "Vàng" : "Xu";
            var    g     = _bets[(int)gate];

            if (g.GateState == -1)
            {
                long refundAmount = g.Logs.Sum(x => x.betAmount) * GetWinnerMulti(gate);
                if (refundAmount > 0)
                {
                    long refund = GameDAO.Refund(sessionId, _banker.AccountId, _banker.AccountName, $"Hoàn tiền bán cửa: {gate.ToString()}, {refundAmount} {money}", refundAmount, (int)_moneyType);
                    if (refund >= 0)
                    {
                        g.GateState = 0;
                    }
                    return(refund);
                }
                throw new SellGateException();
            }
            else
            {
                throw new GateSoldOutException();
            }
        }