fdai7723
11 months ago
1 changed files with 29 additions and 33 deletions
@ -1,54 +1,50 @@ |
|||||
#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')){ |
|
||||
return true; |
|
||||
}else{ |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
|
} else if ((player == PLAYER_BLACK) && (endY == 0) && (Brett[startY][startX] == 'p')) { |
||||
|
return true; |
||||
|
} else { |
||||
|
return false; |
||||
|
} |
||||
} |
} |
||||
|
|
||||
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){ |
|
||||
char* Figur; |
|
||||
printf("Welche Figur soll erstellt werden?"); |
|
||||
if(player == PLAYER_WHITE){ |
|
||||
printf("Q für Dame, R für Turm, B für Läufer oder N für Springer"); |
|
||||
Figur = getUserInput(); |
|
||||
}else{ |
|
||||
printf("q für Dame, r für Turm, b für Läufer oder n für Springer"); |
|
||||
Figur = getUserInput(); |
|
||||
|
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)) { |
||||
|
char Figur; |
||||
|
printf("Welche Figur soll erstellt werden?\n"); |
||||
|
if (player == PLAYER_WHITE) { |
||||
|
printf("Q für Dame, R für Turm, B für Läufer oder N für Springer\n"); |
||||
|
} else { |
||||
|
printf("q für Dame, r für Turm, b für Läufer oder n für Springer\n"); |
||||
} |
} |
||||
|
Figur = getchar(); // Holen Sie das Zeichen von der Eingabe |
||||
|
// Leeren Sie den Eingabepuffer, um unerwünschte Zeichen zu entfernen |
||||
|
while (getchar() != '\n'); |
||||
|
|
||||
if((player == PLAYER_WHITE && (Figur == 'Q' || Figur == 'R' || Figur == 'B' || Figur == 'N')) || |
|
||||
(player == PLAYER_BLACK && (Figur == 'q' || Figur == 'r' || Figur == 'b' || Figur == 'n'))){ |
|
||||
|
if ((player == PLAYER_WHITE && (Figur == 'Q' || Figur == 'R' || Figur == 'B' || Figur == 'N')) || |
||||
|
(player == PLAYER_BLACK && (Figur == 'q' || Figur == 'r' || Figur == 'b' || Figur == 'n'))) { |
||||
return Figur; |
return Figur; |
||||
}else{ |
|
||||
return 'W'; |
|
||||
|
} else { |
||||
|
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){ |
|
||||
|
|
||||
char* Figur = bauer_umwandel_abfrage(Brett,startX,startY,endX,endY,player); |
|
||||
if(Figur != 'W'){ |
|
||||
|
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); |
||||
|
if (Figur != 'W') { |
||||
Brett[endY][endX] = Figur; |
Brett[endY][endX] = Figur; |
||||
Brett[startY][startX] = ' '; |
Brett[startY][startX] = ' '; |
||||
}else{ |
|
||||
printf("Zug ungültig"); |
|
||||
|
} else { |
||||
|
printf("Zug ungültig\n"); |
||||
} |
} |
||||
} |
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue