From 25e6cc69a0f25d3ccba43ff25079ea30eefa7a4f Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 13:22:31 +0100 Subject: [PATCH 1/5] Turm else eingebaut, Luis Hahn --- src/Turm.c | 2 ++ test/test_Turm.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/Turm.c b/src/Turm.c index 04991cd..c12a07c 100644 --- a/src/Turm.c +++ b/src/Turm.c @@ -48,6 +48,8 @@ int counter = 0; return true; } + }else{ + return false; } diff --git a/test/test_Turm.c b/test/test_Turm.c index be5226b..a28de2a 100644 --- a/test/test_Turm.c +++ b/test/test_Turm.c @@ -38,6 +38,8 @@ void test_Turm_Y_Bewegung(void) { free(brett); } + + void test_Turm_X_Bewegung(void) { char** brett = Schachbrett_erstellen(); @@ -88,6 +90,31 @@ void test_Turm_negative_Y_Bewegung(void) { free(brett); } +void test_Turm_Falsche_Bewegung(void) { + + char** brett = Schachbrett_erstellen(); + int startX = 0; + int startY = 0; + int endX = 1; + int endY = 3; + Player player = PLAYER_WHITE; + + + TEST_ASSERT_NOT_NULL(brett); + + + print_Schachfeld(brett); + + + TEST_ASSERT_FALSE(istzugerlaubt_Turm( brett, startX, startY, endX, endY, player)); + + + for (int i = 0; i < 8; i++) { + free(brett[i]); + } + free(brett); +} + #endif // TEST From dbc2290d2571f1cde1d70368d7079e240622e4fa Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 13:27:35 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=C3=9Cberarbeitung=20der=20Print=5FSchachfe?= =?UTF-8?q?ld=20funktion,=20Luis=20Hahn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Schachbrett.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Schachbrett.c b/src/Schachbrett.c index a707b25..96f770e 100644 --- a/src/Schachbrett.c +++ b/src/Schachbrett.c @@ -47,12 +47,18 @@ char** Schachbrett_erstellen() { } void print_Schachfeld(char** Brett) { + int counter = 1; + printf(" - 1 2 3 4 5 6 7 8 \n"); for (int i = 0; i < 8; i++) { + printf(" %d " , counter); + counter++; for (int j = 0; j < 8; j++) { printf(" %c ", Brett[i][j]); } printf("\n"); } + printf("\n"); + printf("\n"); } void Schachbrettspeicher_freigeben(char** Brett) { From a1d79fd563975ab71a83436bdc924b22db9ebc69 Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 13:35:12 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20Verbindung=20zwisch?= =?UTF-8?q?en=20Turm=20und=20Moving,=20Luis=20Hahn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Moving.c | 2 ++ test/test_Moving.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Moving.c b/src/Moving.c index 848f037..d39fbe5 100644 --- a/src/Moving.c +++ b/src/Moving.c @@ -3,6 +3,7 @@ #include #include "spieler.h" #include "Bauer.h" +#include "Turm.h" bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Player player) { @@ -25,6 +26,7 @@ bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Pla switch (Brett[startY][startX]) { case 'R': //Datei von Turm aufrufen + return (istzugerlaubt_Turm(Brett, startX,startY,endX,endY,player)); break; case 'N': //Datei von Springer aufrufen diff --git a/test/test_Moving.c b/test/test_Moving.c index fdf9a48..c0153a9 100644 --- a/test/test_Moving.c +++ b/test/test_Moving.c @@ -3,6 +3,7 @@ #include "Schachbrett.h" #include "Moving.h" #include "Spieler.h" +#include "Turm.h" #include void setUp(void) { @@ -56,4 +57,29 @@ void test_istzugerlaubt(void){ } +void test_istzugerlaubt_Turm(void){ + + char** brett = Schachbrett_erstellen(); + int startX = 0; + int startY = 4; + int endX = 0; + int endY = 2; + Player player = PLAYER_WHITE; + + + TEST_ASSERT_NOT_NULL(brett); + + brett[4][0] = 'r'; + print_Schachfeld(brett); + + + TEST_ASSERT_TRUE(istzugerlaubt(brett, startX, startY, endX, endY, player)); + + + for (int i = 0; i < 8; i++) { + free(brett[i]); + } + free(brett); +} + #endif // TEST From fce07f4c981f08b4764ce5352623178cf113efae Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 13:38:28 +0100 Subject: [PATCH 4/5] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20Verbindung=20zwisch?= =?UTF-8?q?en=20Bauer=20und=20Moving,=20Luis=20Hahn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Moving.c | 8 +++----- test/test_Moving.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/Moving.c b/src/Moving.c index d39fbe5..fd89ebb 100644 --- a/src/Moving.c +++ b/src/Moving.c @@ -41,11 +41,8 @@ bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Pla //Datei von König aufrufen break; case 'P': - /* if(istzugerlaubt_Bauer(Brett,startX,startY,endX,endY,player) == true){ - return true; - }else{ - return false; - }*/ + //Datei von Bauer aufrufen + return (istzugerlaubt_Bauer(Brett, startX,startY,endX,endY,player)); break; default: break; @@ -55,6 +52,7 @@ bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Pla switch (Brett[startY][startX]) { case 'r': //Datei von Turm aufrufen + return (istzugerlaubt_Turm(Brett, startX,startY,endX,endY,player)); break; case 'n': //Datei von Springer aufrufen diff --git a/test/test_Moving.c b/test/test_Moving.c index c0153a9..26f457f 100644 --- a/test/test_Moving.c +++ b/test/test_Moving.c @@ -4,6 +4,7 @@ #include "Moving.h" #include "Spieler.h" #include "Turm.h" +#include "Bauer.h" #include void setUp(void) { @@ -37,6 +38,28 @@ void test_Bauern_bewegen(void) { free(brett); } +void test_Bauer_Y_Verknuepfung_Bewegung(void) { + + char** brett = Schachbrett_erstellen(); + int startX = 1; + int startY = 1; + int endX = 1; + int endY = 2; + Player player = PLAYER_WHITE; + + + TEST_ASSERT_NOT_NULL(brett); + + + TEST_ASSERT_TRUE(istzugerlaubt( brett, startX, startY, endX, endY, player)); + + + for (int i = 0; i < 8; i++) { + free(brett[i]); + } + free(brett); +} + void test_istzugerlaubt(void){ char** brett = Schachbrett_erstellen(); int startX = 1; From 1d10b7d27122fe34f2e216f8cfa62bbb37be603c Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 13:44:10 +0100 Subject: [PATCH 5/5] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20Verbindung=20zwisch?= =?UTF-8?q?en=20Springer=20und=20Moving,=20Luis=20Hahn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Moving.c | 3 +++ test/test_Moving.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Moving.c b/src/Moving.c index fd89ebb..01cddcc 100644 --- a/src/Moving.c +++ b/src/Moving.c @@ -4,6 +4,7 @@ #include "spieler.h" #include "Bauer.h" #include "Turm.h" +#include "Springer.h" bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Player player) { @@ -30,6 +31,7 @@ bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Pla break; case 'N': //Datei von Springer aufrufen + return (istzugerlaubt_Springer(Brett, startX,startY,endX,endY,player)); break; case 'B': //Datei von Läufer aufrufen @@ -68,6 +70,7 @@ bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Pla break; case 'p': //Datei von Bauer aufrufen + return (istzugerlaubt_Bauer(Brett, startX,startY,endX,endY,player)); break; default: break; diff --git a/test/test_Moving.c b/test/test_Moving.c index 26f457f..5d2dbc1 100644 --- a/test/test_Moving.c +++ b/test/test_Moving.c @@ -5,6 +5,7 @@ #include "Spieler.h" #include "Turm.h" #include "Bauer.h" +#include "Springer.h" #include void setUp(void) { @@ -60,6 +61,18 @@ void test_Bauer_Y_Verknuepfung_Bewegung(void) { free(brett); } +void test_istzugerlaubt_Springer_Verknuepfung(void) { + char **Brett = Schachbrett_erstellen(); + + // Viele Test um legale Züge zu prüfen + TEST_ASSERT_TRUE(istzugerlaubt(Brett, 1, 0, 0, 2, PLAYER_WHITE)); + + TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 3, 6, 2, PLAYER_BLACK)); + + + Schachbrettspeicher_freigeben(Brett); +} + void test_istzugerlaubt(void){ char** brett = Schachbrett_erstellen(); int startX = 1;