Esempio n. 1
0
        private long BetNornal(long sessionId, long accountId, string accountName, long amount, Gate gate, out long gateSumary, bool skipDAO = false)
        {
            gateSumary = 0;
            string money     = _moneyType == MoneyType.GOLD ? "Vàng" : "Xu";
            long   betResult = -99;

            if (!skipDAO)
            {
                betResult = GameDAO.Bet(sessionId, accountId, accountName, $"Đặt cửa: {gate.ToString()}, {amount} {money}", amount, (int)_moneyType);
            }
            else
            {
                betResult = 1;
            }
            if (betResult >= 0)
            {
                _bets[(int)gate].Logs.Add(new BetLog
                {
                    accountId   = accountId,
                    accountName = accountName,
                    betAmount   = amount,
                    betGate     = gate
                });
                gateSumary = _bets[(int)gate].Logs.Sum(x => x.betAmount);
            }
            return(betResult);
        }
Esempio n. 2
0
        public long BuyGate(Gate gate, long sessionId, long accountId, string accountName)
        {
            string money = _moneyType == MoneyType.GOLD ? "Vàng" : "Xu";
            var    g     = _bets[(int)gate];

            if (g.GateState == 0)
            {
                long betResult = -99;
                long buyAmount = g.Logs.Sum(x => x.betAmount) * GetWinnerMulti(gate);
                betResult = GameDAO.Bet(sessionId, accountId, accountName, $"Mua cửa: {gate.ToString()}, {buyAmount} {money}", buyAmount, (int)_moneyType);
                if (betResult >= 0)
                {
                    g.Owner     = accountId;
                    g.GateState = 1;
                }
                else
                {
                    throw new BuyGateException();
                }
                return(betResult);
            }
            else
            {
                throw new BuyGateException();
            }
        }
Esempio n. 3
0
        public long Bet(long sessionId, long accountId, string accountName, string betData)
        {
            try
            {
                long betAmount = 0;
                betData = betData.TrimEnd('|');
                string[] data = betData.Split('|');

                foreach (var d in data)
                {
                    string[] parse = d.Split(';');
                    if (long.Parse(parse[1]) < 1000)
                    {
                        return(-99);
                    }
                    betAmount += long.Parse(parse[1]);

                    int gate = int.Parse(parse[0]);
                    if (gate < 1 || gate > 6)
                    {
                        return(-99);
                    }
                }

                long response = GameDAO.Bet(sessionId, accountId, accountName, betData, betAmount, (int)_moneyType);

                if (response > 0)
                {
                    _fund += betAmount;
                    foreach (var d in data)
                    {
                        string[] parse  = d.Split(';');
                        int      gate   = int.Parse(parse[0]);
                        long     amount = long.Parse(parse[1]);

                        BetGates.AddOrUpdate((int)gate, amount, (k, v) => v += amount);
                        if (!_betLogs.ToList().Exists(x => x.accountId == accountId))
                        {
                            BetGateCount.AddOrUpdate(gate, 1, (k, v) => v += 1);
                        }
                        _betLogs.Enqueue(new BetLog {
                            accountId = accountId, amount = amount, betGate = (BetGate)gate, accountName = accountName
                        });
                    }
                }
                return(response);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }