Your bool TicTacToe::check(char player) const
is still completly hardcoded to have a dimension of 3x3. I think it's even worse, as in more hardcoded, than the previous one.
Your class has a constant mDim
. Define your rows, columns and diagonals using that constant. The number of rows and collumns is determined by mDim
. Also the length of each row, column and diagonal is determined by 'mDim'.
The same goes for bool checkCondition(const pairCondition& i, const std::array<int, 3>& a, char player)
. The 3 is hardcoded but should be governed by mDim
.
Try making mDimmDim
selectable in the constructor and play a standard 3x3 game of ticTic-tacTac-toeToe and a larger 4x4 game of ticTic-tacTac-toeToe-tuzTuz to see if you have have removed the hardcoded 3 everywhere.
If you want to go one step further you could remove the hardcoding of the board being a square and the board being 2 dimensional. Ever played 3D ticTic-tacTac-toeToe?