fix: made game quit when pressing q in maze creator
This commit is contained in:
parent
7b10c3bca9
commit
b59c6baed8
2 changed files with 8 additions and 2 deletions
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
#include "MazeParser.h"
|
#include "MazeParser.h"
|
||||||
|
|
||||||
|
#include "Exceptions/ExitGame.h"
|
||||||
#include "Exceptions/MalformedMaze.h"
|
#include "Exceptions/MalformedMaze.h"
|
||||||
|
|
||||||
using game_exceptions::MalformedMaze;
|
using game_exceptions::MalformedMaze;
|
||||||
|
using game_exceptions::ExitGame;
|
||||||
|
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
|
@ -74,6 +76,10 @@ namespace game
|
||||||
if (!cin)
|
if (!cin)
|
||||||
throw MalformedMaze("Cin failed while reading chars!");
|
throw MalformedMaze("Cin failed while reading chars!");
|
||||||
|
|
||||||
|
// Verlasse das Spiel
|
||||||
|
if (input == 'q')
|
||||||
|
throw ExitGame("Schoenen Tag noch!");
|
||||||
|
|
||||||
// Kontrolliere, ob das Element in einem Labyrinth vorkommen darf
|
// Kontrolliere, ob das Element in einem Labyrinth vorkommen darf
|
||||||
if (!is_valid_maze_element(input))
|
if (!is_valid_maze_element(input))
|
||||||
throw MalformedMaze("The given input is not a valid element of a maze!");
|
throw MalformedMaze("The given input is not a valid element of a maze!");
|
||||||
|
|
4
main.cpp
4
main.cpp
|
@ -36,9 +36,9 @@ int main()
|
||||||
// Das Labyrinth einlesen hat nicht geklappt. Gebe Fehlermeldung aus und beende das Programm.
|
// Das Labyrinth einlesen hat nicht geklappt. Gebe Fehlermeldung aus und beende das Programm.
|
||||||
cout << "Fehler beim Einlesen des Labyrinths.\n";
|
cout << "Fehler beim Einlesen des Labyrinths.\n";
|
||||||
return 0;
|
return 0;
|
||||||
} catch (ExitGame& err)
|
} catch (ExitGame& _)
|
||||||
{
|
{
|
||||||
cout << err.what() << "\n";
|
cout << "Schoenen Tag noch!" << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue