I'm trying to create a game of scrabble and I need to create a board. I created the class Board which has mapTiles() as one of it's functions, it's responsible for creating the base of the board, inserting in the correct tiles the word / letter multipliers. I want this function to return the 2d array so that I'm able to use it in other functions. For ex. on another function I want to do:
Board myBoard;
std::string array[15][15];
array = myBoard.array;
I tried using maps, pointers, vectors and 2d arrays, is there another more efficient way of doing this?
std::string tilesMap[15][15];
std::string mapTiles() {
for (int cY = 0; cY < 15; cY++) {
for (int cX = 0; cX < 15; cX++) {
int cXY = cX + cY;
double res = pow(cX, 2) + pow(cY, 2);
tilesMap[cX][cY] = blank;
if (cX == cY || cXY == 14) { // Sets the diagonals of the board with bonuses
if (cX == 0 || cX == 14) { // 3 x Word
tilesMap[cX][cY] = x3W;
}
else if (cX == 5 || cX == 9) { // 3 x Letter
tilesMap[cX][cY] = x3L;
}
else if (cX == 6 || cX == 8) { // 2 x Letter
tilesMap[cX][cY] = x2L;
}
else {
tilesMap[cX][cY] = x2W; // 2 x Word
}
}
else if (cXY % 7 == 0) { // 3 x Word
if (cY == 0 || cY == 7 || cY == 14) {
tilesMap[cX][cY] = x3W;
}
}
else if (res == 26 || res == 82 || res == 194 || res == 250) { // 3 x Letter
if (cY == 1 || cY == 5 || cY == 9 || cY == 13) {
tilesMap[cX][cY] = x3L;
}
}
else if (res == 9 || res == 121 || res == 205 || res == 317) { // 2 x Letter outer ring
if (cY == 0 || cY == 3 || cY == 11 || cY == 14) {
tilesMap[cX][cY] = x2L;
}
}
else if (res == 40 || res == 68 || res == 180 || res == 208) { // 2 x Letter 2nd ring
if (cY == 2 || cY == 6 || cY == 8 || cY == 12) {
tilesMap[cX][cY] = x2L;
}
}
else if (res == 58 || res == 170) { // 2 x Letter 3rd ring
if ((cY == 3) || (cY == 7) | (cY == 11)) {
tilesMap[cX][cY] = x2L;
}
}
}
}
return tilesMap;
}
The error I'm getting is the following: Error (active) E0415 no suitable constructor exists to convert from "std::string [15][15]" to "std::basic_string, std::allocator>