|
|
@ -74,6 +74,13 @@ int singleplayer() { |
|
|
|
char ships1[100]; |
|
|
|
char ships2[100]; |
|
|
|
|
|
|
|
char letco; |
|
|
|
int numco; |
|
|
|
int coor, coor1, coor2; |
|
|
|
int score1 = 0; |
|
|
|
int score2 = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= 99; i++) { |
|
|
|
|
|
|
|
player[i] = '0'; |
|
|
@ -98,6 +105,127 @@ int singleplayer() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("Player, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
printf("Player, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|