Framework for movement and action orders, plus some better organisation of the test code

This commit is contained in:
Marc Di Luzio 2014-12-16 13:13:00 +00:00
parent 008739dee6
commit 72b35dbc06
5 changed files with 115 additions and 44 deletions

View file

@ -1,7 +1,9 @@
#include "orders.h"
#include "mathtypes.h"
// Convert an order to a string
std::string GetStringFromOrder( COrder& order )
std::string GetStringFromOrder(const COrder& order )
{
std::string ret;
ret += std::to_string(order.unit);
@ -12,8 +14,9 @@ std::string GetStringFromOrder( COrder& order )
}
// Convert a string to an order
COrder GetOrderFromString( std::string order )
COrder GetOrderFromString( const std::string& _order )
{
std::string order = _order;
COrder ret;
int pos = order.find(ORDER_DELIMITER);
@ -31,4 +34,26 @@ COrder GetOrderFromString( std::string order )
}
return ret;
}
bool isMovementOrder( const COrder& order )
{
const order_c c = order.order;
for ( unsigned int i = 0; i < _countof(sk_movementOrders); i++ )
{
if ( c == sk_movementOrders[i] )
return true;
}
return false;
}
bool isActionOrder( const COrder& order )
{
const order_c c = order.order;
for ( unsigned int i = 0; i < _countof(sk_actionOrders); i++ )
{
if ( c == sk_actionOrders[i] )
return true;
}
return false;
}