Settings.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. 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. 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. }
  64. }