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:
parent
a90ad9f90c
commit
2a410d98c0
4 changed files with 184 additions and 3 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue