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