Commit 94d899c4 authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Fix anagram creation duplicating letters when word is short.

Thanks to <walch.martin@web.de> for the patch.

BUG:334107
FIXED-IN: 4.13.1
parent 9f9390d8
......@@ -261,21 +261,26 @@ void KanagramGame::restoreWord()
void KanagramGame::createAnagram()
{
QString anagram;
QString letters;
int randomIndex;
do {
letters = m_originalWord;
while (!letters.isEmpty())
{
randomIndex = m_random.getLong(letters.count());
anagram.append(letters.at(randomIndex));
letters.remove(randomIndex, 1);
}
} while (anagram == m_originalWord);
m_anagram = anagram;
if (m_originalWord.count(m_originalWord.at(0)) < m_originalWord.size()) {
QString anagram;
QString letters;
int randomIndex;
do {
anagram.clear();
letters = m_originalWord;
while (!letters.isEmpty())
{
randomIndex = m_random.getLong(letters.count());
anagram.append(letters.at(randomIndex));
letters.remove(randomIndex, 1);
}
} while (anagram == m_originalWord);
m_anagram = anagram;
} else {
m_anagram = m_originalWord;
}
}
QString KanagramGame::documentTitle() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment