Ejemplo n.º 1
0
            private void WriteGame(PGNChessGame game)
            {
                GameSession session = new GameSession ();
                session.Set (game);
                string white = game.White;
                string black = game.Black;
                string result = game.Result;

                if (white == null)
                    white = Catalog.GetString("[White]");
                if (black == null)
                    black = Catalog.GetString("[Black]");
                if (result == null)
                    result = Catalog.GetString("Unknown");

                printer.Font = fonts.titleFont;
                printer.PrintText (white + Catalog.GetString(" vs ") + black +
                           "\n\n");
                printer.Font = fonts.regularFont;
                printer.PrintText (Catalog.GetString("Result: ") + result +
                           "\n\n");

                printer.Font = fonts.moveFont;
                int moveno = 1;
                if (game.HasTag ("FEN"))
                    PrintImageForPosition
                        (session.player);

                foreach (ChessMove move in game.Moves)
                {
                    // print move
                    if (move.whitemove == null)
                        break;
                    printer.PrintText (moveno + ". " +
                               move.whitemove);
                    if (session.HasNext ())
                      {
                          session.Next ();
                          session.player.
                              Move (session.
                                CurrentMove);
                      }
                    if (move.whiteComment != null)
                      {
                          printer.LineBreak ();
                          PrintImageForPosition
                              (session.player);
                          printer.Font =
                              fonts.commentFont;
                          printer.PrintText (move.
                                     whiteComment);
                          printer.Font =
                              fonts.moveFont;
                          if (move.blackmove == null)
                              break;
                          printer.PrintText ("\n" +
                                     moveno +
                                     "...");
                      }

                    if (move.blackmove == null)
                        break;
                    if (session.HasNext ())
                      {
                          session.Next ();
                          session.player.
                              Move (session.
                                CurrentMove);
                      }
                    printer.PrintText (" " +
                               move.blackmove +
                               " ");
                    if (move.blackComment != null)
                      {
                          printer.LineBreak ();
                          PrintImageForPosition
                              (session.player);
                          printer.Font =
                              fonts.commentFont;
                          printer.PrintText (move.
                                     blackComment);
                          printer.Font =
                              fonts.moveFont;
                          printer.PrintText ("\n");
                      }
                    moveno++;
                }
            }