-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCTankAction.h
More file actions
54 lines (36 loc) · 1.09 KB
/
CTankAction.h
File metadata and controls
54 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/******************************************************************************
* Tank AI Programming challenge
*
* Written by: Steven Smethurst
* Created: Nov 04, 2012
*
******************************************************************************/
#pragma once
#include <string>
#include <iostream>
#include <regex>
#define TANK_SPEED 1
#define TANK_PROJECTILES 3
#define TANK_PROJECTILES_SPEED 10
class CTankAction
{
public:
enum ActionEnum {
SHOOT=0, MOVE, PING
};
enum DirectionsEnum {
NORTH=0, EAST, SOUTH, WEST, NONE
};
ActionEnum m_action;
DirectionsEnum m_direction;
CTankAction();
void Set( const ActionEnum action, const DirectionsEnum direction = DirectionsEnum::NONE ) ;
bool Decode( const std::string command );
std::string Encode();
private:
// Helpers
std::string DirectionToString( const DirectionsEnum direction );
std::string ActionToString( const ActionEnum action );
bool StringToAction( std::string value, ActionEnum &action );
bool StringToDirection( std::string value, DirectionsEnum &direction );
};