Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/gamelogic/enum/CardType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
#ifndef SECRETBUNDESTAGSERVER_CARDTYPE_HPP
#define SECRETBUNDESTAGSERVER_CARDTYPE_HPP

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel{

/**
* @enum CardTypes
*/
enum class CardType {
FASCIST, LIBERAL
};
Expand Down
8 changes: 8 additions & 0 deletions src/gamelogic/enum/Fraction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
#ifndef SECRETBUNDESTAGSERVER_FRACTION_HPP
#define SECRETBUNDESTAGSERVER_FRACTION_HPP

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel{

/**
* @enum Fraction
*/
enum class Fraction {
FASCIST_PARTY, LIBERAL_PARTY
};
Expand Down
8 changes: 8 additions & 0 deletions src/gamelogic/enum/Office.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
#ifndef SECRETBUNDESTAGSERVER_OFFICE_HPP
#define SECRETBUNDESTAGSERVER_OFFICE_HPP

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel{

/**
* @enum Office
*/
enum class Office {
CHANCELOR, PRESIDENT, CANDIDATE
};
Expand Down
8 changes: 8 additions & 0 deletions src/gamelogic/enum/Role.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
#ifndef SECRETBUNDESTAGSERVER_ROLE_HPP
#define SECRETBUNDESTAGSERVER_ROLE_HPP

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel{

/**
* @enum Role
*/
enum class Role {
NONE, HITLER
};
Expand Down
8 changes: 8 additions & 0 deletions src/gamelogic/gamecontroller/Controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
#ifndef SECRETBUNDESTAGSERVER_CONTROLLER_HPP
#define SECRETBUNDESTAGSERVER_CONTROLLER_HPP

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameController {

/**
* @class Controller
*/
class Controller {

};
Expand Down
6 changes: 4 additions & 2 deletions src/gamelogic/gamemodel/Board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
#include "Player.hpp"

/**
* @namespace The namespace for the game model.
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel {

/**
* @class The Board class represents the game board which a player would see when playing the board game version.
* The Board class represents the game board which a player would see when playing the board game version.
* @class Board
*/
class Board {

Expand Down
7 changes: 7 additions & 0 deletions src/gamelogic/gamemodel/CardRange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
#include "../enum/CardType.hpp"
#include "Board.hpp"

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel {

/**
* @class CardRange
*/
class CardRange {

private:
Expand Down
11 changes: 6 additions & 5 deletions src/gamelogic/gamemodel/Environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
#include "GameStateRepresentation.hpp"

/**
* @namespace The namespace for the game model.
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel {

/**
* @class The environment class represents the whole game environment containing all game objects and entities.
* The environment class represents the whole game environment containing all game objects and entities.
* @class Environment
*/
class Environment {

Expand Down Expand Up @@ -92,9 +94,8 @@ namespace GameModel {
bool killPlayer(std::shared_ptr<Player> player);

/**
*
* ToDo: Was soll hier nochmal zurück gegeben werden?
* @param player
* Get the current game state for a specified player.
* @param player The specified player.
* @return
*/
auto getGameState(std::shared_ptr<Player> player) -> GameStateRepresentation;
Expand Down
25 changes: 22 additions & 3 deletions src/gamelogic/gamemodel/GameStateRepresentation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
//
// Created by bjorn on 08.12.20.
//
/**
* @file GameStateRepresentation.cpp
* @author bjoern
* @date 08.12.20
* Description here TODO
*/

#include "GameStateRepresentation.hpp"

#include <utility>

namespace GameModel {

GameStateRepresentation::GameStateRepresentation(int liberalPolicies, int fascistPolicies,
std::optional<std::string> chancellor, int electionTracker,
std::vector<GameModel::Player> players, int cardPile,
int discardPile) :
liberalPolicies(liberalPolicies), fascistPolicies(fascistPolicies),
chancellor(std::move(chancellor)),
electionTracker(electionTracker), players(std::move(players)),
cardPile(cardPile), discardPile(discardPile){
}

}
40 changes: 35 additions & 5 deletions src/gamelogic/gamemodel/GameStateRepresentation.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
//
// Created by bjorn on 08.12.20.
//
/**
* @file GameStateRepresentation.hpp
* @author bjoern
* @date 08.12.20
* This class represents a snapshot of the current game state which can be send to a game client.
*/

#ifndef SECRETBUNDESTAGSERVER_GAMESTATEREPRESENTATION_HPP
#define SECRETBUNDESTAGSERVER_GAMESTATEREPRESENTATION_HPP

#include <optional>
#include <vector>
#include "Player.hpp"

class GameStateRepresentation {
/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel {

};
/**
* This class represents a snapshot of the current game state which can be send to a game client.
* @class GameStateRepresentation
*/
class GameStateRepresentation {

public:

int liberalPolicies;
int fascistPolicies;
std::optional<std::string> chancellor;
int electionTracker;
std::vector<GameModel::Player> players;
int cardPile;
int discardPile;

GameStateRepresentation(int liberalPolicies, int fascistPolicies, std::optional<std::string> chancellor,
int electionTracker, std::vector<GameModel::Player> players, int cardPile,
int discardPile);

};
}

#endif //SECRETBUNDESTAGSERVER_GAMESTATEREPRESENTATION_HPP
30 changes: 28 additions & 2 deletions src/gamelogic/gamemodel/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

namespace GameModel {

// PlayerRepresentation class implementation -----------------------------------------------------------------------

PlayerRepresentation::PlayerRepresentation(std::string name, bool alive, std::optional<std::string> govRole) :
name(std::move(name)), alive(alive), govRole(std::move(govRole)) {
}

// -----------------------------------------------------------------------------------------------------------------

// Player class implementation -------------------------------------------------------------------------------------

Player::Player(std::string name, const Fraction fraction, const Role role, const std::size_t sessId) : name(
std::move(name)), fraction(fraction), role(role), sessionID(sessId) {

Expand Down Expand Up @@ -40,11 +50,27 @@ namespace GameModel {
role = playerRole;
}

size_t Player::getSessionId() const {
return sessionID;
void Player::setAlive(bool isPlayerAlive) {
this->alive = isPlayerAlive;
}

bool Player::getAlive() const {
return alive;
}

void Player::setSessionId(size_t sessionId) {
sessionID = sessionId;
}


size_t Player::getSessionId() const {
return sessionID;
}

// ToDo Fix return...
auto Player::getPlayerRepresentation() -> PlayerRepresentation {
return PlayerRepresentation(name, alive, "");
}

// -----------------------------------------------------------------------------------------------------------------
}
30 changes: 29 additions & 1 deletion src/gamelogic/gamemodel/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,33 @@
#define SECRETBUNDESTAGSERVER_PLAYER_HPP

#include <string>
#include <optional>

#include "../enum/Role.hpp"
#include "../enum/Fraction.hpp"

/**
* The namespace for the game model.
* @namespace GameModel
*/
namespace GameModel {

/**
* This class represents a player object which can be send to a game client.
* @class PlayerRepresentation
*/
class PlayerRepresentation {
public:
std::string name;
bool alive;
std::optional<std::string> govRole;

explicit PlayerRepresentation(std::string name, bool alive, std::optional<std::string> govRole);
};

/**
* @class Player
*/
class Player {

public:
Expand All @@ -34,15 +56,21 @@ namespace GameModel {

[[nodiscard]] std::size_t getSessionId() const;

void setAlive(bool isPlayerAlive);

bool getAlive() const;

void setSessionId(std::size_t sessionId);

auto getPlayerRepresentation() -> PlayerRepresentation;

private:
std::string name;
Fraction fraction;
Role role;
bool alive;
std::size_t sessionID;
};

}

#endif // SECRETBUNDESTAGSERVER_PLAYER_HPP