Пример #1
0
// starts test
void WMain::test(unsigned howmany, bool intoforeign, bool include, bool ignoreSynonyms) {
	// prepare test variables
	setMode(testMode);
	this->howmany = howmany;
	this->countdown = howmany;
	this->intoforeign = intoforeign;
	this->include = include;
	this->ignoreSynonyms = ignoreSynonyms;
	this->answered = true;
	this->hintsize = 1;
	this->caseSensitive = QSettings("dicto.ini", QSettings::IniFormat).value("testing/case_sensitive").value<bool>();
	
	// reset all words to unpassed
	for(unsigned i=0; i<dictionarySize(); i++) cDocument->dictionary[i].passed = false;
	
	// prepare test queue
	testQueue.clear();
	int i;
	for(i=0; i<howmany; i++) {
		int newWord = pickWord(include);
		if(newWord == -1) {
			setMode(normalMode);
			updateStatusbar();
			break;
		}
		testQueue.enqueue(&cDocument->dictionary[newWord]);
		cDocument->dictionary[newWord].passed = true;
	}
	if(testQueue.empty()) { // not supposed to happen
		endTest(true, tr("No words match your criteria"));
		return;
	}
	check();
}
Пример #2
0
/**
*Sneaky Part!
*Changes the word when the user guesses correctly
*updates the vector with the possible equivalances
*@returns true if the word is changed
*/
bool Hangman::changeWord(){
	int position = bestPosition();
	update(position);
	hangManWord = pickWord();
	if(position!=-1){
		for(int i=0;i<hangManWord.length();i++){
			if(hangManWord[i]==guessedLetter){
				answer[i] = guessedLetter;
				guessedCorrect++;
			}
		}
	}
	
	return position==-1;
}