|
|
|
@ -9,16 +9,17 @@ |
|
|
|
|
using std::string; |
|
|
|
|
|
|
|
|
|
enum class GameState { |
|
|
|
|
START, IDLE, IN_ROUND, DEAD, ALIVE |
|
|
|
|
START, IDLE, IN_ROUND, DEAD, SUCCESS, FAILURE |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class GameEvent { |
|
|
|
|
BUILD_START, BUILD_END, |
|
|
|
|
HIT |
|
|
|
|
BUILD_START, BUILD_SUCCESS, |
|
|
|
|
BUILD_DONE, BUILD_FAILED, HIT |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class GameEngine : DeadSimpleFSM<GameState, GameEvent> { |
|
|
|
|
|
|
|
|
|
std::map<string, int> damage_types{ |
|
|
|
|
{"error", 4}, |
|
|
|
|
{"warning", 1}, |
|
|
|
@ -31,7 +32,6 @@ class GameEngine : DeadSimpleFSM<GameState, GameEvent> { |
|
|
|
|
int hits_taken = 0; |
|
|
|
|
int rounds = 0; |
|
|
|
|
int streak = 0; |
|
|
|
|
GameState _state = GameState::START; |
|
|
|
|
|
|
|
|
|
GameEngine(int hp); |
|
|
|
|
|
|
|
|
@ -47,7 +47,8 @@ class GameEngine : DeadSimpleFSM<GameState, GameEvent> { |
|
|
|
|
FSM_STATE(GameState::IDLE, idle, ev); |
|
|
|
|
FSM_STATE(GameState::IN_ROUND, in_round, ev); |
|
|
|
|
FSM_STATE(GameState::DEAD, dead, ev); |
|
|
|
|
FSM_STATE(GameState::ALIVE, alive, ev); |
|
|
|
|
FSM_STATE(GameState::SUCCESS, success, ev); |
|
|
|
|
FSM_STATE(GameState::FAILURE, failure, ev); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -56,12 +57,10 @@ class GameEngine : DeadSimpleFSM<GameState, GameEvent> { |
|
|
|
|
void idle(GameEvent ev); |
|
|
|
|
void in_round(GameEvent ev); |
|
|
|
|
void dead(GameEvent ev); |
|
|
|
|
void alive(GameEvent ev); |
|
|
|
|
|
|
|
|
|
void success(GameEvent ev); |
|
|
|
|
void failure(GameEvent ev); |
|
|
|
|
|
|
|
|
|
// current API that will die
|
|
|
|
|
void start_round(); |
|
|
|
|
void end_round(); |
|
|
|
|
void heal(); |
|
|
|
|
bool hit(string &type); |
|
|
|
|
void reset(); |
|
|
|
|