This commit is contained in:
pvtrx 2025-11-07 07:49:35 +01:00
parent 2255a7f02f
commit 6bcf871acd
3 changed files with 6 additions and 5 deletions

View File

@ -84,7 +84,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
}
}
printf("Words aborted: %d\n", wordsaborted);
return wordsplaced;
return wordsaborted;;
}
// Prints the word salad to console

View File

@ -10,6 +10,7 @@
int main(int argc, char *argv[])
{
int exitCode = EXIT_SUCCESS;
int wordsaborted;
// Check if the correct number of arguments is provided
if(argc != 2)
@ -34,13 +35,13 @@ int main(int argc, char *argv[])
fclose(file);
// Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
wordsaborted = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// Start game if all valid words were placed
if (placedWords == wordCount) {
if (wordsaborted == 0) {
startGame(wordSalad, SALAD_SIZE, words, wordCount, 750);
} else {
printf("Could not place all valid words. Placed %d out of %d words.\n", placedWords, wordCount);
printf("Could not place all valid words. Placed %d out of %d words.\n", wordCount - wordsaborted, wordCount);
}
}

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "unity.h"
#include "unity/unity.h"
#include "input.h"
#include "game.h"