diff options
author | jacopograndi <jak.sk8@hotmail.it> | 2021-09-06 20:11:36 +0200 |
---|---|---|
committer | jacopograndi <jak.sk8@hotmail.it> | 2021-09-06 20:11:36 +0200 |
commit | 411d2f6d6a6e5370d33f0f54b2f2de7147a9d977 (patch) | |
tree | 82b631079a3d7226ce6384f695f2e3b213a2c635 /game/ai/performer.h | |
parent | 522a43d16e812e10ff69747ee916918b4bd29f2f (diff) |
started ai
Diffstat (limited to 'game/ai/performer.h')
-rw-r--r-- | game/ai/performer.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/game/ai/performer.h b/game/ai/performer.h new file mode 100644 index 0000000..472773b --- /dev/null +++ b/game/ai/performer.h @@ -0,0 +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; + } +}; + +} +#endif
\ No newline at end of file |