aboutsummaryrefslogtreecommitdiff
path: root/game/playercontrol.h
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-04 13:35:02 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-04 13:35:02 +0100
commitbb16c32bde58cba70e4877aa2d3ebd04332eb575 (patch)
treede3d82cca043c26cbaa64837a3b2c18efc6ddb64 /game/playercontrol.h
parent411d2f6d6a6e5370d33f0f54b2f2de7147a9d977 (diff)
linux compile and imgs
Diffstat (limited to 'game/playercontrol.h')
-rw-r--r--game/playercontrol.h182
1 files changed, 91 insertions, 91 deletions
diff --git a/game/playercontrol.h b/game/playercontrol.h
index c0075d4..d6b1fd7 100644
--- a/game/playercontrol.h
+++ b/game/playercontrol.h
@@ -1,92 +1,92 @@
-#ifndef PLAYERCONTROL_H
-#define PLAYERCONTROL_H
-
-#include <iostream>
-
-#include "gst.h"
-#include "view.h"
-#include <vector>
-#include <functional>
-
-
-enum pc_state {
- select,
- move,
- attack,
- train,
- build,
- merge,
- trade,
- age_up,
- heal,
- power,
- move_target,
- attack_target,
- menu_train,
- menu_build,
- target_build,
- merge_target,
- target_heal,
- target_convert,
- menu_power,
- target_power,
- menu_unit,
- menu_day,
- menu_tech,
- menu_trade,
- menu_age_up,
- end
-};
-
-enum pc_action {
- sel_unit,
- sel_ground,
- opt,
- back
-};
-
-
-class Fsm;
-using lambda = std::function<pc_state(Gst&, View&, Fsm&, int p)>;
-
-
-class Arc {
- public:
- Arc (pc_state from, pc_action act, int p, lambda f)
- : from(from), act(act), p(p), f(f) {};
- pc_state from;
- pc_action act;
- int p;
-
- lambda f;
-};
-
-class Fsm {
- public:
- Fsm() { state = select; }
-
- void transition (Gst &gst, View &view, Fsm &fsm, pc_action act, int p) {
- std::cout << "> transitioning from " << state << " with " << act << std::endl;
- for (Arc a : arcs) {
- if (a.from == state && a.act == act && (a.p == p || a.p == -1)) {
- state = a.f(gst, view, fsm, p);
- break;
- }
- }
- }
- std::vector<Arc> arcs;
-
- private:
- pc_state state;
-};
-
-
-class Player_control {
- public:
- Player_control ();
- void process (Gst &gst, View &view);
-
- Fsm fsm;
-};
-
+#ifndef PLAYERCONTROL_H
+#define PLAYERCONTROL_H
+
+#include <iostream>
+
+#include "gst.h"
+#include "view.h"
+#include <vector>
+#include <functional>
+
+
+enum pc_state {
+ select,
+ move,
+ attack,
+ train,
+ build,
+ merge,
+ trade,
+ age_up,
+ heal,
+ power,
+ move_target,
+ attack_target,
+ menu_train,
+ menu_build,
+ target_build,
+ merge_target,
+ target_heal,
+ target_convert,
+ menu_power,
+ target_power,
+ menu_unit,
+ menu_day,
+ menu_tech,
+ menu_trade,
+ menu_age_up,
+ end
+};
+
+enum pc_action {
+ sel_unit,
+ sel_ground,
+ opt,
+ back
+};
+
+
+class Fsm;
+using lambda = std::function<pc_state(Gst&, View&, Fsm&, int p)>;
+
+
+class Arc {
+ public:
+ Arc (pc_state from, pc_action act, int p, lambda f)
+ : from(from), act(act), p(p), f(f) {};
+ pc_state from;
+ pc_action act;
+ int p;
+
+ lambda f;
+};
+
+class Fsm {
+ public:
+ Fsm() { state = select; }
+
+ void transition (Gst &gst, View &view, Fsm &fsm, pc_action act, int p) {
+ std::cout << "> transitioning from " << state << " with " << act << std::endl;
+ for (Arc a : arcs) {
+ if (a.from == state && a.act == act && (a.p == p || a.p == -1)) {
+ state = a.f(gst, view, fsm, p);
+ break;
+ }
+ }
+ }
+ std::vector<Arc> arcs;
+
+ private:
+ pc_state state;
+};
+
+
+class Player_control {
+ public:
+ Player_control ();
+ void process (Gst &gst, View &view);
+
+ Fsm fsm;
+};
+
#endif \ No newline at end of file