From dbde6ebd43ec6aeb4d3abe935121ac8d4bcd5f96 Mon Sep 17 00:00:00 2001 From: fdai7731 Date: Fri, 2 Feb 2024 15:33:49 +0000 Subject: [PATCH 001/160] Update team.md --- team.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/team.md b/team.md index d2652c3..76bf093 100644 --- a/team.md +++ b/team.md @@ -3,4 +3,5 @@ Peter Wiebe, fdai7773 Simon Hildebrandt, fdai7864 Lucas Heil, fdai7356 Celine Khazarian, fdai7781 -Ahmad Thaljeh, fdai7726 \ No newline at end of file +Ahmad Thaljeh, fdai7726 +Yasin Al Satouf, fdai7731 From bf139ce197b80679afc141797340a3bf67646c42 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 17:59:40 +0100 Subject: [PATCH 002/160] Commit 1 - Bibliotheken --- src/main/c/hangman.c | 6 ++++++ src/main/c/hangman.txt | 1 + src/main/c/hangman_words.txt | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/main/c/hangman.c create mode 100644 src/main/c/hangman.txt create mode 100644 src/main/c/hangman_words.txt diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c new file mode 100644 index 0000000..e2f3360 --- /dev/null +++ b/src/main/c/hangman.c @@ -0,0 +1,6 @@ +#include +#include +#include +#include +#include +#include \ No newline at end of file diff --git a/src/main/c/hangman.txt b/src/main/c/hangman.txt new file mode 100644 index 0000000..4456b2e --- /dev/null +++ b/src/main/c/hangman.txt @@ -0,0 +1 @@ +name:peter,level:01 \ No newline at end of file diff --git a/src/main/c/hangman_words.txt b/src/main/c/hangman_words.txt new file mode 100644 index 0000000..0720bb4 --- /dev/null +++ b/src/main/c/hangman_words.txt @@ -0,0 +1,20 @@ +fulda +galgenmann +programmiermethoden +test +peter +ahmad +joe +celine +sigi +jonas +mitochondrien +aufmerksamkeitsdefizithyperaktivitaetsstoerung +donaudampfschifffahrtelekrizitaetenhauptbetriebswerkbauunternehmenbeamtengesellschaft +malaysia +lucas +yasin +samuel +celli +hochschule +fulda \ No newline at end of file From 0f601c53bdb1f7db864b049a98e06e6b58bf964f Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:00:46 +0100 Subject: [PATCH 003/160] =?UTF-8?q?Commit=202=20-=20func=20Protokoll=20hin?= =?UTF-8?q?zuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index e2f3360..7bcb8a3 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -3,4 +3,8 @@ #include #include #include -#include \ No newline at end of file +#include + +void protokoll(); + +void protokoll(){} \ No newline at end of file From bde4a9ddd58c970c37b037a893000956fea155ec Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:01:27 +0100 Subject: [PATCH 004/160] =?UTF-8?q?Commit=203=20-=20func=20clearscreen=20h?= =?UTF-8?q?inzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 7bcb8a3..f04044a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -6,5 +6,14 @@ #include void protokoll(); +void clear_screen(); -void protokoll(){} \ No newline at end of file +void protokoll(){ + clear_screen(); +} + +void clear_screen() { + system("clear"); + // system("cls"); // fuer Windows + // system("clear"); // fuer UNIX/Linux +} \ No newline at end of file From 5f115df6847ac96cd437d9084a74f420eb25241b Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:02:06 +0100 Subject: [PATCH 005/160] =?UTF-8?q?Commit=204=20-=20func=20willkomen=20hin?= =?UTF-8?q?zuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f04044a..932b123 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -7,13 +7,19 @@ void protokoll(); void clear_screen(); +void willkommen(); void protokoll(){ clear_screen(); + willkommen(); } void clear_screen() { system("clear"); // system("cls"); // fuer Windows // system("clear"); // fuer UNIX/Linux +} + +void willkommen(){ + //Druecke Enter zun fortfahren } \ No newline at end of file From 9d644608cdc208bdf6dc673ef42710e22a823bc7 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:02:51 +0100 Subject: [PATCH 006/160] Commit 5 - func willkommen funktion einbauen --- src/main/c/hangman.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 932b123..11ab69d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -21,5 +21,8 @@ void clear_screen() { } void willkommen(){ - //Druecke Enter zun fortfahren + char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; + + printf("%s", ENTERtxt); + getchar(); } \ No newline at end of file From dd520029451a273a673366f951a48113a6a3df9c Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:05:36 +0100 Subject: [PATCH 007/160] =?UTF-8?q?Commit=206=20-=20func=20namepruefen=20e?= =?UTF-8?q?inf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 11ab69d..b013cca 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -8,10 +8,12 @@ void protokoll(); void clear_screen(); void willkommen(); +int namePruefen(); void protokoll(){ clear_screen(); willkommen(); + namePruefen(); } void clear_screen() { @@ -25,4 +27,32 @@ void willkommen(){ printf("%s", ENTERtxt); getchar(); +} + +int namePruefen() { + char KonfDatei[100]; + int laengeKonfDatei = 0; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + if (fp == NULL) { + printf("Fehler beim Öffnen der Konfigurationsdatei\n"); + return 1; + } else { + fscanf(fp, "%s", KonfDatei); //Inhalt der KonfDatei wird ins Array gelesen + + while(KonfDatei[laengeKonfDatei] != 0){ //Laenge der KonfDatei wird ermittelt + laengeKonfDatei++; + } + + if(laengeKonfDatei > 14){ //mit der Laenge wird geschaut, ob ein Name gespeichert ist oder nicht + fclose(fp); + return 0; + } else { + fclose(fp); + return 0; + } + } + fclose(fp); } \ No newline at end of file From adf66c53137f92c28a0ec7284b40ab4a619d171d Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:06:39 +0100 Subject: [PATCH 008/160] =?UTF-8?q?Commit=207=20-=20func=20namewahelen=20h?= =?UTF-8?q?inzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index b013cca..1263218 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -9,6 +9,7 @@ void protokoll(); void clear_screen(); void willkommen(); int namePruefen(); +void nameWaehlen(); void protokoll(){ clear_screen(); @@ -55,4 +56,23 @@ int namePruefen() { } } fclose(fp); +} + +void nameWaehlen(){ + char name[50]; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "w"); + + clear_screen(); // + printf("Geben Sie den Namen ein: "); + scanf("%s", name); + + char KonfDatei[100]; + snprintf(KonfDatei, sizeof(KonfDatei), "name:%s,level:01", name); + + fprintf(fp, "%s", KonfDatei); + fclose(fp); + + startauswahl(); } \ No newline at end of file From a1603172fefda69d14d2a77627f843e571a66e54 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:07:51 +0100 Subject: [PATCH 009/160] Commit 8 - namewaehlen einbinden --- src/main/c/hangman.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 1263218..fe020bf 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -26,6 +26,7 @@ void clear_screen() { void willkommen(){ char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; + printf("%s", ENTERtxt); getchar(); } @@ -51,6 +52,8 @@ int namePruefen() { fclose(fp); return 0; } else { + printf("Sieht aus, als haettest du noch keinen Namen :(\n"); + nameWaehlen(); fclose(fp); return 0; } @@ -65,6 +68,7 @@ void nameWaehlen(){ fp = fopen("hangman.txt", "w"); clear_screen(); // + printf("Geben Sie den Namen ein: "); scanf("%s", name); @@ -73,6 +77,4 @@ void nameWaehlen(){ fprintf(fp, "%s", KonfDatei); fclose(fp); - - startauswahl(); } \ No newline at end of file From 8308d24c85ce1d524584c87f86a465f7621b70b0 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:08:33 +0100 Subject: [PATCH 010/160] =?UTF-8?q?Commit=209=20-=20func=20startauswahl=20?= =?UTF-8?q?hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index fe020bf..f17a135 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -10,11 +10,13 @@ void clear_screen(); void willkommen(); int namePruefen(); void nameWaehlen(); +void startauswahl(); void protokoll(){ clear_screen(); willkommen(); namePruefen(); + startauswahl(); } void clear_screen() { @@ -77,4 +79,9 @@ void nameWaehlen(){ fprintf(fp, "%s", KonfDatei); fclose(fp); +} + +void startauswahl() { + printf("Willkommen "); + printf("[1] Spielen\n[2] Namen aendern\n"); } \ No newline at end of file From 8b45bc51ecefd0c079c7d44ff784f614f4e28ede Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:09:07 +0100 Subject: [PATCH 011/160] Commit 10 - Func startauswahl funktion einbauen --- src/main/c/hangman.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f17a135..61763f7 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -82,6 +82,20 @@ void nameWaehlen(){ } void startauswahl() { + int auswahl; + int modus; + + clear_screen(); // + printf("Willkommen "); printf("[1] Spielen\n[2] Namen aendern\n"); + scanf("%d", &auswahl); + + if(auswahl == 1){ + //levelauswahl + } else if (auswahl == 2){ + nameWaehlen(); + } else { + printf("Eingabe ungueltig"); + } } \ No newline at end of file From e2eb6bcab96d9c53335a25bfab2cc70aab7293b7 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:09:52 +0100 Subject: [PATCH 012/160] =?UTF-8?q?Commit=2011=20-=20func=20nameausgeben?= =?UTF-8?q?=20f=C3=BCr=20func=20startauswahl=20einbauen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 61763f7..f89cc80 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -11,6 +11,7 @@ void willkommen(); int namePruefen(); void nameWaehlen(); void startauswahl(); +void nameAusgeben(); void protokoll(){ clear_screen(); @@ -98,4 +99,35 @@ void startauswahl() { } else { printf("Eingabe ungueltig"); } +} + +void nameAusgeben(){ + char KonfDatei[100]; + char name[50]; + int i = 5; + int zaehler = 0; + int nullt; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + fscanf(fp, "%s", KonfDatei); + while(KonfDatei[i] != ','){ + zaehler++; + i++; + } + nullt = zaehler; + while(zaehler != 0){ + name[--zaehler] = KonfDatei[--i]; + } + + i = 0; + while(name[i] != 0){ + i++; + } + + name[nullt] = '\0'; + printf("%s\n", name); + + fclose(fp); } \ No newline at end of file From a7023651e87b803a87273fc88bd78e70a9149999 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:10:35 +0100 Subject: [PATCH 013/160] =?UTF-8?q?Commit=2012=20-=20func=20nameausgeben?= =?UTF-8?q?=20in=20func=20startauswahl=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f89cc80..64f828a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -89,6 +89,7 @@ void startauswahl() { clear_screen(); // printf("Willkommen "); + nameAusgeben(); printf("[1] Spielen\n[2] Namen aendern\n"); scanf("%d", &auswahl); From eaf67504f0a7f6542dd27f31fe6cf8d107f69a57 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:11:16 +0100 Subject: [PATCH 014/160] Commit 13 - func levelauswahl erstellen --- src/main/c/hangman.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 64f828a..c5f8452 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -12,6 +12,7 @@ int namePruefen(); void nameWaehlen(); void startauswahl(); void nameAusgeben(); +void levelauswahl(); void protokoll(){ clear_screen(); @@ -87,7 +88,7 @@ void startauswahl() { int modus; clear_screen(); // - + printf("Willkommen "); nameAusgeben(); printf("[1] Spielen\n[2] Namen aendern\n"); @@ -130,5 +131,30 @@ void nameAusgeben(){ name[nullt] = '\0'; printf("%s\n", name); + fclose(fp); +} + +void levelauswahl(){ + char levelstr[3]; + char KonfDatei[100]; + int level; + int i = 0; + + clear_screen(); // + + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r"); + + fscanf(fp, "%s", KonfDatei); + while(KonfDatei[i] != 0){ + i++; + } + levelstr[0] = KonfDatei[i-2]; + levelstr[1] = KonfDatei[i-1]; + levelstr[2] = '\0'; + level = atoi(levelstr); + //hauptspiel mit dem Level starten + fclose(fp); } \ No newline at end of file From cdb61e6e7b93011fc423d3baec9f853d939e82ef Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:21:14 +0100 Subject: [PATCH 015/160] =?UTF-8?q?Commit=2014=20-=20func=20levelauswahl?= =?UTF-8?q?=20in=20func=20startauswahl=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index c5f8452..6454af6 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -30,7 +30,7 @@ void clear_screen() { void willkommen(){ char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; - + printf("%s", ENTERtxt); getchar(); } @@ -72,7 +72,7 @@ void nameWaehlen(){ fp = fopen("hangman.txt", "w"); clear_screen(); // - + printf("Geben Sie den Namen ein: "); scanf("%s", name); @@ -95,7 +95,7 @@ void startauswahl() { scanf("%d", &auswahl); if(auswahl == 1){ - //levelauswahl + levelauswahl(); } else if (auswahl == 2){ nameWaehlen(); } else { @@ -155,6 +155,5 @@ void levelauswahl(){ levelstr[2] = '\0'; level = atoi(levelstr); //hauptspiel mit dem Level starten - fclose(fp); } \ No newline at end of file From 2a4b49f8a12ec8a907dc26c1e267980f3ce8e71c Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:21:58 +0100 Subject: [PATCH 016/160] Commit 15 - func hauptspiel erstellen --- src/main/c/hangman.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 6454af6..446fa7a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -13,6 +13,7 @@ void nameWaehlen(); void startauswahl(); void nameAusgeben(); void levelauswahl(); +void hauptSpiel(int level); void protokoll(){ clear_screen(); @@ -156,4 +157,21 @@ void levelauswahl(){ level = atoi(levelstr); //hauptspiel mit dem Level starten fclose(fp); +} + +void hauptSpiel(int level){ + char secret_word[100]; + int attempts = 0; + char guessed_letter; + char guessed_letters[100]; + char path[] = "hangman_words.txt"; + int result; + int won = 0; + //secret_word soll vergeben werden + //secret_word soll geladen werden + //path soll erstellt werden + //hangman soll gemalt werden + //Buchstaben sollen gezeigt werden + //Buchstaben sollen eingegeben werden können + //eingegeben Buchstaben sollen überprüft und dem Lösungswort hinzugefügt werden, damit Gewinn ermittelt werden kann } \ No newline at end of file From 2cb16c70024b9f2f1a30a13f46348e5f4ec9e031 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:23:00 +0100 Subject: [PATCH 017/160] =?UTF-8?q?Commit=2016=20-=20func=20hangman=20soll?= =?UTF-8?q?=20gezeichnet=20werden=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 446fa7a..847a301 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -14,6 +14,7 @@ void startauswahl(); void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); +void draw_hangman(int attempts); void protokoll(){ clear_screen(); @@ -174,4 +175,78 @@ void hauptSpiel(int level){ //Buchstaben sollen gezeigt werden //Buchstaben sollen eingegeben werden können //eingegeben Buchstaben sollen überprüft und dem Lösungswort hinzugefügt werden, damit Gewinn ermittelt werden kann +} + +void draw_hangman(int attempts) { + clear_screen(); + printf("Galgenmann!\n"); + printf("v.1.0.2\n\n"); + + switch(attempts) { + case 0: + printf(" _______\n"); + printf(" | |\n"); + printf(" |\n"); + printf(" |\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 1: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" |\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 2: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | |\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 3: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 4: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\\\n"); + printf(" |\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 5: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\\\n"); + printf(" | /\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + case 6: + printf(" _______\n"); + printf(" | |\n"); + printf(" | O\n"); + printf(" | /|\\\n"); + printf(" | / \\\n"); + printf(" |\n"); + printf("__|_________\n\n\n\n"); + break; + default: + break; + } } \ No newline at end of file From eef1885341c7fe5aa7fef2aa9999bed7098f6fb2 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:24:06 +0100 Subject: [PATCH 018/160] =?UTF-8?q?Commit=2017=20-=20jeder=20eingegebene?= =?UTF-8?q?=20Buchstabe=20soll=20dem=20Array=20aller=20eingegebenen=20Buch?= =?UTF-8?q?staben=20hinzugef=C3=BCgt=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 847a301..4a8045d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -15,6 +15,7 @@ void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); void draw_hangman(int attempts); +void add_guessed_letter(char* guessed_letters, char guessed_letter); void protokoll(){ clear_screen(); @@ -249,4 +250,12 @@ void draw_hangman(int attempts) { default: break; } +} + +void add_guessed_letter(char* guessed_letters, char guessed_letter){ + for (int i = 0; i < strlen(guessed_letters); i++){ + if (guessed_letters[i] == guessed_letter){ + return; + } + } } \ No newline at end of file From acff3629568741492c0ce4533fef963453f315e1 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:25:15 +0100 Subject: [PATCH 019/160] Commit 18 - Erweiterung der Funktion add_guessed_letter --- src/main/c/hangman.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 4a8045d..dd978ec 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -258,4 +258,6 @@ void add_guessed_letter(char* guessed_letters, char guessed_letter){ return; } } + guessed_letters[strlen(guessed_letters)] = guessed_letter; + guessed_letters[strlen(guessed_letters) + 1] = '\0'; } \ No newline at end of file From 82b77097a0a00369ed2cf86f05faa30f4829a120 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:26:26 +0100 Subject: [PATCH 020/160] =?UTF-8?q?Commit=2019=20-=20eingabe=20eines=20Buc?= =?UTF-8?q?hstaben=20in=20die=20func=20Hauptspiel=20soll=20erm=C3=B6glicht?= =?UTF-8?q?=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index dd978ec..bec8f47 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -16,6 +16,7 @@ void levelauswahl(); void hauptSpiel(int level); void draw_hangman(int attempts); void add_guessed_letter(char* guessed_letters, char guessed_letter); +char eingabe_buchstabe(); void protokoll(){ clear_screen(); @@ -260,4 +261,11 @@ void add_guessed_letter(char* guessed_letters, char guessed_letter){ } guessed_letters[strlen(guessed_letters)] = guessed_letter; guessed_letters[strlen(guessed_letters) + 1] = '\0'; +} + +char eingabe_buchstabe(){ + char guess; + scanf(" %c", &guess); + guess = tolower(guess); + return guess; } \ No newline at end of file From 6bc8c8dfc5de732ba69fc167cc81d1495a3ac7fa Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:28:30 +0100 Subject: [PATCH 021/160] Commit 20 - func lade secret_word zum laden des wortes soll erstellt werden --- src/main/c/hangman.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index bec8f47..93892bb 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -17,6 +17,7 @@ void hauptSpiel(int level); void draw_hangman(int attempts); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); +void lade_secret_word(char* secret_word, int level, char* path); void protokoll(){ clear_screen(); @@ -268,4 +269,27 @@ char eingabe_buchstabe(){ scanf(" %c", &guess); guess = tolower(guess); return guess; +} + +void lade_secret_word(char* secret_word, int level, char* path){ + FILE *file = fopen(path, "r"); + int count = 0; + if ( file != NULL ) + { + char line[100]; /* or other suitable maximum line size */ + while (fgets(line, sizeof line, file) != NULL) /* read a line */ + { + if (count == level) + { + strcpy(secret_word, line); + secret_word[strlen(secret_word) - 1] = '\0'; + return; + } + else + { + count++; + } + } + fclose(file); + } } \ No newline at end of file From bb1c11d4e38cf26a3bf514401065ae678e001a21 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:41:49 +0100 Subject: [PATCH 022/160] =?UTF-8?q?Commit=2021=20-=20lade=20secret=5Fword?= =?UTF-8?q?=20in=20hauptspiel=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 93892bb..f10ca13 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -171,9 +171,9 @@ void hauptSpiel(int level){ char path[] = "hangman_words.txt"; int result; int won = 0; - //secret_word soll vergeben werden - //secret_word soll geladen werden - //path soll erstellt werden + + lade_secret_word(secret_word, level, path); + //hangman soll gemalt werden //Buchstaben sollen gezeigt werden //Buchstaben sollen eingegeben werden können From 8d30fbee47d633b91afdd5c4cc466c548dc8952b Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:42:57 +0100 Subject: [PATCH 023/160] Commit 22 - Buchstaben sollen gezeigt werden --- src/main/c/hangman.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index f10ca13..6f4a00f 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -18,6 +18,7 @@ void draw_hangman(int attempts); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); +void show_letters(char secret_word[100], char guessed_letters[100]); void protokoll(){ clear_screen(); @@ -292,4 +293,13 @@ void lade_secret_word(char* secret_word, int level, char* path){ } fclose(file); } +} + +void show_letters(char secret_word[100], char guessed_letters[100]){ + printf("Erratene Buchstaben: "); + for(int i = 0; i < strlen(secret_word); i++) { + if(strchr(guessed_letters, secret_word[i])){ + printf("%c ", secret_word[i]); + } +} } \ No newline at end of file From 273fa7c4dab5aa1c4345688a60354ce9826a0571 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:43:50 +0100 Subject: [PATCH 024/160] Commit 23 - func show_letters um else Bedingung erweitern --- src/main/c/hangman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 6f4a00f..1be3268 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -301,5 +301,9 @@ void show_letters(char secret_word[100], char guessed_letters[100]){ if(strchr(guessed_letters, secret_word[i])){ printf("%c ", secret_word[i]); } -} + else{ + printf("_ "); + } + } + printf("\n"); } \ No newline at end of file From 81eddf4ec227f1cf1a88fd1d0e79ce5530f15701 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:44:46 +0100 Subject: [PATCH 025/160] Commit 24 - func letters in secret word wird eingebaut --- src/main/c/hangman.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 1be3268..be37548 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -19,6 +19,7 @@ void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); +int letter_in_secret_word(char guessed_letter, char secret_word[100]); void protokoll(){ clear_screen(); @@ -306,4 +307,13 @@ void show_letters(char secret_word[100], char guessed_letters[100]){ } } printf("\n"); +} + +int letter_in_secret_word(char guessed_letter, char secret_word[100]){ + for(int i = 0; i < strlen(secret_word); i++){ + if(guessed_letter == secret_word[i]){ + return 0; + } + } + return 1; } \ No newline at end of file From f62a2d3e76f963d8eb1f68ada7824a59b6098fba Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:46:12 +0100 Subject: [PATCH 026/160] Commit 25 - hauptspiel bisweit erweitern --- src/main/c/hangman.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index be37548..25cb67d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -176,10 +176,19 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); - //hangman soll gemalt werden - //Buchstaben sollen gezeigt werden - //Buchstaben sollen eingegeben werden können - //eingegeben Buchstaben sollen überprüft und dem Lösungswort hinzugefügt werden, damit Gewinn ermittelt werden kann + while (attempts < 6) { //um gewinnen erweitern + draw_hangman(attempts); + show_letters(secret_word, guessed_letters); + guessed_letter = eingabe_buchstabe(); + result = letter_in_secret_word(guessed_letter, secret_word); + if (result == 0){ + add_guessed_letter(guessed_letters, guessed_letter); + } + else { + attempts++; + } + //gewonnen erweitern + } } void draw_hangman(int attempts) { From d8b150ea5417278034955404ed54d537ed47b064 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:48:37 +0100 Subject: [PATCH 027/160] Commit 27 - gewonnen funktionalitt in hauptspiel einbinden --- src/main/c/hangman.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 25cb67d..d20711d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -20,6 +20,7 @@ char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); +int has_won(char secret_word[100], char guessed_letters[100]); void protokoll(){ clear_screen(); @@ -176,7 +177,7 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); - while (attempts < 6) { //um gewinnen erweitern + while (attempts < 6 && won == 0) { draw_hangman(attempts); show_letters(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); @@ -187,7 +188,7 @@ void hauptSpiel(int level){ else { attempts++; } - //gewonnen erweitern + won = has_won(secret_word, guessed_letters); } } @@ -325,4 +326,20 @@ int letter_in_secret_word(char guessed_letter, char secret_word[100]){ } } return 1; +} + +int has_won(char secret_word[100], char guessed_letters[100]){ + int occured; + for (int i = 0; i < strlen(secret_word); i++){ + occured = 0; + for (int k = 0; k < strlen(guessed_letters); k++){ + if (secret_word[i] == guessed_letters[k]){ + occured = 1; + } + } + if (occured == 0){ + return 0; + } + } + return 1; } \ No newline at end of file From cfb70011a9d987c618739c73d026d79e256b4b05 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:49:35 +0100 Subject: [PATCH 028/160] Commit 28 - func level_plus einbauen --- src/main/c/hangman.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index d20711d..037c170 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -21,6 +21,7 @@ void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); +void level_plus(); void protokoll(){ clear_screen(); @@ -342,4 +343,31 @@ int has_won(char secret_word[100], char guessed_letters[100]){ } } return 1; +} + +void level_plus(){ + char KonfDatei[100]; + char levelstr[3]; + int i = 0; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r+"); + fscanf(fp, "%s", KonfDatei); + + while(KonfDatei[i] != 0){ + i++; + } + levelstr[0] = KonfDatei[i-2]; + levelstr[1] = KonfDatei[i-1]; + levelstr[2] = '\0'; + if (levelstr[1] == '9'){ + KonfDatei[i-2]++; + KonfDatei[i-1] = '0'; + } else { + KonfDatei[i-1]++; + } + fclose(fp); + fp = fopen("hangman.txt", "w"); + fprintf(fp, "%s", KonfDatei); + fclose(fp); } \ No newline at end of file From 862ea944d09e98b63904c2a244fec8b2ba480696 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:50:31 +0100 Subject: [PATCH 029/160] Commit 29 - level_plus in Hauptspiel einbauen --- src/main/c/hangman.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 037c170..d1f72c3 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -191,6 +191,9 @@ void hauptSpiel(int level){ } won = has_won(secret_word, guessed_letters); } + if (won == 1){ + level_plus(); + } } void draw_hangman(int attempts) { From ce9fcaef3147fa6b10209556fb48251f299bdc32 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:51:31 +0100 Subject: [PATCH 030/160] Commit 30 - func Overlay einbauen & hauptspiel mit levelauswahl verbinden --- src/main/c/hangman.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index d1f72c3..2fc5f8a 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -22,6 +22,7 @@ void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); void level_plus(); +int overlay(); void protokoll(){ clear_screen(); @@ -39,7 +40,7 @@ void clear_screen() { void willkommen(){ char ENTERtxt[] = {"-Druecke ENTER zum starten-\n"}; - + overlay(); printf("%s", ENTERtxt); getchar(); } @@ -81,7 +82,7 @@ void nameWaehlen(){ fp = fopen("hangman.txt", "w"); clear_screen(); // - + overlay(); printf("Geben Sie den Namen ein: "); scanf("%s", name); @@ -97,7 +98,7 @@ void startauswahl() { int modus; clear_screen(); // - + overlay(); printf("Willkommen "); nameAusgeben(); printf("[1] Spielen\n[2] Namen aendern\n"); @@ -150,7 +151,7 @@ void levelauswahl(){ int i = 0; clear_screen(); // - + overlay(); FILE *fp = NULL; fp = fopen("hangman.txt", "r"); @@ -163,7 +164,7 @@ void levelauswahl(){ levelstr[1] = KonfDatei[i-1]; levelstr[2] = '\0'; level = atoi(levelstr); - //hauptspiel mit dem Level starten + hauptSpiel(level); fclose(fp); } @@ -373,4 +374,25 @@ void level_plus(){ fp = fopen("hangman.txt", "w"); fprintf(fp, "%s", KonfDatei); fclose(fp); +} + +int overlay(){ + char hangmanArt[10][41] = { + " _______ ", + " | | ", + " | ", + " | ", + " | ", + " | ", + "__|_________\n" + }; + + printf("Galgenmann!\n"); + printf("v.1.0.2\n\n"); + + + for (int i = 0; i < 9; i++) { + printf("%s\n", hangmanArt[i]); + } + return 0; } \ No newline at end of file From 128bfa21d26b2a424935637176d2be39bac6d918 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:19:55 +0100 Subject: [PATCH 031/160] Importiere wichtige Bibliotheken --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/main/c/VierGewinnt.c diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c new file mode 100644 index 0000000..cf058e3 --- /dev/null +++ b/src/main/c/VierGewinnt.c @@ -0,0 +1,3 @@ +//Importiere wichtige Bibliotheken +#include +#include From 0f92499ece4dfe239b70bface7b5477d33b8f222 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:20:41 +0100 Subject: [PATCH 032/160] =?UTF-8?q?Definiere=20Feldgr=C3=B6=C3=9Fe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index cf058e3..661ea87 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -1,3 +1,7 @@ //Importiere wichtige Bibliotheken #include #include + +//Definiere Feldgröße +#define ROWS 6 +#define COLS 7 From bf61a009911977c0148c6ec6d50b14de3011355e Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:21:21 +0100 Subject: [PATCH 033/160] Definiere Farben --- src/main/c/VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 661ea87..5d0a497 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -5,3 +5,14 @@ //Definiere Feldgröße #define ROWS 6 #define COLS 7 + +// Definiere Farben +#define RESET_COLOR "\033[0m" +#define BLACK "\033[0;30m" +#define RED "\033[0;31m" +#define GREEN "\033[0;32m" +#define YELLOW "\033[0;33m" +#define BLUE "\033[0;34m" +#define MAGENTA "\033[0;35m" +#define CYAN "\033[0;36m" +#define WHITE "\033[0;37m" From 107475af8f4a011a6093d1d55cbbac77ab42f1d9 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:22:18 +0100 Subject: [PATCH 034/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20initiali?= =?UTF-8?q?zeBoard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 5d0a497..d07efff 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -16,3 +16,7 @@ #define MAGENTA "\033[0;35m" #define CYAN "\033[0;36m" #define WHITE "\033[0;37m" + + +//Funktionsprototyp für initializeBoard +void initializeBoard(char board[ROWS][COLS]); From 7fe15fcedca072ba8e556e196c8351fc3d023198 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:23:13 +0100 Subject: [PATCH 035/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20printBoa?= =?UTF-8?q?rd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index d07efff..5a6ddb2 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -20,3 +20,6 @@ //Funktionsprototyp für initializeBoard void initializeBoard(char board[ROWS][COLS]); + +//Funktionsprototyp für printBoard +void printBoard(char board[ROWS][COLS]); From 99373604d53b7ee0b9ada1fad7fb325c05120ee8 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:24:00 +0100 Subject: [PATCH 036/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20clearScr?= =?UTF-8?q?een?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 5a6ddb2..e4a5031 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -23,3 +23,6 @@ void initializeBoard(char board[ROWS][COLS]); //Funktionsprototyp für printBoard void printBoard(char board[ROWS][COLS]); + +// Funktionsprototyp für clearScreen +void clearScreen(); From f166bb60ff691bf47508fd569f667c07707c78ee Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:24:55 +0100 Subject: [PATCH 037/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20isColumn?= =?UTF-8?q?Full?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index e4a5031..bc8d922 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -26,3 +26,6 @@ void printBoard(char board[ROWS][COLS]); // Funktionsprototyp für clearScreen void clearScreen(); + +//Funktionsprototyp für isColumnFull +int isColumnFull(char board[ROWS][COLS], int col); From 4898e38878c5b0ab2aa8a6e0a3b150a48a2903bf Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:25:38 +0100 Subject: [PATCH 038/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20dropPiec?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index bc8d922..edcbe34 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -29,3 +29,7 @@ void clearScreen(); //Funktionsprototyp für isColumnFull int isColumnFull(char board[ROWS][COLS], int col); + +//Funktionsprototyp für dropPiece +int dropPiece(char board[ROWS][COLS], int col, char player); + From 399950a81b1e3632825e3bc19b761dcc349f0fd4 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:26:24 +0100 Subject: [PATCH 039/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkWin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index edcbe34..7139b27 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -32,4 +32,6 @@ int isColumnFull(char board[ROWS][COLS], int col); //Funktionsprototyp für dropPiece int dropPiece(char board[ROWS][COLS], int col, char player); +//Funktionsprototyp für checkWin +int checkWin(char board[ROWS][COLS], char player); From 8cd86a70242fde344826d673093bd2757905737a Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:27:10 +0100 Subject: [PATCH 040/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkHor?= =?UTF-8?q?izontal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 7139b27..3e60a29 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -34,4 +34,6 @@ int isColumnFull(char board[ROWS][COLS], int col); int dropPiece(char board[ROWS][COLS], int col, char player); //Funktionsprototyp für checkWin int checkWin(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkHorizontal +int checkHorizontal(char board[ROWS][COLS], char player); From 9f9046af94507448f70496949d08a7670c128296 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:27:57 +0100 Subject: [PATCH 041/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkVer?= =?UTF-8?q?tical?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 3e60a29..dcb003d 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -37,3 +37,6 @@ int checkWin(char board[ROWS][COLS], char player); // Funktionsprototyp für checkHorizontal int checkHorizontal(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkVertical +int checkVertical(char board[ROWS][COLS], char player); + From f3f300a91694b7abd02ff62442ab8a0248d1b312 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:29:00 +0100 Subject: [PATCH 042/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkDia?= =?UTF-8?q?gonalLR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index dcb003d..939c436 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -40,3 +40,6 @@ int checkHorizontal(char board[ROWS][COLS], char player); // Funktionsprototyp für checkVertical int checkVertical(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkDiagonalLR +int checkDiagonalLR(char board[ROWS][COLS], char player); + From 1b3477fd2da316cfc538f874be2f5c90ef0d1709 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:30:22 +0100 Subject: [PATCH 043/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20checkDia?= =?UTF-8?q?gonalRL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 939c436..77795f7 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -43,3 +43,6 @@ int checkVertical(char board[ROWS][COLS], char player); // Funktionsprototyp für checkDiagonalLR int checkDiagonalLR(char board[ROWS][COLS], char player); +// Funktionsprototyp für checkDiagonalRL +int checkDiagonalRL(char board[ROWS][COLS], char player); + From 1e33053766e4e1d671672b625dde2147b9d0e979 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:31:02 +0100 Subject: [PATCH 044/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showMess?= =?UTF-8?q?age?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 77795f7..4fdd8c3 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -46,3 +46,6 @@ int checkDiagonalLR(char board[ROWS][COLS], char player); // Funktionsprototyp für checkDiagonalRL int checkDiagonalRL(char board[ROWS][COLS], char player); +// Funktionsprototyp für showMessage +void showMessage(const char* messageColor, const char* message); + From 20b97fe1eaf62fc9c3a2c06d31a34b0e741a1f75 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:31:44 +0100 Subject: [PATCH 045/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showInva?= =?UTF-8?q?lidInputMessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 4fdd8c3..2a68a6e 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -48,4 +48,5 @@ int checkDiagonalRL(char board[ROWS][COLS], char player); // Funktionsprototyp für showMessage void showMessage(const char* messageColor, const char* message); - +//Funktionsprototyp für showInvalidInputMessage +void showInvalidInputMessage(); From 04ca12eff98fcff5aeae8a1616c259dbc71c7ed3 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:32:48 +0100 Subject: [PATCH 046/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showColu?= =?UTF-8?q?mnFullMessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 2a68a6e..f77c5da 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -50,3 +50,6 @@ int checkDiagonalRL(char board[ROWS][COLS], char player); void showMessage(const char* messageColor, const char* message); //Funktionsprototyp für showInvalidInputMessage void showInvalidInputMessage(); + +//Funktionsprototyp für showColumnFullMessage +void showColumnFullMessage(); From fd012eff4f61d664856afb9cd3e983085915d300 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:33:37 +0100 Subject: [PATCH 047/160] =?UTF-8?q?Funktionsprototyp=20f=C3=BCr=20showWinM?= =?UTF-8?q?essage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index f77c5da..b1b9d51 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -53,3 +53,6 @@ void showInvalidInputMessage(); //Funktionsprototyp für showColumnFullMessage void showColumnFullMessage(); + +//Funktionsprototyp für showWinMessage +void showWinMessage(int player); From 1b57cd1dba5593247014c405ff77c7385a4cb26f Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:34:40 +0100 Subject: [PATCH 048/160] Write starter function --- src/main/c/VierGewinnt.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index b1b9d51..9108a58 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -56,3 +56,44 @@ void showColumnFullMessage(); //Funktionsprototyp für showWinMessage void showWinMessage(int player); + + +//Write starter function +int main_function() { + char board[ROWS][COLS]; + int currentPlayer = 1; // Spieler 1 beginnt + + initializeBoard(board); + printBoard(board); + + int column; + while (1) { + printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, currentPlayer); + + scanf("%d", &column); + if (column < 1 || column > 7) { + showInvalidInputMessage(); + continue; + } + + column--; + + if (isColumnFull(board, column)) { + showColumnFullMessage(); + continue; + } + + if (dropPiece(board, column, (currentPlayer == 1) ? 'X' : 'O')) { + printBoard(board); + if (checkWin(board, (currentPlayer == 1) ? 'X' : 'O')) { + showWinMessage(currentPlayer); + break; + } + + currentPlayer = (currentPlayer == 1) ? 2 : 1; + } + } + + return 0; +} + From e5a065d12a668302ed7c0b3c214d8b77637e1cb5 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:35:23 +0100 Subject: [PATCH 049/160] Write initializeBoard function --- src/main/c/VierGewinnt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 9108a58..0b7b0c1 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -96,4 +96,11 @@ int main_function() { return 0; } - +// Write initializeBoard function +void initializeBoard(char board[ROWS][COLS]) { + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + board[i][j] = ' '; + } + } +} From 177bf0211d8eb297697dbfb6c3b3fa79bf90b905 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:36:25 +0100 Subject: [PATCH 050/160] Write printBoard function --- src/main/c/VierGewinnt.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 0b7b0c1..7fde45c 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -104,3 +104,25 @@ void initializeBoard(char board[ROWS][COLS]) { } } } + + +// Write printBoard function +void printBoard(char board[ROWS][COLS]) { + clearScreen(); + printf("\n"); + + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + printf("| %c ", board[i][j]); + } + printf("|\n"); + + for (int j = 0; j < COLS; j++) { + printf("----"); + } + printf("-\n"); + } + + printf(" 1 2 3 4 5 6 7\n\n"); +} + From e5e445ec0faa798ee505f7bcf35986a3b5f4785f Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:37:13 +0100 Subject: [PATCH 051/160] Write clearScreen function --- src/main/c/VierGewinnt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 7fde45c..043054e 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -125,4 +125,11 @@ void printBoard(char board[ROWS][COLS]) { printf(" 1 2 3 4 5 6 7\n\n"); } - +// Write clearScreen function +void clearScreen() { +#ifdef _WIN32 + system("cls"); +#else + system("clear"); +#endif +} From 7640258c05046740d35146998eeed2a8e3a883d7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:37:48 +0100 Subject: [PATCH 052/160] Write isColumnFull function --- src/main/c/VierGewinnt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 043054e..000a60e 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -133,3 +133,8 @@ void clearScreen() { system("clear"); #endif } + +// Write isColumnFull function +int isColumnFull(char board[ROWS][COLS], int col) { + return (board[0][col] != ' '); +} From d796abbae3c3c296f25aaebe3d027a76fa341241 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:38:30 +0100 Subject: [PATCH 053/160] Write dropPiece function --- src/main/c/VierGewinnt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 000a60e..5959d98 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -138,3 +138,15 @@ void clearScreen() { int isColumnFull(char board[ROWS][COLS], int col) { return (board[0][col] != ' '); } + +//Write dropPiece function +int dropPiece(char board[ROWS][COLS], int col, char player) { + for (int i = ROWS - 1; i >= 0; i--) { + if (board[i][col] == ' ') { + board[i][col] = player; + return 1; + } + } + + return 0; // Column is full +} From 1e1e37b79180d2a17a6759aa9d6b2daae9542e04 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:39:09 +0100 Subject: [PATCH 054/160] Write checkHorizontal function --- src/main/c/VierGewinnt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 5959d98..2ae4fc6 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -150,3 +150,19 @@ int dropPiece(char board[ROWS][COLS], int col, char player) { return 0; // Column is full } + + +// Write checkHorizontal function +int checkHorizontal(char board[ROWS][COLS], char player) { + for (int row = 0; row < ROWS; row++) { + for (int col = 0; col <= COLS - 4; col++) { + if (board[row][col] == player && + board[row][col + 1] == player && + board[row][col + 2] == player && + board[row][col + 3] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} From 46f3cb93c69cfc7630e1ce3d8ce7fdf998a3af96 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:39:53 +0100 Subject: [PATCH 055/160] Write checkVertical function --- src/main/c/VierGewinnt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 2ae4fc6..9bcbac0 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -166,3 +166,18 @@ int checkHorizontal(char board[ROWS][COLS], char player) { } return 0; } + +//Write checkVertical function +int checkVertical(char board[ROWS][COLS], char player) { + for (int col = 0; col < COLS; col++) { + for (int row = 0; row <= ROWS - 4; row++) { + if (board[row][col] == player && + board[row + 1][col] == player && + board[row + 2][col] == player && + board[row + 3][col] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} From 234b2bf10390c9fe6477f39d423d9ec6f514d46e Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:40:29 +0100 Subject: [PATCH 056/160] Write checkDiagonalLR function --- src/main/c/VierGewinnt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 9bcbac0..fd18639 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -181,3 +181,27 @@ int checkVertical(char board[ROWS][COLS], char player) { } return 0; } + + + +// Write checkDiagonalLR function +int checkDiagonalLR(char board[ROWS][COLS], char player) { + for (int row = 0; row <= ROWS - 4; row++) { + for (int col = 0; col <= COLS - 4; col++) { + if (board[row][col] == player && + board[row + 1][col + 1] == player && + board[row + 2][col + 2] == player && + board[row + 3][col + 3] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} + + + + + + + From 79e09720038332773849c206aafa833cc0e33bd7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:41:14 +0100 Subject: [PATCH 057/160] Write checkDiagonalRL function --- src/main/c/VierGewinnt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index fd18639..d54a6bf 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -202,6 +202,21 @@ int checkDiagonalLR(char board[ROWS][COLS], char player) { +// Write checkDiagonalRL function +int checkDiagonalRL(char board[ROWS][COLS], char player) { + for (int row = 0; row <= ROWS - 4; row++) { + for (int col = 3; col < COLS; col++) { + if (board[row][col] == player && + board[row + 1][col - 1] == player && + board[row + 2][col - 2] == player && + board[row + 3][col - 3] == player) { + return 1; // Gewonnen + } + } + } + return 0; +} + From 095a9188c2b00c5e2ee91467825ce66a1e5ed21c Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:41:49 +0100 Subject: [PATCH 058/160] Write checkWin function --- src/main/c/VierGewinnt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index d54a6bf..13b8674 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -215,6 +215,15 @@ int checkDiagonalRL(char board[ROWS][COLS], char player) { } } return 0; + +} + +// Write checkWin function +int checkWin(char board[ROWS][COLS], char player) { + return checkHorizontal(board, player) || + checkVertical(board, player) || + checkDiagonalLR(board, player) || + checkDiagonalRL(board, player); } From 20a83ac492fcc3713cc32cab71db4a3ef29059ea Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:42:23 +0100 Subject: [PATCH 059/160] Write showMessage function --- src/main/c/VierGewinnt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 13b8674..a1e92e3 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -227,5 +227,8 @@ int checkWin(char board[ROWS][COLS], char player) { } - +// Write showMessage function +void showMessage(const char* messageColor, const char* message) { + printf("%s%s"RESET_COLOR, messageColor, message); +} From 949cce4dc8ca1f0807bbd3d97af74c147ca815ec Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:43:04 +0100 Subject: [PATCH 060/160] Write showInvalidInputMessage function --- src/main/c/VierGewinnt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index a1e92e3..d9261e8 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -232,3 +232,7 @@ void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } +// Write showInvalidInputMessage function +void showInvalidInputMessage() { + showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); +} From b3e4f6284788eb82c518a1d69708c9dce06c4d3b Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:43:42 +0100 Subject: [PATCH 061/160] Write showColumnFullMessage function --- src/main/c/VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index d9261e8..37d49cc 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -236,3 +236,14 @@ void showMessage(const char* messageColor, const char* message) { void showInvalidInputMessage() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } + + + + +// Write showColumnFullMessage function +void showColumnFullMessage() { + showMessage(RED, "Die Spalte ist voll. Bitte wähle eine andere.\n"); +} + + + From 8cf7073811eabff1b121d9b5e4dc0ca455fa2237 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:44:31 +0100 Subject: [PATCH 062/160] Write showWinMessage function} --- src/main/c/VierGewinnt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 37d49cc..c4d1419 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -247,3 +247,10 @@ void showColumnFullMessage() { +// Write showWinMessage function +void showWinMessage(int player) { + printf("Spieler %d hat gewonnen!\n", player); +} + + + From d7ea58f33a9145995d6b7e63e418759a63029313 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:46:40 +0100 Subject: [PATCH 063/160] add constants --- src/main/c/VierGewinnt.h | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/c/VierGewinnt.h diff --git a/src/main/c/VierGewinnt.h b/src/main/c/VierGewinnt.h new file mode 100644 index 0000000..6ec2043 --- /dev/null +++ b/src/main/c/VierGewinnt.h @@ -0,0 +1,5 @@ +#ifndef VIERGEWINNT_H +#define VIERGEWINNT_H + +#define ROWS 6 +#define COLS 7 From 4b61913ed74468c25733390daf6f5b2dc4a15542 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:47:16 +0100 Subject: [PATCH 064/160] define function --- src/main/c/VierGewinnt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/c/VierGewinnt.h b/src/main/c/VierGewinnt.h index 6ec2043..a52d6cd 100644 --- a/src/main/c/VierGewinnt.h +++ b/src/main/c/VierGewinnt.h @@ -3,3 +3,17 @@ #define ROWS 6 #define COLS 7 + +void initializeBoard(char board[ROWS][COLS]); +void printBoard(char board[ROWS][COLS]); +int isColumnFull(char board[ROWS][COLS], int col); +int dropPiece(char board[ROWS][COLS], int col, char player); +int checkWin(char board[ROWS][COLS], char player); +int checkHorizontal(char board[ROWS][COLS], char player); +int checkVertical(char board[ROWS][COLS], char player); +int checkDiagonalLR(char board[ROWS][COLS], char player); +int checkDiagonalRL(char board[ROWS][COLS], char player); +void showMessage(const char* messageColor, const char* message); +void showInvalidInputMessage(); +void showColumnFullMessage(); +void showWinMessage(int player); From 7dd63bde307f30f32a705194115fcd611bb1c517 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:47:52 +0100 Subject: [PATCH 065/160] define function --- src/main/c/VierGewinnt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/VierGewinnt.h b/src/main/c/VierGewinnt.h index a52d6cd..689034c 100644 --- a/src/main/c/VierGewinnt.h +++ b/src/main/c/VierGewinnt.h @@ -17,3 +17,4 @@ void showMessage(const char* messageColor, const char* message); void showInvalidInputMessage(); void showColumnFullMessage(); void showWinMessage(int player); +#endif From 7292f053a2be6851c30652da4819c29655afdba5 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:55:52 +0100 Subject: [PATCH 066/160] test_dropPiece_ValidMove --- src/test/c/test_VierGewinnt.c | 17 +++++++++++++++++ src/test/c/test_test.c | 28 ---------------------------- 2 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 src/test/c/test_VierGewinnt.c delete mode 100644 src/test/c/test_test.c diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c new file mode 100644 index 0000000..4690b45 --- /dev/null +++ b/src/test/c/test_VierGewinnt.c @@ -0,0 +1,17 @@ +#include "unity.h" +#include "VierGewinnt.h" + +void setUp(void) { +} + +void tearDown(void) { +} + + +void test_dropPiece_ValidMove(void) { + char board[6][7]; + initializeBoard(board); + + TEST_ASSERT_EQUAL_INT(1, dropPiece(board, 3, 'X')); +} + diff --git a/src/test/c/test_test.c b/src/test/c/test_test.c deleted file mode 100644 index 4f61ea7..0000000 --- a/src/test/c/test_test.c +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef TEST - -#include "unity.h" - -#include "test.h" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_test__return_5(void) -{ - /* arrange */ - int expected = 5; - int actual; - - /* act */ - actual = return_5(); - - /* assert */ - TEST_ASSERT_EQUAL_INT(expected, actual); -} - -#endif // TEST From 2824ad7a74355cb1b245558ab4d2691b3a2a2fc7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:57:30 +0100 Subject: [PATCH 067/160] test_dropPiece_FullColum --- src/test/c/test_VierGewinnt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 4690b45..91bfaff 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -15,3 +15,16 @@ void test_dropPiece_ValidMove(void) { TEST_ASSERT_EQUAL_INT(1, dropPiece(board, 3, 'X')); } + +void test_dropPiece_FullColumn(void) { + char board[6][7] = { + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'} + }; + + TEST_ASSERT_EQUAL_INT(0, dropPiece(board, 3, 'X')); // Spalte ist voll, sollte 0 zurückgeben +} From 0b85b5496c1c8ad4f189b39e27223e6d253fb0a3 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 00:59:00 +0100 Subject: [PATCH 068/160] test_checkWin_Horizontal_X --- src/test/c/test_VierGewinnt.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 91bfaff..8ad593b 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -28,3 +28,38 @@ void test_dropPiece_FullColumn(void) { TEST_ASSERT_EQUAL_INT(0, dropPiece(board, 3, 'X')); // Spalte ist voll, sollte 0 zurückgeben } + + +void test_checkWin_Horizontal_X(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'X', 'X', 'X', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Horizontale Gewinnsituation für 'X' +} + + + + + + + + + + + + + + + + + + + + + From 389ca705ed111104f02495bb9145727ff6bad3f4 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:00:24 +0100 Subject: [PATCH 069/160] test_checkWin_Horizontal_O --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 8ad593b..f487364 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -43,7 +43,18 @@ void test_checkWin_Horizontal_X(void) { TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Horizontale Gewinnsituation für 'X' } +void test_checkWin_Horizontal_O(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', 'O', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'X', ' ', 'X', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Horizontale Gewinnsituation für 'X' +} From 3209502194d434c378be157aadc21d6e23703811 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:02:32 +0100 Subject: [PATCH 070/160] test_checkWin_Diagonal_X --- src/test/c/test_VierGewinnt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index f487364..73f89e0 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -56,6 +56,19 @@ void test_checkWin_Horizontal_O(void) { TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Horizontale Gewinnsituation für 'X' } +void test_checkWin_Diagonal_X(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', 'X', ' ', ' ', ' '}, + {' ', 'X', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'X', 'X', 'X', ' ', ' '}, + {' ', ' ', ' ','X', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', 'X', ' '} + }; + + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Horizontale Gewinnsituation für 'X' +} + From fe1df3e2224f7c86bdbc02576a17661fc9cbf3da Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:04:02 +0100 Subject: [PATCH 071/160] test_checkWin_Diagonal_O --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 73f89e0..9681ea7 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -73,7 +73,18 @@ void test_checkWin_Diagonal_X(void) { +void test_checkWin_Diagonal_O(void) { + char board[6][7] = { + {'X', 'X', ' ', ' ', ' ', ' ', ' '}, + {'O', 'O', 'O', 'X', ' ', ' ', ' '}, + {' ', 'O', ' ', ' ', ' ', ' ', ' '}, + {' ', 'X', 'O', 'X', 'X', ' ', ' '}, + {' ', ' ', ' ','O', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', 'X', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Horizontale Gewinnsituation für 'X' +} From 8fa684587d69292a79be5d69aa0f03d20811e156 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:05:34 +0100 Subject: [PATCH 072/160] test_checkWin_Vertical_X --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 9681ea7..6896efe 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -92,7 +92,18 @@ void test_checkWin_Diagonal_O(void) { +void test_checkWin_Vertical_X(void) { + char board[6][7] = { + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'X')); // Vertikale Gewinnsituation für 'X' +} From 00da72c029afbda55cd5631e055d797bb16a7ff2 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:07:26 +0100 Subject: [PATCH 073/160] test_checkWin_Vertical_O --- src/test/c/test_VierGewinnt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 6896efe..6569d15 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -107,5 +107,16 @@ void test_checkWin_Vertical_X(void) { +void test_checkWin_Vertical_O(void) { + char board[6][7] = { + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {'X', 'O', ' ', ' ', ' ', ' ', ' '}, + {' ', 'O', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' '} + }; + TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Vertikale Gewinnsituation für 'X' +} From 30327565fe7dc0ac2eb2463d9e9db1693f8c7061 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 01:12:14 +0100 Subject: [PATCH 074/160] test_checkWin_NoWinner --- src/test/c/test_VierGewinnt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index 6569d15..efe7a13 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -119,4 +119,19 @@ void test_checkWin_Vertical_O(void) { TEST_ASSERT_EQUAL_INT(1, checkWin(board, 'O')); // Vertikale Gewinnsituation für 'X' } +void test_checkWin_NoWinner(void) { +char board[6][7] = { + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'} + }; + + + + TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'X')); // Kein Gewinner, horizontale Reihe ist voll + TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'O')); // Kein Gewinner, horizontale Reihe ist voll +} From b9c75e4a231b8a8e291434c72a4cb8d19ffe6a05 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:44:41 +0100 Subject: [PATCH 075/160] refactoring: attempts --> versuche --- src/main/c/hangman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 2fc5f8a..03667c1 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -14,7 +14,7 @@ void startauswahl(); void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); -void draw_hangman(int attempts); +void draw_hangman(int versuche); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); From 8c500778398edaf2cbbd1e7a6151ec66925caf00 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:45:04 +0100 Subject: [PATCH 076/160] refactoring: attempts --> versuche --- src/main/c/hangman.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 03667c1..ad7a86f 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -170,7 +170,7 @@ void levelauswahl(){ void hauptSpiel(int level){ char secret_word[100]; - int attempts = 0; + int versuche = 0; char guessed_letter; char guessed_letters[100]; char path[] = "hangman_words.txt"; @@ -179,8 +179,8 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); - while (attempts < 6 && won == 0) { - draw_hangman(attempts); + while (versuche < 6 && won == 0) { + draw_hangman(versuche); show_letters(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); @@ -188,7 +188,7 @@ void hauptSpiel(int level){ add_guessed_letter(guessed_letters, guessed_letter); } else { - attempts++; + versuche++; } won = has_won(secret_word, guessed_letters); } @@ -197,12 +197,12 @@ void hauptSpiel(int level){ } } -void draw_hangman(int attempts) { +void draw_hangman(int versuche) { clear_screen(); printf("Galgenmann!\n"); printf("v.1.0.2\n\n"); - switch(attempts) { + switch(versuche) { case 0: printf(" _______\n"); printf(" | |\n"); From 2a1e0f356ba97f57e427c2d3b3ff22616a7b3b07 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:46:41 +0100 Subject: [PATCH 077/160] refactoring: draw_hangman --> zeichne_galgen --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index ad7a86f..b5fb04c 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -14,7 +14,7 @@ void startauswahl(); void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); -void draw_hangman(int versuche); +void zeichne_galgen(int versuche); void add_guessed_letter(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); @@ -180,7 +180,7 @@ void hauptSpiel(int level){ lade_secret_word(secret_word, level, path); while (versuche < 6 && won == 0) { - draw_hangman(versuche); + zeichne_galgen(versuche); show_letters(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); @@ -197,7 +197,7 @@ void hauptSpiel(int level){ } } -void draw_hangman(int versuche) { +void zeichne_galgen(int versuche) { clear_screen(); printf("Galgenmann!\n"); printf("v.1.0.2\n\n"); From d462e29b615a12b70d51e70ec65fd8a738845a38 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:48:36 +0100 Subject: [PATCH 078/160] refactoring: add_guessed_letter --> erratene_buchstaben_hinzufuegen --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index b5fb04c..62fc135 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -15,7 +15,7 @@ void nameAusgeben(); void levelauswahl(); void hauptSpiel(int level); void zeichne_galgen(int versuche); -void add_guessed_letter(char* guessed_letters, char guessed_letter); +void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); @@ -185,7 +185,7 @@ void hauptSpiel(int level){ guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); if (result == 0){ - add_guessed_letter(guessed_letters, guessed_letter); + erratenen_buchstaben_hinzufuegen(guessed_letters, guessed_letter); } else { versuche++; @@ -271,7 +271,7 @@ void zeichne_galgen(int versuche) { } } -void add_guessed_letter(char* guessed_letters, char guessed_letter){ +void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter){ for (int i = 0; i < strlen(guessed_letters); i++){ if (guessed_letters[i] == guessed_letter){ return; From 745e22138d0967dbcd65de5731457b681107129f Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:50:24 +0100 Subject: [PATCH 079/160] refactoring: load_secret_word --> hole_zu_erratendes_wort --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 62fc135..b558f02 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -17,7 +17,7 @@ void hauptSpiel(int level); void zeichne_galgen(int versuche); void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); -void lade_secret_word(char* secret_word, int level, char* path); +void hole_zu_erratendes_wort(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); @@ -177,7 +177,7 @@ void hauptSpiel(int level){ int result; int won = 0; - lade_secret_word(secret_word, level, path); + hole_zu_erratendes_wort(secret_word, level, path); while (versuche < 6 && won == 0) { zeichne_galgen(versuche); @@ -288,7 +288,7 @@ char eingabe_buchstabe(){ return guess; } -void lade_secret_word(char* secret_word, int level, char* path){ +void hole_zu_erratendes_wort(char* secret_word, int level, char* path){ FILE *file = fopen(path, "r"); int count = 0; if ( file != NULL ) From 416d01bce77f02f895ed86f9396248bc1149d8ab Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:51:33 +0100 Subject: [PATCH 080/160] refactoring: show_letters --> zeige_Buchstabenfeld --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index b558f02..81d746d 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -18,7 +18,7 @@ void zeichne_galgen(int versuche); void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); char eingabe_buchstabe(); void hole_zu_erratendes_wort(char* secret_word, int level, char* path); -void show_letters(char secret_word[100], char guessed_letters[100]); +void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); void level_plus(); @@ -181,7 +181,7 @@ void hauptSpiel(int level){ while (versuche < 6 && won == 0) { zeichne_galgen(versuche); - show_letters(secret_word, guessed_letters); + zeige_Buchstabenfeld(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); result = letter_in_secret_word(guessed_letter, secret_word); if (result == 0){ @@ -311,7 +311,7 @@ void hole_zu_erratendes_wort(char* secret_word, int level, char* path){ } } -void show_letters(char secret_word[100], char guessed_letters[100]){ +void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]){ printf("Erratene Buchstaben: "); for(int i = 0; i < strlen(secret_word); i++) { if(strchr(guessed_letters, secret_word[i])){ From 936934f3b9f2f408073b1b8fee94b2499544f4e6 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:53:07 +0100 Subject: [PATCH 081/160] refactoring: letter_in_secret_word --> Buchstabe_im_zu_erratenden_wort --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 81d746d..bc7d492 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -19,7 +19,7 @@ void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter char eingabe_buchstabe(); void hole_zu_erratendes_wort(char* secret_word, int level, char* path); void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); -int letter_in_secret_word(char guessed_letter, char secret_word[100]); +int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); void level_plus(); int overlay(); @@ -183,7 +183,7 @@ void hauptSpiel(int level){ zeichne_galgen(versuche); zeige_Buchstabenfeld(secret_word, guessed_letters); guessed_letter = eingabe_buchstabe(); - result = letter_in_secret_word(guessed_letter, secret_word); + result = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); if (result == 0){ erratenen_buchstaben_hinzufuegen(guessed_letters, guessed_letter); } @@ -324,7 +324,7 @@ void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]){ printf("\n"); } -int letter_in_secret_word(char guessed_letter, char secret_word[100]){ +int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]){ for(int i = 0; i < strlen(secret_word); i++){ if(guessed_letter == secret_word[i]){ return 0; From a292fb10619856bf493998aa1dd6228bbd424a97 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:54:13 +0100 Subject: [PATCH 082/160] refactoring: has_won --> gewonnen --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index bc7d492..4b54af8 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -20,7 +20,7 @@ char eingabe_buchstabe(); void hole_zu_erratendes_wort(char* secret_word, int level, char* path); void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]); -int has_won(char secret_word[100], char guessed_letters[100]); +int gewonnen(char secret_word[100], char guessed_letters[100]); void level_plus(); int overlay(); @@ -190,7 +190,7 @@ void hauptSpiel(int level){ else { versuche++; } - won = has_won(secret_word, guessed_letters); + won = gewonnen(secret_word, guessed_letters); } if (won == 1){ level_plus(); @@ -333,7 +333,7 @@ int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]){ return 1; } -int has_won(char secret_word[100], char guessed_letters[100]){ +int gewonnen(char secret_word[100], char guessed_letters[100]){ int occured; for (int i = 0; i < strlen(secret_word); i++){ occured = 0; From a0de73329667ea7211ad149056d7b42744132ef9 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 09:56:20 +0100 Subject: [PATCH 083/160] refactoring: nameAusgeben nullt --> nullterminante --- src/main/c/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 4b54af8..1d490a4 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -118,7 +118,7 @@ void nameAusgeben(){ char name[50]; int i = 5; int zaehler = 0; - int nullt; + int nullterminante; FILE *fp = NULL; fp = fopen("hangman.txt", "r"); @@ -128,7 +128,7 @@ void nameAusgeben(){ zaehler++; i++; } - nullt = zaehler; + nullterminante = zaehler; while(zaehler != 0){ name[--zaehler] = KonfDatei[--i]; } @@ -138,7 +138,7 @@ void nameAusgeben(){ i++; } - name[nullt] = '\0'; + name[nullterminante] = '\0'; printf("%s\n", name); fclose(fp); From 34e44fbcbd3c0fb6871d95bb102013d00ec74b4b Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:05:23 +0100 Subject: [PATCH 084/160] refactoring: level --- src/main/c/hangman.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 1d490a4..41bfcda 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -351,7 +351,7 @@ int gewonnen(char secret_word[100], char guessed_letters[100]){ void level_plus(){ char KonfDatei[100]; - char levelstr[3]; + char level[3]; int i = 0; FILE *fp = NULL; @@ -361,10 +361,10 @@ void level_plus(){ while(KonfDatei[i] != 0){ i++; } - levelstr[0] = KonfDatei[i-2]; - levelstr[1] = KonfDatei[i-1]; - levelstr[2] = '\0'; - if (levelstr[1] == '9'){ + level[0] = KonfDatei[i-2]; + level[1] = KonfDatei[i-1]; + level[2] = '\0'; + if (level[1] == '9'){ KonfDatei[i-2]++; KonfDatei[i-1] = '0'; } else { From b054a28ae875235457bea447b862f600952a0f22 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:06:15 +0100 Subject: [PATCH 085/160] refactoring: galgen_overlay --- src/main/c/hangman.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 41bfcda..014302c 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -377,7 +377,7 @@ void level_plus(){ } int overlay(){ - char hangmanArt[10][41] = { + char galgen_overlay[10][41] = { " _______ ", " | | ", " | ", @@ -392,7 +392,7 @@ int overlay(){ for (int i = 0; i < 9; i++) { - printf("%s\n", hangmanArt[i]); + printf("%s\n", galgen_overlay[i]); } return 0; } \ No newline at end of file From 7786aa4f6b50a33e956c2fb79541578c3946573a Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:23:37 +0100 Subject: [PATCH 086/160] test_Buchstabe_im_zu_erratenden_wort 1 --- src/main/c/hangman.h | 23 +++++++++++++++++++++++ src/main/c/hangman.txt | 2 +- src/test/c/test_hangman_test.c | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/main/c/hangman.h create mode 100644 src/test/c/test_hangman_test.c diff --git a/src/main/c/hangman.h b/src/main/c/hangman.h new file mode 100644 index 0000000..8d2ac70 --- /dev/null +++ b/src/main/c/hangman.h @@ -0,0 +1,23 @@ +#ifndef TEST_H +#define TEST_H + +void protokoll(); +void clear_screen(); +void willkommen(); +int namePruefen(); +void nameWaehlen(); +void startauswahl(); +void nameAusgeben(); +void levelauswahl(); +void hauptSpiel(int level); +void zeichne_galgen(int versuche); +void erratenen_buchstaben_hinzufuegen(char* guessed_letters, char guessed_letter); +char eingabe_buchstabe(); +void hole_zu_erratendes_wort(char* secret_word, int level, char* path); +void zeige_Buchstabenfeld(char secret_word[100], char guessed_letters[100]); +int buchstabe_im_zu_erratenden_wort(char guessed_letter, char secret_word[100]); +int gewonnen(char secret_word[100], char guessed_letters[100]); +void level_plus(); +int overlay(); + +#endif // TEST_H diff --git a/src/main/c/hangman.txt b/src/main/c/hangman.txt index 4456b2e..4e41ffd 100644 --- a/src/main/c/hangman.txt +++ b/src/main/c/hangman.txt @@ -1 +1 @@ -name:peter,level:01 \ No newline at end of file +name:peter,level:02 \ No newline at end of file diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c new file mode 100644 index 0000000..b29661a --- /dev/null +++ b/src/test/c/test_hangman_test.c @@ -0,0 +1,24 @@ +#ifdef TEST + +#include "unity.h" +#include "hangman.h" + +void setUp(void) {} + +void tearDown(void) {} + +void test_Buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { + // arrange + int expected = 1; + int actual; + char guessed_letter = 'j'; + char secret_word[100] = ""; + + // act + actual = Buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + +#endif // TEST From dbfa72438aa84dca3d643c366d3a6e7797c55cc5 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:25:30 +0100 Subject: [PATCH 087/160] test_buchstabe_im_zu_erratenden_wort 1 richtigstellung --- src/test/c/test_hangman_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index b29661a..b84d988 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -7,7 +7,7 @@ void setUp(void) {} void tearDown(void) {} -void test_Buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { +void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { // arrange int expected = 1; int actual; @@ -15,7 +15,7 @@ void test_Buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { char secret_word[100] = ""; // act - actual = Buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); // assert TEST_ASSERT_EQUAL_INT(expected, actual); From 16403a8a6fd49012d46cdcfa29342ef244d4ef06 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:26:29 +0100 Subject: [PATCH 088/160] test_buchstabe_im_zu_erratenden_wort 2 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index b84d988..6f70048 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -21,4 +21,18 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_leerstring_falsch() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_joe_richtig() { + // arrange + int expected = 0; + int actual; + char guessed_letter = 'j'; + char secret_word[100] = "joe"; + + // act + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From 3c8a80091a6102216bd213b9f26c10f5a27dbb57 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:27:13 +0100 Subject: [PATCH 089/160] test_buchstabe_im_zu_erratenden_wort 3 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 6f70048..f244008 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -35,4 +35,18 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_joe_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_buchstabe_im_zu_erratenden_wort_eingabe_k_in_joe_falsch() { + // arrange + int expected = 1; + int actual; + char guessed_letter = 'k'; + char secret_word[100] = "joe"; + + // act + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From 44c23009a6ee4df11c5ed9ea0a032403e52393de Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:28:49 +0100 Subject: [PATCH 090/160] test_buchstabe_im_zu_erratenden_wort 4 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index f244008..a092ee3 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -49,4 +49,18 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_k_in_joe_falsch() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_eoj_richtig() { + // arrange + int expected = 0; + int actual; + char guessed_letter = 'j'; + char secret_word[100] = "eoj"; + + // act + actual = buchstabe_im_zu_erratenden_wort(guessed_letter, secret_word); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From b4331381c018243325f5b72b918b283f594a958c Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:29:44 +0100 Subject: [PATCH 091/160] test_erratene_buchstaben_hinzufuegen 1 --- src/test/c/test_hangman_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index a092ee3..c8fe86b 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -63,4 +63,17 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_eoj_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_erratene_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_richtig() { + // arrange + char expected[100] = "r"; + char actual[100] = ""; + char to_add = 'r'; + + // act + erratene_buchstaben_hinzufuegen(actual, to_add); + + // assert + TEST_ASSERT_EQUAL_STRING(expected, actual); +} + #endif // TEST From bd85f32d84e9e3ec48fd09622f4241f03bface92 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:30:49 +0100 Subject: [PATCH 092/160] test_erratene_buchstaben_hinzufuegen 1 richtigstellung --- src/test/c/test_hangman_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index c8fe86b..a799622 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -63,14 +63,14 @@ void test_buchstabe_im_zu_erratenden_wort_eingabe_j_in_eoj_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } -void test_erratene_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_richtig() { +void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_richtig() { // arrange char expected[100] = "r"; char actual[100] = ""; char to_add = 'r'; // act - erratene_buchstaben_hinzufuegen(actual, to_add); + erratenen_buchstaben_hinzufuegen(actual, to_add); // assert TEST_ASSERT_EQUAL_STRING(expected, actual); From 84daac09abe3602274daa279fd390a249b5c158a Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:31:44 +0100 Subject: [PATCH 093/160] test_erratene_buchstaben_hinzufuegen 2 --- src/test/c/test_hangman_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index a799622..98308e8 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -76,4 +76,17 @@ void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_leerstring_zu_peter_ri TEST_ASSERT_EQUAL_STRING(expected, actual); } +void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_pete_zu_peter_richtig() { + // arrange + char expected[100] = "peter"; + char actual[100] = "pete"; + char to_add = 'r'; + + // act + erratenen_buchstaben_hinzufuegen(actual, to_add); + + // assert + TEST_ASSERT_EQUAL_STRING(expected, actual); +} + #endif // TEST From 7a4bc9f343ab331700cdc71188f61a7adec43668 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:32:22 +0100 Subject: [PATCH 094/160] test_erratene_buchstaben_hinzufuegen 3 --- src/test/c/test_hangman_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 98308e8..aade409 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -89,4 +89,17 @@ void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_pete_zu_peter_richtig( TEST_ASSERT_EQUAL_STRING(expected, actual); } +void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_peter_zu_peter_falsch() { + // arrange + char expected[100] = "peter"; + char actual[100] = "peter"; + char to_add = 'r'; + + // act + erratenen_buchstaben_hinzufuegen(actual, to_add); + + // assert + TEST_ASSERT_FALSE(expected == actual); +} + #endif // TEST From 76e514199ce4855f6d55763d0458cd600e587f0f Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:32:57 +0100 Subject: [PATCH 095/160] test_gewonnen 1 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index aade409..99550b1 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -102,4 +102,18 @@ void test_erratenen_buchstaben_hinzufuegen_anhaengen_r_an_peter_zu_peter_falsch( TEST_ASSERT_FALSE(expected == actual); } +void test_gewonnen_petr_in_peter_richtig() { + // arrange + int expected = 1; + char actual; + char secret_word[100] = "peter"; + char guessed_letters[100] = "petr"; + + // act + actual = gewonnen(secret_word, guessed_letters); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From c68a10ea8e048694bfb135f367d30e464d359252 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:33:23 +0100 Subject: [PATCH 096/160] test_gewonnen 2 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 99550b1..07ceafa 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -116,4 +116,18 @@ void test_gewonnen_petr_in_peter_richtig() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_gewonnen_p_in_peter_falsch() { + // arrange + int expected = 0; + char actual; + char secret_word[100] = "peter"; + char guessed_letters[100] = "p"; + + // act + actual = gewonnen(secret_word, guessed_letters); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From e8ad1176a1fa114d942c8f59ffeffc325b5b5df1 Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Wed, 7 Feb 2024 10:33:53 +0100 Subject: [PATCH 097/160] test_gewonnen 3 --- src/test/c/test_hangman_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_hangman_test.c b/src/test/c/test_hangman_test.c index 07ceafa..e63bdba 100644 --- a/src/test/c/test_hangman_test.c +++ b/src/test/c/test_hangman_test.c @@ -130,4 +130,18 @@ void test_gewonnen_p_in_peter_falsch() { TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_gewonnen_petr_in_leerstring_richtig() { + // arrange + int expected = 1; + char actual; + char secret_word[100] = ""; + char guessed_letters[100] = "petr"; + + // act + actual = gewonnen(secret_word, guessed_letters); + + // assert + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif // TEST From 152fea0f0d3f47f17e9c8d348029b94965e66632 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:40:35 +0100 Subject: [PATCH 098/160] 1 Init Board --- src/main/c/TicTacToe.c | 14 ++++++++++++++ src/main/c/a.exe | Bin 0 -> 42690 bytes 2 files changed, 14 insertions(+) create mode 100644 src/main/c/TicTacToe.c create mode 100644 src/main/c/a.exe diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c new file mode 100644 index 0000000..e011caf --- /dev/null +++ b/src/main/c/TicTacToe.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +// Funktion, um das Spielfeld zu initialisieren +//1 +void Brett(char Feld[3][3]) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + Feld[i][j] = '_'; + } + } +} \ No newline at end of file diff --git a/src/main/c/a.exe b/src/main/c/a.exe new file mode 100644 index 0000000000000000000000000000000000000000..b9e385d1dd5fc87e0a27275592ca9c71612bbfaa GIT binary patch literal 42690 zcmeIb4}4VBwJ*NU%!CXi;}9;|23^L18=!2}w^>Ez z;C%d$Knrk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ywj5?zm?v|sIN z!Uk9h{);VL)onD~nZWpDD;ug``< zjOl|!Phf9}BKmE1otKOJYl%_AZO(aYgjkHFfmZKCBA9`onG}ah(oaS~t{V-y7QQOITjt7nX)W zz6G$@e`JFX-*CX|%i{LSC8rpx+SpK4itq0XO=6YDyam-?yzx+*xeKhWiY11{;tNya zHY4V)YWR=dm3TNc#IWqX%Y!lBxR}$$e`A84hs{%H|5`K(Br*5g6&`5tqg!z!tO^Hc zjHxUp08PHl#DhBr?GIx(hvkzNbdUJpMO!Qx?I-rm)pPoEj|*-Mxb(oo+FHW>#@qYY zw32=U3Hiq9ha$#}=VHcIy^2Cj9MdT-ev$65k)g%7A!VF_EVgrTENqOO;PJpSe&85y zvudttYzyQuAs{}Wiw06nWuO~%j(pk*4|K6ePto7-FuFA{Bu)HhXyZ%CS8wpqEls94 zAAM;A6PCn(r>3J=H;qPX>E<=V<(NKTiSu27b|cJx?#ODL@fzak^Exi-Uz#IaKq>$K% zGV6VvZ9YG?8L0;_zH7z#r2g>82&HBV#|y~iiS2LBy-7sgL|r&)Z1d?@%UOemrD2+I zm!OZowPWT+oY_UEI-lRE#~WBUzp?RK_v6@Z+n*PZjnNe2hiTl{v`ryZM7+b)DekU> aVEF8u0)f%P^w2rhQWx#LTy%Z)`+os4M^G~W literal 0 HcmV?d00001 From 2107498e6bb3d070cb2aaee847fbb799bd32a4c2 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:41:40 +0100 Subject: [PATCH 099/160] 2 display Board --- src/main/c/TicTacToe.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index e011caf..837e2a2 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -4,11 +4,18 @@ #include // Funktion, um das Spielfeld zu initialisieren -//1 void Brett(char Feld[3][3]) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Feld[i][j] = '_'; } } +} +void Bild(char Feld[3][3]) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + printf("%c ", Feld[i][j]); + } + printf("\n"); + } } \ No newline at end of file From 403fd219da53cef366d89b28afdde9d0e13e2dcc Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:43:01 +0100 Subject: [PATCH 100/160] 3 del old Board --- src/main/c/TicTacToe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 837e2a2..31999f4 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -12,6 +12,11 @@ void Brett(char Feld[3][3]) { } } void Bild(char Feld[3][3]) { +#ifdef _WIN32 + system("cls"); +#else + system("clear"); +#endif for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("%c ", Feld[i][j]); From 4af9a27662f2e87139e7b8b09d9e6d373d578084 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:45:41 +0100 Subject: [PATCH 101/160] 4 win condition row --- src/main/c/TicTacToe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 31999f4..762fcb3 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -23,4 +23,16 @@ void Bild(char Feld[3][3]) { } printf("\n"); } +} +int Entscheiden(char Feld[3][3]) { + // Überprüfen Sieg + // Überprüfen Reihen + for (int i = 0; i < 3; i++) { + if (Feld[i][0] == Feld[i][1] && Feld[i][1] == Feld[i][2] && Feld[i][0] != '_') { + if (Feld[i][0] == 'X') { + return 1; + } + else return 2; + } + } } \ No newline at end of file From 7b8852835f197bb834d1fd62ed361d9c07510893 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:49:16 +0100 Subject: [PATCH 102/160] refactoring: function winner --- src/main/c/TicTacToe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 762fcb3..d6a2860 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -24,7 +24,7 @@ void Bild(char Feld[3][3]) { printf("\n"); } } -int Entscheiden(char Feld[3][3]) { +int Winner(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { From 54a3160ebe0cedbfd89f05a944fd7e8bed11bb84 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 12:57:12 +0100 Subject: [PATCH 103/160] 6 erster Test + Header --- src/main/c/TicTacToe.h | 7 +++++++ src/test/c/test_TicTacToe.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/c/TicTacToe.h create mode 100644 src/test/c/test_TicTacToe.c diff --git a/src/main/c/TicTacToe.h b/src/main/c/TicTacToe.h new file mode 100644 index 0000000..1e04a7d --- /dev/null +++ b/src/main/c/TicTacToe.h @@ -0,0 +1,7 @@ +#ifndef TICTACTOE_H +#define TICTACTOE_H + +int Winner(char board[3][3]); + +#endif + diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c new file mode 100644 index 0000000..b1c8b25 --- /dev/null +++ b/src/test/c/test_TicTacToe.c @@ -0,0 +1,29 @@ + +#include "unity.h" + +#include "TicTacToe.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_TicTacToe_Winner_X_line_1(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'X', 'X', 'X'}, + {'O', 'O', '_'}, + {'O', '_', '_'} + }; + /* act */ + actual = Winner(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} \ No newline at end of file From 535f9a54b0c30211d50629c07034ca212c372f54 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 13:06:34 +0100 Subject: [PATCH 104/160] 7 zweiter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index b1c8b25..f8a1c62 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -26,4 +26,20 @@ void test_TicTacToe_Winner_X_line_1(void) /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_line_2(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'X', 'O', 'X'}, + {'O', 'O', 'O'}, + {'O', 'X', 'X'} + }; + /* act */ + actual = Winner(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From aa593e91a3ef765f6e3933d87430ff0f5e31eb56 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 13:09:37 +0100 Subject: [PATCH 105/160] 8 dritter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index f8a1c62..fc12b42 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -40,6 +40,22 @@ void test_TicTacToe_Winner_O_line_2(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_X_line_3(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'O', '_', '_'}, + {'O', 'O', '_'}, + {'X', 'X', 'X'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 65918b52a6d7ba8175f401ff0e59394aa1ac138c Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 15:22:49 +0100 Subject: [PATCH 106/160] 9 win condition column --- src/main/c/TicTacToe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index d6a2860..035d6c4 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -35,4 +35,13 @@ int Winner(char Feld[3][3]) { else return 2; } } + // Überprüfen Spalten + for (int j = 0; j < 3; j++) { + if (Feld[0][j] == Feld[1][j] && Feld[1][j] == Feld[2][j] && Feld[0][j] != '_') { + if (Feld[0][j] == 'X') { + return 1; + } + else return 2; + } + } } \ No newline at end of file From 46ae979f08ff3c39ead782c4187b01db9989c6c2 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:23:03 +0100 Subject: [PATCH 107/160] test_isColumnFull --- src/test/c/test_VierGewinnt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/c/test_VierGewinnt.c b/src/test/c/test_VierGewinnt.c index efe7a13..1f14b9f 100644 --- a/src/test/c/test_VierGewinnt.c +++ b/src/test/c/test_VierGewinnt.c @@ -135,3 +135,17 @@ char board[6][7] = { TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'X')); // Kein Gewinner, horizontale Reihe ist voll TEST_ASSERT_EQUAL_INT(0, checkWin(board, 'O')); // Kein Gewinner, horizontale Reihe ist voll } + +void test_isColumnFull(void) { + char board[6][7] = { + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'}, + {'X', 'O', 'X', 'O', 'X', 'O', 'X'}, + {'O', 'X', 'O', 'X', 'O', 'X', 'O'} + }; + + TEST_ASSERT_EQUAL_INT(1, isColumnFull(board, 3)); // Column 3 is full +} + From 8b7146705acce6a764bc2b0b9901d3c1e7d4d7e1 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 15:26:03 +0100 Subject: [PATCH 108/160] 10 vierter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index fc12b42..57809a8 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -56,6 +56,22 @@ void test_TicTacToe_Winner_X_line_3(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_col_1(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'O', 'X', 'X'}, + {'O', 'O', '_'}, + {'O', '_', '_'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 6a30e7372ca7ea669dcffe32357123c608c31048 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 15:28:06 +0100 Subject: [PATCH 109/160] =?UTF-8?q?11=20f=C3=BCnfter=20Test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index 57809a8..d65895b 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -72,6 +72,22 @@ void test_TicTacToe_Winner_O_col_1(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_X_col_2(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'O', 'X', 'X'}, + {'_', 'X', 'O'}, + {'O', 'X', '_'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From ff4961c714bd5b80b2078734227002a5e69e34e5 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:33:31 +0100 Subject: [PATCH 110/160] refactoring: change function name from showInvalidInputMessage() int showInvalidInputWarning() --- src/main/c/VierGewinnt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index c4d1419..ee289c8 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -49,7 +49,7 @@ int checkDiagonalRL(char board[ROWS][COLS], char player); // Funktionsprototyp für showMessage void showMessage(const char* messageColor, const char* message); //Funktionsprototyp für showInvalidInputMessage -void showInvalidInputMessage(); +void showInvalidInputWarning(); //Funktionsprototyp für showColumnFullMessage void showColumnFullMessage(); @@ -72,7 +72,7 @@ int main_function() { scanf("%d", &column); if (column < 1 || column > 7) { - showInvalidInputMessage(); + showInvalidInputWarning(); continue; } @@ -233,7 +233,7 @@ void showMessage(const char* messageColor, const char* message) { } // Write showInvalidInputMessage function -void showInvalidInputMessage() { +void showInvalidInputWarning() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } From 802e23fa9bc627e49f4fea738cc39896f2cbb0a7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:36:35 +0100 Subject: [PATCH 111/160] refactoring: Ausgabetext Anpassen --- src/main/c/VierGewinnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index ee289c8..f91b268 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -242,7 +242,7 @@ void showInvalidInputWarning() { // Write showColumnFullMessage function void showColumnFullMessage() { - showMessage(RED, "Die Spalte ist voll. Bitte wähle eine andere.\n"); + showMessage(RED, "Die ausgewählte Spalte ist bereits belegt. Bitte wähle eine andere Spalte aus.\n"); } From 241aa5116b64d44149dc1d3f1ee9bd24d4052836 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:41:20 +0100 Subject: [PATCH 112/160] =?UTF-8?q?refactoring:=20Funktionsprototypen=20An?= =?UTF-8?q?passen=20und=20unn=C3=B6tige=20Kommentare=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index f91b268..65613cf 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -17,44 +17,18 @@ #define CYAN "\033[0;36m" #define WHITE "\033[0;37m" - -//Funktionsprototyp für initializeBoard +//Funktionsprototypen void initializeBoard(char board[ROWS][COLS]); - -//Funktionsprototyp für printBoard void printBoard(char board[ROWS][COLS]); - -// Funktionsprototyp für clearScreen void clearScreen(); - -//Funktionsprototyp für isColumnFull int isColumnFull(char board[ROWS][COLS], int col); - -//Funktionsprototyp für dropPiece int dropPiece(char board[ROWS][COLS], int col, char player); -//Funktionsprototyp für checkWin int checkWin(char board[ROWS][COLS], char player); -// Funktionsprototyp für checkHorizontal int checkHorizontal(char board[ROWS][COLS], char player); - -// Funktionsprototyp für checkVertical int checkVertical(char board[ROWS][COLS], char player); - -// Funktionsprototyp für checkDiagonalLR -int checkDiagonalLR(char board[ROWS][COLS], char player); - -// Funktionsprototyp für checkDiagonalRL int checkDiagonalRL(char board[ROWS][COLS], char player); - -// Funktionsprototyp für showMessage -void showMessage(const char* messageColor, const char* message); -//Funktionsprototyp für showInvalidInputMessage void showInvalidInputWarning(); - -//Funktionsprototyp für showColumnFullMessage void showColumnFullMessage(); - -//Funktionsprototyp für showWinMessage void showWinMessage(int player); From 651527c3bbe9472dc9521e19108853483de185e6 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:43:33 +0100 Subject: [PATCH 113/160] =?UTF-8?q?refactoring:=20unn=C3=B6tige=20Kommenta?= =?UTF-8?q?re=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 65613cf..88b2b33 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -32,10 +32,9 @@ void showColumnFullMessage(); void showWinMessage(int player); -//Write starter function int main_function() { char board[ROWS][COLS]; - int currentPlayer = 1; // Spieler 1 beginnt + int currentPlayer = 1; initializeBoard(board); printBoard(board); @@ -70,7 +69,6 @@ int main_function() { return 0; } -// Write initializeBoard function void initializeBoard(char board[ROWS][COLS]) { for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLS; j++) { @@ -80,7 +78,6 @@ void initializeBoard(char board[ROWS][COLS]) { } -// Write printBoard function void printBoard(char board[ROWS][COLS]) { clearScreen(); printf("\n"); @@ -99,7 +96,6 @@ void printBoard(char board[ROWS][COLS]) { printf(" 1 2 3 4 5 6 7\n\n"); } -// Write clearScreen function void clearScreen() { #ifdef _WIN32 system("cls"); @@ -108,12 +104,10 @@ void clearScreen() { #endif } -// Write isColumnFull function int isColumnFull(char board[ROWS][COLS], int col) { return (board[0][col] != ' '); } -//Write dropPiece function int dropPiece(char board[ROWS][COLS], int col, char player) { for (int i = ROWS - 1; i >= 0; i--) { if (board[i][col] == ' ') { @@ -122,11 +116,10 @@ int dropPiece(char board[ROWS][COLS], int col, char player) { } } - return 0; // Column is full + return 0; } -// Write checkHorizontal function int checkHorizontal(char board[ROWS][COLS], char player) { for (int row = 0; row < ROWS; row++) { for (int col = 0; col <= COLS - 4; col++) { @@ -134,14 +127,13 @@ int checkHorizontal(char board[ROWS][COLS], char player) { board[row][col + 1] == player && board[row][col + 2] == player && board[row][col + 3] == player) { - return 1; // Gewonnen + return 1; } } } return 0; } -//Write checkVertical function int checkVertical(char board[ROWS][COLS], char player) { for (int col = 0; col < COLS; col++) { for (int row = 0; row <= ROWS - 4; row++) { @@ -149,7 +141,7 @@ int checkVertical(char board[ROWS][COLS], char player) { board[row + 1][col] == player && board[row + 2][col] == player && board[row + 3][col] == player) { - return 1; // Gewonnen + return 1; } } } @@ -158,7 +150,6 @@ int checkVertical(char board[ROWS][COLS], char player) { -// Write checkDiagonalLR function int checkDiagonalLR(char board[ROWS][COLS], char player) { for (int row = 0; row <= ROWS - 4; row++) { for (int col = 0; col <= COLS - 4; col++) { @@ -166,7 +157,7 @@ int checkDiagonalLR(char board[ROWS][COLS], char player) { board[row + 1][col + 1] == player && board[row + 2][col + 2] == player && board[row + 3][col + 3] == player) { - return 1; // Gewonnen + return 1; } } } @@ -176,7 +167,6 @@ int checkDiagonalLR(char board[ROWS][COLS], char player) { -// Write checkDiagonalRL function int checkDiagonalRL(char board[ROWS][COLS], char player) { for (int row = 0; row <= ROWS - 4; row++) { for (int col = 3; col < COLS; col++) { @@ -184,7 +174,7 @@ int checkDiagonalRL(char board[ROWS][COLS], char player) { board[row + 1][col - 1] == player && board[row + 2][col - 2] == player && board[row + 3][col - 3] == player) { - return 1; // Gewonnen + return 1; } } } @@ -192,7 +182,6 @@ int checkDiagonalRL(char board[ROWS][COLS], char player) { } -// Write checkWin function int checkWin(char board[ROWS][COLS], char player) { return checkHorizontal(board, player) || checkVertical(board, player) || @@ -201,12 +190,10 @@ int checkWin(char board[ROWS][COLS], char player) { } -// Write showMessage function void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } -// Write showInvalidInputMessage function void showInvalidInputWarning() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } @@ -214,14 +201,12 @@ void showInvalidInputWarning() { -// Write showColumnFullMessage function void showColumnFullMessage() { showMessage(RED, "Die ausgewählte Spalte ist bereits belegt. Bitte wähle eine andere Spalte aus.\n"); } -// Write showWinMessage function void showWinMessage(int player) { printf("Spieler %d hat gewonnen!\n", player); } From e4024a180d839af04327e00ad6ea77d4d13431c3 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 15:47:08 +0100 Subject: [PATCH 114/160] =?UTF-8?q?refactoring:=20=C3=84ndere=20variabel?= =?UTF-8?q?=20currentPlayer=20zu=20=20Player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 88b2b33..711d018 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -34,14 +34,14 @@ void showWinMessage(int player); int main_function() { char board[ROWS][COLS]; - int currentPlayer = 1; + int Player = 1; initializeBoard(board); printBoard(board); int column; while (1) { - printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, currentPlayer); + printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, Player); scanf("%d", &column); if (column < 1 || column > 7) { @@ -56,14 +56,14 @@ int main_function() { continue; } - if (dropPiece(board, column, (currentPlayer == 1) ? 'X' : 'O')) { + if (dropPiece(board, column, (Player == 1) ? 'X' : 'O')) { printBoard(board); - if (checkWin(board, (currentPlayer == 1) ? 'X' : 'O')) { - showWinMessage(currentPlayer); + if (checkWin(board, (Player == 1) ? 'X' : 'O')) { + showWinMessage(Player); break; } - currentPlayer = (currentPlayer == 1) ? 2 : 1; + Player = (Player == 1) ? 2 : 1; } } From 382719583bd68c52c438b2a3fd0a25a6a4c684e4 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:03:50 +0100 Subject: [PATCH 115/160] =?UTF-8?q?refactoring:=20F=C3=BCge=20fdai-Nummer?= =?UTF-8?q?=20als=20Kommentar=20im=20Code=20f=C3=BCr=20Support=20hinzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 711d018..a9bfaa0 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -1,3 +1,5 @@ +// Author fdai7726 + //Importiere wichtige Bibliotheken #include #include From af94b552d42d531c34c80df69749694aa45a0cd7 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:10:57 +0100 Subject: [PATCH 116/160] =?UTF-8?q?refactoring:=20Spiel=20Beschreibung=20a?= =?UTF-8?q?ls=20Kommentar=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index a9bfaa0..e6b84cc 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -1,5 +1,17 @@ // Author fdai7726 +/* +*Ein Vier-Gewinnt-Spiel, das in der Kommandozeile gespielt wird. +*Das Programm ermöglicht es zwei Spielern, abwechselnd Steine in eine Spalte zu setzen, +*um eine Reihe von vier Steinen horizontal, +*vertikal oder diagonal zu bilden und das Spiel zu gewinnen. +*Das Spielfeld wird grafisch in der Kommandozeile dargestellt, +*und das Programm überprüft automatisch, +*ob einer der Spieler gewonnen hat oder ob das Spielfeld voll ist. + */ + + + //Importiere wichtige Bibliotheken #include #include From a7cff576b79eebb61a1f8a93eaa9dce62280c352 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:15:55 +0100 Subject: [PATCH 117/160] =?UTF-8?q?refactoring:=20Gewinner=20Nachrricht=20?= =?UTF-8?q?=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/VierGewinnt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index e6b84cc..44b22ee 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -222,7 +222,8 @@ void showColumnFullMessage() { void showWinMessage(int player) { - printf("Spieler %d hat gewonnen!\n", player); +printf("Spieler %d ist der Gewinner!\n", player); + } From 7a8cd52f0d93e9dfe5d3a9debef99c43debe7070 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:17:39 +0100 Subject: [PATCH 118/160] refactoring: Funktion showMessage beschreiben --- src/main/c/VierGewinnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index 44b22ee..a8609ca 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -203,7 +203,7 @@ int checkWin(char board[ROWS][COLS], char player) { checkDiagonalRL(board, player); } - +// Die Funktion showMessage gibt eine formatierte Nachricht aus, wobei die Farbe der Nachricht dynamisch festgelegt werden kann. void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } From 3b75ec27be04597cc58e9d1bdaf276f1a1e3534c Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 16:22:30 +0100 Subject: [PATCH 119/160] refactoring: Beschreibung der Funktion showInvalidInputWarning() --- src/main/c/VierGewinnt.c | 2 ++ src/main/c/a.out | Bin 0 -> 10336 bytes 2 files changed, 2 insertions(+) create mode 100755 src/main/c/a.out diff --git a/src/main/c/VierGewinnt.c b/src/main/c/VierGewinnt.c index a8609ca..2072110 100644 --- a/src/main/c/VierGewinnt.c +++ b/src/main/c/VierGewinnt.c @@ -208,6 +208,8 @@ void showMessage(const char* messageColor, const char* message) { printf("%s%s"RESET_COLOR, messageColor, message); } +//Die Funktion showInvalidInputWarning zeigt eine Warnung für ungültige Benutzereingaben an. Sie ruft die Funktion showMessage auf, um die Nachricht in roter Farbe auszugeben, die den Benutzer darüber informiert, dass die Eingabe ungültig ist und er eine Spalte zwischen 1 und 7 wählen soll. + void showInvalidInputWarning() { showMessage(RED, "Ungültige Eingabe. Bitte wähle eine Spalte zwischen 1 und 7.\n"); } diff --git a/src/main/c/a.out b/src/main/c/a.out new file mode 100755 index 0000000000000000000000000000000000000000..b6a2002109ba2d4eef443ffc2d731c453a0436f7 GIT binary patch literal 10336 zcmc&)e{5XGao)R=B8sFW>X$8&mic5$2$@>P<8RS!VM?S_%B2mLavTLw@OZp?BCk5$ zo!=cTS(0HkG7trJP+uV=0-RP#;2@Ndp!&msNx+EhC_o(42FDuh-rUkH@sCb`~Ew=}HHFp_~n$D$k zh8-bP!^ zX|Fl^Og86?H4i6J&B;XSgyVL$6D#%qc|6pg{i(Q{PQ($FO1Z6_!yunIwM4oj-7T#= z%AZ-yGC{I)%Q94{4XfZ3o-6S`unOL`3f{d6u2j(TkNg-=J>cc=SFsH=Yl4cySNnM# z5bB3aA!JRm?POv&W+zgKoU-lMsi+;zIj3~Nbw&~xKo`jIw0lBj+(asOTxDa?6yADl z6$yv4X*F>8K(A_!M{`m0ilxWG5FHyo)qFgWbh6FkSrmj52(dgkhqPvF^x(ACNs4%IiEXOe=fU+l#R5GZ z+&kaCm>RkEMlzQeajb)h)JSyL30nsextwF2y!Ogy(y^RG%CU}QqDerfPbRXlQ72`! zSmUX<)fKK(eF?{kj%P<4%?=)B#UNS3j_V|HSaKd_ShjV*h- znjW;kJf`+!_hfaZEMt+;Fv$9I=VT(4a@<{&MsdrS+KWW44Ah4ndIfYVo(J%H12hBr zA?Wj<^PrbO*I;n3g6;s_ylyy*E%_-Jl?**R)YA z1bxKRx3_O&q`!J+&EE(A4nagR6ecgCejC*z5jKE_Fp{T4*btrzz@(ksDCh9J1T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yn%U>x*)# z>{f7j*b_m|&?EVUoO<4qzz=LL}`UP?l7r&o%7UBRyiA1oZ@ s`9wtvkF+oI?_Yt5?Z}qWdEP(XEFmT%?Fu}P%u4bTyl=F9^T#j$-$UwV$N&HU literal 0 HcmV?d00001 From 36ba25bcdae6b6d0293e91a5a46e354fc652421e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 16:59:34 +0100 Subject: [PATCH 120/160] 12 sechster Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index d65895b..f0d5ab7 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -88,6 +88,22 @@ void test_TicTacToe_Winner_X_col_2(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_col_3(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'X', 'X', 'O'}, + {'_', 'O', 'O'}, + {'_', '_', 'O'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From 47eadc816640b331792e8bbf545c6eb3fb7e5fe4 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:01:40 +0100 Subject: [PATCH 121/160] 13 win condition diagonal --- src/main/c/TicTacToe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 035d6c4..14e960e 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -44,4 +44,13 @@ int Winner(char Feld[3][3]) { else return 2; } } + // Überprüfen Diagonalen + if ((Feld[0][0] == Feld[1][1] && Feld[1][1] == Feld[2][2]) || (Feld[0][2] == Feld[1][1] && Feld[1][1] == Feld[2][0])) { + if (Feld[1][1] != '_') { + if (Feld[1][1] == 'X') { + return 1; + } + else return 2; + } + } } \ No newline at end of file From cb7a7bc6682401d132f5734543df7d29ef286fed Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:04:28 +0100 Subject: [PATCH 122/160] 14 siebter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index f0d5ab7..0dc4844 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -104,6 +104,22 @@ void test_TicTacToe_Winner_O_col_3(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_X_diagonal_1(void) +{ + /* arrange */ + int expected = 1; + int actual; + char board[3][3] = { + {'X', 'O', 'X'}, + {'O', 'X', 'O'}, + {'O', '_', 'X'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From f1d5198ae9bcb40bb4f20ef9383d687cb4d662db Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:05:25 +0100 Subject: [PATCH 123/160] 15 achter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index 0dc4844..fd80b53 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -120,6 +120,22 @@ void test_TicTacToe_Winner_X_diagonal_1(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_Winner_O_diagonal_2(void) +{ + /* arrange */ + int expected = 2; + int actual; + char board[3][3] = { + {'O', 'X', 'O'}, + {'X', 'O', 'X'}, + {'O', '_', '_'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From c021ee3a8829b5e933776d571aa5f4ad99d0ab8e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:08:24 +0100 Subject: [PATCH 124/160] 16 check round --- src/main/c/TicTacToe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 14e960e..72f52ae 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -53,4 +53,13 @@ int Winner(char Feld[3][3]) { else return 2; } } + //Überprüfe Runde + for (int k = 0; k < 3; k++) { + for (int l = 0; l < 3; l++) { + if (Feld[k][l] == '_') { + return 9; + } + } + } + } \ No newline at end of file From 95e096b756294ba49e793686dc453ad9103ff86e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:15:00 +0100 Subject: [PATCH 125/160] 17 neuneter Test --- src/test/c/test_TicTacToe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index fd80b53..53292e3 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -136,6 +136,22 @@ void test_TicTacToe_Winner_O_diagonal_2(void) /* act */ actual = Winner(board); + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} +void test_TicTacToe_mid_Round(void) +{ + /* arrange */ + int expected = 9; + int actual; + char board[3][3] = { + {'X', 'X', 'O'}, + {'_', 'O', 'X'}, + {'_', '_', 'O'} + }; + /* act */ + actual = Winner(board); + /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); } \ No newline at end of file From f9c88ccc940acd3ed5eef5eb6e029a1545c7bc16 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:16:21 +0100 Subject: [PATCH 126/160] 18 win condition Tie --- src/main/c/TicTacToe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 72f52ae..29ac1fe 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -61,5 +61,7 @@ int Winner(char Feld[3][3]) { } } } - + //Bestätige Unendschieden + printf("Es ist ein Unendschieden\n"); + return 0; } \ No newline at end of file From 32a05ff7eb3c9393b5a77eb0bde1a83bdcd5721c Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:17:22 +0100 Subject: [PATCH 127/160] 19 letzter Test --- src/test/c/test_TicTacToe.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/test/c/test_TicTacToe.c b/src/test/c/test_TicTacToe.c index 53292e3..a6e0cf9 100644 --- a/src/test/c/test_TicTacToe.c +++ b/src/test/c/test_TicTacToe.c @@ -62,18 +62,18 @@ void test_TicTacToe_Winner_X_line_3(void) void test_TicTacToe_Winner_O_col_1(void) { /* arrange */ - int expected = 2; - int actual; - char board[3][3] = { - {'O', 'X', 'X'}, - {'O', 'O', '_'}, - {'O', '_', '_'} - }; + int expected = 2; + int actual; + char board[3][3] = { + {'O', 'X', 'X'}, + {'O', 'O', '_'}, + {'O', '_', '_'} + }; /* act */ - actual = Winner(board); + actual = Winner(board); /* assert */ - TEST_ASSERT_EQUAL_INT(expected, actual); + TEST_ASSERT_EQUAL_INT(expected, actual); } void test_TicTacToe_Winner_X_col_2(void) { @@ -154,4 +154,20 @@ void test_TicTacToe_mid_Round(void) /* assert */ TEST_ASSERT_EQUAL_INT(expected, actual); -} \ No newline at end of file +} +void test_TicTacToe_Tie(void) +{ + /* arrange */ + int expected = 0; + int actual; + char board[3][3] = { + {'X', 'X', 'O'}, + {'O', 'O', 'X'}, + {'X', 'X', 'O'} + }; + /* act */ + actual = Winner(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} From 35fa2b71ffe3a19040104ba1a1e96d7a0eefce73 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:20:01 +0100 Subject: [PATCH 128/160] 20 move O --- src/main/c/TicTacToe.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 29ac1fe..024f326 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -3,6 +3,7 @@ #include #include +int Zaehler = 1; // Funktion, um das Spielfeld zu initialisieren void Brett(char Feld[3][3]) { for (int i = 0; i < 3; i++) { @@ -64,4 +65,11 @@ int Winner(char Feld[3][3]) { //Bestätige Unendschieden printf("Es ist ein Unendschieden\n"); return 0; +} +void Zuege(char Feld[3][3], int row, int col) { + if (Zaehler % 2 == 0) { + if (Feld[row][col] == '_') { + Feld[row][col] = 'O'; + } + } } \ No newline at end of file From 334825f98783cd8bdf6c839b0f2bfad2be0d2a09 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:20:41 +0100 Subject: [PATCH 129/160] 21 move X --- src/main/c/TicTacToe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 024f326..d46d3b3 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -69,7 +69,12 @@ int Winner(char Feld[3][3]) { void Zuege(char Feld[3][3], int row, int col) { if (Zaehler % 2 == 0) { if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; + Feld[row][col] = 'O'; + } + } + else { + if (Feld[row][col] == '_') { + Feld[row][col] = 'X'; } } } \ No newline at end of file From 1e3ebab6949aa66754f42f06481e68ff810b0d5d Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:22:16 +0100 Subject: [PATCH 130/160] 22 belegtes Feld O --- src/main/c/TicTacToe.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index d46d3b3..17f75bb 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -71,6 +71,14 @@ void Zuege(char Feld[3][3], int row, int col) { if (Feld[row][col] == '_') { Feld[row][col] = 'O'; } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } else { if (Feld[row][col] == '_') { From 6052ef0c2db46e057aa3d43dfa7098c44ae6b851 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:22:56 +0100 Subject: [PATCH 131/160] 23 belegtes Feld X --- src/main/c/TicTacToe.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 17f75bb..c4de506 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -25,7 +25,8 @@ void Bild(char Feld[3][3]) { printf("\n"); } } -int Winner(char Feld[3][3]) { +int Winner +(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { @@ -69,7 +70,7 @@ int Winner(char Feld[3][3]) { void Zuege(char Feld[3][3], int row, int col) { if (Zaehler % 2 == 0) { if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; + Feld[row][col] = 'O'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); @@ -84,5 +85,13 @@ void Zuege(char Feld[3][3], int row, int col) { if (Feld[row][col] == '_') { Feld[row][col] = 'X'; } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } } \ No newline at end of file From 6f0245fd3b47f6a558700093d84b9d850f165af9 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:24:23 +0100 Subject: [PATCH 132/160] 24 start Hauptfunktion --- src/main/c/TicTacToe.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index c4de506..ed21c57 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -25,8 +25,7 @@ void Bild(char Feld[3][3]) { printf("\n"); } } -int Winner -(char Feld[3][3]) { +int Winner(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { @@ -94,4 +93,21 @@ void Zuege(char Feld[3][3], int row, int col) { Zuege(Feld, row, col); } } +} +// Hauptfunktion zum Spielen des Tic Tac Toe-Spiels +int mainx() { + int row; + int col; + char Feld[3][3]; + Brett(Feld); + Bild(Feld); + if (Zaehler % 2 != 0) { + printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + } + else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); } \ No newline at end of file From 0eb3a3f1a62b7d3dbc85f6bf000c2fa128851960 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:25:26 +0100 Subject: [PATCH 133/160] 25 Nachfrage optimiert --- src/main/c/TicTacToe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index ed21c57..8f3df43 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -105,8 +105,10 @@ int mainx() { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); row -= 1; col -= 1; Zuege(Feld, row, col); From e24ce5f87f651fe51971bf00f021a4ac7dcf4d33 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:58:01 +0100 Subject: [PATCH 134/160] =?UTF-8?q?26=20Runde=20Z=C3=A4hlen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 8f3df43..0622484 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -112,4 +112,5 @@ int mainx() { row -= 1; col -= 1; Zuege(Feld, row, col); + Zaehler++; } \ No newline at end of file From 67c2f31ce4307dbf745e871398494e726c50f314 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:58:55 +0100 Subject: [PATCH 135/160] =?UTF-8?q?27=20mehr=20Z=C3=BCge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 0622484..37879ef 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -101,16 +101,19 @@ int mainx() { char Feld[3][3]; Brett(Feld); Bild(Feld); - if (Zaehler % 2 != 0) { - printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + while (Winner(Feld) == 9) { + Bild(Feld); + if (Zaehler % 2 != 0) { + printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + } + else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + Zaehler++; } - else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); - printf("Reihe:"); - scanf("%d", &row); - printf("Spalte:"); - scanf("%d", &col); - row -= 1; - col -= 1; - Zuege(Feld, row, col); - Zaehler++; -} \ No newline at end of file +} From 08c90fe18d2ab44f37424493108a6cb59dd4d836 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 17:59:47 +0100 Subject: [PATCH 136/160] 28 Sieger bestimmen --- src/main/c/TicTacToe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 37879ef..c8a72fb 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -116,4 +116,6 @@ int mainx() { Zuege(Feld, row, col); Zaehler++; } + Bild(Feld); + Winner(Feld); } From ce7048da4332ab1099d52d39b37eabafc870c02b Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:01:14 +0100 Subject: [PATCH 137/160] 29 Feldrand --- src/main/c/TicTacToe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index c8a72fb..67733fd 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -113,6 +113,12 @@ int mainx() { scanf("%d", &col); row -= 1; col -= 1; + if (row > 3 || col > 3) { + printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); + scanf("%d %d", &row, &col); + row -= 1; //Für Index eins kleiner + col -= 1; + } Zuege(Feld, row, col); Zaehler++; } From 563b1a9860719d1afda45ccfbaba01d237be31a9 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:03:32 +0100 Subject: [PATCH 138/160] 30 mehr Spiele --- src/main/c/TicTacToe.c | 53 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 67733fd..aa06372 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -99,29 +99,36 @@ int mainx() { int row; int col; char Feld[3][3]; - Brett(Feld); - Bild(Feld); - while (Winner(Feld) == 9) { - Bild(Feld); - if (Zaehler % 2 != 0) { - printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); - } - else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); - printf("Reihe:"); - scanf("%d", &row); - printf("Spalte:"); - scanf("%d", &col); - row -= 1; - col -= 1; - if (row > 3 || col > 3) { - printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); - scanf("%d %d", &row, &col); - row -= 1; //Für Index eins kleiner + char Nochmal[50] = { "Weiter" }; + + while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { + Zaehler = 1; + Brett(Feld); + while (Winner(Feld) == 9) { + + Bild(Feld); + if (Zaehler % 2 != 0) { + printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); + } + else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); + row -= 1; col -= 1; + if (row > 3 || col > 3) { + printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); + scanf("%d %d", &row, &col); + row -= 1; //Für Index eins kleiner + col -= 1; + } + Zuege(Feld, row, col); + Zaehler++; } - Zuege(Feld, row, col); - Zaehler++; + Bild(Feld); + Winner(Feld); + printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); + scanf("%s", Nochmal); } - Bild(Feld); - Winner(Feld); -} +} \ No newline at end of file From 5b25802ccc428833e062aeac35826a134c93ed3a Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:05:57 +0100 Subject: [PATCH 139/160] =?UTF-8?q?31=20Z=C3=BCge=20O=20optimiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index aa06372..983e125 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -67,30 +67,34 @@ int Winner(char Feld[3][3]) { return 0; } void Zuege(char Feld[3][3], int row, int col) { - if (Zaehler % 2 == 0) { - if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; - } - else { - printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); - row -= 1; - col -= 1; - Zuege(Feld, row, col); - } - } - else { - if (Feld[row][col] == '_') { - Feld[row][col] = 'X'; + if (Zaehler < 10) { + if (Zaehler % 2 == 0) { + if (Feld[row][col] == '_') { + Feld[row][col] = 'O'; + } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } else { - printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); - row -= 1; - col -= 1; - Zuege(Feld, row, col); + if (Feld[row][col] == '_') { + Feld[row][col] = 'X'; + } + else { + printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); + printf("[Reihe Spalte]:"); + scanf("%d %d"); + row -= 1; + col -= 1; + Zuege(Feld, row, col); + } } } } @@ -131,4 +135,5 @@ int mainx() { printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } + return 0; } \ No newline at end of file From 51683ecbbc9b6cf27861b4addf5175cc446ef6d2 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:07:06 +0100 Subject: [PATCH 140/160] =?UTF-8?q?32=20Z=C3=BCge=20X=20optimiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 983e125..beda977 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -89,8 +89,10 @@ void Zuege(char Feld[3][3], int row, int col) { } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); - printf("[Reihe Spalte]:"); - scanf("%d %d"); + printf("Reihe:"); + scanf("%d", &row); + printf("Spalte:"); + scanf("%d", &col); row -= 1; col -= 1; Zuege(Feld, row, col); From fc06f65bf6c9a89fb905966e52af3859e0950b3a Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:08:55 +0100 Subject: [PATCH 141/160] 33 Spieler Name --- src/main/c/TicTacToe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index beda977..a544052 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -105,8 +105,10 @@ int mainx() { int row; int col; char Feld[3][3]; + char Spieler1[50], Spieler2[50]; char Nochmal[50] = { "Weiter" }; - + printf("Name der Spieler\[Spieler 1 Spieler2]\n"); + scanf("%s %s", Spieler1, Spieler2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); From 90ace1c085933fd0d9f2f5903ee1b3888bdafa17 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:11:32 +0100 Subject: [PATCH 142/160] =?UTF-8?q?34=20Begr=C3=BC=C3=9Fung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index a544052..e5b7a7f 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -112,6 +112,7 @@ int mainx() { while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); + printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(Feld) == 9) { Bild(Feld); From b68205c26bf6a7307196cfc13995ed511d45ff49 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:12:59 +0100 Subject: [PATCH 143/160] 35 Sieger ausgabe --- src/main/c/TicTacToe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index e5b7a7f..0b8c6a1 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -136,7 +136,9 @@ int mainx() { Zaehler++; } Bild(Feld); - Winner(Feld); + if (Winner(Feld) == 1) { + printf("Der Sieger ist %s", Spieler1); + } printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } From 4fb35bfa936378f6766a912b18b57af6a9522c79 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:14:19 +0100 Subject: [PATCH 144/160] 36 Sieger ausgabe 2 --- src/main/c/TicTacToe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 0b8c6a1..a67fb06 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -139,6 +139,9 @@ int mainx() { if (Winner(Feld) == 1) { printf("Der Sieger ist %s", Spieler1); } + else if (Winner(Feld) == 2) { + printf("Der Sieger ist %s", Spieler2); + } printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } From 97ba4fb289d694223db75790acb506f8165a0bb2 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:17:19 +0100 Subject: [PATCH 145/160] 37 Punktestand --- src/main/c/TicTacToe.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index a67fb06..4b50623 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -106,9 +106,12 @@ int mainx() { int col; char Feld[3][3]; char Spieler1[50], Spieler2[50]; + int Punkte1 = 0, Punkte2 = 0; char Nochmal[50] = { "Weiter" }; - printf("Name der Spieler\[Spieler 1 Spieler2]\n"); - scanf("%s %s", Spieler1, Spieler2); + printf("Name Spieler 1:"); + scanf("%s", Spieler1); + printf("Name Spieler 2:"); + scanf("%s", Spieler2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); @@ -138,10 +141,13 @@ int mainx() { Bild(Feld); if (Winner(Feld) == 1) { printf("Der Sieger ist %s", Spieler1); + Punkte1++; } else if (Winner(Feld) == 2) { printf("Der Sieger ist %s", Spieler2); + Punkte2++; } + printf("%s - %d, %s - %d\n", Spieler1, Punkte1, Spieler2, Punkte2); printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); scanf("%s", Nochmal); } From 49644b1093d32be9be29fd5ce8dd7ec92f412b34 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:18:07 +0100 Subject: [PATCH 146/160] 38 Entscheidung Zeichen --- src/main/c/TicTacToe.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 4b50623..7c7075a 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -107,14 +107,19 @@ int mainx() { char Feld[3][3]; char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; + char Name1[50], Name2[50]; char Nochmal[50] = { "Weiter" }; printf("Name Spieler 1:"); - scanf("%s", Spieler1); + scanf("%s", Name1); printf("Name Spieler 2:"); - scanf("%s", Spieler2); + scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Zaehler = 1; Brett(Feld); + printf("%s, Was willst du sein, X oder O: ", Name1); + scanf("%s", Spieler1); + strcpy(Spieler2, (Spieler1[0] == 'X') ? Name2 : Name1); + strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(Feld) == 9) { From 4e9e07b59d0809f57ff7a5a7860f3373bd171868 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:19:33 +0100 Subject: [PATCH 147/160] 39 Auswahl begrenzt --- src/main/c/TicTacToe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 7c7075a..d92fbbf 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -118,6 +118,10 @@ int mainx() { Brett(Feld); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); + if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { + printf("Ungültige Auswahl. Das Spiel wird beendet.\n"); + break; + } strcpy(Spieler2, (Spieler1[0] == 'X') ? Name2 : Name1); strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); From 9c15212cd2f38063e909734b1fadf068680669c6 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:20:34 +0100 Subject: [PATCH 148/160] 40 Farbe definieren --- src/main/c/TicTacToe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index d92fbbf..a01df1b 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -3,6 +3,11 @@ #include #include +#define ANSI_COLOR_BRIGHT_RED "\x1b[91m" +#define ANSI_COLOR_BRIGHT_CYAN "\x1b[96m" +#define ANSI_COLOR_BRIGHT_YELLOW "\x1b[93m" +#define ANSI_COLOR_RESET "\x1b[0m" + int Zaehler = 1; // Funktion, um das Spielfeld zu initialisieren void Brett(char Feld[3][3]) { From e9c0a6ec86c96daae68477edb92e3b629dd85803 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:21:29 +0100 Subject: [PATCH 149/160] =?UTF-8?q?41=20Text=20einf=C3=A4rben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/TicTacToe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index a01df1b..c1f9a33 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -25,7 +25,15 @@ void Bild(char Feld[3][3]) { #endif for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - printf("%c ", Feld[i][j]); + if (Feld[i][j] == '_') { + printf(ANSI_COLOR_BRIGHT_YELLOW"%c "ANSI_COLOR_RESET, Feld[i][j]); + } + else if (Feld[i][j] == 'X') { + printf(ANSI_COLOR_BRIGHT_CYAN"%c "ANSI_COLOR_RESET, Feld[i][j]); + } + else { + printf(ANSI_COLOR_BRIGHT_RED"%c "ANSI_COLOR_RESET, Feld[i][j]); + } } printf("\n"); } From c202ab47be1bd9a9783104e164c592c4dd64122e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:24:04 +0100 Subject: [PATCH 150/160] refactoring: Zaehler -> Runde --- src/main/c/TicTacToe.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index c1f9a33..8bbd2da 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -8,7 +8,7 @@ #define ANSI_COLOR_BRIGHT_YELLOW "\x1b[93m" #define ANSI_COLOR_RESET "\x1b[0m" -int Zaehler = 1; +int Runde = 1; // Funktion, um das Spielfeld zu initialisieren void Brett(char Feld[3][3]) { for (int i = 0; i < 3; i++) { @@ -80,8 +80,8 @@ int Winner(char Feld[3][3]) { return 0; } void Zuege(char Feld[3][3], int row, int col) { - if (Zaehler < 10) { - if (Zaehler % 2 == 0) { + if (Runde < 10) { + if (Runde % 2 == 0) { if (Feld[row][col] == '_') { Feld[row][col] = 'O'; } @@ -127,7 +127,7 @@ int mainx() { printf("Name Spieler 2:"); scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { - Zaehler = 1; + Runde = 1; Brett(Feld); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); @@ -139,9 +139,8 @@ int mainx() { strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(Feld) == 9) { - Bild(Feld); - if (Zaehler % 2 != 0) { + if (Runde % 2 != 0) { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } else printf("Spieler 2 gebe das Feld an wo du dein O setzen willst.\n"); @@ -158,7 +157,7 @@ int mainx() { col -= 1; } Zuege(Feld, row, col); - Zaehler++; + Runde++; } Bild(Feld); if (Winner(Feld) == 1) { From 5eb24ac8e0f8ea27c31fd8e6edd2c0f0ad17a365 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:26:21 +0100 Subject: [PATCH 151/160] refactoring: Brett -> initializeBoard --- src/main/c/TicTacToe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 8bbd2da..517be63 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -10,7 +10,7 @@ int Runde = 1; // Funktion, um das Spielfeld zu initialisieren -void Brett(char Feld[3][3]) { +void initializeBoard(char Feld[3][3]) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Feld[i][j] = '_'; @@ -38,6 +38,7 @@ void Bild(char Feld[3][3]) { printf("\n"); } } + int Winner(char Feld[3][3]) { // Überprüfen Sieg // Überprüfen Reihen @@ -128,7 +129,7 @@ int mainx() { scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Runde = 1; - Brett(Feld); + initializeBoard(Feld); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { From b6a62a29618d4acb06aa7d95cb6daf55f35abafd Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:27:07 +0100 Subject: [PATCH 152/160] refactoring: Feld -> board --- src/main/c/TicTacToe.c | 66 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 517be63..2c87b2a 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -9,15 +9,15 @@ #define ANSI_COLOR_RESET "\x1b[0m" int Runde = 1; -// Funktion, um das Spielfeld zu initialisieren -void initializeBoard(char Feld[3][3]) { +// Funktion, um das Spielboard zu initialisieren +void initializeBoard(char board[3][3]) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - Feld[i][j] = '_'; + board[i][j] = '_'; } } } -void Bild(char Feld[3][3]) { +void Bild(char board[3][3]) { #ifdef _WIN32 system("cls"); #else @@ -25,26 +25,26 @@ void Bild(char Feld[3][3]) { #endif for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - if (Feld[i][j] == '_') { - printf(ANSI_COLOR_BRIGHT_YELLOW"%c "ANSI_COLOR_RESET, Feld[i][j]); + if (board[i][j] == '_') { + printf(ANSI_COLOR_BRIGHT_YELLOW"%c "ANSI_COLOR_RESET, board[i][j]); } - else if (Feld[i][j] == 'X') { - printf(ANSI_COLOR_BRIGHT_CYAN"%c "ANSI_COLOR_RESET, Feld[i][j]); + else if (board[i][j] == 'X') { + printf(ANSI_COLOR_BRIGHT_CYAN"%c "ANSI_COLOR_RESET, board[i][j]); } else { - printf(ANSI_COLOR_BRIGHT_RED"%c "ANSI_COLOR_RESET, Feld[i][j]); + printf(ANSI_COLOR_BRIGHT_RED"%c "ANSI_COLOR_RESET, board[i][j]); } } printf("\n"); } } -int Winner(char Feld[3][3]) { +int Winner(char board[3][3]) { // Überprüfen Sieg // Überprüfen Reihen for (int i = 0; i < 3; i++) { - if (Feld[i][0] == Feld[i][1] && Feld[i][1] == Feld[i][2] && Feld[i][0] != '_') { - if (Feld[i][0] == 'X') { + if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != '_') { + if (board[i][0] == 'X') { return 1; } else return 2; @@ -52,17 +52,17 @@ int Winner(char Feld[3][3]) { } // Überprüfen Spalten for (int j = 0; j < 3; j++) { - if (Feld[0][j] == Feld[1][j] && Feld[1][j] == Feld[2][j] && Feld[0][j] != '_') { - if (Feld[0][j] == 'X') { + if (board[0][j] == board[1][j] && board[1][j] == board[2][j] && board[0][j] != '_') { + if (board[0][j] == 'X') { return 1; } else return 2; } } // Überprüfen Diagonalen - if ((Feld[0][0] == Feld[1][1] && Feld[1][1] == Feld[2][2]) || (Feld[0][2] == Feld[1][1] && Feld[1][1] == Feld[2][0])) { - if (Feld[1][1] != '_') { - if (Feld[1][1] == 'X') { + if ((board[0][0] == board[1][1] && board[1][1] == board[2][2]) || (board[0][2] == board[1][1] && board[1][1] == board[2][0])) { + if (board[1][1] != '_') { + if (board[1][1] == 'X') { return 1; } else return 2; @@ -71,7 +71,7 @@ int Winner(char Feld[3][3]) { //Überprüfe Runde for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { - if (Feld[k][l] == '_') { + if (board[k][l] == '_') { return 9; } } @@ -80,11 +80,11 @@ int Winner(char Feld[3][3]) { printf("Es ist ein Unendschieden\n"); return 0; } -void Zuege(char Feld[3][3], int row, int col) { +void Zuege(char board[3][3], int row, int col) { if (Runde < 10) { if (Runde % 2 == 0) { - if (Feld[row][col] == '_') { - Feld[row][col] = 'O'; + if (board[row][col] == '_') { + board[row][col] = 'O'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); @@ -94,12 +94,12 @@ void Zuege(char Feld[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(Feld, row, col); + Zuege(board, row, col); } } else { - if (Feld[row][col] == '_') { - Feld[row][col] = 'X'; + if (board[row][col] == '_') { + board[row][col] = 'X'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); @@ -109,7 +109,7 @@ void Zuege(char Feld[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(Feld, row, col); + Zuege(board, row, col); } } } @@ -118,7 +118,7 @@ void Zuege(char Feld[3][3], int row, int col) { int mainx() { int row; int col; - char Feld[3][3]; + char board[3][3]; char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; char Name1[50], Name2[50]; @@ -129,7 +129,7 @@ int mainx() { scanf("%s", Name2); while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { Runde = 1; - initializeBoard(Feld); + initializeBoard(board); printf("%s, Was willst du sein, X oder O: ", Name1); scanf("%s", Spieler1); if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { @@ -139,8 +139,8 @@ int mainx() { strcpy(Spieler2, (Spieler1[0] == 'X') ? Name2 : Name1); strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); - while (Winner(Feld) == 9) { - Bild(Feld); + while (Winner(board) == 9) { + Bild(board); if (Runde % 2 != 0) { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } @@ -157,15 +157,15 @@ int mainx() { row -= 1; //Für Index eins kleiner col -= 1; } - Zuege(Feld, row, col); + Zuege(board, row, col); Runde++; } - Bild(Feld); - if (Winner(Feld) == 1) { + Bild(board); + if (Winner(board) == 1) { printf("Der Sieger ist %s", Spieler1); Punkte1++; } - else if (Winner(Feld) == 2) { + else if (Winner(board) == 2) { printf("Der Sieger ist %s", Spieler2); Punkte2++; } From 36e4e5f55d28f202296a93d89f09e88a1e46ac2e Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:27:50 +0100 Subject: [PATCH 153/160] refactoring: Bild -> displayBoard --- src/main/c/TicTacToe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 2c87b2a..422b99b 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -17,7 +17,7 @@ void initializeBoard(char board[3][3]) { } } } -void Bild(char board[3][3]) { +void displayBoard(char board[3][3]) { #ifdef _WIN32 system("cls"); #else @@ -140,7 +140,7 @@ int mainx() { strcpy(Spieler1, (Spieler1[0] == 'X') ? Name1 : Name2); printf("\nWillkommen %s und %s. Eure Runde Beginnt jetzt.", Spieler1, Spieler2); while (Winner(board) == 9) { - Bild(board); + displayBoard(board); if (Runde % 2 != 0) { printf("Spieler 1 gebe das Feld an wo du dein X setzen willst.\n"); } @@ -160,7 +160,7 @@ int mainx() { Zuege(board, row, col); Runde++; } - Bild(board); + displayBoard(board); if (Winner(board) == 1) { printf("Der Sieger ist %s", Spieler1); Punkte1++; From 4d2a421e44f2f6e8236b605607884591d453543c Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:28:41 +0100 Subject: [PATCH 154/160] refactoring: Zuege -> makeMove --- src/main/c/TicTacToe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 422b99b..01f704b 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -80,7 +80,7 @@ int Winner(char board[3][3]) { printf("Es ist ein Unendschieden\n"); return 0; } -void Zuege(char board[3][3], int row, int col) { +void makeMove(char board[3][3], int row, int col) { if (Runde < 10) { if (Runde % 2 == 0) { if (board[row][col] == '_') { @@ -94,7 +94,7 @@ void Zuege(char board[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(board, row, col); + makeMove(board, row, col); } } else { @@ -109,7 +109,7 @@ void Zuege(char board[3][3], int row, int col) { scanf("%d", &col); row -= 1; col -= 1; - Zuege(board, row, col); + makeMove(board, row, col); } } } @@ -157,7 +157,7 @@ int mainx() { row -= 1; //Für Index eins kleiner col -= 1; } - Zuege(board, row, col); + makeMove(board, row, col); Runde++; } displayBoard(board); From d08e371c2e6d83f74db85752db6c9a84da6632a8 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:30:17 +0100 Subject: [PATCH 155/160] refactoring: Nochmal -> Ende --- src/main/c/TicTacToe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 01f704b..6ee5c0e 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -122,12 +122,12 @@ int mainx() { char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; char Name1[50], Name2[50]; - char Nochmal[50] = { "Weiter" }; + char Ende[50] = { "Weiter" }; printf("Name Spieler 1:"); scanf("%s", Name1); printf("Name Spieler 2:"); scanf("%s", Name2); - while (Nochmal[0] == 'W' || Nochmal[0] == 'w') { + while (Ende[0] == 'W' || Ende[0] == 'w') { Runde = 1; initializeBoard(board); printf("%s, Was willst du sein, X oder O: ", Name1); @@ -171,7 +171,7 @@ int mainx() { } printf("%s - %d, %s - %d\n", Spieler1, Punkte1, Spieler2, Punkte2); printf("Wollt ihr weiter spielen?\n[Weiter]\n[Ende]\n"); - scanf("%s", Nochmal); + scanf("%s", Ende); } return 0; } \ No newline at end of file From f246f8284abd6ae3a487f4b2f56202c8b6b3ea62 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:31:44 +0100 Subject: [PATCH 156/160] refactoring: Main Name --- src/main/c/TicTacToe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index 6ee5c0e..bdcfcc4 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -115,7 +115,7 @@ void makeMove(char board[3][3], int row, int col) { } } // Hauptfunktion zum Spielen des Tic Tac Toe-Spiels -int mainx() { +int TicTacToe_ausfuehren() { int row; int col; char board[3][3]; From e481b36abdf214c629d05904bc1f8654b3d4f94b Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:32:23 +0100 Subject: [PATCH 157/160] refactoring: col -> column --- src/main/c/TicTacToe.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index bdcfcc4..baf3643 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -80,36 +80,36 @@ int Winner(char board[3][3]) { printf("Es ist ein Unendschieden\n"); return 0; } -void makeMove(char board[3][3], int row, int col) { +void makeMove(char board[3][3], int row, int column) { if (Runde < 10) { if (Runde % 2 == 0) { - if (board[row][col] == '_') { - board[row][col] = 'O'; + if (board[row][column] == '_') { + board[row][column] = 'O'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); printf("Reihe:"); scanf("%d", &row); printf("Spalte:"); - scanf("%d", &col); + scanf("%d", &column); row -= 1; - col -= 1; - makeMove(board, row, col); + column -= 1; + makeMove(board, row, column); } } else { - if (board[row][col] == '_') { - board[row][col] = 'X'; + if (board[row][column] == '_') { + board[row][column] = 'X'; } else { printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); printf("Reihe:"); scanf("%d", &row); printf("Spalte:"); - scanf("%d", &col); + scanf("%d", &column); row -= 1; - col -= 1; - makeMove(board, row, col); + column -= 1; + makeMove(board, row, column); } } } @@ -117,7 +117,7 @@ void makeMove(char board[3][3], int row, int col) { // Hauptfunktion zum Spielen des Tic Tac Toe-Spiels int TicTacToe_ausfuehren() { int row; - int col; + int column; char board[3][3]; char Spieler1[50], Spieler2[50]; int Punkte1 = 0, Punkte2 = 0; @@ -148,16 +148,16 @@ int TicTacToe_ausfuehren() { printf("Reihe:"); scanf("%d", &row); printf("Spalte:"); - scanf("%d", &col); + scanf("%d", &column); row -= 1; - col -= 1; - if (row > 3 || col > 3) { + column -= 1; + if (row > 3 || column > 3) { printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); - scanf("%d %d", &row, &col); + scanf("%d %d", &row, &column); row -= 1; //Für Index eins kleiner - col -= 1; + column -= 1; } - makeMove(board, row, col); + makeMove(board, row, column); Runde++; } displayBoard(board); From 8c61a7db7dfd73675f3496d496a025d5ebc830e5 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:34:18 +0100 Subject: [PATCH 158/160] refactoring: print rename --- src/main/c/TicTacToe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/c/TicTacToe.c b/src/main/c/TicTacToe.c index baf3643..8ce9661 100644 --- a/src/main/c/TicTacToe.c +++ b/src/main/c/TicTacToe.c @@ -130,7 +130,7 @@ int TicTacToe_ausfuehren() { while (Ende[0] == 'W' || Ende[0] == 'w') { Runde = 1; initializeBoard(board); - printf("%s, Was willst du sein, X oder O: ", Name1); + printf("%s, Was willst du sein?\n[X/O]\n", Name1); scanf("%s", Spieler1); if (Spieler1[0] != 'X' && Spieler1[0] != 'O') { printf("Ungültige Auswahl. Das Spiel wird beendet.\n"); From 9adde5c98e58b9a196fc4fbc98a45d26c2fe97a4 Mon Sep 17 00:00:00 2001 From: Simon Hildebrandt Date: Wed, 7 Feb 2024 18:35:57 +0100 Subject: [PATCH 159/160] Header aktualisiert --- src/main/c/TicTacToe.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/c/TicTacToe.h b/src/main/c/TicTacToe.h index 1e04a7d..645d5c3 100644 --- a/src/main/c/TicTacToe.h +++ b/src/main/c/TicTacToe.h @@ -1,7 +1,11 @@ #ifndef TICTACTOE_H #define TICTACTOE_H +void initializeBoard(char board[3][3]); +void displayBoard(char board[3][3]); int Winner(char board[3][3]); +void makeMove(char board[3][3], int row, int col); +int TicTacToe_ausfuehren(); #endif From 8aea03cf9826bf6db11a2dcfd9dbe91656befc02 Mon Sep 17 00:00:00 2001 From: fdai7726 Date: Wed, 7 Feb 2024 17:48:21 +0000 Subject: [PATCH 160/160] Delete a.out --- src/main/c/a.out | Bin 10336 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 src/main/c/a.out diff --git a/src/main/c/a.out b/src/main/c/a.out deleted file mode 100755 index b6a2002109ba2d4eef443ffc2d731c453a0436f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10336 zcmc&)e{5XGao)R=B8sFW>X$8&mic5$2$@>P<8RS!VM?S_%B2mLavTLw@OZp?BCk5$ zo!=cTS(0HkG7trJP+uV=0-RP#;2@Ndp!&msNx+EhC_o(42FDuh-rUkH@sCb`~Ew=}HHFp_~n$D$k zh8-bP!^ zX|Fl^Og86?H4i6J&B;XSgyVL$6D#%qc|6pg{i(Q{PQ($FO1Z6_!yunIwM4oj-7T#= z%AZ-yGC{I)%Q94{4XfZ3o-6S`unOL`3f{d6u2j(TkNg-=J>cc=SFsH=Yl4cySNnM# z5bB3aA!JRm?POv&W+zgKoU-lMsi+;zIj3~Nbw&~xKo`jIw0lBj+(asOTxDa?6yADl z6$yv4X*F>8K(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