diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d94aa3..014ed35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,3 +10,4 @@ endif() add_subdirectory( ttrts ) add_subdirectory( game ) add_subdirectory( test ) +add_subdirectory( ui ) diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 13b4d89..935bb02 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -13,7 +13,6 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11" ) # Add the sources set( SOURCES game.cpp - board.cpp unitv.cpp unit.cpp orders.cpp diff --git a/game/game.h b/game/game.h index a14b74f..81b51fc 100644 --- a/game/game.h +++ b/game/game.h @@ -1,7 +1,7 @@ #ifndef _GAME_H_ #define _GAME_H_ -#include "board.h" +#include "unit.h" #include "gametypes.h" #include "orders.h" @@ -27,10 +27,16 @@ public: bool NextTurn(); // Get the number of units - inline unsigned int GetNumUnits() const { return m_orders.size(); } + inline unsigned int GetNumUnits() const { return m_allUnits.size(); } // Get unit by index as above (not unit ID) - inline const CUnit& GetUnitByIndex( unsigned int i ) const { return *m_orders[i]; } + inline const CUnit& GetUnitByIndex( unsigned int i ) const { return *m_allUnits[i]; } + + // Get the number of order + inline unsigned int GetNumOrders() const { return m_orders.size(); } + + // Get orders by index as above + inline const COrder& GetOrdersByIndex( unsigned int i ) const { return m_orders[i]; } private: @@ -39,7 +45,7 @@ private: // Simulate all actions bool SimulateActions(); - + // Vector to store points to all units sharedUnitVector_t m_allUnits; diff --git a/game/gametypes.h b/game/gametypes.h index fe2deb9..47dd9ab 100644 --- a/game/gametypes.h +++ b/game/gametypes.h @@ -10,4 +10,10 @@ typedef unsigned short player_id_t; // Type for unit IDs typedef unsigned short unit_id_t; +// Type for the unit type-id +typedef char unitType_c; + +// Typedef for unit visual representations +typedef char unitVis_c; + #endif //_GAME_TYPES_H_ \ No newline at end of file diff --git a/game/unit.h b/game/unit.h index 585c6c7..4fc71b7 100644 --- a/game/unit.h +++ b/game/unit.h @@ -7,12 +7,6 @@ #include "gametypes.h" #include "vector2.h" -// Type for the unit type-id -typedef char unitType_c; - -// Typedef for unit visual representations -typedef char unitVis_c; - // Base unit type class CUnit { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ceca484..6ef211e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,6 +6,7 @@ project( ttrts-test ) include_directories( ../game ../maths + ../ui ) set( SOURCES @@ -18,4 +19,4 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11" ) # Add the executable add_executable( ttrts-test ${SOURCES} ) -target_link_libraries( ttrts-test game ) \ No newline at end of file +target_link_libraries( ttrts-test game ui ) \ No newline at end of file diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index e69de29..8b508ff 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.7) + +# game project +project( ui ) + +include_directories( + ../maths + ../game +) + +# Set to use c++11, because we're cool like that +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11" ) + +# Add the sources +set( SOURCES + board.cpp +) + +add_library( ui ${SOURCES} ) \ No newline at end of file diff --git a/game/board.cpp b/ui/board.cpp similarity index 100% rename from game/board.cpp rename to ui/board.cpp diff --git a/game/board.h b/ui/board.h similarity index 96% rename from game/board.h rename to ui/board.h index ce7236d..d36ab3a 100644 --- a/game/board.h +++ b/ui/board.h @@ -1,8 +1,8 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#include "gametypes.h" #include "basetypes.h" -#include "unit.h" #include // std::numeric_limits #include // std::vector