out.write( "\" /></inferno>" );
turns -= board.getInfernoBurnTurns( coords ); turns = -turns; if ( turns > 0 ) { out.write( "<standard turns=\"" ); out.write( turns ); out.write( "\" />" ); } out.write( "</inferno>" );
    public static void encode( Board board, Writer out )        throws IOException    {        Enumeration iter; // used when marching through a list of sub-elements        Coords coords;        int x;        int y;        int turns;        // First, validate our input.        if ( null == board ) {            throw new IllegalArgumentException( "The board is null." );        }        if ( null == out ) {            throw new IllegalArgumentException( "The writer is null." );        }        // Start the XML stream for this board        out.write( "<board version=\"1.0\" >" );        // Write the hex array to the stream.        out.write( "<boardData width=\"" );        out.write( board.width );        out.write( "\" height=\"" );        out.write( board.height );        out.write( "\" roadsAutoExit=\"" );        out.write( board.getRoadsAutoExit() ? "true" : "false" );        out.write( "\" >" );        for ( x = 0; x < board.width; x++ ) {            for ( y = 0; y < board.height; y++ ) {                HexEncoder.encode( board.getHex(x,y), out );            }        }        out.write( "</boardData>" );        // Write out the buildings (if any).        iter = board.getBuildings();        if ( iter.hasMoreElements() ) {            out.write( "<buildings>" );            while ( iter.hasMoreElements() ) {                BuildingEncoder.encode( (Building) iter.nextElement(), out );            }            out.write( "</buildings>" );        }        // Write out the infernos (if any).        iter = board.getInfernoBurningCoords();        if ( iter.hasMoreElements() ) {            out.write( "<infernos>" );            while ( iter.hasMoreElements() ) {                // Encode the infernos as these coordinates.                coords = (Coords) iter.nextElement();                out.write( "<inferno>" );                CoordsEncoder.encode( coords, out );                turns = board.getInfernoBurnTurns( coords );                out.write( "<standard turns=\"" );                out.write( turns );                turns = board.getInfernoIVBurnTurns( coords );                // This value may be zero.                if ( turns > 0 ) {                    out.write( "\" /><arrowiv turns=\"" );                    out.write( turns );                }                out.write( "\" /></inferno>" );            }            out.write( "</infernos>" );        }        // Finish the XML stream for this board.        out.write( "</board>" );    }