public void Set(PGNChessGame g) { idx = -1; move = null; total_moves = 0; player = g.HasTag ("FEN") ? ChessGamePlayer. CreateFromFEN (g. GetTagValue ("FEN", null)) : ChessGamePlayer.CreatePlayer (); game = g; int n = game.Moves.Count; if (n > 0) { total_moves = (n - 1) * 2; // now see the last move ChessMove lastmove = (ChessMove) game.Moves[n - 1]; if (lastmove.blackmove == null) total_moves += 1; else total_moves += 2; } if (total_moves == 0) hasNext = false; else hasNext = true; }
public void Set(ChessGame g) { idx = -1; move = null; total_moves = 0; if (g == null) { player = ChessGamePlayer. CreatePlayer (); return; } player = g.HasTag ("FEN") ? ChessGamePlayer. CreateFromFEN (g. GetTagValue ("FEN", null)) : ChessGamePlayer.CreatePlayer (); game = g; int n = game.Moves.Count; if (n > 0) { total_moves = n; } if (total_moves == 0) hasNext = false; else hasNext = true; }
private MovesGetter(int id, GetMovesDelegate cb) { moves = new ArrayList (); player = ChessGamePlayer.CreatePlayer (); start_parsing = true; callback = cb; gameid = id; }
public static ChessGamePlayer CreateFromFEN(string fen) { PositionInfo info = new PositionInfo (fen); string[]lines = info.position_str.Split ('/'); if (lines.Length != 8) throw new ChessException (Catalog.GetString("Invalid number tokens in the FEN position")); ChessSide whites = new ChessSide (ColorType.WHITE); ChessSide blacks = new ChessSide (ColorType.BLACK); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; for (int j = 0; j < line.Length; j++) { char ch = line[j]; if (Char.IsNumber (ch)) { j += ch - '1'; // starting from 1 since j++ will increment 1 continue; } int rank = 7 - i; int file = j; ChessPiece piece; GetPieceForFENChar (ch, whites, blacks, rank, file, out piece); piece.addToSide (); } } whites.King.CanCastle = info.WhiteCanCastle; blacks.King.CanCastle = info.BlackCanCastle; ChessGamePlayer game = new ChessGamePlayer (); game.turn = info.Turn; game.StartGame (whites, blacks); return game; }
private void PrintImageForPosition(ChessGamePlayer player) { int width = 200; int height = 200; PositionSnapshot ps = new PositionSnapshot (player. GetPosition (), width, height); ps.DrawMove (player.LastMoveInfo.src_rank, player.LastMoveInfo.src_file, player.LastMoveInfo.dest_rank, player.LastMoveInfo.dest_file); Gdk.Pixbuf image = Gdk.Pixbuf.FromDrawable (ps.Pixmap, ps.Pixmap. Colormap, 0, 0, 0, 0, width, height); printer.PrintImage (image); }