Settings.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/mapObjects/MapObjects.h"
  17. #include "../../../lib/modding/CModHandler.h"
  18. #include "../../../lib/GameLibrary.h"
  19. #include "../../../lib/filesystem/Filesystem.h"
  20. #include "../../../lib/json/JsonUtils.h"
  21. namespace NKAI
  22. {
  23. Settings::Settings(int difficultyLevel)
  24. : maxRoamingHeroes(8),
  25. mainHeroTurnDistanceLimit(10),
  26. scoutHeroTurnDistanceLimit(5),
  27. threatTurnDistanceLimit(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. useOneWayMonoliths(false),
  38. useTroopsFromGarrisons(false),
  39. updateHitmapOnTileReveal(false),
  40. openMap(true),
  41. useFuzzy(false)
  42. {
  43. const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
  44. const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
  45. const JsonNode & node = rootNode[difficultyName];
  46. maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
  47. mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
  48. scoutHeroTurnDistanceLimit = node["scoutHeroTurnDistanceLimit"].Integer();
  49. maxPass = node["maxPass"].Integer();
  50. maxPriorityPass = node["maxPriorityPass"].Integer();
  51. pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer();
  52. pathfinderBucketSize = node["pathfinderBucketSize"].Integer();
  53. maxGoldPressure = node["maxGoldPressure"].Float();
  54. retreatThresholdRelative = node["retreatThresholdRelative"].Float();
  55. retreatThresholdAbsolute = node["retreatThresholdAbsolute"].Float();
  56. maxArmyLossTarget = node["maxArmyLossTarget"].Float();
  57. safeAttackRatio = node["safeAttackRatio"].Float();
  58. allowObjectGraph = node["allowObjectGraph"].Bool();
  59. updateHitmapOnTileReveal = node["updateHitmapOnTileReveal"].Bool();
  60. openMap = node["openMap"].Bool();
  61. useFuzzy = node["useFuzzy"].Bool();
  62. useTroopsFromGarrisons = node["useTroopsFromGarrisons"].Bool();
  63. useOneWayMonoliths = node["useOneWayMonoliths"].Bool();
  64. }
  65. }