Beispiel #1
0
        public override bool Action(NotifyType notifyType, BaseInfo baseInfo, UserInfo userInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Request_Betting:
            {
                DiceInfo diceInfo = (DiceInfo)_GameTable.GetTableInfo();

                int playerIndex = _GameTable.GetPlayerIndex(userInfo);

                if (playerIndex < 0)
                {
                    return(false);
                }

                BettingInfo bettingInfo = (BettingInfo)baseInfo;

                int nCurUserMoney = userInfo.GetGameMoney();

                // added by usc at 2014/02/03
                int curBettingMoney = 0;
                for (int i = 0; i < 4; i++)
                {
                    curBettingMoney += diceInfo.m_lUserScore[playerIndex, i];
                }

                if (nCurUserMoney < curBettingMoney + bettingInfo._Score)
                {
                    BaseInfo.SetError(ErrorType.Notenough_Cash, "베팅할 금액이 부족합니다");
                    return(false);
                }

                if (curBettingMoney + bettingInfo._Score > GameDefine.MAX_BETTING_MONEY)
                {
                    return(false);
                }

                diceInfo.m_lUserScore[playerIndex, bettingInfo._Area] += bettingInfo._Score;
                diceInfo.m_lPlayerBetAll[bettingInfo._Area]           += bettingInfo._Score;

                // added by usc at 2014/04/09
                diceInfo.m_lUserBetScore[playerIndex] += bettingInfo._Score;

                _GameTable.BroadCastGame(NotifyType.Reply_Betting, baseInfo);
            }
            break;

            default:
                return(base.Action(notifyType, baseInfo, userInfo));

                break;
            }

            return(true);
        }
Beispiel #2
0
        public async void Betting(string bettingType, int amount)
        {
            BettingInfo req = new BettingInfo()
            {
                UserId      = this.UserId,
                BettingType = bettingType,
                Amount      = amount,
            };

            var result = await _gameManager.Betting(req);
        }
Beispiel #3
0
        public override bool Action(NotifyType notifyType, BaseInfo baseInfo, UserInfo userInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Request_Betting:
            {
                SicboInfo sicboInfo = (SicboInfo)_GameTable.GetTableInfo();

                int playerIndex = _GameTable.GetPlayerIndex(userInfo);

                if (playerIndex < 0)
                {
                    return(false);
                }

                BettingInfo bettingInfo = (BettingInfo)baseInfo;

                if (userInfo.nCashOrPointGame == 0)
                {
                    if (userInfo.Cash < bettingInfo._Score)
                    {
                        BaseInfo.SetError(ErrorType.Notenough_Cash, "베팅할 금액이 부족합니다");
                        return(false);
                    }
                }
                else
                {
                    if (userInfo.Point < bettingInfo._Score)
                    {
                        BaseInfo.SetError(ErrorType.Notenough_Cash, "베팅할 금액이 부족합니다");
                        return(false);
                    }
                }

                //Cash.GetInstance().GiveCash(userInfo.Id, -bettingInfo._Score);
                //Cash.GetInstance().GiveGameSum(userInfo, -bettingInfo._Score);
                //Cash.GetInstance().GiveGameSum(Database.GetInstance().GetManager(UserKind.Manager), bettingInfo._Score);

                sicboInfo.m_lUserScore[bettingInfo._Area, playerIndex] += bettingInfo._Score;

                _GameTable.BroadCastGame(NotifyType.Reply_Betting, baseInfo);
            }
            break;

            default:
                return(base.Action(notifyType, baseInfo, userInfo));

                break;
            }

            return(true);
        }
Beispiel #4
0
        public override void NotifyGameTimer(GameTimer gameTimer)
        {
            if (gameTimer.timerId != TimerID.Custom || gameTimer.autoInfo == null)
            {
                return;
            }

            BettingInfo bettingInfo = new BettingInfo();

            bettingInfo._Area = _random.Next() % SicboDefine.COUNT_AZIMUTH;

            int[] bettingScores = new int[] { 5, 10, 50, 100, 500, 1000, 5000 };
            bettingInfo._Score = bettingScores[_random.Next() % bettingScores.Length];

            bettingInfo._UserIndex = _GameTable.GetPlayerIndex(gameTimer.autoInfo);

            Action(NotifyType.Request_Betting, bettingInfo, gameTimer.autoInfo);
        }
Beispiel #5
0
        public void OnReceive(NotifyType type, Socket socket, BaseInfo baseInfo)
        {
            try
            {
                switch (type)
                {
                case NotifyType.Reply_GameChat:
                {
                    ChatEngine.StringInfo strInfo = (ChatEngine.StringInfo)baseInfo;

                    AddMessageToHistoryTextBox(strInfo);
                }
                break;

                case NotifyType.Reply_Betting:
                {
                    if (!(baseInfo is BettingInfo))
                    {
                        return;
                    }

                    BettingInfo bettingInfo = (BettingInfo)baseInfo;

                    if (m_wMeChairID == bettingInfo._UserIndex || m_tableinfo == null)
                    {
                        return;
                    }

                    string strMsg = string.Format("{0} <{1}> 下注", m_tableinfo._Players[bettingInfo._UserIndex].Nickname, GetUriString(bettingInfo._Score));

                    InterpretServerMessgae("AMDIN_MSG", strMsg, 12, "Segoe UI", "b", "d", "#FFFFFF");
                }
                break;
                }
            }
            catch (Exception)
            { }
        }
Beispiel #6
0
        public override bool Action(NotifyType notifyType, BaseInfo baseInfo, UserInfo userInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Request_Betting:
            {
                //效验数据
                if (!(baseInfo is BettingInfo))
                {
                    return(false);
                }

                //用户效验
                if (_GameTable.GetPlayerIndex(userInfo) < 0)
                {
                    return(false);
                }

                BettingInfo bettingInfo = (BettingInfo)baseInfo;

                if (OnUserPlaceJetton(userInfo, bettingInfo._Area, bettingInfo._Score) == false)
                {
                    return(false);
                }

                _GameTable.BroadCastGame(NotifyType.Reply_Betting, baseInfo);
            }
            break;

            default:
                return(base.Action(notifyType, baseInfo, userInfo));

                break;
            }

            return(true);
        }
Beispiel #7
0
 public Task<int> Betting(BettingInfo req)
 {
     return _context.RequestAsync<int>(_user, req);
 }
Beispiel #8
0
        public override void NotifyGameTimer(GameTimer gameTimer)
        {
            if (gameTimer.timerId != TimerID.Custom || gameTimer.autoInfo == null)
            {
                return;
            }

            int[] bettingScores = new int[] { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
                                              100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
                                              1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
                                              10000, 10000, 10000, 10000, 10000 /*,
                                                                                 * 100000*/};

            // added by usc at 2014/02/27
            BumperCarInfo bumperCarInfo = (BumperCarInfo)_GameTable.GetTableInfo();

            int[] aAreaMultiple = { 40, 30, 20, 10, 5, 5, 5, 5 };

            CurBettingInfo curBettingInfo = GetCurBettingInfo(bumperCarInfo);

            int nBettingArea = curBettingInfo.nMinArea;
            int nMinScore    = curBettingInfo.nMinScore;
            int nMaxArea     = curBettingInfo.nMaxArea;
            int nMaxScore    = curBettingInfo.nMaxScore;

            int nScore = 0;

            if (nMaxScore <= 1000 * aAreaMultiple[nMaxArea - 1])
            {
                if (nMaxScore == 0)
                {
                    nScore = (int)(Math.Pow(10, (double)(_random.Next() % 2) + 2));
                }
                else
                {
                    nScore = bettingScores[_random.Next() % bettingScores.Length];
                }

                nBettingArea = _random.Next() % BumperCarDefine.AREA_COUNT + 1;
            }
            else
            {
                int nReaptCnt = 0;

                while (true)
                {
                    nReaptCnt++;

                    nScore = bettingScores[_random.Next() % bettingScores.Length];

                    if (nMinScore + nScore * aAreaMultiple[nBettingArea - 1] <= nMaxScore + nMaxScore * _random.Next(25, 75) / 100)
                    {
                        break;
                    }

                    if (nReaptCnt > 20)
                    {
                        break;
                    }
                }
            }

            BettingInfo bettingInfo = new BettingInfo();

            bettingInfo._Area      = nBettingArea;
            bettingInfo._Score     = nScore;
            bettingInfo._UserIndex = _GameTable.GetPlayerIndex(gameTimer.autoInfo);

            Action(NotifyType.Request_Betting, bettingInfo, gameTimer.autoInfo);
        }
