From 108be3035fad323b4dd2106befaa28fd29553570 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 16 Dec 2014 13:12:58 +0000 Subject: [PATCH] Final bit of design doe the game class, should be enough of a final interface to get started on implementation --- game/game.cpp | 7 ------- game/game.h | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/game/game.cpp b/game/game.cpp index b014a7b..7bb61ba 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -1,8 +1 @@ #include "game.h" - - -// Initialise the game with default configuration -void CTTRTSGame::Initialise() -{ - -} \ No newline at end of file diff --git a/game/game.h b/game/game.h index 81b51fc..c639b5c 100644 --- a/game/game.h +++ b/game/game.h @@ -13,18 +13,29 @@ class CTTRTSGame { public: - CTTRTSGame(); + CTTRTSGame( ucoord_t c, ucoord_t r ) + : cols (c) + , rows (r) + { + + } + + // Default dtor ~CTTRTSGame() = default; - // Initialise the game with default configuration - void Initialise(); - - // Issue orders to the game - bool IssueOrders( std::string orders ); - bool IssueOrders( COrderVector orders ); + // Issue orders to the game, returns non-zero if orders are incorrect + int IssueOrders( player_id_t player, std::string orders ); + int IssueOrders( player_id_t player, COrderVector orders ); // Simulate and progress to the next turn - bool NextTurn(); + // Returns non-zero if simulation failed + int SimulateToNextTurn(); + + // Add a unit, nonzero return value indicates error + int AddUnit( std::shared_ptr unit ); + + // Add a units, nonzero return value indicates error + int AddUnits( sharedUnitVector_t units ); // Get the number of units inline unsigned int GetNumUnits() const { return m_allUnits.size(); } @@ -46,11 +57,18 @@ private: // Simulate all actions bool SimulateActions(); + // Verify any order + bool VerifyOrder( player_id_t player, COrder& order ); + // Vector to store points to all units - sharedUnitVector_t m_allUnits; + sharedUnitVector_t m_allUnits; // Orders to execute this turn - COrderVector m_orders; + COrderVector m_orders; + + // Dimensions of the game + ucoord_t rows; + ucoord_t cols; }; #endif //_GAME_H_ \ No newline at end of file