|
@ -1,13 +1,12 @@ |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
#include <stdlib.h> |
|
|
|
|
|
#include <stdbool.h> |
|
|
#include <stdbool.h> |
|
|
|
|
|
#include <string.h> |
|
|
#include "spieler.h" |
|
|
#include "spieler.h" |
|
|
#include "Moving.h" |
|
|
#include "Moving.h" |
|
|
#include "Bauer.h" |
|
|
#include "Bauer.h" |
|
|
#include "Input.h" |
|
|
#include "Input.h" |
|
|
|
|
|
|
|
|
bool ist_umwandlung_gerlaubt_Bauer(char** Brett, int startX, int startY, int endX, int endY, Player player) { |
|
|
bool ist_umwandlung_gerlaubt_Bauer(char** Brett, int startX, int startY, int endX, int endY, Player player) { |
|
|
|
|
|
|
|
|
if ((player == PLAYER_WHITE) && (endY == 7) && (Brett[startY][startX] == 'P')) { |
|
|
if ((player == PLAYER_WHITE) && (endY == 7) && (Brett[startY][startX] == 'P')) { |
|
|
return true; |
|
|
return true; |
|
|
} else if ((player == PLAYER_BLACK) && (endY == 0) && (Brett[startY][startX] == 'p')) { |
|
|
} else if ((player == PLAYER_BLACK) && (endY == 0) && (Brett[startY][startX] == 'p')) { |
|
@ -15,19 +14,18 @@ bool ist_umwandlung_gerlaubt_Bauer(char** Brett, int startX, int startY, int end |
|
|
} else { |
|
|
} else { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int endY, Player player){ |
|
|
char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int endY, Player player){ |
|
|
|
|
|
|
|
|
if(ist_umwandlung_gerlaubt_Bauer(Brett ,startX,startY,endX,endY,player) == true){ |
|
|
if(ist_umwandlung_gerlaubt_Bauer(Brett ,startX,startY,endX,endY,player) == true){ |
|
|
char* Figur; |
|
|
char* Figur; |
|
|
printf("Welche Figur soll erstellt werden?"); |
|
|
|
|
|
|
|
|
printf("Which piece would you like to create?"); |
|
|
if(player == PLAYER_WHITE){ |
|
|
if(player == PLAYER_WHITE){ |
|
|
printf("Q für Dame, R für Turm, B für Läufer oder N für Springer"); |
|
|
|
|
|
|
|
|
printf("Q for Queen, R for Rook, B for Bishop, or N for Knight"); |
|
|
Figur = getUserInput(); |
|
|
Figur = getUserInput(); |
|
|
}else{ |
|
|
}else{ |
|
|
printf("q für Dame, r für Turm, b für Läufer oder n für Springer"); |
|
|
|
|
|
|
|
|
printf("q for Queen, r for Rook, b for Bishop, or n for Knight"); |
|
|
Figur = getUserInput(); |
|
|
Figur = getUserInput(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -35,20 +33,18 @@ char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int |
|
|
(player == PLAYER_BLACK && (Figur == 'q' || Figur == 'r' || Figur == 'b' || Figur == 'n'))) { |
|
|
(player == PLAYER_BLACK && (Figur == 'q' || Figur == 'r' || Figur == 'b' || Figur == 'n'))) { |
|
|
return Figur; |
|
|
return Figur; |
|
|
} else { |
|
|
} else { |
|
|
return 'W'; |
|
|
|
|
|
|
|
|
return 'W'; // Undefiniertes Zeichen als Fehlerwert |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 'W'; // Undefiniertes Zeichen als Fehlerwert |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void bauer_umwandeln(char** Brett, int startX, int startY, int endX, int endY, Player player) { |
|
|
void bauer_umwandeln(char** Brett, int startX, int startY, int endX, int endY, Player player) { |
|
|
|
|
|
|
|
|
char* Figur = bauer_umwandel_abfrage(Brett,startX,startY,endX,endY,player); |
|
|
|
|
|
|
|
|
char Figur = bauer_umwandel_abfrage(Brett, startX, startY, endX, endY, player); |
|
|
if (Figur != 'W') { |
|
|
if (Figur != 'W') { |
|
|
Brett[endY][endX] = Figur; |
|
|
Brett[endY][endX] = Figur; |
|
|
Brett[startY][startX] = ' '; |
|
|
Brett[startY][startX] = ' '; |
|
|
}else{ |
|
|
}else{ |
|
|
printf("Zug ungültig"); |
|
|
|
|
|
|
|
|
printf("Invalid move"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|