Set up a basic ttrts binary

It takes a game description from the command line.
Looks in a folder 'ttrts_gamename' for turn commands
Reads those in and simulates until a winner is found
This commit is contained in:
Marc Di Luzio 2014-12-16 13:13:03 +00:00
parent a90ad9f90c
commit 2a410d98c0
4 changed files with 184 additions and 3 deletions

View file

@ -342,6 +342,25 @@ CUnit& CTTRTSGame::GetUnitByID( unit_id_t id )
return invalid_unit;
}
// Get a vector of the teams in the current game
std::vector<Team> CTTRTSGame::GetTeams() const
{
std::vector<Team> teams;
teams.reserve(GetNumUnits());
// Grab all teams
for ( const OrderUnitPair& pair : m_OrderUnitPairs )
{
teams.push_back(pair.unit.getTeam());
}
// Remove dupes
std::sort( teams.begin(), teams.end() );
teams.erase( std::unique( teams.begin(), teams.end() ), teams.end() );
return teams;
}
// Check if we have a win state
Team CTTRTSGame::CheckForWin() const
{

View file

@ -96,6 +96,10 @@ public:
// Set the turn of the game
inline int SetTurn( int in ) { return (turn = in); }
inline int GetTurn() const { return turn; }
// Get a vector of the teams in the current game
std::vector<Team> GetTeams() const;
private: