Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <random>
- #include <ctime>
- using namespace std;
- // 24 БИЛЕТ //
- struct mechanic {
- string name;
- string ammo_type;
- int health;
- int damage;
- int defence;
- };
- struct animal {
- string name;
- int speed;
- int health;
- int damage;
- int defence;
- };
- struct soldier {
- string name;
- string defence_type;
- int health;
- int damage;
- int defence;
- };
- struct rider {
- string name;
- string animal;
- int health;
- int damage;
- int defence;
- };
- struct army_template {
- string name;
- string animal;
- string unit_name;
- string defence_type;
- string ammo_type;
- int health;
- int damage;
- int defence;
- };
- int main()
- {
- int animals = 0;
- int humans = 0;
- int machanics = 0;
- int riders = 0;
- mechanic mechanics[2];
- soldier soldiers[2];
- //animal animals[2];
- //rider riders[2];
- army_template *army;
- int armySize;
- cout << "Введите размер армии." << endl;
- cin >> armySize;
- while (armySize < 4 && armySize > 12) {
- cout << "Размер армии должен быть не меньше 4 и не больше 12" << endl;
- cin >> armySize;
- }
- srand(time(0));
- int max_animals_count = 1 + rand() % 3;
- int max_machanics_count = 1 + rand() % 3;
- int max_soldiers_count = 1 + rand() % 3;
- int max_riders_count = 1 + max_animals_count;
- int current_animals_count = 0;
- int current_machanics_count = 0;
- int current_soldiers_count = 0;
- int current_riders_count = 0;
- army = new army_template[armySize];
- for (int i = 0; i < armySize; i++)
- {
- int health = 40 + rand() % 100;
- int damage = 30 + rand() % 100;
- int defence = 5 + rand() % 35;
- int speed = 0;
- string animal = "no";
- string name = "no";
- string unit_name = "no";
- string ammo_type = "no";
- if (current_animals_count != max_animals_count) {
- srand(time(0));
- int index = 1 + rand() % 1;
- unit_name = "animal";
- string names = { "Bear", "White Bear" };
- speed = 1 + rand() % 30;
- name = names[index];
- } else if (current_machanics_count != max_machanics_count) {
- srand(time(0));
- int index = 1 + rand() % 1;
- unit_name = "mechanic";
- string names = { "Catapult", "Balista" };
- string ammo_types = { "Bolt", "Bullet" };
- name = names[index];
- ammo_type = ammo_types[index];
- } else {
- srand(time(0));
- int index = 1 + rand() % 1;
- unit_name = "soldier";
- string names = {"Wizard", "Rogue"};
- string defence_types = {"suit", "cloak"};
- name = names[index];
- defence_types = defence_types[index];
- }
- army[i].unit_name = unit_name;
- army[i].health = health;
- army[i].damage = damage;
- army[i].animal = animal;
- army[i].ammo_type = ammo_type;
- for (int i = 0; i < armySize; i++)
- {
- cout << army[i].unit_name << endl;
- cout << army[i].health << endl;
- cout << army[i].damage << endl;
- cout << army[i].animal << endl;
- cout << army[i].ammo_type << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement