diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-04 13:35:02 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-04 13:35:02 +0100 |
commit | bb16c32bde58cba70e4877aa2d3ebd04332eb575 (patch) | |
tree | de3d82cca043c26cbaa64837a3b2c18efc6ddb64 /game/ai/performer.h | |
parent | 411d2f6d6a6e5370d33f0f54b2f2de7147a9d977 (diff) |
linux compile and imgs
Diffstat (limited to 'game/ai/performer.h')
-rw-r--r-- | game/ai/performer.h | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/game/ai/performer.h b/game/ai/performer.h index 472773b..17be028 100644 --- a/game/ai/performer.h +++ b/game/ai/performer.h @@ -1,49 +1,49 @@ -#ifndef PERFORMER_H -#define PERFORMER_H - -#include <iostream> - -#include <string> -#include <vector> - -#include "../ground.h" -#include "../gst.h" -#include "action.h" -#include "tactic.h" - -namespace ai { - -class performer { - public: - performer (Gst &gst) : init(gst) {} - Gst &init; - - Gst apply (tactic t) { - Gst next { init }; - for (action a : t.acts) { - next = act(next, a); - } - next.end_day(); - return next; - } - - Gst& act (Gst &gst, action a) { - if (a.type == actype::move) { - Entity &ent = gst.get_at(a.x, a.y); - ent.x = a.mx; ent.y = a.my; - ent.moved = 1; ent.done = true; - } - if (a.type == actype::attack) { - Entity &ent = gst.get_at(a.x, a.y); - ent.x = a.mx; ent.y = a.my; - ent.moved = 1; - Entity &def = gst.get_at(a.tx, a.ty); - gst.battle(ent, def); - ent.done = true; - } - return gst; - } -}; - -} +#ifndef PERFORMER_H
+#define PERFORMER_H
+
+#include <iostream>
+
+#include <string>
+#include <vector>
+
+#include "../ground.h"
+#include "../gst.h"
+#include "action.h"
+#include "tactic.h"
+
+namespace ai {
+
+class performer {
+ public:
+ performer (Gst &gst) : init(gst) {}
+ Gst &init;
+
+ Gst apply (tactic t) {
+ Gst next { init };
+ for (action a : t.acts) {
+ next = act(next, a);
+ }
+ next.end_day();
+ return next;
+ }
+
+ Gst& act (Gst &gst, action a) {
+ if (a.type == actype::move) {
+ Entity &ent = gst.get_at(a.x, a.y);
+ ent.x = a.mx; ent.y = a.my;
+ ent.moved = 1; ent.done = true;
+ }
+ if (a.type == actype::attack) {
+ Entity &ent = gst.get_at(a.x, a.y);
+ ent.x = a.mx; ent.y = a.my;
+ ent.moved = 1;
+ Entity &def = gst.get_at(a.tx, a.ty);
+ gst.battle(ent, def);
+ ent.done = true;
+ }
+ return gst;
+ }
+};
+
+}
#endif
\ No newline at end of file |