From 3806bb74674f305679efdaa2889d155531bc3643 Mon Sep 17 00:00:00 2001 From: dawidg81 Date: Mon, 26 Jan 2026 17:24:50 +0100 Subject: dir rename --- src/Game/Game.hpp | 24 ++++++++++++++++++++++++ src/Game/display.cpp | 14 ++++++++++++++ src/Game/edit.cpp | 24 ++++++++++++++++++++++++ src/Game/init.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/Utils/Utils.hpp | 11 +++++++++++ src/Utils/catchInputInt.cpp | 15 +++++++++++++++ src/Utils/catchReturn.cpp | 11 +++++++++++ src/game/Game.hpp | 24 ------------------------ src/game/display.cpp | 14 -------------- src/game/edit.cpp | 27 --------------------------- src/game/init.cpp | 38 -------------------------------------- src/main.cpp | 2 +- src/utils/Utils.hpp | 11 ----------- src/utils/catchInputInt.cpp | 15 --------------- src/utils/catchReturn.cpp | 11 ----------- 15 files changed, 138 insertions(+), 141 deletions(-) create mode 100644 src/Game/Game.hpp create mode 100644 src/Game/display.cpp create mode 100644 src/Game/edit.cpp create mode 100644 src/Game/init.cpp create mode 100644 src/Utils/Utils.hpp create mode 100644 src/Utils/catchInputInt.cpp create mode 100644 src/Utils/catchReturn.cpp delete mode 100644 src/game/Game.hpp delete mode 100644 src/game/display.cpp delete mode 100644 src/game/edit.cpp delete mode 100644 src/game/init.cpp delete mode 100644 src/utils/Utils.hpp delete mode 100644 src/utils/catchInputInt.cpp delete mode 100644 src/utils/catchReturn.cpp diff --git a/src/Game/Game.hpp b/src/Game/Game.hpp new file mode 100644 index 0000000..767ab94 --- /dev/null +++ b/src/Game/Game.hpp @@ -0,0 +1,24 @@ +#ifndef GAME_HPP +#define GAME_HPP + +class Game { +private: + static constexpr int MAX_W = 32; + static constexpr int MAX_H = 32; + + int boardWidth; + int boardHeight; + + bool bombMap[MAX_H][MAX_W]; + int tileMap[MAX_H][MAX_W]; + + int mines; + +public: + int editDiff(); + void initDiff(int diff); + void initBoard(); + void displayBoard(); +}; + +#endif diff --git a/src/Game/display.cpp b/src/Game/display.cpp new file mode 100644 index 0000000..4fb16cb --- /dev/null +++ b/src/Game/display.cpp @@ -0,0 +1,14 @@ +#include "Game.hpp" + +#include +#include +#include + + +void Game::displayBoard() { + for (int i = 0; i < boardHeight; i++) { + for (int j = 0; j < boardWidth; j++) + putchar(tileMap[i][j]); + putchar('\n'); + } +} \ No newline at end of file diff --git a/src/Game/edit.cpp b/src/Game/edit.cpp new file mode 100644 index 0000000..8d9c37f --- /dev/null +++ b/src/Game/edit.cpp @@ -0,0 +1,24 @@ +#include "Game.hpp" +#include "../Utils/Utils.hpp" + +#include +#include +#include +#include + +int Game::editDiff(){ + Utils util; + + std::cout << "Now editing custom difficulty" << std::endl; + + std::cout << "Board width: "; + if(util.catchReturn(util.catchInputInt(Game::boardWidth)) != 0) return 1; + + std::cout << "Board height: "; + if(util.catchReturn(util.catchInputInt(Game::boardHeight)) != 0) return 1; + + std::cout << "Mines: "; + if(util.catchReturn(util.catchInputInt(Game::mines)) != 0) return 1; + + return 0; +} \ No newline at end of file diff --git a/src/Game/init.cpp b/src/Game/init.cpp new file mode 100644 index 0000000..a572fbc --- /dev/null +++ b/src/Game/init.cpp @@ -0,0 +1,38 @@ +#include "Game.hpp" + +#include +#include +#include + +void Game::initDiff(int diff) { + switch (diff) { + case 0: + boardWidth = 9; + boardHeight = 9; + mines = 9; + break; + case 1: + boardWidth = 16; + boardHeight = 16; + mines = 12; + break; + case 2: + boardWidth = 30; + boardHeight = 16; + mines = 16; + break; + case 3: + std::cout << "Editing game parameters\n"; + break; + } +} + +void Game::initBoard() { + for (int i = 0; i < boardHeight; i++) + for (int j = 0; j < boardWidth; j++) + bombMap[i][j] = rand() % 2; + + for (int i = 0; i < boardHeight; i++) + for (int j = 0; j < boardWidth; j++) + tileMap[i][j] = 0; +} \ No newline at end of file diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp new file mode 100644 index 0000000..7df9e3d --- /dev/null +++ b/src/Utils/Utils.hpp @@ -0,0 +1,11 @@ +#include + +#ifndef UTILS_HPP + +class Utils{ + public: + int catchInputInt(int input); + int catchReturn(int renum); +}; + +#endif \ No newline at end of file diff --git a/src/Utils/catchInputInt.cpp b/src/Utils/catchInputInt.cpp new file mode 100644 index 0000000..dd804b5 --- /dev/null +++ b/src/Utils/catchInputInt.cpp @@ -0,0 +1,15 @@ +#include "Utils.hpp" + +#include +#include + +int Utils::catchInputInt(int input){ + std::cin >> input; + + if (std::cin.fail()) { + std::cout << "error: Input failed" << std::endl; + return 1; + } + + return 0; +} \ No newline at end of file diff --git a/src/Utils/catchReturn.cpp b/src/Utils/catchReturn.cpp new file mode 100644 index 0000000..c3d6722 --- /dev/null +++ b/src/Utils/catchReturn.cpp @@ -0,0 +1,11 @@ +#include "Utils.hpp" + +#include +#include + +int Utils::catchReturn(int renum){ + if (renum != 0) { + std::cout << "Received error signal, sending further" << std::endl; + } + return 0; +} \ No newline at end of file diff --git a/src/game/Game.hpp b/src/game/Game.hpp deleted file mode 100644 index 767ab94..0000000 --- a/src/game/Game.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef GAME_HPP -#define GAME_HPP - -class Game { -private: - static constexpr int MAX_W = 32; - static constexpr int MAX_H = 32; - - int boardWidth; - int boardHeight; - - bool bombMap[MAX_H][MAX_W]; - int tileMap[MAX_H][MAX_W]; - - int mines; - -public: - int editDiff(); - void initDiff(int diff); - void initBoard(); - void displayBoard(); -}; - -#endif diff --git a/src/game/display.cpp b/src/game/display.cpp deleted file mode 100644 index 4fb16cb..0000000 --- a/src/game/display.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "Game.hpp" - -#include -#include -#include - - -void Game::displayBoard() { - for (int i = 0; i < boardHeight; i++) { - for (int j = 0; j < boardWidth; j++) - putchar(tileMap[i][j]); - putchar('\n'); - } -} \ No newline at end of file diff --git a/src/game/edit.cpp b/src/game/edit.cpp deleted file mode 100644 index b2d2542..0000000 --- a/src/game/edit.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "Game.hpp" -#include "../utils/Utils.hpp" - -#include -#include -#include -#include - -int Game::editDiff(){ - Utils util; - - std::cout << "Now editing custom difficulty" << std::endl; - - std::cout << "Board width: "; - util.catchInputInt(Game::boardWidth); - if(util.catchReturn(util.catchInputInt(Game::boardWidth)) != 0) return 1; - - std::cout << "Board height: "; - util.catchInputInt(Game::boardHeight); - if(util.catchReturn(util.catchInputInt(Game::boardHeight)) != 0) return 1; - - std::cout << "Mines: "; - util.catchInputInt(Game::mines); - if(util.catchReturn(util.catchInputInt(Game::mines)) != 0) return 1; - - return 0; -} \ No newline at end of file diff --git a/src/game/init.cpp b/src/game/init.cpp deleted file mode 100644 index a572fbc..0000000 --- a/src/game/init.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "Game.hpp" - -#include -#include -#include - -void Game::initDiff(int diff) { - switch (diff) { - case 0: - boardWidth = 9; - boardHeight = 9; - mines = 9; - break; - case 1: - boardWidth = 16; - boardHeight = 16; - mines = 12; - break; - case 2: - boardWidth = 30; - boardHeight = 16; - mines = 16; - break; - case 3: - std::cout << "Editing game parameters\n"; - break; - } -} - -void Game::initBoard() { - for (int i = 0; i < boardHeight; i++) - for (int j = 0; j < boardWidth; j++) - bombMap[i][j] = rand() % 2; - - for (int i = 0; i < boardHeight; i++) - for (int j = 0; j < boardWidth; j++) - tileMap[i][j] = 0; -} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index cbee490..d36b797 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ #include -#include "game/Game.hpp" +#include "Game/Game.hpp" using namespace std; int main(){ diff --git a/src/utils/Utils.hpp b/src/utils/Utils.hpp deleted file mode 100644 index 7df9e3d..0000000 --- a/src/utils/Utils.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#ifndef UTILS_HPP - -class Utils{ - public: - int catchInputInt(int input); - int catchReturn(int renum); -}; - -#endif \ No newline at end of file diff --git a/src/utils/catchInputInt.cpp b/src/utils/catchInputInt.cpp deleted file mode 100644 index 0dc8fc9..0000000 --- a/src/utils/catchInputInt.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Utils.hpp" - -#include -#include - -int Utils::catchInputInt(int input){ - std::cin >> input; - - if (std::cin.fail()) { - std::cout << "error: Input failed" << std::endl; - return 1; - } - - return 0; -} \ No newline at end of file diff --git a/src/utils/catchReturn.cpp b/src/utils/catchReturn.cpp deleted file mode 100644 index c3d6722..0000000 --- a/src/utils/catchReturn.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Utils.hpp" - -#include -#include - -int Utils::catchReturn(int renum){ - if (renum != 0) { - std::cout << "Received error signal, sending further" << std::endl; - } - return 0; -} \ No newline at end of file -- cgit v1.2.3