package com.editev.chess.printer; import com.editev.chess.GameHTML; import com.editev.chess.Move; /** Prints the move history for a Game. * * @see See the source here. */ public class HistoryPrinter extends Printer { public void printOneMove( GameHTML game, int moveIndex, StringBuffer moveString ) { Move move = game.moveHistory.getAt( moveIndex ); game.out.print( "" ); game.out.print( move.toString() ); game.out.print( "  "); } public static final int MOVES_PER_TABLE = 25; /** Prints the move history for a Game. * @param game the GameHTML with the board status and PrintStream for this board. */ public void print( GameHTML game ) { int moves = game.getMoves(); if (moves == 0) return; //game.out.startTag( "\n"); game.out.startTag( "
\n"); StringBuffer str = null; if (!game.hasJavascript) { str = new StringBuffer( game.baseURL ); str.append( "?moves=" ); } for (int moveIndex=0; moveIndex" ); game.out.print( " "); printOneMove( game, moveIndex, str ); if ((moveIndex+1) < moves) { printOneMove( game, moveIndex+1, str ); game.out.print( "\n" ); if ( (1+moveIndex/2) % MOVES_PER_TABLE == 0 && moveIndex+2 < moves ) { // out of space, start a new table! game.out.endTag( "
"); int m = 1+moveIndex/2; if (game.textOnly) { if (m < 100) game.out.print( " " ); if (m < 10 ) game.out.print( " " ); } game.out.print( m+"." ); game.out.print( "
\n"); game.out.endTag( "\n"); //game.out.startTag( "\n"); game.out.startTag( "\n"); game.out.startTag( "\n"); } } else { game.out.print( "\n" ); } } game.out.endTag( "
\n" ); } }