ttrts/source/game/order.h
Marc Di Luzio 3fc1f5ee5d Change unit Attack behaviour to a charge
All charges on a turn are evaluated at the same time, step by step
2014-12-17 13:38:06 +00:00

54 lines
1.2 KiB
C++

#ifndef _ORDERS_H_
#define _ORDERS_H_
#include <vector>
#include <string>
#include "gametypes.h"
#define ORDER_FORMATTER "ORDER:%c id:%u"
// Type for all orders ( as a char )
enum class command_c : char
{
F = 'F', // Move forward one square
L = 'L', // Turn left
R = 'R', // Turn right
A = 'A', // Attack forwards until a unit or edge of the arena is hit
NUM_INVALID
};
// Container for an order
struct COrder
{
// Base constructor makes invalid order
COrder()
: unit ( unit_id_invalid )
, command( command_c::NUM_INVALID )
{}
// Unit order is for
unit_id_t unit;
// Order command issued
command_c command;
// Basic operators
inline bool operator==( const COrder& rhs ) const;
inline bool operator!=( const COrder& rhs ) const { return !(*this==rhs); }
};
// Simple == operator
inline bool COrder::operator== ( const COrder& rhs ) const
{
return ( unit == rhs.unit ) && ( command == rhs.command);
}
// Typedef a vector of orders
typedef std::vector<COrder> COrderVector;
// string <--> order conversion functions
std::string GetStringFromOrder(const COrder& order );
COrder GetOrderFromString( const std::string& order );
#endif //_ORDERS_H_