From 361cd9469247825c3d26e1a2c7919ae5de5d7d6f Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 19:27:35 +0100 Subject: [PATCH] Basic abfrage von En Passaut, Luis Hahn --- src/En_Passaut.c | 12 ++++++++++-- src/En_Passaut.h | 2 +- test/test_En_Passaut.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 test/test_En_Passaut.c diff --git a/src/En_Passaut.c b/src/En_Passaut.c index 7f9c571..9018d74 100644 --- a/src/En_Passaut.c +++ b/src/En_Passaut.c @@ -4,10 +4,18 @@ #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) { - +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(letzteFigur == 'p'){ + return true; + }else{ + return false; + } } diff --git a/src/En_Passaut.h b/src/En_Passaut.h index 382efa8..64da831 100644 --- a/src/En_Passaut.h +++ b/src/En_Passaut.h @@ -4,7 +4,7 @@ #include #include "spieler.h" -bool ist_En_Passaut_erlaubt_Bauer(char** Brett, int startX, int startY, int endX, int endY, Player player); +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 diff --git a/test/test_En_Passaut.c b/test/test_En_Passaut.c new file mode 100644 index 0000000..e623eb6 --- /dev/null +++ b/test/test_En_Passaut.c @@ -0,0 +1,44 @@ +#ifdef TEST +#include "unity.h" +#include +#include "Schachbrett.h" +#include "Historie.h" +#include "En_Passaut.h" +#include "Bauer.h" + +void setUp(void) { +} + +void tearDown(void) { +} + +void test_En_Passaut_Weiss(void) { + + /* void test_hinzufuegen_historie(void) { + int MAX_ZUEGE = 70; + int ZUG_INFO = 5; + + // Historie erstellen + int** meineHistorie = erstellen_historie(); + + // Testdaten + int startX = 1; + int startY = 2; + int endX = 3; + int endY = 4; + Player currentPlayer = PLAYER_WHITE; + int anzahl_Zuege = 0; + + // Züge zur Historie hinzufügen + hinzufuegen_historie(meineHistorie, startX, startY, endX, endY, currentPlayer, anzahl_Zuege); + + + // Speicher freigeben + for (int i = 0; i < MAX_ZUEGE; i++) { + free(meineHistorie[i]); + } + +} +*/ +} +#endif // TEST