示例#1
0
        public static UserGameType GetUserGameRating(Cxt cxt, int chessTypeID, int gameTypeID, int userID)
        {
            DataTable    table        = BaseCollection.ExecuteSql(InfiChess.UserGameType, "SELECT TOP 1 * FROM [UserGameType] WHERE ChessTypeID = @p1 AND GameTypeID = @p2 AND UserID = @p3", chessTypeID, gameTypeID, userID);
            UserGameType userGameType = null;

            if (table.Rows.Count > 0)
            {
                userGameType = new UserGameType(cxt, table.Rows[0]);
            }
            else
            {
                //userGameType = null;
                userGameType               = new UserGameType();
                userGameType.UserID        = userID;
                userGameType.GameTypeID    = gameTypeID;
                userGameType.ChessTypeID   = chessTypeID;
                userGameType.NoOfGames     = 0;
                userGameType.StoredMatches = 0;
                if (chessTypeID == (int)ChessTypeE.Human)
                {
                    userGameType.EloRating = 1500;
                }
                else
                {
                    userGameType.EloRating = 2200;
                }
            }

            return(userGameType);
        }
示例#2
0
        private static Game CreateGame(Cxt cxt, TournamentMatch m, Challenge c)
        {
            Game g = new Game(cxt, 0);

            g.WhiteChessTypeIDE = m.Tournament.ChessTypeIDE;
            g.BlackChessTypeIDE = m.Tournament.ChessTypeIDE;
            g.GameTypeIDE       = c.GameTypeIDE;
            g.WhiteUserID       = c.ChallengerUserID;
            g.BlackUserID       = c.OpponentUserID;
            g.RoomID            = c.RoomID;
            g.TournamentMatchID = c.TournamentMatchID;
            g.ChallengeID       = c.ChallengeID;
            g.TimeMin           = c.TimeMin;
            g.GainPerMoveMin    = c.GainPerMoveMin;
            g.StartDate         = DateTime.Now;
            g.IsRated           = m.Tournament.Rated;
            g.GameResultIDE     = m.GameResultIDE;

            UserGameType userGameTypeWhite = UserGameType.GetUserGameRating(cxt, g.WhiteChessTypeID, g.GameTypeID, g.WhiteUserID);
            UserGameType userGameTypeBlack = UserGameType.GetUserGameRating(cxt, g.BlackChessTypeID, g.GameTypeID, g.BlackUserID);

            g.EloWhiteBefore = (userGameTypeWhite == null ? 0 : userGameTypeWhite.EloRating);
            g.EloBlackBefore = (userGameTypeBlack == null ? 0 : userGameTypeBlack.EloRating);

            return(g);
        }