2024-12-16 23:20:04 +01:00
|
|
|
//
|
|
|
|
// Created by moonleay on 12/16/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "MazeParser.h"
|
|
|
|
|
2024-12-16 23:21:24 +01:00
|
|
|
namespace game
|
|
|
|
{
|
2024-12-16 23:20:04 +01:00
|
|
|
vector<int> MazeParser::request_numbers_from_user(const int amount_of_numbers)
|
|
|
|
{
|
|
|
|
int input;
|
|
|
|
vector<int> list;
|
|
|
|
for (int i = 0; i < amount_of_numbers; ++i)
|
|
|
|
{
|
|
|
|
cin >> input;
|
|
|
|
if (!cin)
|
|
|
|
throw runtime_error("Cin failed while reading numbers!");
|
|
|
|
list.push_back(input);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Maze MazeParser::request_maze_from_user()
|
|
|
|
{
|
|
|
|
vector<int> maze_size = request_numbers_from_user(2);
|
|
|
|
char input;
|
|
|
|
vector<vector<char>> field;
|
|
|
|
for (int i = 0; i < maze_size[0]; ++i)
|
|
|
|
{
|
|
|
|
vector<char> row;
|
|
|
|
for (int j = 0; j < maze_size[1]; ++j)
|
|
|
|
{
|
|
|
|
cin >> input;
|
|
|
|
if (!cin)
|
|
|
|
throw runtime_error("Cin failed while reading chars!");
|
|
|
|
row.push_back(input);
|
|
|
|
}
|
|
|
|
field.push_back(row);
|
|
|
|
}
|
|
|
|
vector<int> player_start_pos = request_numbers_from_user(2);
|
|
|
|
return Maze(field, player_start_pos);
|
|
|
|
} // `4 3 #.# #.K #T# #Z# 0 1`
|
|
|
|
} // game
|