|
@ -1,33 +1,67 @@ |
|
|
#include "word_selector.h" |
|
|
#include "word_selector.h" |
|
|
|
|
|
#include "playHangman.h" |
|
|
|
|
|
|
|
|
const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|
|
|
|
|
"skill", |
|
|
|
|
|
|
|
|
// easy words |
|
|
|
|
|
const char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|
|
|
|
|
"apple", |
|
|
"world", |
|
|
"world", |
|
|
"difference", |
|
|
|
|
|
"celebration", |
|
|
|
|
|
"association", |
|
|
|
|
|
"customer", |
|
|
|
|
|
|
|
|
"banana", |
|
|
|
|
|
"cat", |
|
|
|
|
|
"lemon", |
|
|
|
|
|
"dog", |
|
|
"mood", |
|
|
"mood", |
|
|
"agreement", |
|
|
|
|
|
"audience", |
|
|
|
|
|
"professor", |
|
|
|
|
|
|
|
|
"orange", |
|
|
|
|
|
"kite", |
|
|
|
|
|
"nest", |
|
|
"year", |
|
|
"year", |
|
|
"dealer", |
|
|
|
|
|
"patience", |
|
|
|
|
|
"table tennis", |
|
|
|
|
|
"pollution", |
|
|
|
|
|
"awareness", |
|
|
|
|
|
|
|
|
"grape", |
|
|
|
|
|
"sun", |
|
|
|
|
|
"mouse", |
|
|
|
|
|
"tennis", |
|
|
|
|
|
"queen", |
|
|
"problem", |
|
|
"problem", |
|
|
"vehicle", |
|
|
"vehicle", |
|
|
"death", |
|
|
"death", |
|
|
"cousin" |
|
|
"cousin" |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const char* selectRandomWord() { |
|
|
|
|
|
|
|
|
// hard words |
|
|
|
|
|
const char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|
|
|
|
|
"database", |
|
|
|
|
|
"programming", |
|
|
|
|
|
"mountain", |
|
|
|
|
|
"customer", |
|
|
|
|
|
"table tennis", |
|
|
|
|
|
"customer", |
|
|
|
|
|
"laughter", |
|
|
|
|
|
"expression", |
|
|
|
|
|
"audience", |
|
|
|
|
|
"professor", |
|
|
|
|
|
"twilight", |
|
|
|
|
|
"dealer", |
|
|
|
|
|
"symphony", |
|
|
|
|
|
"table tennis", |
|
|
|
|
|
"pollution", |
|
|
|
|
|
"inspiration", |
|
|
|
|
|
"supermarket", |
|
|
|
|
|
"difficulty", |
|
|
|
|
|
"budget", |
|
|
|
|
|
"quarter" |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const char* selectRandomWord(int difficulty) { |
|
|
|
|
|
|
|
|
// pick a random number and assign it to index of wordsList array |
|
|
|
|
|
|
|
|
// pick a random number and assign it to index of wordsList_easy array |
|
|
srand((unsigned int)time(NULL)); |
|
|
srand((unsigned int)time(NULL)); |
|
|
int randomIndex = rand() % NUM_WORDS; |
|
|
int randomIndex = rand() % NUM_WORDS; |
|
|
|
|
|
|
|
|
return wordsList[randomIndex]; |
|
|
|
|
|
|
|
|
switch(difficulty){ |
|
|
|
|
|
case 1: |
|
|
|
|
|
return wordsList_easy[randomIndex]; |
|
|
|
|
|
case 2: |
|
|
|
|
|
return wordsList_hard[randomIndex]; |
|
|
|
|
|
default: |
|
|
|
|
|
printf("Invalid difficulty level. Using easy difficulty.\n"); |
|
|
|
|
|
return wordsList_easy[randomIndex]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |