From cce629ba44bdf563845e2aa60607703e04d09c7d Mon Sep 17 00:00:00 2001 From: Aimee Reincke Date: Thu, 2 Feb 2023 18:22:12 +0100 Subject: [PATCH] added validation 7/9 --- src/c/ticTacToe.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/c/ticTacToe.c b/src/c/ticTacToe.c index 553ef9a..c7b19e5 100644 --- a/src/c/ticTacToe.c +++ b/src/c/ticTacToe.c @@ -392,34 +392,46 @@ void fillAlmostFull(char field[3][3], bool* pt) { } if (field[2][0] == 'X') { if (field[2][1] == 'X') { + if( field[2][2] == '-'){ field[2][2] = 'X'; *pt = true; return; + } } else if (field[2][2] == 'X') { + if( field[2][1] == '-'){ field[2][1] = 'X'; *pt = true; return; + } } else if (field[0][0] == 'X') { - field[1][0] = 'X'; + if( field[2][1] == '-'){ + field[2][1] = 'X'; *pt = true; return; + } } else if (field[1][0] == 'X') { + if( field[0][0] == '-'){ field[0][0] = 'X'; *pt = true; return; + } } else if (field[1][1] == 'X') { + if( field[0][2] == '-'){ field[0][2] = 'X'; *pt = true; return; + } } else if (field[0][2] == 'X') { + if( field[1][1] == '-'){ field[1][1] = 'X'; *pt = true; return; + } } } if (field[2][1] == 'X') { @@ -715,34 +727,46 @@ void fillAlmostFull(char field[3][3], bool* pt) { } if (field[2][0] == 'O') { if (field[2][1] == 'O') { + if( field[2][2] == '-'){ field[2][2] = 'X'; *pt = true; return; + } } else if (field[2][2] == 'O') { + if( field[2][1] == '-'){ field[2][1] = 'X'; *pt = true; return; + } } else if (field[0][0] == 'O') { - field[1][0] = 'X'; + if( field[2][1] == '-'){ + field[2][1] = 'X'; *pt = true; return; + } } else if (field[1][0] == 'O') { + if( field[0][0] == '-'){ field[0][0] = 'X'; *pt = true; return; + } } else if (field[1][1] == 'O') { + if( field[0][2] == '-'){ field[0][2] = 'X'; *pt = true; return; + } } else if (field[0][2] == 'O') { + if( field[1][1] == '-'){ field[1][1] = 'X'; *pt = true; return; + } } } if (field[2][1] == 'O') {