Compare commits

..

No commits in common. "c95c264a3ac2513871d134feac435abae0544094" and "4041e9ee9bcb5d2c6797b282762a0d15f551e6bf" have entirely different histories.

3 changed files with 16 additions and 24 deletions

View File

@ -37,21 +37,17 @@ int main(int argc, char *argv[])
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// Check if all words were successfully placed // Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed // error message if some words couldn't be placed
if (placedWords < wordCount) if (placedWords < wordCount)
{ {
int notPlacedNum = wordCount - placedWords; fprintf(stderr, "some words couldn't be placed\n");
fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum); exitCode = EXIT_FAILURE;
} }
// TODO: // TODO:
// correct parameters for startGame // Start the game if successful
// Start the game if at least 1 word has been successfully placed
else if (placedWords >= 1)
{
startGame(wordSalad, 80, words, placedWords, 800);
}
} }
else else
{ {

View File

@ -16,9 +16,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
// set seed for random number generator // set seed for random number generator
srand(time(NULL)); srand(time(NULL));
int r, c, placedWords=0; int r, c;
//Gesamtes Feld auf 0 setzen, am besten in eigene Fkt, dann aber extra Tests dafür erstellen //Gesamtes Feld auf 0 setzen
for (r=0; r < searchFieldLen; r++) { for (r=0; r < searchFieldLen; r++) {
for (c=0; c < searchFieldLen; c++) { for (c=0; c < searchFieldLen; c++) {
salad [r][c] = EMPTY_CHAR; salad [r][c] = EMPTY_CHAR;
@ -31,9 +31,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
dir = (rand() % 2 == 0) ? HORIZONTAL : VERTIKAL; dir = (rand() % 2 == 0) ? HORIZONTAL : VERTIKAL;
//Schleife, die das Setzen für alle Wörter durchführt, Zufällig horizontal(0) oder vertikal(1), an zufällige Stelle //Schleife, die das Setzen für alle Wörter durchführt, Zufällig horizontal(0) oder vertikal(1), an zufällige Stelle
//Prüfen, ob das Wort von der Länge her ins Feld passt //Prüfen, ob das Wort von der Länge her ins Feld passt
//Felder, in denen keine Wörter stehen, werden mit zufälligen Buchstaben befüllt, am besten in eigene Fkt, dann aber extra Tests dafür erstellen
//Felder, in denen keine Wörter stehen, werden mit zufälligen Buchstaben befüllt
for (r=0; r < searchFieldLen; r++) { for (r=0; r < searchFieldLen; r++) {
for (c=0; c < searchFieldLen; c++) { for (c=0; c < searchFieldLen; c++) {
if (salad[r][c] == EMPTY_CHAR) { if (salad[r][c] == EMPTY_CHAR) {
@ -41,8 +41,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
} }
} }
} }
//return "Anzahl platzierter Wörter", wird in Main dann mit soll verglichen
return placedWords; return 0;
} }
// Prints the word salad to console // Prints the word salad to console

View File

@ -37,21 +37,17 @@ int main(int argc, char *argv[])
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// Check if all words were successfully placed // Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed // error message if some words couldn't be placed
if (placedWords < wordCount) if (placedWords < wordCount)
{ {
int notPlacedNum = wordCount - placedWords; fprintf(stderr, "some words couldn't be placed\n");
fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum); exitCode = EXIT_FAILURE;
} }
// TODO: // TODO:
// correct parameters for startGame // Start the game if successful
// Start the game if at least 1 word has been successfully placed
else if (placedWords >= 1)
{
startGame(wordSalad, 80, words, placedWords, 800);
}
} }
else else
{ {