diff --git a/CMakeLists.txt b/CMakeLists.txt index bf5de03..f0e2055 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,5 +16,8 @@ endif() # Subprojects add_subdirectory( ttrts ) add_subdirectory( game ) -add_subdirectory( test ) add_subdirectory( ui ) + +# Auxhilary binaries +add_subdirectory( test ) +add_subdirectory( gen ) diff --git a/game/game.h b/game/game.h index fad3b68..a218b92 100644 --- a/game/game.h +++ b/game/game.h @@ -92,6 +92,7 @@ public: // Set the game name // NOTE: Names with spaces not allowed inline std::string SetName( const std::string& in ) { return (name = in); } + inline std::string GetName() const { return name; } // Set the turn of the game inline int SetTurn( int in ) { return (turn = in); } diff --git a/gen/CMakeLists.txt b/gen/CMakeLists.txt new file mode 100644 index 0000000..9eff3b8 --- /dev/null +++ b/gen/CMakeLists.txt @@ -0,0 +1,17 @@ +# ====================== gen ======================= +# Project name +project( ttrts-gen ) + +include_directories( + ../game + ../maths +) + +set( SOURCES + gen.cpp +) + +# Add the executable +add_executable( ttrts-gen ${SOURCES} ) + +target_link_libraries( ttrts-gen game ) \ No newline at end of file diff --git a/gen/gen.cpp b/gen/gen.cpp new file mode 100644 index 0000000..f020348 --- /dev/null +++ b/gen/gen.cpp @@ -0,0 +1,44 @@ +#include "game.h" + +#include +#include + +void AddUnitToGame( player_id_t player, Team team, char vis, uvector2 vec, CTTRTSGame& game ) +{ + CUnit unit = CUnit::GetUnitFromVis(vis); + unit.setPos( vec ); + unit.setPlayer(player); + unit.setTeam(team); + game.AddUnit(std::move(unit)); +} + +void OutputGame( CTTRTSGame& game ) +{ + std::ofstream output; + output.open (game.GetName() + ".txt"); + output << game.GetStateAsString(); + output.close(); +} + +int main() +{ + // Basic 5v5 game + { + CTTRTSGame game(21, 11); + game.SetName("Basic_5_v_5"); + + AddUnitToGame(0, Team::Blue, '>', uvector2(1, 1), game); + AddUnitToGame(0, Team::Blue, '>', uvector2(1, 3), game); + AddUnitToGame(0, Team::Blue, '>', uvector2(1, 5), game); + AddUnitToGame(0, Team::Blue, '>', uvector2(1, 7), game); + AddUnitToGame(0, Team::Blue, '>', uvector2(1, 9), game); + + AddUnitToGame(1, Team::Red, '<', uvector2(19, 1), game); + AddUnitToGame(1, Team::Red, '<', uvector2(19, 3), game); + AddUnitToGame(1, Team::Red, '<', uvector2(19, 5), game); + AddUnitToGame(1, Team::Red, '<', uvector2(19, 7), game); + AddUnitToGame(1, Team::Red, '<', uvector2(19, 9), game); + + OutputGame(game); + } +} \ No newline at end of file diff --git a/test/test.cpp b/test/test.cpp index 903ecc1..b604f92 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -136,6 +136,7 @@ const char* tests() // Test on a tiny board, whether a unit can correctly attack another { CTTRTSGame game( 2, 1 ); + game.SetName("Test_578"); unit_id_t id; {