|
@ -224,52 +224,73 @@ int singleplayer() { |
|
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
printf("\nKoordinate: "); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
for (int i = 0; i < 1; i++) { |
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
printf("\nKoordinate: "); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
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--; |
|
|
|
|
|
|
|
|
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--; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
system("cls"); |
|
|
system("cls"); |
|
|
|
|
|
|
|
|
int runde = 1; |
|
|
int runde = 1; |
|
|
|
|
|
int higherscore = 0; |
|
|
|
|
|
|
|
|
while (score1 || score2 < 16) { |
|
|
|
|
|
|
|
|
while (higherscore < 16) { |
|
|
|
|
|
|
|
|
!feld(player); |
|
|
|
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer, gib eine Zielkoordinate ein: ", runde, score1); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
!feld(player); |
|
|
|
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer, gib eine Zielkoordinate ein: ", runde, score1); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
if (ships2[coor] == 'X') { |
|
|
|
|
|
player[coor] = 'X'; |
|
|
|
|
|
score1 += 1; |
|
|
|
|
|
printf("Treffer!!\n"); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
player[coor] = '-'; |
|
|
|
|
|
printf("Kein Treffer.\n"); |
|
|
|
|
|
|
|
|
if (ships2[coor] == 'X') { |
|
|
|
|
|
player[coor] = 'X'; |
|
|
|
|
|
score1 += 1; |
|
|
|
|
|
system("cls"); |
|
|
|
|
|
printf("Treffer!!\n\n"); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
player[coor] = '-'; |
|
|
|
|
|
system("cls"); |
|
|
|
|
|
printf("Kein Treffer.\n\n"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (score1 >= score2) { |
|
|
|
|
|
higherscore = score1; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
higherscore = score2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
runde++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
runde++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
system("cls"); |
|
|
|
|
|
|
|
|
|
|
|
if (score1 = 16) { |
|
|
|
|
|
printf("Player 1 hat gewonnen."); |
|
|
|
|
|
} |
|
|
|
|
|
if (score2 = 16) { |
|
|
|
|
|
printf("Player 2 hat gewonnen."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
@ -323,7 +344,6 @@ int multiplayer() { |
|
|
coor1 = convertcoor(letco, numco); |
|
|
coor1 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
ships1[coor1] = 'X'; |
|
|
!feld(ships1); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
for (int i = 0; i < 4; i++) { |
|
|
!feld(ships1); |
|
|
!feld(ships1); |
|
@ -433,26 +453,28 @@ int multiplayer() { |
|
|
|
|
|
|
|
|
ships1[coor1] = 'X'; |
|
|
ships1[coor1] = 'X'; |
|
|
|
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
printf("\nKoordinate: "); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
for (int i = 0; i < 1; i++) { |
|
|
|
|
|
!feld(ships1); |
|
|
|
|
|
printf("\nKoordinate: "); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
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--; |
|
|
|
|
|
|
|
|
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); |
|
|
!feld(ships1); |
|
@ -577,33 +599,36 @@ int multiplayer() { |
|
|
|
|
|
|
|
|
ships2[coor1] = 'X'; |
|
|
ships2[coor1] = 'X'; |
|
|
|
|
|
|
|
|
!feld(ships2); |
|
|
|
|
|
printf("\nKoordinate: "); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
for (int i = 0; i < 1; i++) { |
|
|
|
|
|
!feld(ships2); |
|
|
|
|
|
printf("\nKoordinate: "); |
|
|
|
|
|
scanf(" %c%d", &letco, &numco); |
|
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
coor2 = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
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--; |
|
|
|
|
|
|
|
|
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--; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
system("cls"); |
|
|
system("cls"); |
|
|
|
|
|
|
|
|
int runde = 1; |
|
|
int runde = 1; |
|
|
|
|
|
int higherscore = 0; |
|
|
|
|
|
|
|
|
while (score1 || score2 < 16) { |
|
|
|
|
|
|
|
|
while (higherscore < 16) { |
|
|
|
|
|
|
|
|
!feld(player1); |
|
|
!feld(player1); |
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer 1, gib eine Zielkoordinate ein: ", runde, score1); |
|
|
printf("Runde %d\n\nScore: %d\n\nPlayer 1, gib eine Zielkoordinate ein: ", runde, score1); |
|
@ -611,14 +636,16 @@ int multiplayer() { |
|
|
|
|
|
|
|
|
coor = convertcoor(letco, numco); |
|
|
coor = convertcoor(letco, numco); |
|
|
|
|
|
|
|
|
if (ships2[coor] = 'X') { |
|
|
|
|
|
|
|
|
if (ships2[coor] == 'X') { |
|
|
player1[coor] = 'X'; |
|
|
player1[coor] = 'X'; |
|
|
score1 += 1; |
|
|
score1 += 1; |
|
|
printf("Treffer!!\n"); |
|
|
|
|
|
|
|
|
system("cls"); |
|
|
|
|
|
printf("Treffer!!\n\n"); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
player[coor] = '-' |
|
|
|
|
|
printf("Kein Treffer.\n") |
|
|
|
|
|
|
|
|
player1[coor] = '-'; |
|
|
|
|
|
system("cls"); |
|
|
|
|
|
printf("Kein Treffer.\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
!feld(player2); |
|
|
!feld(player2); |
|
@ -630,21 +657,32 @@ int multiplayer() { |
|
|
if (ships1[coor] == 'X') { |
|
|
if (ships1[coor] == 'X') { |
|
|
player2[coor] = 'X'; |
|
|
player2[coor] = 'X'; |
|
|
score2 += 1; |
|
|
score2 += 1; |
|
|
printf("Treffer!!\n"); |
|
|
|
|
|
|
|
|
system("cls"); |
|
|
|
|
|
printf("Treffer!!\n\n"); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
player2[coor] = '-'; |
|
|
player2[coor] = '-'; |
|
|
|
|
|
system("cls"); |
|
|
printf("Kein Treffer.\n"); |
|
|
printf("Kein Treffer.\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (score1 >= score2) { |
|
|
|
|
|
higherscore = score1; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
higherscore = score2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
runde++; |
|
|
runde++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
system("cls"); |
|
|
|
|
|
|
|
|
if (score1 = 16) { |
|
|
if (score1 = 16) { |
|
|
printf("Player 1 hat gewonnen."); |
|
|
printf("Player 1 hat gewonnen."); |
|
|
} |
|
|
} |
|
|
if (score1 = 16) { |
|
|
|
|
|
printf("Player 1 hat gewonnen."); |
|
|
|
|
|
|
|
|
if (score2 = 16) { |
|
|
|
|
|
printf("Player 2 hat gewonnen."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|