Settings.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/GameLibrary.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. threatTurnDistanceLimit(5),
  29. maxGoldPressure(0.3f),
  30. retreatThresholdRelative(0.3),
  31. retreatThresholdAbsolute(10000),
  32. safeAttackRatio(1.1),
  33. maxPass(10),
  34. maxPriorityPass(10),
  35. pathfinderBucketsCount(1),
  36. pathfinderBucketSize(32),
  37. allowObjectGraph(true),
  38. useOneWayMonoliths(false),
  39. useTroopsFromGarrisons(false),
  40. updateHitmapOnTileReveal(false),
  41. openMap(true),
  42. useFuzzy(false)
  43. {
  44. const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
  45. const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
  46. const JsonNode & node = rootNode[difficultyName];
  47. maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
  48. mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
  49. scoutHeroTurnDistanceLimit = node["scoutHeroTurnDistanceLimit"].Integer();
  50. maxPass = node["maxPass"].Integer();
  51. maxPriorityPass = node["maxPriorityPass"].Integer();
  52. pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer();
  53. pathfinderBucketSize = node["pathfinderBucketSize"].Integer();
  54. maxGoldPressure = node["maxGoldPressure"].Float();
  55. retreatThresholdRelative = node["retreatThresholdRelative"].Float();
  56. retreatThresholdAbsolute = node["retreatThresholdAbsolute"].Float();
  57. maxArmyLossTarget = node["maxArmyLossTarget"].Float();
  58. safeAttackRatio = node["safeAttackRatio"].Float();
  59. allowObjectGraph = node["allowObjectGraph"].Bool();
  60. updateHitmapOnTileReveal = node["updateHitmapOnTileReveal"].Bool();
  61. openMap = node["openMap"].Bool();
  62. useFuzzy = node["useFuzzy"].Bool();
  63. useTroopsFromGarrisons = node["useTroopsFromGarrisons"].Bool();
  64. useOneWayMonoliths = node["useOneWayMonoliths"].Bool();
  65. }
  66. }