-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameView.h
63 lines (45 loc) · 1.95 KB
/
GameView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "Board.h"
#include "Game.h"
#include "glfw-3.3.8/include/GLFW/glfw3.h"
class GameView {
public:
virtual ~GameView() = default;
virtual void viewBoard(const Board& b) const = 0;
virtual void viewPiece(const Piece& piece) const = 0;
[[nodiscard]] virtual std::string readInput(std::string_view message) const = 0;
virtual void displayEndOfGameMessage(Game::GameState gameState) const = 0;
virtual void displayTurn(const Player& player) const = 0;
virtual void displayException(const std::exception& e) const = 0;
[[nodiscard]] virtual std::unique_ptr<GameView> clone() const noexcept = 0;
};
class GameViewCLI : public GameView {
public:
void viewBoard(const Board &b) const override;
void viewPiece(const Piece& piece) const override;
[[nodiscard]] std::string readInput(std::string_view message) const override;
void displayEndOfGameMessage(Game::GameState gameState) const override;
void displayTurn(const Player& player) const override;
void displayException(const std::exception& e) const override;
[[nodiscard]] std::unique_ptr<GameView> clone() const noexcept override {
return std::make_unique<GameViewCLI>(*this);
}
};
class GameViewOpenGL : public GameView {
private:
GLFWwindow* window;
public:
GameViewOpenGL();
~GameViewOpenGL() override;
void viewBoard(const Board &b) const override {
// TODO: Remove code duplication w/ GameViewCLI::viewBoard()
}
void viewPiece(const Piece& piece) const override {}
[[nodiscard]] std::string readInput(std::string_view message) const override {}
void displayEndOfGameMessage(Game::GameState gameState) const override {}
void displayTurn(const Player& player) const override {}
void displayException(const std::exception& e) const override {}
[[nodiscard]] std::unique_ptr<GameView> clone() const noexcept override {
return std::make_unique<GameViewOpenGL>(*this);
}
};