Eile Mit Weile
Loading...
Searching...
No Matches
GameController Class Reference

Responsible for sending ClientRequests to the server and updating the local game state. from the server. More...

#include <GameController.hpp>

Static Public Member Functions

static void Init (GameWindow *game_window)
 
static void ConnectToServer ()
 
static void UpdateGameState (GameState *new_game_state)
 
static void StartGame ()
 
static void MoveFigure (Figure *, Space *)
 
static void SkipTurn ()
 
static void ThrowDice ()
 
static wxEvtHandlerGetMainThreadEventHandler ()
 
static void ShowError (const std::string &title, const std::string &message)
 
static void ShowStatus (const std::string &message)
 
static void ShowGameOverMessage ()
 

Static Private Attributes

static GameWindow_game_window = nullptr
 
static ConnectionPanel_connection_panel = nullptr
 
static MainGamePanel_main_game_panel = nullptr
 
static Player_me = nullptr
 
static GameState_current_game_state = nullptr
 

Detailed Description

Responsible for sending ClientRequests to the server and updating the local game state. from the server.

This class is unable to update the game state on its own; it can only copy the game state from the server. It also updates the UI to reflect the current game state or the connection panel before the game starts. Note: This class design is taken from https://gitlab.ethz.ch/hraymond/cse-lama-example-project. As a result, this class only contains static methods and members. This means that is not instsntiated anywhere and all methods can be called without an instance of this class. We consider this bad design (i.e. just fake Object-Oriented programming), but changing it would require a lot of refactoring so we decided to leave it as it is.

Member Function Documentation

◆ ConnectToServer()

void GameController::ConnectToServer ( )
static

Connects to the server using addresses inputted by player in ConnectionPanel.

◆ GetMainThreadEventHandler()

wxEvtHandler * GameController::GetMainThreadEventHandler ( )
static

Wrapped wxFrame::GetEventHandler (see wxWidgets doc).

◆ Init()

void GameController::Init ( GameWindow game_window)
static

Initializes the game controller. Creates the ConnectionPanel and MainGamePanel and shows the ConnectionPanel.

◆ MoveFigure()

void GameController::MoveFigure ( Figure figure,
Space space 
)
static

Sends a move_figure_request to the server.

◆ ShowError()

void GameController::ShowError ( const std::string &  title,
const std::string &  message 
)
static

Shows an error message to the user as a popup window.

◆ ShowGameOverMessage()

void GameController::ShowGameOverMessage ( )
static

Shows a popup window with the game over message (incl. the winner).

◆ ShowStatus()

void GameController::ShowStatus ( const std::string &  message)
static

Updates the status bar of the GameWindow.

◆ SkipTurn()

void GameController::SkipTurn ( )
static

Sends a skip_turn_request to the server.

◆ StartGame()

void GameController::StartGame ( )
static

Sends a start_game_request to the server.

◆ ThrowDice()

void GameController::ThrowDice ( )
static

Sends a throw_dice_request to the server.

◆ UpdateGameState()

void GameController::UpdateGameState ( GameState new_game_state)
static

Updates the _current_game_state with the given game state.

Member Data Documentation

◆ _connection_panel

ConnectionPanel * GameController::_connection_panel = nullptr
staticprivate

The panel that is shown before the game starts. Here players input the host address and their name.

◆ _current_game_state

GameState * GameController::_current_game_state = nullptr
staticprivate

The current GameState.

◆ _game_window

GameWindow * GameController::_game_window = nullptr
staticprivate

The main window of the game client.

◆ _main_game_panel

MainGamePanel * GameController::_main_game_panel = nullptr
staticprivate

The panel that is shown during the game. Here players can see the game board and their figures.

◆ _me

Player * GameController::_me = nullptr
staticprivate

The Player that is controlled by the client.


The documentation for this class was generated from the following files: