コード例 #1
0
ファイル: GameTable.cs プロジェクト: toowind/BBMessenger
        public virtual bool PlayerEnterTable(BaseInfo baseInfo, UserInfo userInfo)
        {
            _AutoEners.Remove(userInfo);

            if (GetPlayerIndex(userInfo) >= 0)
            {
                return(true);
            }

            if (userInfo.nCashOrPointGame == 0)
            {
                if (userInfo.Cash <= _TableInfo.m_lMinScore)
                {
                    BaseInfo.SetError(ErrorType.Notenough_Cash, "캐쉬가 부족하여 게임을 할수 없습니다.");
                    return(false);
                }
            }
            else
            {
                if (userInfo.Point <= _TableInfo.m_lMinScore)
                {
                    BaseInfo.SetError(ErrorType.Notenough_Cash, "포인트가 부족하여 게임을 할수 없습니다.");
                    return(false);
                }
            }

            if (_TableInfo._Players.Count >= GameDefine.GAME_PLAYER)
            {
                BaseInfo.SetError(ErrorType.Full_Gamer, "인원이 꽉 찼습니다.");
                return(false);
            }

            _TableInfo._Players.Add(userInfo);
            _TableInfo._Viewers.Remove(userInfo);

            View._isUpdateGameList = true;

            if (_GameInfo.nCashOrPointGame == 0 && userInfo.Auto == 0 && userInfo.Kind == (int)UserKind.Buyer)
            {
                GameHistoryInfo gameHistoryInfo = new GameHistoryInfo();

                gameHistoryInfo.GameId        = _GameInfo.GameId;
                gameHistoryInfo.GameSource    = _GameInfo.GameName;
                gameHistoryInfo.BuyerId       = userInfo.Id;
                gameHistoryInfo.RecommenderId = userInfo.Recommender;
                gameHistoryInfo.StartTime     = DateTime.Now;
                gameHistoryInfo.EndTime       = DateTime.Now;

                userInfo.GameHistoryId = Database.GetInstance().AddGameHistory(gameHistoryInfo);
            }

            return(true);
        }
コード例 #2
0
ファイル: GameTable.cs プロジェクト: toowind/BBMessenger
        public virtual bool PlayerOutTable(BaseInfo baseInfo, UserInfo userInfo)
        {
            _AutoEners.Remove(userInfo);

            if (GetPlayerIndex(userInfo) < 0)
            {
                return(true);
            }

            _TableInfo._Players.Remove(userInfo);

            // modified by usc at 2014/04/02
            //_TableInfo._Viewers.Add(userInfo);

            if (userInfo.Auto == 0)
            {
                _TableInfo._Viewers.Add(userInfo);
            }
            else
            {
                userInfo.GameId = string.Empty;
            }

            GameHistoryInfo gameHistoryInfo = Database.GetInstance().FindGameHistory(userInfo.GameHistoryId);

            if (gameHistoryInfo != null && gameHistoryInfo.BuyerTotal == 0 && gameHistoryInfo.RecommenderTotal == 0 && gameHistoryInfo.ManagerTotal == 0 && gameHistoryInfo.AdminTotal == 0)
            {
                Database.GetInstance().DeleteGameHistory(gameHistoryInfo.Id);
            }

            // added by usc at 2014/03/04
            if (userInfo.Auto == 0)
            {
                Server.GetInstance().Send(userInfo.Socket, NotifyType.Reply_UserInfo, userInfo);
            }

            return(true);
        }
