User insert
This commit is contained in:
parent
5a9bee22fe
commit
136451c53b
@ -63,6 +63,15 @@ unsigned int Boggle::getPointsForWord(const std::string &word) {
|
||||
return std::min(pointsForValidWord, 0);
|
||||
}
|
||||
|
||||
bool Boggle::userInsert(std::string word){
|
||||
bool existsAlready = std::find(m_playedWords.begin(), m_playedWords.end(), word) != m_playedWords.end();
|
||||
if (existsAlready)
|
||||
return false;
|
||||
|
||||
m_playedWords.push_back(std::move(word));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> Boggle::computerPlay() const {
|
||||
std::unordered_set<std::string> visited;
|
||||
std::vector<std::string> valiWords;
|
||||
|
@ -29,6 +29,12 @@ public:
|
||||
bool isWordLongEnough(const std::string &word) const;
|
||||
bool isWordPlayed(const std::string &word) const;
|
||||
static unsigned int getPointsForWord(const std::string &word);
|
||||
|
||||
/**
|
||||
* @brief userInsert saves the users word
|
||||
* @return false if the word is already inserted
|
||||
*/
|
||||
bool userInsert(std::string word);
|
||||
/**
|
||||
* @brief computerPlay calculates all possible english words which can be
|
||||
* formed from the Lexicon recursivly
|
||||
@ -41,6 +47,7 @@ private:
|
||||
std::unordered_set<string> &visited, std::string &word) const;
|
||||
|
||||
private:
|
||||
// This is kept as a vector since there's max 16 words
|
||||
std::vector<std::string> m_playedWords;
|
||||
std::array<std::string, g_NUM_ROLLED_CUBES> m_showingSides;
|
||||
Lexicon m_englishWords;
|
||||
|
Loading…
Reference in New Issue
Block a user