#include "dark.hpp"
#include "common/ini.hpp"
void load_plr_dark(CN(a83::Str) dir_name) {
  INI ini(Game::archive, dir_name + "conf.ini");
  auto info = new Dark_info();
  mp_info_mu.lock();
  mp_info[PLR_DARK] = info;
  mp_info_mu.unlock();
  cauto sct_dark = "dark";
  #define LDI(val, sct, name, deflt) info->val = ini.getInt(sct, name, deflt);
  #define LDF(val, sct, name, deflt) info->val = ini.getFloat(sct, name, deflt);
  LDI(dmg, sct_dark, "dmg", {})
  LDF(cld_dist, sct_dark, "cld_dist", {})
  LDF(check_dist, sct_dark, "check_dist", {})
  cauto offset_x = ini.getFloat(sct_dark, "offset_x", 0);
  cauto offset_y = ini.getFloat(sct_dark, "offset_y", 0);
  LDF(accel_add, sct_dark, "accel_add", 0)
  LDF(DEFAULT_SPEED, sct_dark, "DEFAULT_SPEED", 0)
  LDF(accel_rot, sct_dark, "accel_rot", 0)
  LDF(accel_rot_focus, sct_dark, "accel_rot_focus", 0)
  LDF(spd_min, sct_dark, "MIN_SPEED", 0)
  info->accel_max = info->spd_max = ini.getFloat(sct_dark, "MAX_SPEED", 0);
  LDF(JOLT_RATIO, sct_dark, "JOLT_RATIO", 0)
  LDF(JOLTING_THRESOLD, sct_dark, "JOLTING_THRESOLD", 0)
  LDF(LINES_SPEED, sct_dark, "LINES_SPEED", 0)
  LDF(JOLT_POWER, sct_dark, "JOLT_POWER", 5)
  LDF(JOLT_DECREASE, sct_dark, "JOLT_DECREASE", 0.5f)
  LDF(main_cost, sct_dark, "main_cost", 5);
  LDF(side_cost, sct_dark, "side_cost", 15);
  LDF(back_cost, sct_dark, "back_cost", 30);
  LDF(shield_cost, sct_dark, "shield_cost", 60);
  LDF(shield_hit_cost, sct_dark, "shield_hit_cost", 120);
  LDF(SHOOT_CLDWN, sct_dark, "SHOOT_CLDWN", 1);
  LDF(SHOOT_SIDE_CLDWN, sct_dark, "SHOOT_SIDE_CLDWN", 1);
  LDF(SHOOT_BACK_CLDWN, sct_dark, "SHOOT_BACK_CLDWN", 1);
// опции зависящие от сложнсоти:
  static const a83::Str DIFF_TABLE[difficulty_max]
    = {"easy", "normal", "hard", "die"};
  cauto CUR_DIFFICULTY = DIFF_TABLE[uint(Game::difficulty) % difficulty_max];
  vp_figure_t hits;
  parse_hits(hits, ini.getStr(CUR_DIFFICULTY, "hits", {}));
  LDI(hp, CUR_DIFFICULTY, "hp", 50);
  info->smoke_hp = info->hp / 3;
  LDI(en, CUR_DIFFICULTY, "en", 1300);
  LDI(en_ext, CUR_DIFFICULTY, "en_ext", 1000);
  LDF(en_reg, CUR_DIFFICULTY, "en_reg", 10);
  // спрайты:
  bank_anim_mu.lock();
  info->p_anim = bank_anim.add_noanim_rot3(Game::archive, {
    dir_name + "0.png",
    dir_name + "1.png",
    dir_name + "2.png"}, {offset_x, offset_y}, hits,
    Sprite::LightMode::way4);
  bank_anim_mu.unlock();
  vp_delete(hits);
  #undef LDI
  #undef LDF
} // load_plr_dark