Move the board code out to ui as it's only for board visualisation
This commit is contained in:
parent
a17a9db2ad
commit
2abd4ad832
9 changed files with 39 additions and 13 deletions
|
@ -10,3 +10,4 @@ endif()
|
||||||
add_subdirectory( ttrts )
|
add_subdirectory( ttrts )
|
||||||
add_subdirectory( game )
|
add_subdirectory( game )
|
||||||
add_subdirectory( test )
|
add_subdirectory( test )
|
||||||
|
add_subdirectory( ui )
|
||||||
|
|
|
@ -13,7 +13,6 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11" )
|
||||||
# Add the sources
|
# Add the sources
|
||||||
set( SOURCES
|
set( SOURCES
|
||||||
game.cpp
|
game.cpp
|
||||||
board.cpp
|
|
||||||
unitv.cpp
|
unitv.cpp
|
||||||
unit.cpp
|
unit.cpp
|
||||||
orders.cpp
|
orders.cpp
|
||||||
|
|
12
game/game.h
12
game/game.h
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _GAME_H_
|
#ifndef _GAME_H_
|
||||||
#define _GAME_H_
|
#define _GAME_H_
|
||||||
|
|
||||||
#include "board.h"
|
#include "unit.h"
|
||||||
#include "gametypes.h"
|
#include "gametypes.h"
|
||||||
#include "orders.h"
|
#include "orders.h"
|
||||||
|
|
||||||
|
@ -27,10 +27,16 @@ public:
|
||||||
bool NextTurn();
|
bool NextTurn();
|
||||||
|
|
||||||
// Get the number of units
|
// 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)
|
// 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:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -10,4 +10,10 @@ typedef unsigned short player_id_t;
|
||||||
// Type for unit IDs
|
// Type for unit IDs
|
||||||
typedef unsigned short unit_id_t;
|
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_
|
#endif //_GAME_TYPES_H_
|
|
@ -7,12 +7,6 @@
|
||||||
#include "gametypes.h"
|
#include "gametypes.h"
|
||||||
#include "vector2.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
|
// Base unit type
|
||||||
class CUnit
|
class CUnit
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ project( ttrts-test )
|
||||||
include_directories(
|
include_directories(
|
||||||
../game
|
../game
|
||||||
../maths
|
../maths
|
||||||
|
../ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set( SOURCES
|
set( SOURCES
|
||||||
|
@ -18,4 +19,4 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11" )
|
||||||
# Add the executable
|
# Add the executable
|
||||||
add_executable( ttrts-test ${SOURCES} )
|
add_executable( ttrts-test ${SOURCES} )
|
||||||
|
|
||||||
target_link_libraries( ttrts-test game )
|
target_link_libraries( ttrts-test game ui )
|
|
@ -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} )
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#include "gametypes.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "unit.h"
|
|
||||||
|
|
||||||
#include <limits> // std::numeric_limits
|
#include <limits> // std::numeric_limits
|
||||||
#include <vector> // std::vector
|
#include <vector> // std::vector
|
Loading…
Add table
Add a link
Reference in a new issue