game is running! player can be created.

This commit is contained in:
DeLiss
2026-06-04 04:08:55 +05:00
commit d81111f001
10 changed files with 346 additions and 0 deletions

77
game.cpp Normal file
View File

@@ -0,0 +1,77 @@
#include "game.h"
#include "player.h"
#include <iostream>
#include <string>
void Game::run() {
showMainMenu();
while (isRunning) {
render();
processCommand();
}
}
void Game::showMainMenu() {
while (true) {
std::cout << "\n=== ASCII-G - The Cookies Edition ===\n";
std::cout << "1. New Game\n";
std::cout << "2. Load Game\n";
std::cout << "3. Exit\n";
std::cout << "> ";
std::string str;
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";
continue;
}
char select = str[0];
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.";
break;
}
else if (select == '2') {
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!";
}
}
}
void Game::render() {
std::cout << "\n=== ASCII-G - The Cookies Edition ===\n";
std::cout << "Commands: stats, exit\n";
}
void Game::processCommand() {
std::string command;
std::cout << "> ";
std::cin >> command;
if (command == "exit") {
isRunning = false;
}
else if (command == "stats") {
if (player != nullptr) {
player->showStats();
}
else {
std::cout << "No character created yet.\n";
}
}
else {
std::cout << "Unknown command.\n";
}
}