Add macro to have correct path on macOS

This commit is contained in:
Love 2024-09-11 17:44:51 +02:00
parent dfbceae848
commit d638edb34a
3 changed files with 13 additions and 6 deletions

View File

@ -12,9 +12,17 @@
#include "strlib.h" #include "strlib.h"
#include <sstream> #include <sstream>
// The res folder isn't copied the same way on macOS
#ifdef __APPLE__
const std::string Boggle::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 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 CUBE_SIDES = 6; // the number of sides on each cube
static string CUBES[NUM_CUBES] = { // the letters on all 6 sides of every cube static std::string CUBES[NUM_CUBES] = { // 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"};

View File

@ -11,13 +11,10 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
// TODO: include any other header files you need
using namespace std;
class Boggle { class Boggle {
public: public:
const string DICTIONARY_FILE = "EnglishWords.dat"; static const std::string DICTIONARY_FILE;
const int MIN_WORD_LENGTH = 4; const int MIN_WORD_LENGTH = 4;
const int BOARD_SIZE = 4; const int BOARD_SIZE = 4;
@ -27,4 +24,6 @@ private:
// TODO: decide the private member variables/functions and declare them // TODO: decide the private member variables/functions and declare them
}; };
#endif #endif

View File

@ -44,7 +44,7 @@ void shuffle(T** array2d, int rows, int cols) {
} }
template <typename T> template <typename T>
void shuffle(vector<T>& v) { void shuffle(std::vector<T>& v) {
for (int i = 0, length = v.size(); i < length; i++) { for (int i = 0, length = v.size(); i < length; i++) {
int j = randomInteger(i, length - 1); int j = randomInteger(i, length - 1);
if (i != j) { if (i != j) {