|
|
@ -1,5 +1,6 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
|
|
|
int feld(char prifield[]) { |
|
|
@ -107,8 +108,9 @@ int singleplayer() { |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("Player, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
printf("\nPlayer, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -116,7 +118,7 @@ int singleplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -124,21 +126,26 @@ int singleplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("\nPlayer, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -146,7 +153,7 @@ int singleplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -154,22 +161,28 @@ int singleplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
printf("Player, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("\nPlayer, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -177,7 +190,7 @@ int singleplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -185,29 +198,34 @@ int singleplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("\nPlayer, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -215,21 +233,27 @@ int singleplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
int runde = 1; |
|
|
|
|
|
|
|
while (score1 || score2 < 16) { |
|
|
|
|
|
|
|
!feld(player); |
|
|
|
printf("Player 1, gib eine Zielkoordinate ein: "); |
|
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer, gib eine Zielkoordinate ein: ", runde, score1); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
@ -243,6 +267,8 @@ int singleplayer() { |
|
|
|
player[coor] = '-'; |
|
|
|
printf("Kein Treffer.\n"); |
|
|
|
} |
|
|
|
|
|
|
|
runde++; |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
@ -285,18 +311,23 @@ int multiplayer() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
!feld(multi); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
|
|
|
|
printf("Player 1, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
printf("\nPlayer 1, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -304,21 +335,26 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player 1, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("\nPlayer 1, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -326,7 +362,7 @@ int multiplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -334,22 +370,28 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
printf("Player 1, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("\nPlayer 1, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -357,7 +399,7 @@ int multiplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -365,29 +407,34 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player 1, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
printf("\nPlayer 1, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -395,24 +442,28 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships1[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
|
|
|
|
printf("\n\n\n"); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("Player 2, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
printf("\nPlayer 2, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -420,7 +471,7 @@ int multiplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -428,21 +479,26 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player 2, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("\nPlayer 2, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -450,7 +506,7 @@ int multiplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -458,22 +514,28 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
printf("Player 2, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("\nPlayer 2, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
@ -481,7 +543,7 @@ int multiplayer() { |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -489,29 +551,34 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player 2, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("\nPlayer 2, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships2[coor1] = 'X'; |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
printf("\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
@ -519,24 +586,27 @@ int multiplayer() { |
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
system("cls"); |
|
|
|
} |
|
|
|
else { |
|
|
|
system("cls"); |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("\n\n\n"); |
|
|
|
system("cls"); |
|
|
|
|
|
|
|
int runde = 1; |
|
|
|
|
|
|
|
while (score1 || score2 < 16) { |
|
|
|
|
|
|
|
!feld(player1); |
|
|
|
printf("Player 1, gib eine Zielkoordinate ein: "); |
|
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer 1, gib eine Zielkoordinate ein: ", runde, score1); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
@ -552,7 +622,7 @@ int multiplayer() { |
|
|
|
} |
|
|
|
|
|
|
|
!feld(player2); |
|
|
|
printf("Player 2, gib eine Zielkoordinate ein: "); |
|
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer 2, gib eine Zielkoordinate ein: ", runde, score2); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
@ -567,7 +637,7 @@ int multiplayer() { |
|
|
|
printf("Kein Treffer.\n"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
runde++; |
|
|
|
} |
|
|
|
|
|
|
|
if (score1 = 16) { |
|
|
|