From 728abda9dc6fc8e65c7c0e0240a2e7d61a43a583 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Sun, 5 Sep 2021 22:36:13 +0200 Subject: tech tostring, all sprites, heal and convert --- game/ground.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'game/ground.cpp') diff --git a/game/ground.cpp b/game/ground.cpp index 4308047..1cadd9b 100644 --- a/game/ground.cpp +++ b/game/ground.cpp @@ -98,9 +98,37 @@ std::vector Ground::attack_targets (Gst &gst, Entity &ent) { for (Entity &e : gst.entities) { if (!units && e.info->unit == 1) continue; if (!builds && e.info->unit == 0) continue; - if (e.owner != ent.owner && abs(e.x-ent.x)+abs(e.y-ent.y) <= range) { + int dist = abs(e.x-ent.x)+abs(e.y-ent.y); + if (dist > 0 && e.owner != ent.owner && dist <= range) { attacks.push_back(at(e.x, e.y)); } } return attacks; +} + +std::vector Ground::heal_targets (Gst &gst, Entity &ent) { + std::vector heals; + int range = gst.get_range(ent); + for (Entity &e : gst.entities) { + if (e.info->unit == 0) continue; + if (e.info->ent_class == EntityInfo::Class::sie) continue; + int dist = abs(e.x-ent.x)+abs(e.y-ent.y); + if (dist > 0 && e.owner == ent.owner && dist <= range) { + heals.push_back(at(e.x, e.y)); + } + } + return heals; +} + +std::vector Ground::convert_targets (Gst &gst, Entity &ent) { + std::vector converts; + int range = gst.get_range(ent); + for (Entity &e : gst.entities) { + if (e.info->unit == 0) continue; + int dist = abs(e.x-ent.x)+abs(e.y-ent.y); + if (dist > 0 && e.owner != ent.owner && dist <= range) { + converts.push_back(at(e.x, e.y)); + } + } + return converts; } \ No newline at end of file -- cgit v1.2.3-54-g00ecf