diff --git a/ASCII-G.vcxproj b/ASCII-G.vcxproj index 82c39d3..23bb508 100644 --- a/ASCII-G.vcxproj +++ b/ASCII-G.vcxproj @@ -123,13 +123,13 @@ - - - + + + - - + + diff --git a/ASCII-G.vcxproj.filters b/ASCII-G.vcxproj.filters index 942462a..0b563bd 100644 --- a/ASCII-G.vcxproj.filters +++ b/ASCII-G.vcxproj.filters @@ -15,21 +15,21 @@ - + Исходные файлы - + Исходные файлы - + Исходные файлы - + Исходные файлы - + Исходные файлы diff --git a/game.h b/include/game.h similarity index 86% rename from game.h rename to include/game.h index de0a82d..3021646 100644 --- a/game.h +++ b/include/game.h @@ -7,7 +7,7 @@ public: private: bool isRunning = true; - Player* player = nullptr; + Player player; void showMainMenu(); void processCommand(); diff --git a/include/player.h b/include/player.h new file mode 100644 index 0000000..ca7350c --- /dev/null +++ b/include/player.h @@ -0,0 +1,20 @@ +#pragma once +#include +#include + +class Player { +public: + std::string name = "Character Name"; + int hp = 100; + int atk = 1; + int gold = 0; + int currentLocation = 1; + int weaponId = 101; + std::vector items; + + Player() {}; + Player(std::string _name); + void showStats(); +}; + +#pragma once diff --git a/location.cpp b/location.cpp new file mode 100644 index 0000000..e69de29 diff --git a/location.h b/location.h new file mode 100644 index 0000000..49a3aa9 --- /dev/null +++ b/location.h @@ -0,0 +1,17 @@ +#pragma once +#include + +class Location { +public: + std::string title; + int id; + int sizeX; + int sizeY; + int gold = 0; + + Location() {}; + Location(std::string _name); + void showStats(); +}; + +#pragma once diff --git a/player.h b/player.h deleted file mode 100644 index ab447e8..0000000 --- a/player.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include - -class Player { -public: - std::string name; - int hp; - int atk; - int gold; - - Player(std::string _name); - void showStats(); -}; - -#pragma once diff --git a/game.cpp b/src/game.cpp similarity index 59% rename from game.cpp rename to src/game.cpp index 510e2db..9750835 100644 --- a/game.cpp +++ b/src/game.cpp @@ -1,5 +1,5 @@ -#include "game.h" -#include "player.h" +#include "../include/game.h" +#include "../include/player.h" #include #include @@ -13,7 +13,7 @@ void Game::run() { void Game::showMainMenu() { while (true) { - std::cout << "\n=== ASCII-G - The Cookies Edition ===\n"; + std::cout << "=== ASCII-G - The Cookies Edition ===\n"; std::cout << "1. New Game\n"; std::cout << "2. Load Game\n"; std::cout << "3. Exit\n"; @@ -23,7 +23,7 @@ void Game::showMainMenu() { std::getline(std::cin, str); if (str.length() != 1) { - std::cout << "It seems you've tried to input more than 1 digit... Just don't do this please!\n"; + std::cout << "It seems you've tried to input more than 1 digit... Don't do this please.\n"; continue; } @@ -31,27 +31,33 @@ void Game::showMainMenu() { if (select == '1') { std::string name; - std::cout << "Enter your character name: "; - std::cin >> name; - player = new Player(name); - std::cout << "Created new character " << player->name << "! Amazing choice."; + std::cout << ">>> Enter your character name: "; + std::getline(std::cin, name); + if (name == "") { + std::cout << ">>> Empty name? Damn... let's call you Zero!\n"; + player = Player("Zero"); + } + else { + player = Player(name); + } + std::cout << ">>> Created new character " << player.name << "!"; break; } else if (select == '2') { - std::cout << "I can't do this... yet."; + std::cout << ">>> I can't do this... yet."; } else if (select == '3') { isRunning = false; break; } else { - std::cout << "I can't do this... yet? Let's try again!"; + std::cout << ">>> I can't do this... yet? Let's try again!"; } } } void Game::render() { - std::cout << "\n=== ASCII-G - The Cookies Edition ===\n"; + std::cout << "\n\n=== ASCII-G - The Cookies Edition ===\n"; std::cout << "Commands: stats, exit\n"; } @@ -64,12 +70,7 @@ void Game::processCommand() { isRunning = false; } else if (command == "stats") { - if (player != nullptr) { - player->showStats(); - } - else { - std::cout << "No character created yet.\n"; - } + player.showStats(); } else { std::cout << "Unknown command.\n"; diff --git a/main.cpp b/src/main.cpp similarity index 65% rename from main.cpp rename to src/main.cpp index c3006ba..373b45c 100644 --- a/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "Game.h" +#include "../include/game.h" int main() { Game game; diff --git a/player.cpp b/src/player.cpp similarity index 91% rename from player.cpp rename to src/player.cpp index 7b86b53..8c360d8 100644 --- a/player.cpp +++ b/src/player.cpp @@ -1,4 +1,4 @@ -#include "player.h" +#include "../include/player.h" #include Player::Player(std::string _name)