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