don't exit if some words couldn't be placed

This commit is contained in:
Simon Wiesend 2025-10-31 12:42:54 +01:00
parent 147fc502eb
commit c95c264a3a
No known key found for this signature in database
GPG Key ID: 711FA2FAE3A80C81
2 changed files with 18 additions and 10 deletions

View File

@ -37,17 +37,21 @@ 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)
{ {
fprintf(stderr, "some words couldn't be placed\n"); int notPlacedNum = wordCount - placedWords;
exitCode = EXIT_FAILURE; fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum);
} }
// TODO: // TODO:
// Start the game if successful // correct parameters for startGame
// 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

@ -37,17 +37,21 @@ 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)
{ {
fprintf(stderr, "some words couldn't be placed\n"); int notPlacedNum = wordCount - placedWords;
exitCode = EXIT_FAILURE; fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum);
} }
// TODO: // TODO:
// Start the game if successful // correct parameters for startGame
// Start the game if at least 1 word has been successfully placed
else if (placedWords >= 1)
{
startGame(wordSalad, 80, words, placedWords, 800);
}
} }
else else
{ {