Browse Source

Merge branch 'main' of gitlab.cs.hs-fulda.de:fdai7834/taktikmeister

remotes/origin/Spracharbeit
Luis Hahn 11 months ago
parent
commit
e713a70629
  1. 12
      src/Bauernumwandlung.c
  2. 12
      src/schach_in_ein_puzzle/PuzzleI.c
  3. 1
      src/schach_in_ein_puzzle/PuzzleI.h

12
src/Bauernumwandlung.c

@ -1,13 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "spieler.h"
#include "Moving.h"
#include "Bauer.h"
#include "Input.h"
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')) {
return true;
} else if ((player == PLAYER_BLACK) && (endY == 0) && (Brett[startY][startX] == 'p')) {
@ -15,7 +14,6 @@ bool ist_umwandlung_gerlaubt_Bauer(char** Brett, int startX, int startY, int end
} else {
return false;
}
}
char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int endY, Player player){
@ -35,15 +33,14 @@ char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int
(player == PLAYER_BLACK && (Figur == 'q' || Figur == 'r' || Figur == 'b' || Figur == 'n'))) {
return Figur;
} 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) {
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') {
Brett[endY][endX] = Figur;
Brett[startY][startX] = ' ';
@ -51,4 +48,3 @@ void bauer_umwandeln(char** Brett, int startX, int startY, int endX, int endY, P
printf("Invalid move");
}
}

12
src/schach_in_ein_puzzle/PuzzleI.c

@ -60,3 +60,15 @@ void print_Puzzlebrett(char** Brett) {
}
printf("\n");
}
void Puzzlebrettspeicher_freigeben(char** Brett) {
if (Brett == NULL) {
return;
}
for (int i = 0; i < 8; i++) {
free(Brett[i]);
}
free(Brett);
}

1
src/schach_in_ein_puzzle/PuzzleI.h

@ -5,5 +5,6 @@
char** Puzzlebrett_erstellen();
void print_Puzzlebrett(char** Brett);
void Puzzlebrettspeicher_freigeben(char** Brett);
#endif // PUZZLEI_H
Loading…
Cancel
Save