Container.cpp 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987
  1. #include "Container.h"
  2. #define DEBUG
  3. #include <string>
  4. #include <list>
  5. #include <tuple>
  6. #include <vector>
  7. #include <map>
  8. #include <iostream>
  9. #include <algorithm>
  10. #include <memory>
  11. #include <limits.h>
  12. #include <exception>
  13. using namespace std;
  14. using std::get;
  15. #ifdef DEBUG
  16. Container::Container()
  17. {
  18. artyRangesAmmo = { {"2C1", 15.2, 40, 4, 122.0}, {"2C3", 20.5, 46, 3, 152.0}, {"2C12B", 7.1, 60, 9, 82.0}};
  19. shellTypes = {"HE", "shrapnel", "cluster"};
  20. shellFuzes = {"percussion", "radio", "remoteControl"};
  21. targetsPriorities = { {"CP",1}, {"tank", 2}, {"infEntranched", 3}, {"infOpened", 4} };
  22. missions = { "destruction", "supression", "harassment" };
  23. targetGeometries = { "singular", "column", "squared" };
  24. preparingTypes = { "full", "eye", "shortened" };
  25. }
  26. #endif
  27. Container::Container(string file1, string file2) { cout << "i'm dummy" << endl; }
  28. Container::~Container() { cout << "that's all folks!" << endl; }
  29. bool Container::checkCorrectArty(string _artyType, size_t _numInBattery, size_t _numAmmo, string _shellType,
  30. string _shellFuzes, double _temperature)
  31. {
  32. auto it = find_if(artyRangesAmmo.begin(), artyRangesAmmo.end(), [&](auto const& _n)
  33. {
  34. return get<0>(_n) == _artyType; //åñëè àðòñèñòåìà åñòü â ñïèñêå
  35. });
  36. bool first = (it != artyRangesAmmo.end()) ? true : false;
  37. size_t reducedNumShells = static_cast<size_t>(_numAmmo / _numInBattery);
  38. bool second = ((reducedNumShells > 0)&&(reducedNumShells < get<2>(*it))) ? true : false; //åñëè ñíàðÿäîâ áîëüøå 0 íî ìåíüøå ìàêñèìóìà
  39. bool third = (find(shellTypes.begin(), shellTypes.end(), _shellType) != shellTypes.end()) ? true : false;
  40. bool fourth = (find(shellFuzes.begin(), shellFuzes.end(), _shellFuzes) != shellFuzes.end()) ? true : false;
  41. bool fifth = (_temperature > -50.0 && _temperature < +50.0) ? true : false;
  42. try
  43. {
  44. if (first && second && third && fourth && fifth) { return true; } //åñëè çàïðîñ êîððåêòíûé
  45. else
  46. {
  47. throw 2;
  48. }
  49. }
  50. catch (int e)
  51. {
  52. cerr << "A problem with info in artillery list occured. Try check the file." << endl;
  53. exit(e);
  54. }
  55. }
  56. bool Container::checkCorrectTarget(string _targetName, string _mission, string _entrenchedArmoured, string _targetGeom, string _preparingType)
  57. {
  58. auto it = find_if(targetsPriorities.begin(), targetsPriorities.end(), [&](auto const& _n)
  59. {
  60. return get<0>(_n) == _targetName; //åñëè àðòñèñòåìà åñòü â ñïèñêå
  61. });
  62. bool first = (it != targetsPriorities.end()) ? true : false;
  63. bool second = (find(missions.begin(), missions.end(), _mission) != missions.end()) ? true : false; //åñëè ñíàðÿäîâ áîëüøå 0 íî ìåíüøå ìàêñèìóìà
  64. bool third = (_entrenchedArmoured == "-" || _entrenchedArmoured == "entrenched" || _entrenchedArmoured == "armoured") ? true : false;
  65. bool fourth = (find(targetGeometries.begin(), targetGeometries.end(), _targetGeom) != targetGeometries.end()) ? true : false;
  66. bool fifth = (find(preparingTypes.begin(), preparingTypes.end(), _preparingType) != preparingTypes.end()) ? true : false;
  67. try
  68. {
  69. if (first && second && third && fourth && fifth) { return true; } //åñëè çàïðîñ êîððåêòíûé
  70. else
  71. {
  72. throw 2;
  73. }
  74. }
  75. catch (int e)
  76. {
  77. cerr << "A problem with info in target list occured. Try check the file." << endl;
  78. exit(e);
  79. }
  80. }
  81. size_t Container::getPriority(string _targetName)
  82. {
  83. try
  84. {
  85. auto it = find_if(targetsPriorities.begin(), targetsPriorities.end(), [&](auto const& _n)
  86. {return _n.first == _targetName; });
  87. auto it2 = targetsPriorities.begin();
  88. //if (it != targetsPriorities.end())
  89. //{
  90. //advance(it2, distance(targetsPriorities.begin(), it));
  91. //return it->second; //âåðíóòü ïðèîðèòåò òàêîé-òî öåëè
  92. //}
  93. //else { throw 1; }
  94. }
  95. catch (int e)
  96. {
  97. cerr << "Error while searching priority for a target!\n";
  98. exit(e);
  99. }
  100. }
  101. size_t Container::getNormStationary(pair<string, size_t> _caliber, bool _isCluster,
  102. bool _isDoubleIndex, bool _isShortened, bool _isEntrenchedOrArmored, bool _isDestruction, bool _isActiveReactive, double _range, size_t _numInBattery, string _targetName)
  103. {
  104. map<vector<string>, size_t> targets = { {{"artyEntrenched", "mortarEntranched"}, 0},
  105. {{"radarsAuto", "radioAuto", "AAOpened"}, 0 },
  106. {{"infEntranched", "CP", "tank", "APC"}, 0},
  107. {{"infOpened"}, 0},
  108. {{"autoCPOpened"}, 0},
  109. {{"ATGMOpened", "ATGunOpened", "otherUnArmouredOpened"}, 0} };
  110. auto it = targets.begin();
  111. if (_caliber.first == "howitzer")
  112. {
  113. switch (_caliber.second)
  114. {
  115. case 76:
  116. it->second = 540;
  117. advance(it, 1);
  118. it->second = 450;
  119. advance(it, 1);
  120. it->second = 450;
  121. advance(it, 1);
  122. it->second = 90;
  123. advance(it, 1);
  124. it->second = 150;
  125. advance(it, 1);
  126. it->second = 900;
  127. break;
  128. case 85:
  129. it->second = 480;
  130. advance(it, 1);
  131. it->second = 400;
  132. advance(it, 1);
  133. it->second = 400;
  134. advance(it, 1);
  135. it->second = 85;
  136. advance(it, 1);
  137. it->second = 120;
  138. advance(it, 1);
  139. it->second = 800;
  140. break;
  141. case 100:
  142. it->second = 360;
  143. advance(it, 1);
  144. it->second = 300;
  145. advance(it, 1);
  146. it->second = 300;
  147. advance(it, 1);
  148. it->second = 55;
  149. advance(it, 1);
  150. it->second = 80;
  151. advance(it, 1);
  152. it->second = 350;
  153. break;
  154. case 120:
  155. it->second = 200;
  156. advance(it, 1);
  157. it->second = 160;
  158. advance(it, 1);
  159. it->second = 150;
  160. advance(it, 1);
  161. it->second = 35;
  162. advance(it, 1);
  163. it->second = 50;
  164. advance(it, 1);
  165. it->second = 300;
  166. break;
  167. case 122:
  168. it->second = 240;
  169. advance(it, 1);
  170. it->second = 200;
  171. advance(it, 1);
  172. it->second = 180;
  173. advance(it, 1);
  174. it->second = 40;
  175. advance(it, 1);
  176. it->second = 50;
  177. advance(it, 1);
  178. it->second = 300;
  179. break;
  180. case 130:
  181. it->second = 220;
  182. advance(it, 1);
  183. it->second = 180;
  184. advance(it, 1);
  185. it->second = 160;
  186. advance(it, 1);
  187. it->second = 40;
  188. advance(it, 1);
  189. it->second = 50;
  190. advance(it, 1);
  191. it->second = 300;
  192. break;
  193. case 152:
  194. if (_isCluster)
  195. {
  196. it->second = 60;
  197. advance(it, 1);
  198. it->second = 50;
  199. advance(it, 1);
  200. it->second = UINT_MAX;
  201. advance(it, 1);
  202. it->second = 8;
  203. advance(it, 1);
  204. it->second = 15;
  205. advance(it, 1);
  206. it->second = 100;
  207. }
  208. else
  209. {
  210. it->second = 180;
  211. advance(it, 1);
  212. it->second = 150;
  213. advance(it, 1);
  214. it->second = 120;
  215. advance(it, 1);
  216. it->second = 25;
  217. advance(it, 1);
  218. it->second = 40;
  219. advance(it, 1);
  220. it->second = 300;
  221. }
  222. break;
  223. case 203:
  224. if (_isCluster)
  225. {
  226. it->second = 60;
  227. advance(it, 1);
  228. it->second = 30;
  229. advance(it, 1);
  230. it->second = UINT_MAX;
  231. advance(it, 1);
  232. it->second = 7;
  233. advance(it, 1);
  234. it->second = 10;
  235. }
  236. else
  237. {
  238. it->second = 180;
  239. advance(it, 1);
  240. it->second = 100;
  241. advance(it, 1);
  242. it->second = 40;
  243. advance(it, 1);
  244. it->second = 20;
  245. advance(it, 1);
  246. it->second = 30;
  247. }
  248. advance(it, 1);
  249. it->second = UINT_MAX;
  250. break;
  251. }
  252. }
  253. else if (_caliber.first == "mortar")
  254. {
  255. switch (_caliber.second)
  256. {
  257. case 82:
  258. it->second = UINT_MAX;
  259. advance(it, 1);
  260. it->second = UINT_MAX;
  261. advance(it, 1);
  262. it->second = 700;
  263. advance(it, 1);
  264. it->second = 95;
  265. advance(it, 1);
  266. it->second = 100;
  267. advance(it, 1);
  268. it->second = 500;
  269. break;
  270. case 120:
  271. it->second = 300;
  272. advance(it, 1);
  273. it->second = 180;
  274. advance(it, 1);
  275. it->second = 200;
  276. advance(it, 1);
  277. it->second = 25;
  278. advance(it, 1);
  279. it->second = 60;
  280. advance(it, 1);
  281. it->second = 350;
  282. break;
  283. case 160:
  284. it->second = 300;
  285. advance(it, 1);
  286. it->second = 80;
  287. advance(it, 1);
  288. it->second = 100;
  289. advance(it, 1);
  290. it->second = 20;
  291. advance(it, 1);
  292. it->second = 20;
  293. advance(it, 1);
  294. it->second = 200;
  295. break;
  296. case 240:
  297. it->second = 150;
  298. advance(it, 1);
  299. it->second = 40;
  300. advance(it, 1);
  301. it->second = 50;
  302. advance(it, 1);
  303. it->second = 15;
  304. advance(it, 1);
  305. it->second = 20;
  306. advance(it, 1);
  307. it->second = UINT_MAX;
  308. break;
  309. }
  310. }
  311. else if (_caliber.first == "8U32")
  312. {
  313. it->second = 450;
  314. advance(it, 1);
  315. it->second = 300;
  316. advance(it, 1);
  317. it->second = 300;
  318. advance(it, 1);
  319. it->second = 60;
  320. advance(it, 1);
  321. it->second = 60;
  322. advance(it, 1);
  323. it->second = UINT_MAX;
  324. }
  325. else if (_caliber.first == "8U31")
  326. {
  327. it->second = 300;
  328. advance(it, 1);
  329. it->second = 100;
  330. advance(it, 1);
  331. it->second = 90;
  332. advance(it, 1);
  333. it->second = 25;
  334. advance(it, 1);
  335. it->second = 25;
  336. advance(it, 1);
  337. it->second = UINT_MAX;
  338. }
  339. else if (_caliber.first == "9K55")
  340. {
  341. it->second = 400;
  342. advance(it, 1);
  343. it->second = 150;
  344. advance(it, 1);
  345. it->second = 120;
  346. advance(it, 1);
  347. it->second = 25;
  348. advance(it, 1);
  349. it->second = 25;
  350. advance(it, 1);
  351. it->second = UINT_MAX;
  352. }
  353. else if (_caliber.first == "9K51")
  354. {
  355. it->second = 500;
  356. advance(it, 1);
  357. it->second = 240;
  358. advance(it, 1);
  359. it->second = 160;
  360. advance(it, 1);
  361. it->second = 35;
  362. advance(it, 1);
  363. it->second = 40;
  364. advance(it, 1);
  365. it->second = UINT_MAX;
  366. }
  367. else if (_caliber.first == "9K57")
  368. {
  369. if (_isCluster)
  370. {
  371. it->second = 40;
  372. advance(it, 1);
  373. it->second = 80;
  374. advance(it, 1);
  375. it->second = UINT_MAX;
  376. advance(it, 1);
  377. it->second = 1;
  378. advance(it, 1);
  379. it->second = 3;
  380. }
  381. else
  382. {
  383. it->second = 180;
  384. advance(it, 1);
  385. it->second = 120;
  386. advance(it, 1);
  387. it->second = 150;
  388. advance(it, 1);
  389. it->second = 7;
  390. advance(it, 1);
  391. it->second = 10;
  392. }
  393. advance(it, 1);
  394. it->second = UINT_MAX;
  395. }
  396. if (_caliber.first == "howitzer" || _caliber.first == "mortar")
  397. {
  398. if ((_range > 10.0))
  399. {
  400. for_each(targets.begin(), targets.end(), [&](auto& _n)
  401. {
  402. _n.second = static_cast<size_t> (_n.second * 1 / 10 * roundl(_range - 10.0));
  403. });
  404. }
  405. if (_isDoubleIndex) //÷¸ò ôèãíÿ êàêàÿ-òî ñ èíäåêñàìè ÃÐÀÓ, ñòàðûå è íîâûå, õç
  406. {
  407. it = targets.begin();
  408. advance(it, 1);
  409. it->second = static_cast<size_t>(it->second * 0.75);
  410. advance(it, 1);
  411. it->second = static_cast<size_t>(it->second * 0.75);
  412. advance(it, 1);
  413. it->second = static_cast<size_t>(it->second * 0.75);
  414. advance(it, 1);
  415. it->second = static_cast<size_t>(it->second * 0.75);
  416. }
  417. if (_isShortened)
  418. {
  419. for_each(targets.begin(), targets.end(), [&](auto& _n)
  420. {
  421. _n.second = static_cast<size_t> (_n.second * 1.5);
  422. });
  423. }
  424. }
  425. if (_isEntrenchedOrArmored)
  426. {
  427. it = targets.begin();
  428. advance(it, 1);
  429. it->second = static_cast<size_t>(it->second * 3); //ÐËÑ, ÑÀÓ, åù¸ ÷¸òî óêðûòû
  430. advance(it, 4);
  431. it->second = static_cast<size_t>(it->second * 3); //íåáðîíèðîâàííàÿ öåëü óêðûòà
  432. }
  433. else
  434. {
  435. it = targets.begin();
  436. it->second = static_cast<size_t>(it->second / 3); //àðòèëëåðèÿ/ìèíîìåòû íå óêðûòû
  437. }
  438. if (_isDestruction)
  439. {
  440. auto itTemp = targets.begin();
  441. advance(itTemp, 3);
  442. for_each(targets.begin(), itTemp, [&](auto& _n)
  443. {
  444. _n.second = static_cast<size_t> (_n.second * 3); //äëÿ óíè÷òîæåíèÿ öåëåé, óêàçàííûõ íà ïîäàâëåíèå, ÷èñëî ñíàðÿäîâ óâåëè÷èâàåòñÿ âòðîå
  445. });
  446. }
  447. else
  448. {
  449. auto itTemp = targets.begin();
  450. advance(itTemp, 3);
  451. for_each(itTemp, targets.end(), [&](auto& _n)
  452. {
  453. _n.second = static_cast<size_t> (_n.second / 3); //âñ¸ íàîáîðîò, óìåíüøàåì ÷èñëî ñíàðÿäîâ âòðîå
  454. });
  455. }
  456. if (_isActiveReactive && (_caliber.second == 120 || _caliber.second == 152))
  457. {
  458. for_each(targets.begin(), targets.end(), [&](auto& _n)
  459. {
  460. _n.second = static_cast<size_t> (_n.second * 1.4); //âñ¸ íàîáîðîò, óìåíüøàåì ÷èñëî ñíàðÿäîâ âòðîå
  461. });
  462. }
  463. try
  464. {
  465. auto it2 = find_if(targets.begin(), targets.end(), [&](auto const& _n)
  466. {
  467. auto it3 = find_if(_n.first.begin(), _n.first.end(), [&](auto const& _m)
  468. {
  469. return _targetName == _m;
  470. });
  471. if (it3 != _n.first.end())
  472. {
  473. return true;
  474. }
  475. return false;
  476. });
  477. if (it2 == targets.end())
  478. {
  479. throw invalid_argument("Thiis target now found in the list for stationery targets");
  480. }
  481. else
  482. {
  483. return static_cast<size_t>(ceil(it2->second/ _numInBattery));
  484. }
  485. }
  486. catch (exception e)
  487. {
  488. cerr << e.what() << endl;
  489. exit(1);
  490. }
  491. }
  492. size_t Container::getNormMoving(pair<string, size_t> _caliber,bool _isCluster, bool _isArmoured, size_t _numInBattery, string _targetName)
  493. {
  494. map<vector<string>, size_t> targets = { {{"column"}, 0},
  495. {{"SPGArmoured", "SPMortarArmoured"}, 0 },
  496. {{"SPG", "SPMortar"}, 0},
  497. {{"launchSystem", "MLRS", "SAM", "AA", "helicopter"}, 0} };
  498. auto it = targets.begin();
  499. try
  500. {
  501. if (_caliber.first == "howitzer")
  502. {
  503. switch (_caliber.second)
  504. {
  505. case 76:
  506. it->second = 20;
  507. advance(it, 1);
  508. it->second = UINT_MAX;
  509. advance(it, 1);
  510. it->second = UINT_MAX;
  511. advance(it, 1);
  512. it->second = UINT_MAX;
  513. break;
  514. case 85:
  515. it->second = 16;
  516. advance(it, 1);
  517. it->second = UINT_MAX;
  518. advance(it, 1);
  519. it->second = UINT_MAX;
  520. advance(it, 1);
  521. it->second = UINT_MAX;
  522. break;
  523. case 100:
  524. it->second = 10;
  525. advance(it, 1);
  526. it->second = 16;
  527. advance(it, 1);
  528. it->second = 16;
  529. advance(it, 1);
  530. it->second = 18;
  531. break;
  532. case 120:
  533. it->second = 6;
  534. advance(it, 1);
  535. it->second = 12;
  536. advance(it, 1);
  537. it->second = 12;
  538. advance(it, 1);
  539. it->second = 9;
  540. break;
  541. case 122:
  542. it->second = 8;
  543. advance(it, 1);
  544. it->second = 16;
  545. advance(it, 1);
  546. it->second = 16;
  547. advance(it, 1);
  548. it->second = 10;
  549. break;
  550. case 130:
  551. it->second = 8;
  552. advance(it, 1);
  553. it->second = 10;
  554. advance(it, 1);
  555. it->second = 10;
  556. advance(it, 1);
  557. it->second = 8;
  558. break;
  559. case 152:
  560. it->second = 6;
  561. advance(it, 1);
  562. it->second = 10;
  563. advance(it, 1);
  564. it->second = 10;
  565. advance(it, 1);
  566. it->second = 8;
  567. break;
  568. case 203:
  569. throw runtime_error("Error! 203-mm howitzers can't be assigned to fire mission against moving targets!");
  570. break;
  571. }
  572. }
  573. else if (_caliber.first == "mortar")
  574. {
  575. throw runtime_error("Error! Mortars can't be assigned to fire mission against moving targets!");
  576. }
  577. else if (_caliber.first == "8U32")
  578. {
  579. it->second = 16;
  580. advance(it, 1);
  581. it->second = UINT_MAX;
  582. advance(it, 1);
  583. it->second = UINT_MAX;
  584. advance(it, 1);
  585. it->second = UINT_MAX;
  586. }
  587. else if (_caliber.first == "8U31")
  588. {
  589. it->second = 12;
  590. advance(it, 1);
  591. it->second = UINT_MAX;
  592. advance(it, 1);
  593. it->second = UINT_MAX;
  594. advance(it, 1);
  595. it->second = 12;
  596. }
  597. else if (_caliber.first == "9K55")
  598. {
  599. it->second = 36;
  600. advance(it, 1);
  601. it->second = 36;
  602. advance(it, 1);
  603. it->second = 36;
  604. advance(it, 1);
  605. it->second = 20;
  606. }
  607. else if (_caliber.first == "9K51")
  608. {
  609. it->second = 40;
  610. advance(it, 1);
  611. it->second = 40;
  612. advance(it, 1);
  613. it->second = 40;
  614. advance(it, 1);
  615. it->second = 30;
  616. }
  617. else if (_caliber.first == "9K57")
  618. {
  619. it->second = 16;
  620. advance(it, 1);
  621. it->second = UINT_MAX;
  622. advance(it, 1);
  623. if (_isCluster)
  624. {
  625. it->second = 10;
  626. }
  627. else
  628. {
  629. it->second = 16;
  630. }
  631. advance(it, 1);
  632. it->second = 16;
  633. advance(it, 1);
  634. it->second = 3;
  635. }
  636. if (_isArmoured)
  637. {
  638. cout << "should be assigned at least one division!" << endl;
  639. }
  640. }
  641. catch (exception e)
  642. {
  643. cerr << e.what() << endl;
  644. exit(1);
  645. }
  646. try
  647. {
  648. auto it2 = find_if(targets.begin(), targets.end(), [&](auto const& _n)
  649. {
  650. auto it3 = find_if(_n.first.begin(), _n.first.end(), [&](auto const& _m)
  651. {
  652. return _targetName == _m;
  653. });
  654. if (it3 != _n.first.end())
  655. {
  656. return true;
  657. }
  658. return false;
  659. });
  660. if (it2 == targets.end())
  661. {
  662. throw invalid_argument("Thiis target now found in the list for stationery targets");
  663. }
  664. else
  665. {
  666. return static_cast<size_t>(ceil(it2->second/ _numInBattery));
  667. }
  668. }
  669. catch (exception e)
  670. {
  671. cerr << e.what() << endl;
  672. exit(1);
  673. }
  674. }
  675. size_t getNormFireAtWill(pair<string, size_t> _caliber, double _meters, double _minutes)
  676. {
  677. size_t result = 0;
  678. try
  679. {
  680. if (_caliber.first == "howitzer")
  681. {
  682. switch (_caliber.second)
  683. {
  684. case 76: result = 18; break;
  685. case 85: result = 16; break;
  686. case 100: result = 12; break;
  687. case 120: result = 6; break;
  688. case 122: result = 8; break;
  689. case 130: result = 6; break;
  690. case 152: result = 6; break;
  691. case 203: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  692. }
  693. }
  694. else if (_caliber.first == "mortar")
  695. {
  696. switch (_caliber.second)
  697. {
  698. case 82: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  699. case 120: result = 6; break;
  700. case 160: result = 4; break;
  701. case 240: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  702. }
  703. }
  704. else
  705. {
  706. throw invalid_argument("MLRS cant be assigned to fire-at-will missions");
  707. }
  708. }
  709. catch (exception e)
  710. {
  711. cerr << e.what() << endl;
  712. exit(1);
  713. }
  714. return static_cast<size_t>(result * (_meters / 100) * (_minutes));
  715. }
  716. size_t getNormSmoke(pair<string, size_t> _caliber, double _meters, double _minutes, bool _isSideWind)
  717. {
  718. size_t result = 0;
  719. try
  720. {
  721. if (_caliber.first == "howitzer" && _isSideWind)
  722. {
  723. switch (_caliber.second)
  724. {
  725. case 76: result = 4; break;
  726. case 85: result = 4; break;
  727. case 100: result = 2; break;
  728. case 120: result = 2; break;
  729. case 122: result = 1; break;
  730. case 130: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  731. case 152: result = 1; break;
  732. case 203: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  733. }
  734. }
  735. else if (_caliber.first == "howitzer" && not _isSideWind)
  736. {
  737. switch (_caliber.second)
  738. {
  739. case 76: result = 6; break;
  740. case 85: result = 6; break;
  741. case 100: result = 4; break;
  742. case 120: result = 2; break;
  743. case 122: result = 2; break;
  744. case 130: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  745. case 152: result = 2; break;
  746. case 203: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  747. }
  748. }
  749. else if (_caliber.first == "mortar" && _isSideWind)
  750. {
  751. switch (_caliber.second)
  752. {
  753. case 82: result = 4; break;
  754. case 120: result = 2; break;
  755. case 160: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  756. case 240: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  757. }
  758. }
  759. else if (_caliber.first == "mortar" && not _isSideWind)
  760. {
  761. switch (_caliber.second)
  762. {
  763. case 82: result = 6; break;
  764. case 120: result = 3; break;
  765. case 160: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  766. case 240: throw runtime_error("this caliber is not used for fire-at-will missions"); break;
  767. }
  768. }
  769. else
  770. {
  771. throw invalid_argument("MLRS cant be assigned to fire-at-will missions");
  772. }
  773. }
  774. catch (exception e)
  775. {
  776. cerr << e.what() << endl;
  777. exit(1);
  778. }
  779. return static_cast<size_t>(result * (_meters / 100) * (_minutes));
  780. }
  781. double Container::getRange(string _artyType)
  782. {
  783. auto it = find_if(artyRangesAmmo.begin(), artyRangesAmmo.end(), [&](auto const& _n)
  784. {
  785. return _artyType == get<0>(_n);
  786. });
  787. return get<1>(*it);
  788. }
  789. double Container::getCaliber(string _artyType)
  790. {
  791. auto it = find_if(artyRangesAmmo.begin(), artyRangesAmmo.end(), [&](auto const& _n)
  792. {
  793. return _artyType == get<0>(_n);
  794. });
  795. return get<4>(*it);
  796. }
  797. string Container::getType(string _artyType)
  798. {
  799. try
  800. {
  801. list<string> howitzer = { "2C1", "2C3", "2C5", "2C7", "A-222", "2A31", "52P367", "2A18", "52P546", "52P482" };
  802. if (find(howitzer.begin(), howitzer.end(), _artyType) != howitzer.end()) { return "howitzer"; }
  803. list<string> mortar = { "2C4", "2C9", "2B9", "2B14", "52M853", "52M864", "2A51" };
  804. if (find(mortar.begin(), mortar.end(), _artyType) != mortar.end()) { return "mortar"; }
  805. list<string> MLRS = { "8U32", "8U32", "2K51", "2K55", "2K57" };
  806. if (find(MLRS.begin(), MLRS.end(), _artyType) != MLRS.end()) { return "MLRS"; }
  807. throw invalid_argument("Can't recognize such a type of arty!");
  808. }
  809. catch (exception e)
  810. {
  811. cerr << e.what() << endl;
  812. exit(1);
  813. }
  814. }
  815. bool Container::checkStationary(string _targetType)
  816. {
  817. list<string> stat = { "artyEntranched", "mortarEntranched", "radarsAuto", "radioAuto", "AAOpened",
  818. "infEntranched", "CP", "tank", "APC", "infOpened", "autoCPOpened", "ATGMOpened", "ATGunOpened", "otherUnArmouredOpened" };
  819. if (find(stat.begin(), stat.end(), _targetType) != stat.end()) { return true; }
  820. return false;
  821. }
  822. size_t Container::measureFireRate(pair<string, size_t> _caliber, size_t _charge, double _temperature, size_t _numShells, string _specificType)
  823. {
  824. map<size_t, size_t> targets = { {1, 0}, {3, 0 }, {5, 0}, {10, 0}, {15, 0}, {20, 0}, {25, 0}, {30, 0 }, {40, 0}, {50, 0},
  825. {60, 0}, {120, 0}, {UINT_MAX, 0} };
  826. auto it = targets.begin();
  827. if (_caliber.first == "howitzer")
  828. {
  829. double percentUsageTemperature = 1.0;
  830. if (abs(20 - _temperature) > 10)
  831. {
  832. percentUsageTemperature += (_temperature - 20) / 100;
  833. }
  834. switch (_caliber.second)
  835. {
  836. case 76:
  837. it->second = static_cast<size_t>(ceil(15* percentUsageTemperature));
  838. advance(it, 1);
  839. it->second = static_cast<size_t>(ceil(35 * percentUsageTemperature));
  840. advance(it, 1);
  841. it->second = static_cast<size_t>(ceil(50 * percentUsageTemperature));
  842. advance(it, 1);
  843. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  844. advance(it, 1);
  845. it->second = static_cast<size_t>(ceil(85 * percentUsageTemperature));
  846. advance(it, 1);
  847. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  848. advance(it, 1);
  849. if (_charge == 0)
  850. {
  851. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  852. advance(it, 1);
  853. it->second = static_cast<size_t>(ceil(115 * percentUsageTemperature));
  854. advance(it, 1);
  855. it->second = static_cast<size_t>(ceil(125 * percentUsageTemperature));
  856. advance(it, 1);
  857. it->second = static_cast<size_t>(ceil(140 * percentUsageTemperature));
  858. advance(it, 1);
  859. it->second = static_cast<size_t>(ceil(150 * percentUsageTemperature));
  860. advance(it, 1);
  861. it->second = static_cast<size_t>(ceil(220 * percentUsageTemperature));
  862. advance(it, 1);
  863. if (_numShells > 220) {
  864. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 220) / 70) + static_cast<size_t>((_numShells - 220) % 70);
  865. it->second = static_cast<size_t>(ceil((220 + static_cast<size_t>(70 * (minutes - 120) / 60)) * percentUsageTemperature));
  866. }
  867. else { it->second = 220; }
  868. }
  869. else
  870. {
  871. it->second = static_cast<size_t>(ceil(115 * percentUsageTemperature));
  872. advance(it, 1);
  873. it->second = static_cast<size_t>(ceil(130 * percentUsageTemperature));
  874. advance(it, 1);
  875. it->second = static_cast<size_t>(ceil(160 * percentUsageTemperature));
  876. advance(it, 1);
  877. it->second = static_cast<size_t>(ceil(180 * percentUsageTemperature));
  878. advance(it, 1);
  879. it->second = static_cast<size_t>(ceil(200 * percentUsageTemperature));
  880. advance(it, 1);
  881. it->second = static_cast<size_t>(ceil(320 * percentUsageTemperature));
  882. advance(it, 1);
  883. if (_numShells > 320) {
  884. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 320) / 100) + static_cast<size_t>((_numShells - 320) % 70);
  885. it->second = static_cast<size_t>(ceil((320 + static_cast<size_t>(100 * (minutes - 120) / 60)) * percentUsageTemperature));
  886. }
  887. else { it->second = 220; }
  888. }
  889. break;
  890. case 85:
  891. it->second = static_cast<size_t>(ceil(10 * percentUsageTemperature));
  892. advance(it, 1);
  893. it->second = static_cast<size_t>(ceil(25 * percentUsageTemperature));
  894. advance(it, 1);
  895. it->second = static_cast<size_t>(ceil(40 * percentUsageTemperature));
  896. advance(it, 1);
  897. if (_charge == 0)
  898. {
  899. it->second = static_cast<size_t>(ceil(50 * percentUsageTemperature));
  900. advance(it, 1);
  901. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  902. advance(it, 1);
  903. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  904. advance(it, 1);
  905. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  906. advance(it, 1);
  907. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  908. advance(it, 1);
  909. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  910. advance(it, 1);
  911. it->second = static_cast<size_t>(ceil(125 * percentUsageTemperature));
  912. advance(it, 1);
  913. it->second = static_cast<size_t>(ceil(140 * percentUsageTemperature));
  914. advance(it, 1);
  915. it->second = static_cast<size_t>(ceil(230 * percentUsageTemperature));
  916. advance(it, 1);
  917. if (_numShells > 230) {
  918. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 230) / 80) + static_cast<size_t>((_numShells - 230) % 80);
  919. it->second = static_cast<size_t>(ceil((230 + static_cast<size_t>(80 * (minutes - 120) / 60)) * percentUsageTemperature));
  920. }
  921. else { it->second = 230; }
  922. }
  923. else
  924. {
  925. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  926. advance(it, 1);
  927. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  928. advance(it, 1);
  929. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  930. advance(it, 1);
  931. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  932. advance(it, 1);
  933. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  934. advance(it, 1);
  935. it->second = static_cast<size_t>(ceil(130 * percentUsageTemperature));
  936. advance(it, 1);
  937. it->second = static_cast<size_t>(ceil(150 * percentUsageTemperature));
  938. advance(it, 1);
  939. it->second = static_cast<size_t>(ceil(170 * percentUsageTemperature));
  940. advance(it, 1);
  941. it->second = static_cast<size_t>(ceil(290 * percentUsageTemperature));
  942. advance(it, 1);
  943. if (_numShells > 290) {
  944. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 290) / 100) + static_cast<size_t>((_numShells - 290) % 100);
  945. it->second = static_cast<size_t>(ceil((290 + static_cast<size_t>(100 * (minutes - 120) / 60)) * percentUsageTemperature));
  946. }
  947. else { it->second = 290; }
  948. }
  949. break;
  950. case 100:
  951. it->second = static_cast<size_t>(ceil(7 * percentUsageTemperature));
  952. advance(it, 1);
  953. it->second = static_cast<size_t>(ceil(18 * percentUsageTemperature));
  954. advance(it, 1);
  955. it->second = static_cast<size_t>(ceil(30 * percentUsageTemperature));
  956. advance(it, 1);
  957. it->second = static_cast<size_t>(ceil(50 * percentUsageTemperature));
  958. advance(it, 1);
  959. if (_charge == 0)
  960. {
  961. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  962. advance(it, 1);
  963. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  964. advance(it, 1);
  965. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  966. advance(it, 1);
  967. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  968. advance(it, 1);
  969. it->second = static_cast<size_t>(ceil(85 * percentUsageTemperature));
  970. advance(it, 1);
  971. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  972. advance(it, 1);
  973. it->second = static_cast<size_t>(ceil(95 * percentUsageTemperature));
  974. advance(it, 1);
  975. it->second = static_cast<size_t>(ceil(135 * percentUsageTemperature));
  976. advance(it, 1);
  977. if (_numShells > 135) {
  978. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 135) / 40) + static_cast<size_t>((_numShells - 135) % 40);
  979. it->second = static_cast<size_t>(ceil((135 + static_cast<size_t>(40 * (minutes - 120) / 60)) * percentUsageTemperature));
  980. }
  981. else { it->second = 135; }
  982. }
  983. else
  984. {
  985. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  986. advance(it, 1);
  987. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  988. advance(it, 1);
  989. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  990. advance(it, 1);
  991. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  992. advance(it, 1);
  993. it->second = static_cast<size_t>(ceil(120 * percentUsageTemperature));
  994. advance(it, 1);
  995. it->second = static_cast<size_t>(ceil(140 * percentUsageTemperature));
  996. advance(it, 1);
  997. it->second = static_cast<size_t>(ceil(160 * percentUsageTemperature));
  998. advance(it, 1);
  999. it->second = static_cast<size_t>(ceil(250 * percentUsageTemperature));
  1000. advance(it, 1);
  1001. if (_numShells > 250) {
  1002. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 250) / 80) + static_cast<size_t>((_numShells - 250) % 80);
  1003. it->second = static_cast<size_t>(ceil((250 + static_cast<size_t>(80 * (minutes - 120) / 60)) * percentUsageTemperature));
  1004. }
  1005. else { it->second = 250; }
  1006. }
  1007. break;
  1008. case 120:
  1009. it->second = static_cast<size_t>(ceil(6 * percentUsageTemperature));
  1010. advance(it, 1);
  1011. it->second = static_cast<size_t>(ceil(16 * percentUsageTemperature));
  1012. advance(it, 1);
  1013. it->second = static_cast<size_t>(ceil(25 * percentUsageTemperature));
  1014. advance(it, 1);
  1015. it->second = static_cast<size_t>(ceil(40 * percentUsageTemperature));
  1016. advance(it, 1);
  1017. it->second = static_cast<size_t>(ceil(55 * percentUsageTemperature));
  1018. advance(it, 1);
  1019. if (_charge < 2)
  1020. {
  1021. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  1022. advance(it, 1);
  1023. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1024. advance(it, 1);
  1025. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1026. advance(it, 1);
  1027. it->second = static_cast<size_t>(ceil(85 * percentUsageTemperature));
  1028. advance(it, 1);
  1029. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1030. advance(it, 1);
  1031. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  1032. advance(it, 1);
  1033. it->second = static_cast<size_t>(ceil(150 * percentUsageTemperature));
  1034. advance(it, 1);
  1035. if (_numShells > 150) {
  1036. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 150) / 50) + static_cast<size_t>((_numShells - 150) % 50);
  1037. it->second = static_cast<size_t>(ceil((150 + static_cast<size_t>(50 * (minutes - 120) / 60)) * percentUsageTemperature));
  1038. }
  1039. else { it->second = 150; }
  1040. }
  1041. else if (_charge > 3)
  1042. {
  1043. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1044. advance(it, 1);
  1045. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1046. advance(it, 1);
  1047. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1048. advance(it, 1);
  1049. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1050. advance(it, 1);
  1051. it->second = static_cast<size_t>(ceil(130 * percentUsageTemperature));
  1052. advance(it, 1);
  1053. it->second = static_cast<size_t>(ceil(150 * percentUsageTemperature));
  1054. advance(it, 1);
  1055. it->second = static_cast<size_t>(ceil(260 * percentUsageTemperature));
  1056. advance(it, 1);
  1057. if (_numShells > 260) {
  1058. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 260) / 80) + static_cast<size_t>((_numShells - 260) % 80);
  1059. it->second = static_cast<size_t>(ceil((260 + static_cast<size_t>(80 * (minutes - 120) / 60)) * percentUsageTemperature));
  1060. }
  1061. else { it->second = 260; }
  1062. }
  1063. else
  1064. {
  1065. it->second = static_cast<size_t>(ceil(68 * percentUsageTemperature));
  1066. advance(it, 1);
  1067. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1068. advance(it, 1);
  1069. it->second = static_cast<size_t>(ceil(83 * percentUsageTemperature));
  1070. advance(it, 1);
  1071. it->second = static_cast<size_t>(ceil(98 * percentUsageTemperature));
  1072. advance(it, 1);
  1073. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1074. advance(it, 1);
  1075. it->second = static_cast<size_t>(ceil(125 * percentUsageTemperature));
  1076. advance(it, 1);
  1077. it->second = static_cast<size_t>(ceil(215 * percentUsageTemperature));
  1078. advance(it, 1);
  1079. if (_numShells > 215) {
  1080. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 215) / 65) + static_cast<size_t>((_numShells - 215) % 65);
  1081. it->second = static_cast<size_t>(ceil((220 + static_cast<size_t>(65 * (minutes - 120) / 60)) * percentUsageTemperature));
  1082. }
  1083. else { it->second = 215; }
  1084. }
  1085. break;
  1086. case 122:
  1087. it->second = static_cast<size_t>(ceil(6 * percentUsageTemperature));
  1088. advance(it, 1);
  1089. it->second = static_cast<size_t>(ceil(16 * percentUsageTemperature));
  1090. advance(it, 1);
  1091. it->second = static_cast<size_t>(ceil(25 * percentUsageTemperature));
  1092. advance(it, 1);
  1093. it->second = static_cast<size_t>(ceil(40 * percentUsageTemperature));
  1094. advance(it, 1);
  1095. it->second = static_cast<size_t>(ceil(55 * percentUsageTemperature));
  1096. advance(it, 1);
  1097. if (_charge < 2)
  1098. {
  1099. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  1100. advance(it, 1);
  1101. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1102. advance(it, 1);
  1103. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1104. advance(it, 1);
  1105. it->second = static_cast<size_t>(ceil(85 * percentUsageTemperature));
  1106. advance(it, 1);
  1107. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1108. advance(it, 1);
  1109. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  1110. advance(it, 1);
  1111. it->second = static_cast<size_t>(ceil(150 * percentUsageTemperature));
  1112. advance(it, 1);
  1113. if (_numShells > 150) {
  1114. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 150) / 50) + static_cast<size_t>((_numShells - 150) % 50);
  1115. it->second = static_cast<size_t>(ceil((150 + static_cast<size_t>(50 * (minutes - 120) / 60)) * percentUsageTemperature));
  1116. }
  1117. else { it->second = 150; }
  1118. }
  1119. else if (_charge > 3)
  1120. {
  1121. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1122. advance(it, 1);
  1123. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1124. advance(it, 1);
  1125. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1126. advance(it, 1);
  1127. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1128. advance(it, 1);
  1129. it->second = static_cast<size_t>(ceil(130 * percentUsageTemperature));
  1130. advance(it, 1);
  1131. it->second = static_cast<size_t>(ceil(150 * percentUsageTemperature));
  1132. advance(it, 1);
  1133. it->second = static_cast<size_t>(ceil(260 * percentUsageTemperature));
  1134. advance(it, 1);
  1135. if (_numShells > 260) {
  1136. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 260) / 80) + static_cast<size_t>((_numShells - 260) % 80);
  1137. it->second = static_cast<size_t>(ceil((260 + static_cast<size_t>(80 * (minutes - 120) / 60)) * percentUsageTemperature));
  1138. }
  1139. else { it->second = 260; }
  1140. }
  1141. else
  1142. {
  1143. it->second = static_cast<size_t>(ceil(68 * percentUsageTemperature));
  1144. advance(it, 1);
  1145. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1146. advance(it, 1);
  1147. it->second = static_cast<size_t>(ceil(83 * percentUsageTemperature));
  1148. advance(it, 1);
  1149. it->second = static_cast<size_t>(ceil(98 * percentUsageTemperature));
  1150. advance(it, 1);
  1151. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1152. advance(it, 1);
  1153. it->second = static_cast<size_t>(ceil(125 * percentUsageTemperature));
  1154. advance(it, 1);
  1155. it->second = static_cast<size_t>(ceil(215 * percentUsageTemperature));
  1156. advance(it, 1);
  1157. if (_numShells > 215) {
  1158. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 215) / 65) + static_cast<size_t>((_numShells - 215) % 65);
  1159. it->second = static_cast<size_t>(ceil((215 + static_cast<size_t>(65 * (minutes - 120) / 60)) * percentUsageTemperature));
  1160. }
  1161. else { it->second = 215; }
  1162. }
  1163. break;
  1164. case 130:
  1165. it->second = static_cast<size_t>(ceil(5 * percentUsageTemperature));
  1166. advance(it, 1);
  1167. it->second = static_cast<size_t>(ceil(12 * percentUsageTemperature));
  1168. advance(it, 1);
  1169. it->second = static_cast<size_t>(ceil(20 * percentUsageTemperature));
  1170. advance(it, 1);
  1171. it->second = static_cast<size_t>(ceil(35 * percentUsageTemperature));
  1172. advance(it, 1);
  1173. it->second = static_cast<size_t>(ceil(45 * percentUsageTemperature));
  1174. advance(it, 1);
  1175. it->second = static_cast<size_t>(ceil(55 * percentUsageTemperature));
  1176. advance(it, 1);
  1177. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  1178. advance(it, 1);
  1179. if (_charge < 2)
  1180. {
  1181. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1182. advance(it, 1);
  1183. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1184. advance(it, 1);
  1185. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1186. advance(it, 1);
  1187. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  1188. advance(it, 1);
  1189. it->second = static_cast<size_t>(ceil(160 * percentUsageTemperature));
  1190. advance(it, 1);
  1191. if (_numShells > 160) {
  1192. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 160) / 35) + static_cast<size_t>((_numShells - 160) % 35);
  1193. it->second = static_cast<size_t>(ceil((160 + static_cast<size_t>(35 * (minutes - 120) / 60)) * percentUsageTemperature));
  1194. }
  1195. else { it->second = 160; }
  1196. }
  1197. else if (_charge > 2)
  1198. {
  1199. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1200. advance(it, 1);
  1201. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1202. advance(it, 1);
  1203. it->second = static_cast<size_t>(ceil(105 * percentUsageTemperature));
  1204. advance(it, 1);
  1205. it->second = static_cast<size_t>(ceil(120 * percentUsageTemperature));
  1206. advance(it, 1);
  1207. it->second = static_cast<size_t>(ceil(210 * percentUsageTemperature));
  1208. advance(it, 1);
  1209. if (_numShells > 210) {
  1210. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 210) / 70) + static_cast<size_t>((_numShells - 210) % 70);
  1211. it->second = static_cast<size_t>(ceil((210 + static_cast<size_t>(70 * (minutes - 120) / 60)) * percentUsageTemperature));
  1212. }
  1213. else { it->second = 210; }
  1214. }
  1215. else
  1216. {
  1217. it->second = static_cast<size_t>(ceil(73 * percentUsageTemperature));
  1218. advance(it, 1);
  1219. it->second = static_cast<size_t>(ceil(85 * percentUsageTemperature));
  1220. advance(it, 1);
  1221. it->second = static_cast<size_t>(ceil(98 * percentUsageTemperature));
  1222. advance(it, 1);
  1223. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1224. advance(it, 1);
  1225. it->second = static_cast<size_t>(ceil(185 * percentUsageTemperature));
  1226. advance(it, 1);
  1227. if (_numShells > 185) {
  1228. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 185) / 54) + static_cast<size_t>((_numShells - 185) % 54);
  1229. it->second = static_cast<size_t>(ceil((185 + static_cast<size_t>(54 * (minutes - 120) / 60)) * percentUsageTemperature));
  1230. }
  1231. else { it->second = 185; }
  1232. }
  1233. break;
  1234. case 152:
  1235. it->second = static_cast<size_t>(ceil(4 * percentUsageTemperature));
  1236. advance(it, 1);
  1237. it->second = static_cast<size_t>(ceil(12 * percentUsageTemperature));
  1238. advance(it, 1);
  1239. it->second = static_cast<size_t>(ceil(20 * percentUsageTemperature));
  1240. advance(it, 1);
  1241. it->second = static_cast<size_t>(ceil(30 * percentUsageTemperature));
  1242. advance(it, 1);
  1243. it->second = static_cast<size_t>(ceil(40 * percentUsageTemperature));
  1244. advance(it, 1);
  1245. it->second = static_cast<size_t>(ceil(50 * percentUsageTemperature));
  1246. advance(it, 1);
  1247. if (_specificType == "howitzer")
  1248. {
  1249. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  1250. advance(it, 1);
  1251. if (_charge < 2)
  1252. {
  1253. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  1254. advance(it, 1);
  1255. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1256. advance(it, 1);
  1257. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1258. advance(it, 1);
  1259. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1260. advance(it, 1);
  1261. it->second = static_cast<size_t>(ceil(135 * percentUsageTemperature));
  1262. advance(it, 1);
  1263. if (_numShells > 135) {
  1264. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 135) / 45) + static_cast<size_t>((_numShells - 135) % 45);
  1265. it->second = static_cast<size_t>(ceil((135 + static_cast<size_t>(45 * (minutes - 120) / 60)) * percentUsageTemperature));
  1266. }
  1267. else { it->second = 135; }
  1268. }
  1269. else if (_charge > 3)
  1270. {
  1271. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1272. advance(it, 1);
  1273. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1274. advance(it, 1);
  1275. it->second = static_cast<size_t>(ceil(105 * percentUsageTemperature));
  1276. advance(it, 1);
  1277. it->second = static_cast<size_t>(ceil(120 * percentUsageTemperature));
  1278. advance(it, 1);
  1279. it->second = static_cast<size_t>(ceil(210 * percentUsageTemperature));
  1280. advance(it, 1);
  1281. if (_numShells > 210) {
  1282. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 210) / 70) + static_cast<size_t>((_numShells - 210) % 70);
  1283. it->second = static_cast<size_t>(ceil((210 + static_cast<size_t>(70 * (minutes - 120) / 60)) * percentUsageTemperature));
  1284. }
  1285. else { it->second = 210; }
  1286. }
  1287. else
  1288. {
  1289. it->second = static_cast<size_t>(ceil(68 * percentUsageTemperature));
  1290. advance(it, 1);
  1291. it->second = static_cast<size_t>(ceil(83 * percentUsageTemperature));
  1292. advance(it, 1);
  1293. it->second = static_cast<size_t>(ceil(93 * percentUsageTemperature));
  1294. advance(it, 1);
  1295. it->second = static_cast<size_t>(ceil(105 * percentUsageTemperature));
  1296. advance(it, 1);
  1297. it->second = static_cast<size_t>(ceil(173 * percentUsageTemperature));
  1298. advance(it, 1);
  1299. if (_numShells > 173) {
  1300. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 173) / 58) + static_cast<size_t>((_numShells - 173) % 58);
  1301. it->second = static_cast<size_t>(ceil((173 + static_cast<size_t>(58 * (minutes - 120) / 60)) * percentUsageTemperature));
  1302. }
  1303. else { it->second = 173; }
  1304. }
  1305. }
  1306. else if (_specificType == "howitzer-gun")
  1307. {
  1308. if (_charge < 2)
  1309. {
  1310. it->second = static_cast<size_t>(ceil(55 * percentUsageTemperature));
  1311. advance(it, 1);
  1312. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  1313. advance(it, 1);
  1314. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1315. advance(it, 1);
  1316. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1317. advance(it, 1);
  1318. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1319. advance(it, 1);
  1320. it->second = static_cast<size_t>(ceil(120 * percentUsageTemperature));
  1321. advance(it, 1);
  1322. if (_numShells > 120) {
  1323. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 120) / 35) + static_cast<size_t>((_numShells - 120) % 35);
  1324. it->second = static_cast<size_t>(ceil((220 + static_cast<size_t>(35 * (minutes - 120) / 60)) * percentUsageTemperature));
  1325. }
  1326. else { it->second = 120; }
  1327. }
  1328. else if (_charge > 5)
  1329. {
  1330. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  1331. advance(it, 1);
  1332. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1333. advance(it, 1);
  1334. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1335. advance(it, 1);
  1336. it->second = static_cast<size_t>(ceil(95 * percentUsageTemperature));
  1337. advance(it, 1);
  1338. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1339. advance(it, 1);
  1340. it->second = static_cast<size_t>(ceil(200 * percentUsageTemperature));
  1341. advance(it, 1);
  1342. if (_numShells > 200) {
  1343. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 200) / 60) + static_cast<size_t>((_numShells - 200) % 60);
  1344. it->second = static_cast<size_t>(ceil((200 + static_cast<size_t>(60 * (minutes - 120) / 60)) * percentUsageTemperature));
  1345. }
  1346. else { it->second = 200; }
  1347. }
  1348. else
  1349. {
  1350. it->second = static_cast<size_t>(ceil(58 * percentUsageTemperature));
  1351. advance(it, 1);
  1352. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  1353. advance(it, 1);
  1354. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1355. advance(it, 1);
  1356. it->second = static_cast<size_t>(ceil(85 * percentUsageTemperature));
  1357. advance(it, 1);
  1358. it->second = static_cast<size_t>(ceil(95 * percentUsageTemperature));
  1359. advance(it, 1);
  1360. it->second = static_cast<size_t>(ceil(160 * percentUsageTemperature));
  1361. advance(it, 1);
  1362. if (_numShells > 160) {
  1363. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 160) / 48) + static_cast<size_t>((_numShells - 160) % 48);
  1364. it->second = static_cast<size_t>(ceil((160 + static_cast<size_t>(48 * (minutes - 120) / 60)) * percentUsageTemperature));
  1365. }
  1366. else { it->second = 160; }
  1367. }
  1368. }
  1369. else
  1370. {
  1371. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  1372. advance(it, 1);
  1373. if (_charge < 2)
  1374. {
  1375. it->second = static_cast<size_t>(ceil(65 * percentUsageTemperature));
  1376. advance(it, 1);
  1377. it->second = static_cast<size_t>(ceil(75 * percentUsageTemperature));
  1378. advance(it, 1);
  1379. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1380. advance(it, 1);
  1381. it->second = static_cast<size_t>(ceil(90 * percentUsageTemperature));
  1382. advance(it, 1);
  1383. it->second = static_cast<size_t>(ceil(135 * percentUsageTemperature));
  1384. advance(it, 1);
  1385. if (_numShells > 135) {
  1386. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 135) / 45) + static_cast<size_t>((_numShells - 135) % 45);
  1387. it->second = static_cast<size_t>(ceil((135 + static_cast<size_t>(45 * (minutes - 120) / 60)) * percentUsageTemperature));
  1388. }
  1389. else { it->second = 135; }
  1390. }
  1391. else if (_charge > 3)
  1392. {
  1393. it->second = static_cast<size_t>(ceil(70 * percentUsageTemperature));
  1394. advance(it, 1);
  1395. it->second = static_cast<size_t>(ceil(80 * percentUsageTemperature));
  1396. advance(it, 1);
  1397. it->second = static_cast<size_t>(ceil(95 * percentUsageTemperature));
  1398. advance(it, 1);
  1399. it->second = static_cast<size_t>(ceil(110 * percentUsageTemperature));
  1400. advance(it, 1);
  1401. it->second = static_cast<size_t>(ceil(200 * percentUsageTemperature));
  1402. advance(it, 1);
  1403. if (_numShells > 200) {
  1404. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 200) / 60) + static_cast<size_t>((_numShells - 200) % 60);
  1405. it->second = static_cast<size_t>(ceil((200 + static_cast<size_t>(60 * (minutes - 120) / 60)) * percentUsageTemperature));
  1406. }
  1407. else { it->second = 200; }
  1408. }
  1409. else
  1410. {
  1411. it->second = static_cast<size_t>(ceil(68 * percentUsageTemperature));
  1412. advance(it, 1);
  1413. it->second = static_cast<size_t>(ceil(78 * percentUsageTemperature));
  1414. advance(it, 1);
  1415. it->second = static_cast<size_t>(ceil(88 * percentUsageTemperature));
  1416. advance(it, 1);
  1417. it->second = static_cast<size_t>(ceil(100 * percentUsageTemperature));
  1418. advance(it, 1);
  1419. it->second = static_cast<size_t>(ceil(168 * percentUsageTemperature));
  1420. advance(it, 1);
  1421. if (_numShells > 168) {
  1422. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 168) / 53) + static_cast<size_t>((_numShells - 168) % 53);
  1423. it->second = static_cast<size_t>(ceil((168 + static_cast<size_t>(53 * (minutes - 120) / 60)) * percentUsageTemperature));
  1424. }
  1425. else { it->second = 168; }
  1426. }
  1427. }
  1428. break;
  1429. case 203:
  1430. it->second = static_cast<size_t>(ceil(1 * percentUsageTemperature));
  1431. advance(it, 1);
  1432. it->second = static_cast<size_t>(ceil(2 * percentUsageTemperature));
  1433. advance(it, 1);
  1434. it->second = static_cast<size_t>(ceil(3 * percentUsageTemperature));
  1435. advance(it, 1);
  1436. it->second = static_cast<size_t>(ceil(6 * percentUsageTemperature));
  1437. advance(it, 1);
  1438. it->second = static_cast<size_t>(ceil(9 * percentUsageTemperature));
  1439. advance(it, 1);
  1440. it->second = static_cast<size_t>(ceil(12 * percentUsageTemperature));
  1441. advance(it, 1);
  1442. it->second = static_cast<size_t>(ceil(15 * percentUsageTemperature));
  1443. advance(it, 1);
  1444. it->second = static_cast<size_t>(ceil(18 * percentUsageTemperature));
  1445. advance(it, 1);
  1446. it->second = static_cast<size_t>(ceil(22 * percentUsageTemperature));
  1447. advance(it, 1);
  1448. it->second = static_cast<size_t>(ceil(26 * percentUsageTemperature));
  1449. advance(it, 1);
  1450. it->second = static_cast<size_t>(ceil(30 * percentUsageTemperature));
  1451. advance(it, 1);
  1452. it->second = static_cast<size_t>(ceil(60 * percentUsageTemperature));
  1453. advance(it, 1);
  1454. if (_numShells > 60) {
  1455. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 60) / 25) + static_cast<size_t>((_numShells - 60) % 25);
  1456. it->second = static_cast<size_t>(ceil((60 + static_cast<size_t>(25 * (minutes - 120) / 60)) * percentUsageTemperature));
  1457. }
  1458. else { it->second = 60; }
  1459. break;
  1460. }
  1461. }
  1462. else if (_caliber.first == "mortar")
  1463. {
  1464. switch (_caliber.second)
  1465. {
  1466. case 82:
  1467. it->second = 20;
  1468. advance(it, 1);
  1469. it->second = 45;
  1470. advance(it, 1);
  1471. advance(it, 1);
  1472. if (_charge == 0)
  1473. {
  1474. it->second = 75;
  1475. advance(it, 1);
  1476. it->second = 110;
  1477. advance(it, 1);
  1478. it->second = 125;
  1479. it->second = 65;
  1480. advance(it, 1);
  1481. it->second = 150;
  1482. advance(it, 1);
  1483. it->second = UINT_MAX;
  1484. advance(it, 1);
  1485. if (_numShells > 150) {
  1486. it->second = UINT_MAX;
  1487. }
  1488. else { it->second = 150; }
  1489. }
  1490. else if (_charge == 1)
  1491. {
  1492. it->second = 60;
  1493. advance(it, 1);
  1494. it->second = 75;
  1495. advance(it, 1);
  1496. it->second = 85;
  1497. it->second = 100;
  1498. advance(it, 1);
  1499. it->second = 140;
  1500. advance(it, 1);
  1501. it->second = UINT_MAX;
  1502. advance(it, 1);
  1503. if (_numShells > 140) {
  1504. it->second = UINT_MAX;
  1505. }
  1506. else { it->second = 140; }
  1507. }
  1508. break;
  1509. case 120:
  1510. it->second = 9;
  1511. advance(it, 1);
  1512. it->second = 25;
  1513. advance(it, 1);
  1514. it->second = 30;
  1515. advance(it, 1);
  1516. it->second = 35;
  1517. advance(it, 1);
  1518. it->second = 40;
  1519. advance(it, 1);
  1520. if (_charge == 0)
  1521. {
  1522. it->second = 50;
  1523. advance(it, 1);
  1524. it->second = 70;
  1525. advance(it, 1);
  1526. it->second = 110;
  1527. advance(it, 1);
  1528. if (_numShells > 110) {
  1529. it->second = 150;
  1530. }
  1531. else
  1532. {
  1533. it->second = 110;
  1534. }
  1535. }
  1536. else if (_charge > 0)
  1537. {
  1538. it->second = 75;
  1539. advance(it, 1);
  1540. it->second = 105;
  1541. advance(it, 1);
  1542. it->second = 165;
  1543. advance(it, 1);
  1544. if (_numShells > 165) {
  1545. it->second = 225;
  1546. }
  1547. else
  1548. {
  1549. it->second = 165;
  1550. }
  1551. }
  1552. break;
  1553. case 160:
  1554. it->second = 3;
  1555. advance(it, 1);
  1556. it->second = 9;
  1557. advance(it, 1);
  1558. it->second = 12;
  1559. advance(it, 1);
  1560. it->second = 18;
  1561. advance(it, 1);
  1562. it->second = 21;
  1563. advance(it, 1);
  1564. it->second = 30;
  1565. advance(it, 1);
  1566. it->second = 48;
  1567. advance(it, 1);
  1568. it->second = 88;
  1569. if (_numShells > 88) {
  1570. it->second = 128;
  1571. }
  1572. else
  1573. {
  1574. it->second = 88;
  1575. }
  1576. break;
  1577. case 240:
  1578. it->second = 1;
  1579. advance(it, 1);
  1580. it->second = 3;
  1581. advance(it, 1);
  1582. it->second = 5;
  1583. advance(it, 1);
  1584. it->second = 10;
  1585. advance(it, 1);
  1586. if (_charge == 0)
  1587. {
  1588. it->second = 15;
  1589. advance(it, 1);
  1590. it->second = 30;
  1591. advance(it, 1);
  1592. it->second = 38;
  1593. advance(it, 1);
  1594. it->second = 51;
  1595. advance(it, 1);
  1596. if (_numShells > 51) {
  1597. it->second = 64;
  1598. }
  1599. else
  1600. {
  1601. it->second = 51;
  1602. }
  1603. }
  1604. else if (_charge > 0)
  1605. {
  1606. it->second = 13;
  1607. advance(it, 1);
  1608. it->second = 20;
  1609. advance(it, 1);
  1610. it->second = 25;
  1611. advance(it, 1);
  1612. it->second = 35;
  1613. advance(it, 1);
  1614. if (_numShells > 35) {
  1615. it->second = 45;
  1616. }
  1617. else
  1618. {
  1619. it->second = 35;
  1620. }
  1621. }
  1622. break;
  1623. }
  1624. }
  1625. else if (_caliber.first == "8U32") //çäåñü âîîáùå ïî=õîðîøåìó íàäî ñ÷èòàòü îòäåëüíî íîðìû íà áàòàðåþ è íà äèâèçèîí
  1626. {
  1627. it->second = UINT_MAX;
  1628. advance(it, 1);
  1629. it->second = 16;
  1630. advance(it, 1);
  1631. it->second = 16;
  1632. advance(it, 1);
  1633. it->second = 16*2;
  1634. advance(it, 1);
  1635. it->second = 16*3;
  1636. advance(it, 1);
  1637. it->second = 16*3;
  1638. advance(it, 1);
  1639. it->second = 16 * 4;
  1640. advance(it, 1);
  1641. it->second = 16 * 5;
  1642. advance(it, 1);
  1643. it->second = 16 * 6;
  1644. advance(it, 1);
  1645. it->second = 16 * 7;
  1646. advance(it, 1);
  1647. it->second = 16 * 8;
  1648. advance(it, 1);
  1649. if (_numShells > 16*8) {
  1650. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 16*8) / 16*6) + static_cast<size_t>((_numShells - 16*8) % 16*6);
  1651. it->second = 16*8 + static_cast<size_t>(16*6 * (minutes - 120) / 60);
  1652. }
  1653. else { it->second = 16*8; }
  1654. }
  1655. else if (_caliber.first == "8U31")
  1656. {
  1657. it->second = UINT_MAX; //1
  1658. advance(it, 1);
  1659. it->second = 12; //3
  1660. advance(it, 1);
  1661. it->second = 12; //5
  1662. advance(it, 1);
  1663. it->second = 12; //10
  1664. advance(it, 1);
  1665. it->second = 12 * 2; //15
  1666. advance(it, 1);
  1667. it->second = 12 * 2; //20
  1668. advance(it, 1);
  1669. it->second = 12 * 2; //25
  1670. advance(it, 1);
  1671. it->second = 12 * 3; //30
  1672. advance(it, 1);
  1673. it->second = 12 * 3; //40
  1674. advance(it, 1);
  1675. it->second = 12 * 4; //50
  1676. advance(it, 1);
  1677. it->second = 12 * 5; //60
  1678. advance(it, 1);
  1679. if (_numShells > 12*5) {
  1680. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 12*5) / 12*3) + static_cast<size_t>((_numShells - 12*5) % 12*3);
  1681. it->second = 12*5 + static_cast<size_t>(12*3 * (minutes - 120) / 60);
  1682. }
  1683. else { it->second = 12*5; }
  1684. }
  1685. else if (_caliber.first == "9K55")
  1686. {
  1687. it->second = UINT_MAX; //1
  1688. advance(it, 1);
  1689. it->second = 36; //3
  1690. advance(it, 1);
  1691. it->second = 36 * 2; //5
  1692. advance(it, 1);
  1693. it->second = 36 * 2; //10
  1694. advance(it, 1);
  1695. it->second = 36 * 3; //15
  1696. advance(it, 1);
  1697. it->second = 36 * 3; //20
  1698. advance(it, 1);
  1699. it->second = 36 * 4; //25
  1700. advance(it, 1);
  1701. it->second = 36 * 5; //30
  1702. advance(it, 1);
  1703. it->second = 36 * 6; //40
  1704. advance(it, 1);
  1705. it->second = 36 * 7; //50
  1706. advance(it, 1);
  1707. it->second = 36 * 8; //60
  1708. advance(it, 1);
  1709. if (_numShells > 36*8) {
  1710. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 36*8) / 36*6) + static_cast<size_t>((_numShells - 36*8) % 36*6);
  1711. it->second = 36*8 + static_cast<size_t>(36*6 * (minutes - 120) / 60);
  1712. }
  1713. else { it->second = 36*8; }
  1714. }
  1715. else if (_caliber.first == "9K51")
  1716. {
  1717. it->second = UINT_MAX; //1
  1718. advance(it, 1);
  1719. it->second = 40; //3
  1720. advance(it, 1);
  1721. it->second = 40 * 2; //5
  1722. advance(it, 1);
  1723. it->second = 40 * 2; //10
  1724. advance(it, 1);
  1725. it->second = 40 * 2; //15
  1726. advance(it, 1);
  1727. it->second = 40 * 3; //20
  1728. advance(it, 1);
  1729. it->second = 40 * 3; //25
  1730. advance(it, 1);
  1731. it->second = 40 * 4; //30
  1732. advance(it, 1);
  1733. it->second = 40 * 4; //40
  1734. advance(it, 1);
  1735. it->second = 40 * 5; //50
  1736. advance(it, 1);
  1737. it->second = 40 * 6; //60
  1738. advance(it, 1);
  1739. if (_numShells > 40*6) {
  1740. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 40*6) / 40*4) + static_cast<size_t>((_numShells - 40*6) % 40*4);
  1741. it->second = 40*6 + static_cast<size_t>(40*4 * (minutes - 120) / 60);
  1742. }
  1743. else { it->second = 40*6; }
  1744. }
  1745. else if (_caliber.first == "9K57")
  1746. {
  1747. it->second = UINT_MAX; //1
  1748. advance(it, 1);
  1749. it->second = 40; //3
  1750. advance(it, 1);
  1751. it->second = 40 * 2; //5
  1752. advance(it, 1);
  1753. it->second = 40 * 2; //10
  1754. advance(it, 1);
  1755. it->second = 40 * 2; //15
  1756. advance(it, 1);
  1757. it->second = 40 * 3; //20
  1758. advance(it, 1);
  1759. it->second = 40 * 3; //25
  1760. advance(it, 1);
  1761. it->second = 40 * 4; //30
  1762. advance(it, 1);
  1763. it->second = 40 * 4; //40
  1764. advance(it, 1);
  1765. it->second = 40 * 5; //50
  1766. advance(it, 1);
  1767. it->second = 40 * 6; //60
  1768. advance(it, 1);
  1769. if (_numShells > 40*6) {
  1770. size_t minutes = 120 + 60 * static_cast<size_t>((_numShells - 40 * 6) / 40 * 4) + static_cast<size_t>((_numShells - 40*6) % 40 * 4);
  1771. it->second = 40*6 + static_cast<size_t>(40 * 4 * (minutes - 120) / 60);
  1772. }
  1773. else { it->second = 40 * 6; }
  1774. }
  1775. try
  1776. {
  1777. auto it2 = find_if(targets.begin(), targets.end(), [&](auto const& _n)
  1778. {
  1779. return _n.second > _numShells; //âîçâðàùàåì íîðìó ïî ïîòîëêó
  1780. });
  1781. auto it3 = it2;
  1782. if (it2 != targets.begin())
  1783. {
  1784. advance(it3, -1);
  1785. }
  1786. if (it2->second - it3->second == 0 && it2 != targets.begin())
  1787. {
  1788. throw runtime_error("Could't interpolate: equal neighbouring shell numbers");
  1789. }
  1790. else if (it2->second - it3->second == 0 && it2 == targets.begin())
  1791. {
  1792. return it3->first;
  1793. }
  1794. if (it2 != targets.end())
  1795. {
  1796. double percent = (_numShells - it3->second) / (it2->second - it3->second);
  1797. return it3->first + static_cast<size_t>(percent * (it2->first - it3->first)); //è èíòåðïîëèðóåì ýòó âåëè÷èíó
  1798. }
  1799. else
  1800. {
  1801. throw invalid_argument("Can't find fitting thresholds for this number of shells");
  1802. }
  1803. }
  1804. catch (exception e)
  1805. {
  1806. cerr << e.what() << endl;
  1807. exit(1);
  1808. }
  1809. }
  1810. string Container::getSpecificType(string _artyType)
  1811. {
  1812. try
  1813. {
  1814. if (getType(_artyType) != "howitzer")
  1815. {
  1816. throw invalid_argument("Trying to implement specification of howitzers on mortars or MLRS");
  1817. }
  1818. }
  1819. catch (invalid_argument e)
  1820. {
  1821. cerr << e.what() << endl;
  1822. exit(1);
  1823. }
  1824. //òàêîå ñåáå, êàê îêàçàëîñü, ýòî áûëî äàæå èçëèøíèì. Ìåæäó íèìè ðàçíèöû íåìíîãî
  1825. list<string> howitzer = { "2C1","2A31","2A18"};
  1826. if (find(howitzer.begin(), howitzer.end(), _artyType) != howitzer.end()) { return "howitzer"; }
  1827. list<string> gunhowitzer = {"2C3", "2C5", "2C7", "A-222","52P367","52P546"};
  1828. if (find(gunhowitzer.begin(), gunhowitzer.end(), _artyType) != gunhowitzer.end()) { return "howitzer-gun"; }
  1829. list<string> howitzergun = {"52P482" };
  1830. if (find(howitzergun.begin(), howitzergun.end(), _artyType) != howitzergun.end()) { return "gun-howitzer"; }
  1831. }
  1832. size_t getCharge(string _artyName, string _targetName, string _fuzeType, bool _isEntrenchedOrArmored, double _range)
  1833. {
  1834. if (_artyName == "2A18")
  1835. {
  1836. if (_isEntrenchedOrArmored) return 0;
  1837. if (_range < 5.800) return 4;
  1838. else if (_range < 7.000) return 3;
  1839. else if (_range < 8.200) return 2;
  1840. else if (_range < 9.400) return 1;
  1841. else return 0;
  1842. }
  1843. if (_artyName == "52P546")
  1844. {
  1845. if (_isEntrenchedOrArmored) return 0;
  1846. else if (_range < 6.000) return 6;
  1847. else if (_range < 7.000) return 5;
  1848. else if (_range < 9.000) return 4;
  1849. else if (_range < 10.200) return 3;
  1850. else if (_range < 11.400) return 2;
  1851. else if (_range < 13.600) return 1;
  1852. else return 0;
  1853. }
  1854. return 0;
  1855. }