More hungarian notation
https://en.wikipedia.org/wiki/Hungarian_notation
This commit is contained in:
parent
1d70b1b3ce
commit
6500a8f87f
@ -15,40 +15,40 @@
|
|||||||
|
|
||||||
// The res folder isn't copied the same way on macOS
|
// The res folder isn't copied the same way on macOS
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
const std::string Boggle::DICTIONARY_FILE = "../../../EnglishWords.dat";
|
const std::string Boggle::s_DICTIONARY_FILE = "../../../EnglishWords.dat";
|
||||||
#else
|
#else
|
||||||
const std::string Boggle::DICTIONARY_FILE = "EnglishWords.dat";
|
const std::string Boggle::DICTIONARY_FILE = "EnglishWords.dat";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const int NUM_CUBES = 16; // the number of cubes in the game
|
static const int g_NUM_CUBES = 16; // the number of cubes in the game
|
||||||
static const int CUBE_SIDES = 6; // the number of sides on each cube
|
static const int g_CUBE_SIDES = 6; // the number of sides on each cube
|
||||||
static std::string CUBES[NUM_CUBES] =
|
static std::string g_CUBES[g_NUM_CUBES] =
|
||||||
{ // the letters on all 6 sides of every cube
|
{ // the letters on all 6 sides of every cube
|
||||||
"AAEEGN", "ABBJOO", "ACHOPS", "AFFKPS", "AOOTTW", "CIMOTU",
|
"AAEEGN", "ABBJOO", "ACHOPS", "AFFKPS", "AOOTTW", "CIMOTU",
|
||||||
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
|
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
|
||||||
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};
|
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};
|
||||||
|
|
||||||
std::array<std::string, NUM_ROLLED_CUBES> rollSides() {
|
std::array<std::string, g_NUM_ROLLED_CUBES> rollSides() {
|
||||||
// Intermediate array to shuffle
|
// Intermediate array to shuffle
|
||||||
std::array<std::string, NUM_CUBES> cubes;
|
std::array<std::string, g_NUM_CUBES> cubes;
|
||||||
std::copy(std::begin(CUBES), std::end(CUBES), cubes.begin());
|
std::copy(std::begin(g_CUBES), std::end(g_CUBES), cubes.begin());
|
||||||
shuffle(cubes.data(), cubes.size());
|
shuffle(cubes.data(), cubes.size());
|
||||||
|
|
||||||
// Just return the first NUM_ROLLED_CUBES (4pcs) entries
|
// Just return the first g_NUM_ROLLED_CUBES (4pcs) entries
|
||||||
std::array<std::string, NUM_ROLLED_CUBES> ret;
|
std::array<std::string, g_NUM_ROLLED_CUBES> ret;
|
||||||
std::copy(cubes.begin(), cubes.begin() + NUM_ROLLED_CUBES, ret.begin());
|
std::copy(cubes.begin(), cubes.begin() + g_NUM_ROLLED_CUBES, ret.begin());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boggle::Boggle()
|
Boggle::Boggle()
|
||||||
: m_showingSides(rollSides()), m_englishWords(Boggle::DICTIONARY_FILE) {}
|
: m_showingSides(rollSides()), m_englishWords(Boggle::s_DICTIONARY_FILE) {}
|
||||||
|
|
||||||
bool Boggle::isWordEnglish(const std::string &word) const {
|
bool Boggle::isWordEnglish(const std::string &word) const {
|
||||||
return m_englishWords.contains(word);
|
return m_englishWords.contains(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Boggle::isWordLongEnough(const std::string &word) const {
|
bool Boggle::isWordLongEnough(const std::string &word) const {
|
||||||
return word.length() >= MIN_WORD_LENGTH;
|
return word.length() >= s_MIN_WORD_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Boggle::isWordPlayed(const std::string &word) const {
|
bool Boggle::isWordPlayed(const std::string &word) const {
|
||||||
|
10
src/Boggle.h
10
src/Boggle.h
@ -14,13 +14,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
static const int NUM_ROLLED_CUBES = 4;
|
static const int g_NUM_ROLLED_CUBES = 4;
|
||||||
|
|
||||||
class Boggle {
|
class Boggle {
|
||||||
public:
|
public:
|
||||||
static const std::string DICTIONARY_FILE;
|
static const std::string s_DICTIONARY_FILE;
|
||||||
const int MIN_WORD_LENGTH = 4;
|
static const int s_MIN_WORD_LENGTH = 4;
|
||||||
const int BOARD_SIZE = 4;
|
static const int s_BOARD_SIZE = 4;
|
||||||
|
|
||||||
Boggle();
|
Boggle();
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_playedWords;
|
std::vector<std::string> m_playedWords;
|
||||||
std::array<std::string, NUM_ROLLED_CUBES> m_showingSides;
|
std::array<std::string, g_NUM_ROLLED_CUBES> m_showingSides;
|
||||||
Lexicon m_englishWords;
|
Lexicon m_englishWords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user