diff --git a/Startcode/game.c b/Startcode/game.c index a0ee4a7..9a475f2 100644 --- a/Startcode/game.c +++ b/Startcode/game.c @@ -5,6 +5,7 @@ #define MAX_RAND_TRIES_PER_WORD 10 #define EMPTY_CHAR 0 +#define WORTLAENGE strlen(words[i]) //TODO: Spiellogik implementieren: /* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren @@ -41,19 +42,19 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi Platzierungsrichtung zufaellige_richtung = rand() % 2; - if(zufaellige_richtung == vertikal && strlen(words[i]) <= (searchFieldLen-y)) + if(zufaellige_richtung == vertikal && (WORTLAENGE <= (searchFieldLen-y))) { int check = 0; - for(int k = 0; k < strlen(words[i]); k++) + for(int k = 0; k < WORTLAENGE; k++) { if(salad[y+k][x] == '0' || salad[y+k][x] == words[i][k]) { check ++; } } - if(check == strlen(words[i])) + if(check == WORTLAENGE) { - for(int j = 0; j < strlen(words[i]); j++) + for(int j = 0; j < WORTLAENGE; j++) { salad[y+j][x] = words[i][j]; } @@ -62,10 +63,10 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi } } - else if( zufaellige_richtung == horizontal && strlen(words[i]) <= (searchFieldLen-x)) + else if( zufaellige_richtung == horizontal && WORTLAENGE <= (searchFieldLen-x)) { int check = 0; - for(int k = 0; k < strlen(words[i]); k++) + for(int k = 0; k < WORTLAENGE; k++) { if(salad[y][x+k] == '0' || salad[y][x+k] == words[i][k]) { @@ -73,9 +74,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi } } - if(check == strlen(words[i])) + if(check == WORTLAENGE) { - for(int j = 0; j < strlen(words[i]); j++) + for(int j = 0; j < WORTLAENGE; j++) { salad[y][x+j] = words[i][j]; @@ -93,7 +94,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi { if(salad[i][j] == '0') { - salad[i][j] = rand() % (90-65+1)+ 65; + salad[i][j] = rand() % (90-65+1)+ 65; //Großbuchstaben } } } diff --git a/Startcode/input.c b/Startcode/input.c index cf9a133..101f7a0 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -25,7 +25,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) } strncpy(words[wordCount], token, MAX_WORD_LEN -1); //speichert einzelnes Wort in das gegeben word array ab und holt sich das nächste im Puffer, bis array leer token == NULL - //words[wordCount][MAX_WORD_LEN - 1] = '\0'; wordCount++;