|
|
|
@ -5,6 +5,7 @@ |
|
|
|
|
#include <array> |
|
|
|
|
#include <sstream> |
|
|
|
|
#include "fsm.hpp" |
|
|
|
|
#include <fmt/core.h> |
|
|
|
|
|
|
|
|
|
using std::string; |
|
|
|
|
|
|
|
|
@ -41,21 +42,35 @@ class GameEngine : DeadSimpleFSM<GameState, GameEvent> { |
|
|
|
|
int determine_damage(string &type); |
|
|
|
|
bool is_dead(); |
|
|
|
|
|
|
|
|
|
void event(GameEvent ev, string &hit_type) { |
|
|
|
|
switch(_state) { |
|
|
|
|
case GameState::IN_ROUND: |
|
|
|
|
in_round(ev, hit_type); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
event(ev); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void event(GameEvent ev) { |
|
|
|
|
switch(_state) { |
|
|
|
|
FSM_STATE(GameState::START, start, ev); |
|
|
|
|
FSM_STATE(GameState::IDLE, idle, ev); |
|
|
|
|
FSM_STATE(GameState::IN_ROUND, in_round, ev); |
|
|
|
|
FSM_STATE(GameState::DEAD, dead, ev); |
|
|
|
|
FSM_STATE(GameState::SUCCESS, success, ev); |
|
|
|
|
FSM_STATE(GameState::FAILURE, failure, ev); |
|
|
|
|
case GameState::IN_ROUND: { |
|
|
|
|
string hit_type = ""; |
|
|
|
|
in_round(ev, hit_type); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FSM to replace the others
|
|
|
|
|
void start(GameEvent ev); |
|
|
|
|
void idle(GameEvent ev); |
|
|
|
|
void in_round(GameEvent ev); |
|
|
|
|
void in_round(GameEvent ev, string &hit_type); |
|
|
|
|
void dead(GameEvent ev); |
|
|
|
|
void success(GameEvent ev); |
|
|
|
|
void failure(GameEvent ev); |
|
|
|
|