#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 (Inv &inv) { inv.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.defence_bonus = it["defence_bonus"]; tile.range_bonus = it["range_bonus"]; tile.spritebounds = vec2 { it["spritebounds"][0], it["spritebounds"][1] }; inv.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.level = it["level"]; 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())); } for (auto ad : it["adjacent"]) { ent.adjacent.push_back(ad); } for (auto ad : it["diagonal"]) { ent.diagonal.push_back(ad); } ent.ent_class = (EntityInfo::Class) EntityClass::from_string( it["class"].get()); for (auto ab : it["abilities"]) { int index = 0; for (int i=0; i> j_techs; for (auto it : j_techs) { Tech tech; tech.name = it["name"]; tech.id = it["id"]; tech.level = it["level"]; tech.req_id = it["req_id"]; for (int i=0; i())); } if (b.contains("aff_level")) { tech.bonus.aff_level = b["aff_level"]; } if (b.contains("aff_all")) { tech.bonus.aff_all = b["aff_all"]; } } inv.techs.push_back(tech); } }