From 4b3a0c31a51c3295968ac3817c34b749e6ebd06c Mon Sep 17 00:00:00 2001 From: Aimee Reincke Date: Thu, 2 Feb 2023 18:24:42 +0100 Subject: [PATCH] added validation 8/9 --- src/c/ticTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/c/ticTacToe.c b/src/c/ticTacToe.c index c7b19e5..89f5d2a 100644 --- a/src/c/ticTacToe.c +++ b/src/c/ticTacToe.c @@ -436,24 +436,32 @@ void fillAlmostFull(char field[3][3], bool* pt) { } if (field[2][1] == 'X') { if (field[2][0] == 'X') { + if( field[2][2] == '-'){ field[2][2] = 'X'; *pt = true; return; + } } else if (field[2][2] == 'X') { + if( field[2][0] == '-'){ field[2][0] = 'X'; *pt = true; return; + } } else if (field[1][1] == 'X') { + if( field[0][1] == '-'){ field[0][1] = 'X'; *pt = true; return; + } } else if (field[0][1] == 'X') { + if( field[1][1] == '-'){ field[1][1] = 'X'; *pt = true; return; + } } } if (field[2][2] == 'X') { @@ -771,24 +779,32 @@ void fillAlmostFull(char field[3][3], bool* pt) { } if (field[2][1] == 'O') { if (field[2][0] == 'O') { + if( field[2][2] == '-'){ field[2][2] = 'X'; *pt = true; return; + } } else if (field[2][2] == 'O') { + if( field[2][0] == '-'){ field[2][0] = 'X'; *pt = true; return; + } } else if (field[1][1] == 'O') { + if( field[0][1] == '-'){ field[0][1] = 'X'; *pt = true; return; + } } else if (field[0][1] == 'O') { + if( field[1][1] == '-'){ field[1][1] = 'X'; *pt = true; return; + } } } if (field[2][2] == 'O') {