public static int GetGameIDByTournamentMatchID(int tournamentMatchID)
        {
            Kv kv = new Kv();

            kv.Set("MethodName", (int)MethodNameE.GetGameIDByTournamentMatchID);
            kv.Set(StdKv.CurrentUserID, Ap.CurrentUserID);
            kv.Set("TournamentMatchID", tournamentMatchID);

            DataSet ds = SocketClient.Instance.Invoke(kv.DataTable);

            if (ds == null)
            {
                return(0);
            }

            if (ds.Tables.Count == 0)
            {
                return(0);
            }

            if (ds.Tables[0].Rows.Count == 0)
            {
                return(0);
            }

            return(BaseItem.GetColInt32(ds.Tables[0].Rows[0], "GameID", 0));
        }
Ejemplo n.º 2
0
        private string GetFen()
        {
            string   fen          = string.Empty;
            int      emptySquares = 0;
            Pieces   piece        = Pieces.NONE;
            RankEnum previousRank = RankEnum.NoRank;
            RankEnum rank         = RankEnum.NoRank;

            foreach (DataRow dr in BoardData.Rows)
            {
                piece = (Pieces)BaseItem.GetColInt32(dr, Board.Piece);
                rank  = (RankEnum)BaseItem.GetColInt32(dr, Board.Rank);

                if (rank != previousRank)
                {
                    if (emptySquares > 0)
                    {
                        fen         += emptySquares;
                        emptySquares = 0;
                    }
                    fen         += "/";
                    previousRank = rank;
                }

                if (piece == Pieces.NONE)
                {
                    emptySquares++;
                }
                else
                {
                    if (emptySquares > 0)
                    {
                        fen         += emptySquares;
                        emptySquares = 0;
                    }
                    fen += GetPieceChar(piece);
                }
            }
            if (emptySquares > 0)
            {
                fen         += emptySquares;
                emptySquares = 0;
            }
            fen = RemoveStartingChar(fen, '/');
            return(fen);
        }
Ejemplo n.º 3
0
        private string GetPieceAscii(Pieces piece)
        {
            string ascii     = string.Empty;
            string filter    = "p = '" + (int)piece + "'";
            char   separator = ',';

            DataRow[] rows = BoardData.Select(filter);
            if (rows.Length > 0)
            {
                ascii += CharFromPiece(piece);

                RankEnum r;
                FileEnum f;
                foreach (DataRow dr in rows)
                {
                    r      = (RankEnum)BaseItem.GetColInt32(dr, Board.Rank);
                    f      = (FileEnum)BaseItem.GetColInt32(dr, Board.File);
                    ascii += GetFileString(f) + GetRankString(r) + separator;
                }
                ascii = RemoveEndingChar(ascii, separator);
            }

            return(ascii);
        }
Ejemplo n.º 4
0
        public Pieces GetPiece(RankEnum rank, FileEnum file)
        {
            DataRow row = GetBoardDataRow(rank, file);

            return((Pieces)BaseItem.GetColInt32(row, Board.Piece));
        }