/// <summary> /// Установить тип ячейки /// </summary> /// <param name="numCell">номер ячейки</param> /// <param name="status">тип</param> public void setStatusCell(int numCell, typeCell status) { if ((numCell >= 0) && (numCell < map.Length)) { map[numCell] = status; } }
/// <summary> /// Ход компьтера /// </summary> /// <param name="type">тип ячейки</param> /// <returns></returns> public int stepComp(typeCell type) { int val; nextStep(); val = getCellToStepInRow(); setStatusCell(val, type); return(val); }
/// <summary> /// Ищем заполненый столбец /// </summary> /// <param name="type">тип ячейки</param> /// <returns></returns> private bool isWinColumn(typeCell type) { for (int i = 0; i < size; i++) { if (checkColumn(type, i)) { return(true); } } return(false); }
/// <summary> /// Проверка столбца на заполненость крестиком или ноликом /// </summary> /// <param name="type">тип ячейки</param> /// <param name="row">номер столбца</param> /// <returns></returns> private bool checkColumn(typeCell type, int column) { for (int i = column; i < map.Length; i += 3) { if (map[i] == type) { } else { return(false); } } return(true); }
/// <summary> /// Проверка строки на заполненость крестиком или ноликом /// </summary> /// <param name="type">тип ячейки</param> /// <param name="row">номер строки</param> /// <returns></returns> private bool checkRow(typeCell type, int row) { for (int i = size * row; i < (size * row + 3); i++) { if (map[i] == type) { } else { return(false); } } return(true); }
/// <summary> /// Поиск победы по обратной диагонали /// </summary> /// <param name="type"></param> /// <returns></returns> bool isWinDiagonal_2(typeCell type) { for (int i = size - 1; i < map.Length - 1; i += size - 1) { if (map[i] == type) { } else { return(false); } } return(true); }
/// <summary> /// Проверка на победу /// </summary> /// <returns></returns> public bool isWin(out typeCell winer) { if (f.isWinCross()) { winer = typeCell.cross; return(true); } else if (f.isWinZero()) { winer = typeCell.zero; return(true); } winer = typeCell.empty; return(false); }
/// <summary> /// Проверка на выигрыш /// </summary> /// <param name="type">тип ячейки</param> /// <returns></returns> bool isWin(typeCell type) { if (isWinDiagonal(type)) { return(true); } else if (isWinDiagonal_2(type)) { return(true); } else if (isWinRow(type)) { return(true); } else if (isWinColumn(type)) { return(true); } return(false); }
/// <summary> /// Установка картинки для кнопки(ячейки) /// </summary> /// <param name="cell"></param> /// <param name="type"></param> void setImageToButton(int cell, typeCell type) { btns[cell].Image = (type == typeCell.zero) ? Properties.Resources.zero : Properties.Resources.cross1; pbNextStep.Image = (type == typeCell.zero) ? Properties.Resources.cross1 : Properties.Resources.zero; }/// <summary>
/// <summary> /// Установить тип ячейки /// </summary> /// <param name="numCell">номер ячейки</param> /// <param name="status">тип</param> public void setStatusCell(int numCell, typeCell status) { f.setStatusCell(numCell, status); }