Settings.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Settings.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include <limits>
  12. #include "Settings.h"
  13. #include "../../../lib/constants/StringConstants.h"
  14. #include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
  15. #include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
  16. #include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
  17. #include "../../../lib/mapObjects/MapObjects.h"
  18. #include "../../../lib/modding/CModHandler.h"
  19. #include "../../../lib/VCMI_Lib.h"
  20. #include "../../../lib/filesystem/Filesystem.h"
  21. #include "../../../lib/json/JsonUtils.h"
  22. namespace NKAI
  23. {
  24. Settings::Settings(int difficultyLevel)
  25. : maxRoamingHeroes(8),
  26. mainHeroTurnDistanceLimit(10),
  27. scoutHeroTurnDistanceLimit(5),
  28. maxGoldPressure(0.3f),
  29. retreatThresholdRelative(0.3),
  30. retreatThresholdAbsolute(10000),
  31. safeAttackRatio(1.1),
  32. maxPass(10),
  33. maxPriorityPass(10),
  34. pathfinderBucketsCount(1),
  35. pathfinderBucketSize(32),
  36. allowObjectGraph(true),
  37. useTroopsFromGarrisons(false),
  38. updateHitmapOnTileReveal(false),
  39. openMap(true),
  40. useFuzzy(false)
  41. {
  42. const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
  43. const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
  44. const JsonNode & node = rootNode[difficultyName];
  45. maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
  46. mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
  47. scoutHeroTurnDistanceLimit = node["scoutHeroTurnDistanceLimit"].Integer();
  48. maxPass = node["maxPass"].Integer();
  49. maxPriorityPass = node["maxPriorityPass"].Integer();
  50. pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer();
  51. pathfinderBucketSize = node["pathfinderBucketSize"].Integer();
  52. maxGoldPressure = node["maxGoldPressure"].Float();
  53. retreatThresholdRelative = node["retreatThresholdRelative"].Float();
  54. retreatThresholdAbsolute = node["retreatThresholdAbsolute"].Float();
  55. maxArmyLossTarget = node["maxArmyLossTarget"].Float();
  56. safeAttackRatio = node["safeAttackRatio"].Float();
  57. allowObjectGraph = node["allowObjectGraph"].Bool();
  58. updateHitmapOnTileReveal = node["updateHitmapOnTileReveal"].Bool();
  59. openMap = node["openMap"].Bool();
  60. useFuzzy = node["useFuzzy"].Bool();
  61. useTroopsFromGarrisons = node["useTroopsFromGarrisons"].Bool();
  62. }
  63. }