generated from freudenreichan/info2Praktikum-Wortsalat
game.c verkürzung
This commit is contained in:
1 parent
7a7062a925
commit
62da76ef4f
1 file changed
+6
-9
+6
-9
@@ -2,7 +2,6 @@
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h> //für toupper
|
||||
|
||||
#define MAX_RAND_TRIES_PER_WORD 10
|
||||
#define EMPTY_CHAR 0
|
||||
@@ -21,7 +20,7 @@ void fillRandLetters(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], uns
|
||||
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||
{
|
||||
fillArrayEmpty(salad, searchFieldLen);
|
||||
|
||||
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
int numberWords = 0;
|
||||
@@ -79,7 +78,7 @@ int placeWords(unsigned int searchFieldLen, const char *wort, int platzierung, i
|
||||
{
|
||||
size_t len = strnlen(wort, MAX_WORD_LEN);
|
||||
|
||||
if ((size_t)xKoord + len > searchFieldLen) //Addition da unsigned int
|
||||
if ((size_t)xKoord + len > searchFieldLen) // Addition da unsigned int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -87,8 +86,7 @@ int placeWords(unsigned int searchFieldLen, const char *wort, int platzierung, i
|
||||
for (size_t j = 0; j < len; j++)
|
||||
{
|
||||
char c = salad[yKoord][xKoord + j];
|
||||
char w = (char)toupper((unsigned char)wort[j]); //Umwandlung in Großbuchstaben
|
||||
if (c != EMPTY_CHAR && c != w)
|
||||
if (c != EMPTY_CHAR)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -96,7 +94,7 @@ int placeWords(unsigned int searchFieldLen, const char *wort, int platzierung, i
|
||||
|
||||
for (size_t j = 0; j < len; j++)
|
||||
{
|
||||
salad[yKoord][xKoord + j] = (char)toupper((unsigned char)wort[j]); //Umwandlung in Großbuchstaben
|
||||
salad[yKoord][xKoord + j] = wort[j];
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -114,8 +112,7 @@ int placeWords(unsigned int searchFieldLen, const char *wort, int platzierung, i
|
||||
for (size_t j = 0; j < len; j++)
|
||||
{
|
||||
char c = salad[yKoord + j][xKoord];
|
||||
char w = (char)toupper((unsigned char)wort[j]);
|
||||
if (c != EMPTY_CHAR && c != w)
|
||||
if (c != EMPTY_CHAR)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -123,7 +120,7 @@ int placeWords(unsigned int searchFieldLen, const char *wort, int platzierung, i
|
||||
|
||||
for (size_t j = 0; j < len; j++)
|
||||
{
|
||||
salad[yKoord + j][xKoord] = (char)toupper((unsigned char)wort[j]);
|
||||
salad[yKoord + j][xKoord] = wort[j];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in new issue
Block a user