From ace5c3f3093c50ff7fa6f8b281a377e3788abbd5 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Sun, 29 Aug 2021 13:57:41 +0200 Subject: adding techs --- game/load.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 game/load.cpp (limited to 'game/load.cpp') diff --git a/game/load.cpp b/game/load.cpp new file mode 100644 index 0000000..d1a1722 --- /dev/null +++ b/game/load.cpp @@ -0,0 +1,91 @@ +#include +#include +#include + +#include "load.h" + +#include "nlohmann/json.hpp" +using json = nlohmann::json; + +std::vector load_abilities () { + std::vector abs; + abs.emplace_back("Anti-Cavalry"); + abs.emplace_back("Skirmish"); + abs.emplace_back("First Strike"); + abs.emplace_back("Rapid Fire"); + abs.emplace_back("Units Only"); + abs.emplace_back("Buildings Only"); + abs.emplace_back("No Counter"); + abs.emplace_back("No Move & Attack"); + abs.emplace_back("Causes Fear"); + abs.emplace_back("Desert Charge"); + abs.emplace_back("Plains Charge"); + abs.emplace_back("Scares Horses"); + abs.emplace_back("Woodsman"); + abs.emplace_back("Volley"); + abs.emplace_back("Frenzy"); + abs.emplace_back("Zeal"); + abs.emplace_back("Scout"); + abs.emplace_back("Convert"); + abs.emplace_back("Heal"); + abs.emplace_back("Seasoned Veteran"); + return abs; +} + +void load_json (Gst &gst) { + gst.abilities = load_abilities(); + + std::ifstream file_tiles("content/tiles.json"); + json j_tiles; file_tiles >> j_tiles; + for (auto it : j_tiles) { + Tile tile; + tile.name = it["name"]; + tile.move_cost = it["move_cost"]; + tile.spritebounds = vec2 { it["spritebounds"][0], it["spritebounds"][1] }; + gst.tiles.push_back(tile); + } + + std::ifstream file_ents("content/entities.json"); + json j_ents; file_ents >> j_ents; + for (auto it : j_ents) { + EntityInfo ent; + ent.id = it["id"]; + ent.name = it["name"]; + ent.range = it["range"]; + ent.move = it["move"]; + ent.attack = it["attack"]; + ent.defence = it["defence"]; + ent.sight = it["sight"]; + ent.unit = it["unit"]; + for (int i=0; i