From a61a03975eab94c907ba5a519b6dc302243cdff4 Mon Sep 17 00:00:00 2001 From: Aimee Reincke Date: Thu, 2 Feb 2023 18:07:18 +0100 Subject: [PATCH] added validation 3/9 --- src/c/ticTacToe.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/c/ticTacToe.c b/src/c/ticTacToe.c index 4fe0ad1..4884cc2 100644 --- a/src/c/ticTacToe.c +++ b/src/c/ticTacToe.c @@ -230,34 +230,46 @@ void fillAlmostFull(char field[3][3], bool* pt) { } if (field[0][2] == 'X') { if (field[0][0] == 'X') { + if( field[0][1] = '-'){ field[0][1] = 'X'; *pt = true; return; + } } else if (field[0][1] == 'X') { + if( field[0][0] = '-'){ field[0][0] = 'X'; *pt = true; return; + } } else if (field[1][1] == 'X') { + if( field[2][0] = '-'){ field[2][0] = 'X'; *pt = true; return; + } } else if (field[2][0] == 'X') { + if( field[1][1] = '-'){ field[1][1] = 'X'; *pt = true; return; + } } else if (field[1][2] == 'X') { + if( field[2][2] = '-'){ field[2][2] = 'X'; *pt = true; return; + } } else if (field[2][2] == 'X') { + if( field[1][2] = '-'){ field[1][2] = 'X'; *pt = true; return; + } } } if (field[1][0] == 'X') { @@ -509,34 +521,46 @@ void fillAlmostFull(char field[3][3], bool* pt) { } if (field[0][2] == 'O') { if (field[0][0] == 'O') { + if( field[0][1] = '-'){ field[0][1] = 'X'; *pt = true; return; + } } else if (field[0][1] == 'O') { + if( field[0][0] = '-'){ field[0][0] = 'X'; *pt = true; return; + } } else if (field[1][1] == 'O') { + if( field[2][0] = '-'){ field[2][0] = 'X'; *pt = true; return; + } } else if (field[2][0] == 'O') { + if( field[1][1] = '-'){ field[1][1] = 'X'; *pt = true; return; + } } else if (field[1][2] == 'O') { + if( field[2][2] = '-'){ field[2][2] = 'X'; *pt = true; return; + } } else if (field[2][2] == 'O') { + if( field[1][2] = '-'){ field[1][2] = 'X'; *pt = true; return; + } } } if (field[1][0] == 'O') {