|
|
@ -233,22 +233,128 @@ int multiplayer() { |
|
|
|
!feld(ships1); |
|
|
|
|
|
|
|
|
|
|
|
int k2 = 1; |
|
|
|
printf("\n\n\n"); |
|
|
|
|
|
|
|
do |
|
|
|
{ |
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("Player 2, platziere deine Schiffe.\nKoordinate: "); |
|
|
|
printf("Player 2, platziere dein Schlachtschiff (5).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships1[coor] = 'X'; |
|
|
|
!feld(ships1); |
|
|
|
ships2[coor1] = 'X'; |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player 2, platziere deinen Kreuzer (4).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships2[coor1] = 'X'; |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
printf("Player 2, platziere deine Zerstoerer 2x(3).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships2[coor1] = 'X'; |
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
i--; |
|
|
|
} |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
printf("Player 2, platziere dein U-Boot (2).\nKoordinate: "); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
ships2[coor1] = 'X'; |
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
printf("\n"); |
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
k2++; |
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
if (coor2 == coor1 + 1 || coor2 == coor1 - 1) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else if (coor2 == coor1 + 10 || coor2 == coor1 - 10) { |
|
|
|
ships2[coor2] = 'X'; |
|
|
|
coor1 = coor2; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Ungueltige Eingabe.\n"); |
|
|
|
} |
|
|
|
|
|
|
|
} while (k2 < 17); |
|
|
|
!feld(ships2); |
|
|
|
|
|
|
|
printf("\n\n\n"); |
|
|
|
|
|
|
|