implemented input.c (fails unit test, wegen Groß/Kleinschreibung) und game.c tests sind jetzt ok

This commit is contained in:
sengpielto106561 committed 2026-10-26 17:22:23 +01:00
1 parent ce4be9f902
commit 029eb426ab
2 files changed
+32 -15

No files matched your search

+7 -15
View File
@@ -31,17 +31,11 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
//Iterate over words
unsigned int counter = 0;
while(counter < wordCount){
//load current word
char currentWord[MAX_WORD_LEN];
if(strncpy(currentWord, words[counter], MAX_WORD_LEN) == NULL){
//strncpy failed
continue;
}
size_t len = strlen(currentWord);
size_t len = strlen(words[counter]);
//try to place a word
int try = 0;
while(try < 10){
for(int try = 0; try < 10; try++){
int x = rand() % MAX_SEARCH_FIELD_LEN;
int y = rand() % MAX_SEARCH_FIELD_LEN;
@@ -50,7 +44,6 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
if ((MAX_SEARCH_FIELD_LEN - x) < len){
if((MAX_SEARCH_FIELD_LEN - y) < len){
// cant place word here (too far in the bottom right corner)
try++;
continue;
}
}
@@ -62,7 +55,6 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
for (int i = 0; i < (int)len; i++){
if(salad[x][y+i] != '0'){
cont = true;
try++;
break;
}
}
@@ -70,12 +62,12 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
if(cont) continue;
//insert currentWord into playing field
for (int i = 0; i < (int)len; i++){
salad[x][y+i] = currentWord[i];
salad[x][y+i] = words[counter][i];
}
placedWords++;
counter++;
break;
}
//place currentWord horizontally
//see if all neccessary spaces are emtry
@@ -83,7 +75,6 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
for (int i = 0; i < (int)len; i++){
if(salad[x+1][y] != '0'){
cont = true;
try++;
break;
}
}
@@ -93,9 +84,10 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
//place currentWord
for (int i = 0; i < (int)len; i++){
salad[x+1][y] = currentWord[i];
salad[x+1][y] = words[counter][i];
}
placedWords++;
counter++;
}
}
for (int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){