2025-01-19 18:23:50 +01:00
|
|
|
#include "Maze.h"
|
2025-01-19 18:20:22 +01:00
|
|
|
#include "Game.h"
|
|
|
|
#include "MalformedMaze.h"
|
|
|
|
#include "GameState.h"
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
using game::Maze;
|
|
|
|
using game::Game;
|
|
|
|
using game::GameState;
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
using game_exceptions::MalformedMaze;
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
// Ein Programm, welches dir erlaubt ein Labyrinth zu erkunden mit 'w', 'a', 's', und 'd'.
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
void print_exit_message_based_on_state(const GameState& state);
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
int main()
|
2025-01-19 17:56:20 +01:00
|
|
|
{
|
2025-01-19 17:59:26 +01:00
|
|
|
GameState state = GameState::RUNNING;
|
|
|
|
try
|
2025-01-19 17:56:20 +01:00
|
|
|
{
|
2025-01-19 17:59:26 +01:00
|
|
|
Maze maze = Maze::request_maze_from_user();
|
2025-01-19 17:56:20 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
Game game = Game(maze);
|
2025-01-19 17:56:20 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
game.run_game();
|
2025-01-19 17:56:20 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
state = game.get_state();
|
2025-01-18 01:21:58 +01:00
|
|
|
}
|
2025-01-19 17:59:26 +01:00
|
|
|
catch (MalformedMaze& _)
|
2025-01-19 17:56:20 +01:00
|
|
|
{
|
2025-01-19 17:59:26 +01:00
|
|
|
cout << "Fehler beim Einlesen des Labyrinths.\n";
|
|
|
|
return 0;
|
2025-01-19 17:56:20 +01:00
|
|
|
}
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
print_exit_message_based_on_state(state);
|
2025-01-18 01:21:58 +01:00
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
return 0;
|
2025-01-18 01:21:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-01-19 17:59:26 +01:00
|
|
|
/// Schriebe eine Nachricht in die Konsole wenn das Programm beendet wird
|
|
|
|
/// @param state Der Spielzustand als das Programm beendet wurde
|
|
|
|
void print_exit_message_based_on_state(const GameState& state) {
|
|
|
|
switch (state){
|
|
|
|
case GameState::QUITTING:
|
|
|
|
cout << "Schoenen Tag noch!" << "\n";
|
2025-01-18 01:21:58 +01:00
|
|
|
break;
|
2025-01-19 17:59:26 +01:00
|
|
|
case GameState::HIT_BY_GHOST:
|
2025-01-19 17:56:20 +01:00
|
|
|
cout << "Sie haben einen Geist getroffen! Game Over!\n";
|
2025-01-19 17:59:26 +01:00
|
|
|
default:
|
|
|
|
break;
|
2025-01-18 01:21:58 +01:00
|
|
|
}
|
|
|
|
}
|