private bool ClueFitsInSpace(Clue clue, Spaces spaces, int clueStart) { //is this clue completely within a space? foreach (Space space in spaces) { //we just need one to be true if (clueStart >= space.SpaceStart && clueStart + clue.Number <= space.SpaceStart + space.SpaceLength) { return(true); } } return(false); }
public void AddClue(Clue clue) { _spaceClues.AddClue(clue); }
public bool ClueExists(Clue clue) { return(_clueList.IndexOf(clue) > -1); }
public void AddClue(Clue clue) { _clueList.Add(clue); }
// Public methods public Board(Puzzle puzzle, Point start_point) { m_rows = puzzle.Row_Hints.Length; m_columns = puzzle.Column_Hints.Length; m_style = Get_Style(puzzle); // Initialize the Board's background m_exterior_rectangle = new Rectangle( new Point( start_point.X + m_style.Clue_Spacing * 4, start_point.Y + m_style.Clue_Spacing * 4), new Size( m_columns * m_style.Cell_Size, m_rows * m_style.Cell_Size)); m_interior_lines = new Line_Segment[m_rows - 1 + m_columns - 1]; int line_segment_index = 0; for (int column = 1; column < m_columns; column++, line_segment_index++) { int x_position = m_exterior_rectangle.Left + m_style.Cell_Size * column; m_interior_lines[line_segment_index] = new Line_Segment { First = new Point(x_position, m_exterior_rectangle.Top), Second = new Point(x_position, m_exterior_rectangle.Bottom), }; } for (int row = 1; row < m_rows; row++, line_segment_index++) { int y_position = m_exterior_rectangle.Top + m_style.Cell_Size * row; m_interior_lines[line_segment_index] = new Line_Segment { First = new Point(m_exterior_rectangle.Left, y_position), Second = new Point(m_exterior_rectangle.Right, y_position), }; } // Initialize the grid of cells m_cells = new Cell[m_columns, m_rows]; for (int row = 0; row < m_rows; row++) { for (int column = 0; column < m_columns; column++) { m_cells[column, row] = new Cell( Cell.State.maybe, m_style, new Rectangle( m_exterior_rectangle.Left + m_style.Cell_Size * column, m_exterior_rectangle.Top + m_style.Cell_Size * row, m_style.Cell_Size, m_style.Cell_Size)); } } // Initialize the clues to match the puzzle m_column_clues = new Clue[m_columns]; for (int column = 0; column < m_columns; column++) { Point clue_position = m_cells[column, 0].Screen_Rectangle.Location; clue_position.X += m_style.Cell_Size / 2; clue_position.Y += m_style.Cell_Size / 2 - m_style.Clue_Board_Offset; m_column_clues[column] = new Clue(puzzle.Column_Hints[column], m_style, clue_position, true); } m_row_clues = new Clue[m_rows]; for (int row = 0; row < m_rows; row++) { Point clue_position = m_cells[0, row].Screen_Rectangle.Location; clue_position.X += m_style.Cell_Size / 2 - m_style.Clue_Board_Offset; clue_position.Y += m_style.Cell_Size / 2; m_row_clues[row] = new Clue(puzzle.Row_Hints[row], m_style, clue_position, false); } // Collect the cells into groups m_groups = new Group[m_rows + m_columns]; int group_count = 0; for (int column = 0; column < m_columns; column++, group_count++) { Group group = new Group(m_rows, m_column_clues[column]); for (int row = 0; row < m_rows; row++) { group.Cells[row] = m_cells[column, row]; } m_groups[group_count] = group; } for (int row = 0; row < m_rows; row++, group_count++) { Group group = new Group(m_columns, m_row_clues[row]); for (int column = 0; column < m_columns; column++) { group.Cells[column] = m_cells[column, row]; } m_groups[group_count] = group; } }
public Group(int cell_count, Clue clue) { Cells = new Cell[cell_count]; Group_Clue = clue; }