Browse Source

added validation 1/9

remotes/origin/ticTacToe
Aimee Reincke 2 years ago
parent
commit
6e79888d3b
  1. 72
      src/c/ticTacToe.c

72
src/c/ticTacToe.c

@ -156,34 +156,46 @@ void getComputerInput(char field[3][3]){
void fillAlmostFull(char field[3][3], bool* pt) {
if (field[0][0] == 'X') {
if (field[0][1] == 'X') {
field[0][2] = 'X';
*pt = true;
return;
if( field[0][2] = '-'){
field[0][2] = 'X';
*pt = true;
return;
}
}
else if (field[0][2] == 'X') {
field[0][1] = 'X';
*pt = true;
return;
if( field[0][1] = '-'){
field[0][1] = 'X';
*pt = true;
return;
}
}
else if (field[1][0] == 'X') {
field[2][0] = 'X';
*pt = true;
return;
if( field[2][0] = '-'){
field[2][0] = 'X';
*pt = true;
return;
}
}
else if (field[2][0] == 'X') {
field[1][0] = 'X';
*pt = true;
return;
if( field[1][0] = '-'){
field[1][0] = 'X';
*pt = true;
return;
}
}
else if (field[1][1] == 'X') {
if( field[2][2] = '-'){
field[2][2] = 'X';
*pt = true;
return;
}
}
else if (field[2][2] == 'X') {
if( field[1][1] = '-'){
field[1][1] = 'X';
*pt = true;
return;
}
}
}
if (field[0][1] == 'X') {
@ -415,34 +427,46 @@ void fillAlmostFull(char field[3][3], bool* pt) {
if (field[0][0] == 'O') {
if (field[0][1] == 'O') {
field[0][2] = 'X';
*pt = true;
return;
if( field[0][2] = '-'){
field[0][2] = 'X';
*pt = true;
return;
}
}
else if (field[0][2] == 'O') {
field[0][1] = 'X';
*pt = true;
return;
if( field[0][1] = '-'){
field[0][1] = 'X';
*pt = true;
return;
}
}
else if (field[1][0] == 'O') {
field[2][0] = 'X';
*pt = true;
return;
if( field[2][0] = '-'){
field[2][0] = 'X';
*pt = true;
return;
}
}
else if (field[2][0] == 'O') {
field[1][0] = 'X';
*pt = true;
return;
if( field[1][0] = '-'){
field[1][0] = 'X';
*pt = true;
return;
}
}
else if (field[1][1] == 'O') {
if( field[2][2] = '-'){
field[2][2] = 'X';
*pt = true;
return;
}
}
else if (field[2][2] == 'O') {
if( field[1][1] = '-'){
field[1][1] = 'X';
*pt = true;
return;
}
}
}
if (field[0][1] == 'O') {

Loading…
Cancel
Save