From aae56ac089aa71c54c59d0f3ac70d74bed6df97c Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 18:38:12 +0100 Subject: [PATCH] =?UTF-8?q?hinzuf=C3=BCgen=20der=20abfrage=20f=C3=BCr=20Ba?= =?UTF-8?q?uernumwandlung,=20Luis=20Hahn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Bauernumwandlung.c | 9 ++++++++- src/Bauernumwandlung.h | 2 +- test/test_Bauernumwandlung.c | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/test_Bauernumwandlung.c diff --git a/src/Bauernumwandlung.c b/src/Bauernumwandlung.c index f232c77..8bb0ecb 100644 --- a/src/Bauernumwandlung.c +++ b/src/Bauernumwandlung.c @@ -7,6 +7,13 @@ 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')){ + return true; + }else{ + return false; + } } @@ -15,6 +22,6 @@ char bauer_umwandel_abfrage(){ } void bauer_umwandeln(){ - + } diff --git a/src/Bauernumwandlung.h b/src/Bauernumwandlung.h index 70dc060..ac2048f 100644 --- a/src/Bauernumwandlung.h +++ b/src/Bauernumwandlung.h @@ -4,7 +4,7 @@ #include #include "spieler.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); char bauer_umwandel_abfrage(); void bauer_umwandeln(); diff --git a/test/test_Bauernumwandlung.c b/test/test_Bauernumwandlung.c new file mode 100644 index 0000000..159ab83 --- /dev/null +++ b/test/test_Bauernumwandlung.c @@ -0,0 +1,37 @@ +#ifdef TEST +#include "unity.h" +#include +#include "Schachbrett.h" +#include "Bauer.h" +#include "Bauernumwandlung.h" + +void setUp(void) { +} + +void tearDown(void) { +} + +void test_Bauernumwandlung_erlaubt(void) { + + char** brett = Schachbrett_erstellen(); + int startX = 6; + int startY = 6; + int endX = 6; + int endY = 7; + Player player = PLAYER_WHITE; + + + TEST_ASSERT_NOT_NULL(brett); + + brett[6][6] = 'P'; + brett[7][6] = ' '; + + TEST_ASSERT_TRUE(ist_umwandlung_gerlaubt_Bauer( brett, startX, startY, endX, endY, player)); + + + for (int i = 0; i < 8; i++) { + free(brett[i]); + } + free(brett); +} +#endif // TEST