コード例 #3
0
ファイル: MngGameHistory.cs プロジェクト: toowind/BBMessenger
        public void RefreshUserList()
        {
            int year  = 0;
            int month = 0;
            int day   = 0;

            try
            {
                year  = Convert.ToInt32(comboYear.Text);
                month = Convert.ToInt32(comboMonth.Text);
                day   = Convert.ToInt32(comboDay.Text);
            }
            catch
            {
            }

            List <GameHistoryInfo> gameHistoryList = Database.GetInstance().GetDayGameHistories(year, month, day);

            if (gameHistoryList == null)
            {
                MessageBox.Show("不能在资料库获取游戏信息.");
                return;
            }

            HistoryView.Rows.Clear();
            SumView.Rows.Clear();

            int sumBuyerTotal    = 0;
            int RecommenderTotal = 0;
            int officerTotal     = 0;
            int sumManagerTotal  = 0;

            for (int i = 0; i < gameHistoryList.Count; i++)
            {
                GameHistoryInfo historyInfo = gameHistoryList[i];

                TimeSpan duration = historyInfo.EndTime - historyInfo.StartTime;

                //string managerId = Users.ManagerInfo.Id;
                //int managerCash = 0;

                //switch (Users.ManagerInfo.Kind)
                //{
                //    case (int)UserKind.Manager:
                //        managerCash = historyInfo.ManagerTotal;
                //        break;

                //    case (int)UserKind.RecommendOfficer:
                //        managerCash = historyInfo.RecommendOfficerTotal;
                //        break;
                //}

                HistoryView.Rows.Add(
                    BaseInfo.ConvDateToString(historyInfo.StartTime),
                    string.Format("{0:00}:{1:00}:{2:00}", duration.Hours, duration.Minutes, duration.Seconds),
                    historyInfo.GameId,
                    historyInfo.BuyerId,
                    historyInfo.BuyerTotal,
                    historyInfo.RecommenderId,
                    historyInfo.RecommenderTotal,
                    historyInfo.OfficerId,
                    historyInfo.RecommendOfficerTotal,
                    historyInfo.ManagerId,
                    historyInfo.ManagerTotal
                    );

                sumBuyerTotal    += historyInfo.BuyerTotal;
                RecommenderTotal += historyInfo.RecommenderTotal;
                officerTotal     += historyInfo.RecommendOfficerTotal;
                sumManagerTotal  += historyInfo.ManagerTotal;
            }

            SumView.Rows.Add(
                "",
                "",
                "",
                "",
                sumBuyerTotal,
                "",
                RecommenderTotal,
                "",
                officerTotal,
                "",
                sumManagerTotal);

            labelSummary.Text = string.Format("总数: {0}", gameHistoryList.Count);
        }
コード例 #4
0
ファイル: Cash.cs プロジェクト: toowind/BBMessenger
        public bool ProcessGameCash(int userIndex, GameInfo gameInfo, TableInfo tableInfo)
        {
            UserInfo admin   = null;
            UserInfo manager = null;

            List <UserInfo> listAdmin   = Database.GetInstance().GetManager(UserKind.Administrator);
            List <UserInfo> listManager = Database.GetInstance().GetManager(UserKind.Manager);

            if (listAdmin.Count > 0 && listManager.Count > 0)
            {
                admin   = listAdmin[0];
                manager = listManager[0];
            }
            else
            {
                return(false);
            }

            UserInfo userInfo = tableInfo._Players[userIndex];

            int userCash        = 0;
            int recommenderCash = 0;
            int managerCash     = 0;
            int commissionCash  = 0;

            commissionCash = tableInfo.m_lUserBetScore[userIndex] * gameInfo.Commission / 100;              // 관리자:
            userCash       = tableInfo.m_lUserWinScore[userIndex] - commissionCash;                         // 사용자:

            if (userCash == 0 && commissionCash == 0)
            {
                return(true);
            }

            if (gameInfo.nCashOrPointGame == 0 && userInfo.Auto == 0 && userInfo.Kind == (int)UserKind.Buyer)
            {
                UserInfo recommender = null;

                if (string.IsNullOrEmpty(userInfo.Recommender) == false)
                {
                    recommender = Database.GetInstance().FindUser(userInfo.Recommender);
                }

                int recommenderPercent = 0;

                if (recommender != null)
                {
                    recommenderPercent = recommender.GamePercent;

                    if (recommenderPercent > 100)
                    {
                        recommenderPercent = 100;
                    }
                }

                //commissionCash = tableInfo.m_lUserBetScore[userIndex] * gameInfo.Commission / 100;              // 관리자:

                // added by usc at 2014/04/09
                //GiveGameSum(admin.Id, commissionCash, gameInfo);

                //userCash = tableInfo.m_lUserWinScore[userIndex] - commissionCash;                               // 사용자:

                // 광고대리가 있으면
                if (recommender != null)
                {
                    managerCash     = -tableInfo.m_lUserWinScore[userIndex] * (100 - recommenderPercent) / 100; // 경영자:
                    recommenderCash = -tableInfo.m_lUserWinScore[userIndex] * recommenderPercent / 100;         // 광고대리:

                    GiveGameSum(admin.Id, commissionCash, gameInfo);
                    GiveGameSum(manager.Id, managerCash, gameInfo);
                    GiveGameSum(recommender.Id, recommenderCash, gameInfo);
                }
                else
                {
                    managerCash = -tableInfo.m_lUserWinScore[userIndex];                                        // 경영자:

                    GiveGameSum(admin.Id, commissionCash, gameInfo);
                    GiveGameSum(manager.Id, managerCash, gameInfo);
                }

                GameHistoryInfo gameHistoryInfo = Database.GetInstance().FindGameHistory(userInfo.GameHistoryId);

                if (gameHistoryInfo != null)
                {
                    gameHistoryInfo.Id                     = userInfo.GameHistoryId;
                    gameHistoryInfo.BuyerTotal            += userCash; // modified by usc at 2014/03/20
                    gameHistoryInfo.RecommenderTotal      += recommenderCash;
                    gameHistoryInfo.RecommendOfficerTotal += 0;
                    gameHistoryInfo.ManagerId              = manager.Id;
                    gameHistoryInfo.ManagerTotal          += managerCash;

                    // added newly
                    gameHistoryInfo.AdminTotal += commissionCash;

                    gameHistoryInfo.EndTime = DateTime.Now;

                    Database.GetInstance().UpdateGameHistory(gameHistoryInfo);
                }
            }

            if (GiveGameSum(userInfo.Id, userCash, gameInfo) == false)
            {
                // modified by usc at 2014/06/15
                //if (userInfo.Auto > 0)
                //    Users.GetInstance().Logout(userInfo.Socket);
                //else
                //    Game.GetInstance().OutGame(userInfo);

                Game.GetInstance().OutGame(userInfo);
            }

            return(true);

            //UserInfo manager = Database.GetInstance().GetManager(UserKind.Manager)[0];
            //UserInfo userInfo = tableInfo._Players[userIndex];

            //int recommenderCash = 0;
            //int recommendOfficerCash = 0;
            //int managerCash = 0;

            //if (userInfo.Auto == 0)
            //    managerCash = -tableInfo.m_lUserWinScore[userIndex];


            //if (userInfo.Kind == (int)UserKind.Buyer && tableInfo.m_lUserWinScore[userIndex] > 0 && gameInfo.Commission > 0 && userInfo.Auto == 0)
            //{
            //    UserInfo recommender = null;
            //    UserInfo recommendOfficer = null;

            //    if (string.IsNullOrEmpty(userInfo.Recommender) == false)
            //    {
            //        recommender = Database.GetInstance().FindUser(userInfo.Recommender);
            //        recommendOfficer = Database.GetInstance().FindUser(recommender.Recommender);
            //    }
            //    else
            //    {
            //        UserInfo friendInfo = Database.GetInstance().FindUser(userInfo.Friend);

            //        if (friendInfo != null && friendInfo.Kind != (int)UserKind.Buyer)
            //        {
            //            recommender = friendInfo;
            //        }
            //    }

            //    int commissionCash = tableInfo.m_lUserWinScore[userIndex] * gameInfo.Commission / 100;
            //    tableInfo.m_lUserWinScore[userIndex] -= commissionCash;

            //    int recommenderPercent = 0;

            //    if (recommender != null)
            //    {
            //        recommenderPercent = recommender.GamePercent;

            //        if (recommenderPercent > 100)
            //            recommenderPercent = 100;
            //    }

            //    int recommendOfficerPercent = 0;

            //    if (recommendOfficer != null)
            //    {
            //        recommendOfficerPercent = recommendOfficer.GamePercent;

            //        if (recommendOfficerPercent > 100)
            //            recommendOfficerPercent = 100;
            //    }

            //    if (recommenderPercent > recommendOfficerPercent)
            //        recommenderPercent = recommendOfficerPercent;

            //    recommendOfficerPercent -= recommenderPercent;

            //    recommenderCash = ProcessCashPercent(recommender, recommenderPercent, commissionCash);
            //    recommendOfficerCash = ProcessCashPercent(recommendOfficer, recommendOfficerPercent, commissionCash);
            //    managerCash += commissionCash - recommendOfficerCash - recommenderCash;


            //    if (recommender != null)
            //        GiveGameSum(recommender.Id, recommenderCash, gameInfo);

            //    if (recommendOfficer != null)
            //        GiveGameSum(recommendOfficer.Id, recommendOfficerCash, gameInfo);

            //}

            //GiveGameSum(manager.Id, managerCash, gameInfo);

            ////GiveCash( userInfo.Id, tableInfo.m_lUserWinScore[i] );
            //if (GiveGameSum(userInfo.Id, tableInfo.m_lUserWinScore[userIndex], gameInfo) == false)
            //{
            //    if (userInfo.Auto > 0)
            //        Users.GetInstance().Logout(userInfo.Socket);
            //    else
            //        Game.GetInstance().OutGame(userInfo);
            //}

            //GameHistoryInfo gameHistoryInfo = Database.GetInstance().FindGameHistory(userInfo.GameHistoryId);

            //if (gameHistoryInfo != null)
            //{
            //    gameHistoryInfo.Id = userInfo.GameHistoryId;
            //    gameHistoryInfo.BuyerTotal += tableInfo.m_lUserWinScore[userIndex];
            //    gameHistoryInfo.RecommenderTotal += recommenderCash;
            //    gameHistoryInfo.RecommendOfficerTotal += recommendOfficerCash;
            //    gameHistoryInfo.ManagerTotal += managerCash;
            //    gameHistoryInfo.EndTime = DateTime.Now;

            //    Database.GetInstance().UpdateGameHistory(gameHistoryInfo);
            //}
        }