forked from University/epr24pr42-ojanssen2
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
|
#include "Environment/Maze.h"
|
||
|
#include "Util/MazeParser.h"
|
||
|
#include "Environment/Game.h"
|
||
|
#include "Exceptions/MalformedMaze.h"
|
||
|
#include "Exceptions/MovementNotPossible.h"
|
||
|
#include "Exceptions/UnkownAction.h"
|
||
|
#include "Util/GameState.h"
|
||
|
|
||
|
using game::Maze;
|
||
|
using game::MazeParser;
|
||
|
using game::Game;
|
||
|
using game::GameState;
|
||
|
|
||
|
using game_exceptions::MalformedMaze;
|
||
|
|
||
|
// Ein Programm, welches dir erlaubt ein Labyrinth zu erkunden mit 'w', 'a', 's', und 'd'.
|
||
|
|
||
|
void print_exit_message_based_on_state(const GameState& state);
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
GameState state = GameState::RUNNING;
|
||
|
try
|
||
|
{
|
||
|
Maze maze = MazeParser::request_maze_from_user();
|
||
|
|
||
|
Game game = Game(maze);
|
||
|
|
||
|
game.run_game();
|
||
|
|
||
|
state = game.get_state();
|
||
|
}
|
||
|
catch (MalformedMaze& _)
|
||
|
{
|
||
|
cout << "Fehler beim Einlesen des Labyrinths.\n";
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
print_exit_message_based_on_state(state);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
void print_exit_message_based_on_state(const GameState& state) {
|
||
|
switch (state){
|
||
|
case GameState::QUITTING:
|
||
|
cout << "Schoenen Tag noch!" << "\n";
|
||
|
break;
|
||
|
case GameState::HIT_BY_GHOST:
|
||
|
cout << "Sie haben einen Geist getroffen! Game Over!\n";
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|