Browse Source
Merge branch 'Luis-Branch' into 'main'
Merge branch 'Luis-Branch' into 'main'
En Passaut See merge request fdai7834/taktikmeister!8remotes/origin/Läufer-fertig,-Hendrik-Voß
fdai7834
11 months ago
6 changed files with 186 additions and 0 deletions
-
33src/En_Passaut.c
-
10src/En_Passaut.h
-
8src/Schachbrett.c
-
1src/Schachbrett.h
-
113test/test_En_Passaut.c
-
21test/test_Schachbrett.c
@ -0,0 +1,33 @@ |
|||||
|
#include <stdio.h> |
||||
|
#include <stdlib.h> |
||||
|
#include <stdbool.h> |
||||
|
#include "spieler.h" |
||||
|
#include "Moving.h" |
||||
|
#include "Bauer.h" |
||||
|
#include "Historie.h" |
||||
|
|
||||
|
bool ist_En_Passaut_erlaubt_Bauer(char** Brett, int startX, int startY, int endX, int endY, Player player |
||||
|
,int anzahl_Zuege, int** Historie) { |
||||
|
|
||||
|
char letzteFigur = Brett[Historie[anzahl_Zuege-1][3]][Historie[anzahl_Zuege-1][2]]; |
||||
|
|
||||
|
if(((startX + 1 == Historie[anzahl_Zuege-1][0])||(startX - 1 == Historie[anzahl_Zuege-1][0])) |
||||
|
&& ((endX == startX + 1) || (endX == startX - 1))){ |
||||
|
printf("Kein Fehler nach X-Verschiebung"); |
||||
|
|
||||
|
if((letzteFigur == 'p') && (player == PLAYER_WHITE) && |
||||
|
(Historie[anzahl_Zuege-1][3] == 4) && (Historie[anzahl_Zuege-1][1] == 6)){ |
||||
|
|
||||
|
return true; |
||||
|
}else if ((letzteFigur == 'P') && (player == PLAYER_BLACK) && |
||||
|
(Historie[anzahl_Zuege-1][3] == 3) && (Historie[anzahl_Zuege-1][1] == 1)){ |
||||
|
|
||||
|
return true; |
||||
|
}else{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,10 @@ |
|||||
|
#ifndef BAUER_EP_H |
||||
|
#define BAUER_EP_H |
||||
|
|
||||
|
#include <stdbool.h> |
||||
|
#include "spieler.h" |
||||
|
|
||||
|
bool ist_En_Passaut_erlaubt_Bauer(char** Brett, int startX, int startY, int endX, int endY, Player player, int anzahl_Zuege, int** Historie); |
||||
|
|
||||
|
|
||||
|
#endif // BAUER_EP_H |
@ -0,0 +1,113 @@ |
|||||
|
#ifdef TEST |
||||
|
#include "unity.h" |
||||
|
#include <stdlib.h> |
||||
|
#include "Schachbrett.h" |
||||
|
#include "Historie.h" |
||||
|
#include "En_Passaut.h" |
||||
|
#include "Bauer.h" |
||||
|
#include "Spieler.h" |
||||
|
|
||||
|
void setUp(void) { |
||||
|
} |
||||
|
|
||||
|
void tearDown(void) { |
||||
|
} |
||||
|
|
||||
|
void test_En_Passaut_Weiss(void) { |
||||
|
|
||||
|
int MAX_ZUEGE = 70; |
||||
|
int ZUG_INFO = 5; |
||||
|
|
||||
|
// Historie erstellen |
||||
|
int** meineHistorie = erstellen_historie(); |
||||
|
|
||||
|
// Testdaten |
||||
|
int startX = 1; |
||||
|
int startY = 6; |
||||
|
int endX = 1; |
||||
|
int endY = 4; |
||||
|
Player currentPlayer = PLAYER_BLACK; |
||||
|
int anzahl_Zuege = 0; |
||||
|
|
||||
|
// Züge zur Historie hinzufügen |
||||
|
hinzufuegen_historie(meineHistorie, startX, startY, endX, endY, currentPlayer, anzahl_Zuege); |
||||
|
|
||||
|
char** brett = Schachbrett_erstellen(); |
||||
|
clear_Schachbrett(brett); |
||||
|
|
||||
|
TEST_ASSERT_NOT_NULL(brett); |
||||
|
|
||||
|
brett[endY][endX] = 'p'; |
||||
|
anzahl_Zuege++; |
||||
|
startX = 2; |
||||
|
startY = 4; |
||||
|
endX = 1; |
||||
|
endY = 5; |
||||
|
currentPlayer = PLAYER_WHITE; |
||||
|
|
||||
|
|
||||
|
TEST_ASSERT_TRUE(ist_En_Passaut_erlaubt_Bauer(brett,startX,startY,endX,endY,currentPlayer,anzahl_Zuege,meineHistorie)); |
||||
|
|
||||
|
|
||||
|
for (int i = 0; i < 8; i++) { |
||||
|
free(brett[i]); |
||||
|
} |
||||
|
free(brett); |
||||
|
|
||||
|
// Speicher freigeben |
||||
|
for (int i = 0; i < MAX_ZUEGE; i++) { |
||||
|
free(meineHistorie[i]); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_En_Passaut_Schwarz(void) { |
||||
|
|
||||
|
int MAX_ZUEGE = 70; |
||||
|
int ZUG_INFO = 5; |
||||
|
|
||||
|
// Historie erstellen |
||||
|
int** meineHistorie = erstellen_historie(); |
||||
|
|
||||
|
// Testdaten |
||||
|
int startX = 1; |
||||
|
int startY = 1; |
||||
|
int endX = 1; |
||||
|
int endY = 3; |
||||
|
Player currentPlayer = PLAYER_WHITE; |
||||
|
int anzahl_Zuege = 0; |
||||
|
|
||||
|
// Züge zur Historie hinzufügen |
||||
|
hinzufuegen_historie(meineHistorie, startX, startY, endX, endY, currentPlayer, anzahl_Zuege); |
||||
|
|
||||
|
char** brett = Schachbrett_erstellen(); |
||||
|
clear_Schachbrett(brett); |
||||
|
|
||||
|
TEST_ASSERT_NOT_NULL(brett); |
||||
|
|
||||
|
brett[endY][endX] = 'P'; |
||||
|
anzahl_Zuege++; |
||||
|
startX = 2; |
||||
|
startY = 3; |
||||
|
endX = 1; |
||||
|
endY = 2; |
||||
|
currentPlayer = PLAYER_BLACK; |
||||
|
|
||||
|
|
||||
|
TEST_ASSERT_TRUE(ist_En_Passaut_erlaubt_Bauer(brett,startX,startY,endX,endY,currentPlayer,anzahl_Zuege,meineHistorie)); |
||||
|
|
||||
|
|
||||
|
for (int i = 0; i < 8; i++) { |
||||
|
free(brett[i]); |
||||
|
} |
||||
|
free(brett); |
||||
|
|
||||
|
// Speicher freigeben |
||||
|
for (int i = 0; i < MAX_ZUEGE; i++) { |
||||
|
free(meineHistorie[i]); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue