Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <random>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. // 24 БИЛЕТ //
  11.  
  12. struct mechanic {
  13. string name;
  14. string ammo_type;
  15.  
  16. int health;
  17. int damage;
  18. int defence;
  19. };
  20.  
  21. struct animal {
  22. string name;
  23.  
  24. int speed;
  25. int health;
  26. int damage;
  27. int defence;
  28. };
  29.  
  30. struct soldier {
  31. string name;
  32. string defence_type;
  33.  
  34. int health;
  35. int damage;
  36. int defence;
  37. };
  38.  
  39. struct rider {
  40. string name;
  41. string animal;
  42.  
  43. int health;
  44. int damage;
  45. int defence;
  46. };
  47.  
  48. struct army_template {
  49. string name;
  50. string animal;
  51. string unit_name;
  52. string defence_type;
  53. string ammo_type;
  54.  
  55. int health;
  56. int damage;
  57. int defence;
  58. };
  59.  
  60.  
  61. int main()
  62. {
  63. int animals = 0;
  64. int humans = 0;
  65. int machanics = 0;
  66. int riders = 0;
  67.  
  68. mechanic mechanics[2];
  69.  
  70. soldier soldiers[2];
  71.  
  72. //animal animals[2];
  73.  
  74. //rider riders[2];
  75.  
  76. army_template *army;
  77.  
  78. int armySize;
  79. cout << "Введите размер армии." << endl;
  80. cin >> armySize;
  81.  
  82. while (armySize < 4 && armySize > 12) {
  83. cout << "Размер армии должен быть не меньше 4 и не больше 12" << endl;
  84. cin >> armySize;
  85. }
  86.  
  87. srand(time(0));
  88.  
  89. int max_animals_count = 1 + rand() % 3;
  90. int max_machanics_count = 1 + rand() % 3;
  91. int max_soldiers_count = 1 + rand() % 3;
  92. int max_riders_count = 1 + max_animals_count;
  93.  
  94. int current_animals_count = 0;
  95. int current_machanics_count = 0;
  96. int current_soldiers_count = 0;
  97. int current_riders_count = 0;
  98.  
  99.  
  100. army = new army_template[armySize];
  101.  
  102. for (int i = 0; i < armySize; i++)
  103. {
  104.  
  105. int health = 40 + rand() % 100;
  106. int damage = 30 + rand() % 100;
  107. int defence = 5 + rand() % 35;
  108. int speed = 0;
  109.  
  110. string animal = "no";
  111. string name = "no";
  112. string unit_name = "no";
  113. string ammo_type = "no";
  114.  
  115. if (current_animals_count != max_animals_count) {
  116. srand(time(0));
  117.  
  118. int index = 1 + rand() % 1;
  119.  
  120. unit_name = "animal";
  121. string names = { "Bear", "White Bear" };
  122.  
  123. speed = 1 + rand() % 30;
  124. name = names[index];
  125. } else if (current_machanics_count != max_machanics_count) {
  126. srand(time(0));
  127.  
  128. int index = 1 + rand() % 1;
  129.  
  130. unit_name = "mechanic";
  131. string names = { "Catapult", "Balista" };
  132. string ammo_types = { "Bolt", "Bullet" };
  133.  
  134. name = names[index];
  135. ammo_type = ammo_types[index];
  136. } else {
  137. srand(time(0));
  138.  
  139. int index = 1 + rand() % 1;
  140.  
  141. unit_name = "soldier";
  142. string names = {"Wizard", "Rogue"};
  143. string defence_types = {"suit", "cloak"};
  144.  
  145. name = names[index];
  146. defence_types = defence_types[index];
  147. }
  148.  
  149. army[i].unit_name = unit_name;
  150. army[i].health = health;
  151. army[i].damage = damage;
  152. army[i].animal = animal;
  153. army[i].ammo_type = ammo_type;
  154.  
  155. for (int i = 0; i < armySize; i++)
  156. {
  157. cout << army[i].unit_name << endl;
  158. cout << army[i].health << endl;
  159. cout << army[i].damage << endl;
  160. cout << army[i].animal << endl;
  161. cout << army[i].ammo_type << endl;
  162. }
  163. }
  164.  
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement