From f4fc4fa5bd0f299bf3e6a5679648898b427833d4 Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Thu, 12 Sep 2024 14:43:35 +0200 Subject: [PATCH] More hungarian notation https://en.wikipedia.org/wiki/Hungarian_notation --- src/Boggle.cpp | 24 ++++++++++++------------ src/Boggle.h | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Boggle.cpp b/src/Boggle.cpp index 4cc46bb..8814215 100755 --- a/src/Boggle.cpp +++ b/src/Boggle.cpp @@ -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 rollSides() { +std::array rollSides() { // Intermediate array to shuffle - std::array cubes; - std::copy(std::begin(CUBES), std::end(CUBES), cubes.begin()); + std::array 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 ret; - std::copy(cubes.begin(), cubes.begin() + NUM_ROLLED_CUBES, ret.begin()); + // Just return the first g_NUM_ROLLED_CUBES (4pcs) entries + std::array 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 { diff --git a/src/Boggle.h b/src/Boggle.h index 3063267..632074b 100755 --- a/src/Boggle.h +++ b/src/Boggle.h @@ -14,13 +14,13 @@ #include #include -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 m_playedWords; - std::array m_showingSides; + std::array m_showingSides; Lexicon m_englishWords; };