Beispiel #9
0
        private void NotifyOccured(NotifyType notifyType, Socket socket, BaseInfo baseInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Reply_TableDetail:
            {
                if (!(baseInfo is TableInfo))
                {
                    return;
                }

                TableInfo tableInfo = (TableInfo)baseInfo;

                m_wMeChairID = GameDefine.INVALID_CHAIR;

                for (int i = 0; i < tableInfo._Players.Count; i++)
                {
                    UserInfo userInfo = tableInfo._Players[i];

                    if (userInfo != null && userInfo.Id == Login._UserInfo.Id)
                    {
                        m_wMeChairID = i;
                        break;
                    }
                }

                if (tableInfo._RoundIndex > 0)
                {
                    // added by usc at 2014/03/11
                    Array.Clear(m_lUserBetAll, 0, m_lUserBetAll.Length);

                    if (_GameInfo.Source == "Horse")
                    {
                        HorseInfo horseInfo = (HorseInfo)tableInfo;

                        for (int i = 0; i < HorseDefine.AREA_COUNT; i++)
                        {
                            m_aAreaSum[i] = horseInfo.m_lPlayerBetAll[i];
                        }

                        DrawBettingGraph(m_aAreaSum);

                        // added by usc at 2014/03/11
                        for (int i = 0; i < horseInfo._Players.Count; i++)
                        {
                            for (int j = 0; j < HorseDefine.AREA_COUNT; j++)
                            {
                                m_lUserBetAll[i] += horseInfo.m_lPlayerBet[i, j];
                            }
                        }
                    }
                    else
                    {
                        BumperCarInfo bumpercarInfo = (BumperCarInfo)tableInfo;

                        for (int i = 0; i < BumperCarDefine.AREA_COUNT; i++)
                        {
                            m_aAreaSum[i] = bumpercarInfo.m_lAllJettonScore[i + 1];
                        }

                        DrawBettingGraph(m_aAreaSum);

                        // added by usc at 2014/03/11
                        for (int i = 0; i < bumpercarInfo._Players.Count; i++)
                        {
                            for (int j = 0; j < BumperCarDefine.AREA_COUNT; j++)
                            {
                                m_lUserBetAll[i] += bumpercarInfo.m_lUserJettonScore[j + 1, i];
                            }
                        }
                    }

                    if (m_tableinfo == null)
                    {
                        DrawUserList(tableInfo, false);

                        // added by usc at 2014/04/03
                        string strMsg = string.Format("欢迎 {0} 进入房间", Login._UserInfo.Nickname);

                        InterpretServerMessgae("AMDIN_MSG", strMsg, 12, "Segoe UI", "b", "d", "#9adf8c");
                    }
                }

                if (m_tableinfo != null && m_tableinfo._RoundIndex == tableInfo._RoundIndex)
                {
                    m_tableinfo = tableInfo;

                    DrawUserList(tableInfo, false);

                    return;
                }

                // added by usc at 2014/03/19
                //if (m_wMeChairID == GameDefine.INVALID_CHAIR)
                //    return;

                m_tableinfo = tableInfo;

                if (tableInfo._RoundIndex == 0)
                {
                    // added by usc at 2014/03/11
                    Array.Clear(m_aAreaSum, 0, m_aAreaSum.Length);
                    Array.Clear(m_lUserBetAll, 0, m_lUserBetAll.Length);

                    DrawBettingGraph(m_aAreaSum);

                    InitUserList(tableInfo);
                }
            }
            break;

            case NotifyType.Reply_GameResult:
            {
                ChatEngine.StringInfo strInfo = (ChatEngine.StringInfo)baseInfo;

                if (strInfo != null)
                {
                    if (strInfo.UserId == Login._UserInfo.Id)
                    {
                        DrawUserList(m_tableinfo, true);
                    }
                }
            }
            break;

            case NotifyType.Reply_Betting:
            {
                if (!(baseInfo is BettingInfo))
                {
                    return;
                }

                BettingInfo bettingInfo = (BettingInfo)baseInfo;

                int nArea = 0;
                if (_GameInfo.Source == "Horse")
                {
                    nArea = bettingInfo._Area;
                }
                else if (_GameInfo.Source == "BumperCar")
                {
                    nArea = bettingInfo._Area - 1;
                }

                m_aAreaSum[nArea] += bettingInfo._Score;

                // added by usc at 2014/03/11
                m_lUserBetAll[bettingInfo._UserIndex] += bettingInfo._Score;

                DrawBettingGraph(m_aAreaSum);

                DrawUserList(m_tableinfo, false);
            }
            break;
            }
        }
Beispiel #10
0
        public override void NotifyGameTimer(GameTimer gameTimer)
        {
            if (gameTimer.timerId != TimerID.Custom || gameTimer.autoInfo == null)
            {
                return;
            }

            int[] bettingScores = new int[] { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
                                              100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
                                              1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
                                              10000, 10000, 10000, 10000, 10000,

                                              /*100000 , 100000,
                                               * 500000*/};

            // added by usc at 2014/02/26
            DiceInfo diceInfo = (DiceInfo)_GameTable.GetTableInfo();

            CurBettingInfo curBettingInfo = GetCurBettingInfo(diceInfo);

            int nBettingArea = curBettingInfo.nMinArea;
            int nMinScore    = curBettingInfo.nMinScore;
            int nMaxScore    = curBettingInfo.nMaxScore;

            int nScore = 0;

            if (nMaxScore <= 1000)
            {
                if (nMaxScore == 0)
                {
                    nScore = (int)(Math.Pow(10, (double)(_random.Next() % 2) + 2));
                }
                else
                {
                    nScore = bettingScores[_random.Next() % bettingScores.Length];
                }

                nBettingArea = _random.Next() % 4;
            }
            else
            {
                int nReaptCnt = 0;

                while (true)
                {
                    nReaptCnt++;

                    nScore = bettingScores[_random.Next() % bettingScores.Length];

                    if (nMinScore + nScore <= nMaxScore + nMaxScore * _random.Next(25, 75) / 100)
                    {
                        break;
                    }

                    if (nReaptCnt > 20)
                    {
                        break;
                    }
                }
            }

            // added by usc at 2014/03/19
            if (nMinScore + nScore > 50000)
            {
                return;
            }

            BettingInfo bettingInfo = new BettingInfo();

            bettingInfo._Area      = nBettingArea;
            bettingInfo._Score     = nScore;
            bettingInfo._UserIndex = _GameTable.GetPlayerIndex(gameTimer.autoInfo);

            Action(NotifyType.Request_Betting, bettingInfo, gameTimer.autoInfo);
        }