From 522a43d16e812e10ff69747ee916918b4bd29f2f Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Sun, 5 Sep 2021 23:00:42 +0200 Subject: invariant added as 'inv' --- game/ground.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'game/ground.cpp') diff --git a/game/ground.cpp b/game/ground.cpp index 1cadd9b..5f58717 100644 --- a/game/ground.cpp +++ b/game/ground.cpp @@ -4,16 +4,12 @@ #include #include -Ground::Ground (int sx, int sy) { +void Ground::build (int sx, int sy) { sizex = sx; sizey = sy; tiles = new int[sx*sy]; for (int i=0; i Ground::move_area (Gst &gst, Entity &ent) { std::vector frontier { step { at(ent.x, ent.y), move_num } }; int maxcost = 99; - if (gst.info_has_ability(ent.info, "Scout")) maxcost = 2; + if (gst.inv->info_has_ability(ent.info, "Scout")) maxcost = 2; int iter=0; for (; iter<10000; iter++) { @@ -66,7 +62,7 @@ std::vector Ground::move_area (Gst &gst, Entity &ent) { for (int t : forward_star) { if (!(std::find(visited.begin(), visited.end(), t) != visited.end()) && !(std::find(frontier.begin(), frontier.end(), t) != frontier.end())) { - int movecost = gst.tiles[gst.ground.tiles[t]].move_cost; + int movecost = gst.inv->tiles[tiles[t]].move_cost; if (movecost > maxcost) movecost = maxcost; int walkedm = maxf.m - movecost; bool obstructed = false; @@ -93,8 +89,8 @@ std::vector Ground::move_area (Gst &gst, Entity &ent) { std::vector Ground::attack_targets (Gst &gst, Entity &ent) { std::vector attacks; int range = gst.get_range(ent); - bool builds = !gst.info_has_ability(ent.info, "Units Only"); - bool units = !gst.info_has_ability(ent.info, "Buildings Only"); + bool builds = !gst.inv->info_has_ability(ent.info, "Units Only"); + bool units = !gst.inv->info_has_ability(ent.info, "Buildings Only"); for (Entity &e : gst.entities) { if (!units && e.info->unit == 1) continue; if (!builds && e.info->unit == 0) continue; -- cgit v1.2.3-54-g00ecf