Compare commits
3 Commits
4041e9ee9b
...
c95c264a3a
| Author | SHA1 | Date | |
|---|---|---|---|
| c95c264a3a | |||
|
|
147fc502eb | ||
| 27eafd14cc |
@ -37,17 +37,21 @@ int main(int argc, char *argv[])
|
||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||
|
||||
// Check if all words were successfully placed
|
||||
// Start the game if successful
|
||||
// error message if some words couldn't be placed
|
||||
|
||||
if (placedWords < wordCount)
|
||||
{
|
||||
fprintf(stderr, "some words couldn't be placed\n");
|
||||
exitCode = EXIT_FAILURE;
|
||||
int notPlacedNum = wordCount - placedWords;
|
||||
fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum);
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
|
||||
@ -16,9 +16,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
// set seed for random number generator
|
||||
srand(time(NULL));
|
||||
|
||||
int r, c;
|
||||
int r, c, placedWords=0;
|
||||
|
||||
//Gesamtes Feld auf 0 setzen
|
||||
//Gesamtes Feld auf 0 setzen, am besten in eigene Fkt, dann aber extra Tests dafür erstellen
|
||||
for (r=0; r < searchFieldLen; r++) {
|
||||
for (c=0; c < searchFieldLen; c++) {
|
||||
salad [r][c] = EMPTY_CHAR;
|
||||
@ -33,7 +33,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
//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
|
||||
//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
|
||||
for (r=0; r < searchFieldLen; r++) {
|
||||
for (c=0; c < searchFieldLen; c++) {
|
||||
if (salad[r][c] == EMPTY_CHAR) {
|
||||
@ -41,8 +41,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
//return "Anzahl platzierter Wörter", wird in Main dann mit soll verglichen
|
||||
return placedWords;
|
||||
}
|
||||
|
||||
// Prints the word salad to console
|
||||
|
||||
@ -37,17 +37,21 @@ int main(int argc, char *argv[])
|
||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||
|
||||
// Check if all words were successfully placed
|
||||
// Start the game if successful
|
||||
// error message if some words couldn't be placed
|
||||
|
||||
if (placedWords < wordCount)
|
||||
{
|
||||
fprintf(stderr, "some words couldn't be placed\n");
|
||||
exitCode = EXIT_FAILURE;
|
||||
int notPlacedNum = wordCount - placedWords;
|
||||
fprintf(stderr, "%d word(s) couldn't be placed\n", notPlacedNum);
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user