Skip to content

Instantly share code, notes, and snippets.

@ImShizer
Created June 23, 2022 18:50
Show Gist options
  • Save ImShizer/4ce2c61db8bb36909f136ff396e48815 to your computer and use it in GitHub Desktop.
Save ImShizer/4ce2c61db8bb36909f136ff396e48815 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;
int main() {
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
setlocale(0, "");
srand(time(0));
int country = 0;
int method = 0;
int plan = 0;
long long int count = 0;
int res_choice = 0;
long long int enemyCount = 0;
long long int maxGerman = 3000000;
long long int maxFrance = 3000000;
int win, lose = 0;
SetConsoleTextAttribute(h, 15);
cout << "1940 год. Франция и Соединённое Королевство объявили войну Германии после вторжения в Польшу." << endl;
cout << "Мировая напряжённость максимальная, и от альянсов \"Союзники\" и \"Ось\" зависит судьба мира" << endl;
do {
cout << "Выберите страну" << endl;
SetConsoleTextAttribute(h, 4);
cout << "1 - Германия" << endl;
SetConsoleTextAttribute(h, 1);
cout << "Остальные страны находятся в разработке" << endl;
SetConsoleTextAttribute(h, 10);
cin >> country;
SetConsoleTextAttribute(h, 15);
} while (country != 1);
cout << "Вы выбрали Германию. Война с Францией неизбежна. \nКакой метод ведения войны стоит выбрать?" << endl;
do {
cout << "Выберите метод ведения войны" << endl;
SetConsoleTextAttribute(h, 4);
cout << "1 - Наступательная" << endl;
SetConsoleTextAttribute(h, 1);
cout << "Другие варианты находятся в разработке" << endl;
SetConsoleTextAttribute(h, 10);
cin >> method;
SetConsoleTextAttribute(h, 15);
} while (method != 1);
if (method == 1) {
cout << "СС и Вермахт готовы к наступлению. У них есть два плана. \nИменно ваше решение станет финальным." << endl;
do {
cout << "Выберите план нападения" << endl;
SetConsoleTextAttribute(h, 1);
cout << "1 - Проход через Бельгию" << endl;
SetConsoleTextAttribute(h, 4);
cout << "2 - Проход напрямую через линию Мажино" << endl;
SetConsoleTextAttribute(h, 10);
cin >> plan;
SetConsoleTextAttribute(h, 15);
} while (plan < 1 || plan > 2);
if (plan == 1) {
cout << "Наступление началось успешно, войска Союзников окружены и прижаты. Сила войск увеличена на 20%" << endl;
do {
cout << "Сколько военных будет выделено на Операцию? (Максимальная численность - " << maxGerman << ')' << endl;
cin >> count;
// cout << "MaxGerman: " << maxGerman << endl;
} while (count < 0 || count > maxGerman);
long long int maxGerman = 3000000 - count;
long long int minEnemy = 1000000;
int k = 3000000 - minEnemy + 1;
srand(time(0));
enemyCount = rand() % k + minEnemy;
SetConsoleTextAttribute(h, 4);
cout << "Враг выделил на эту операцию " << enemyCount << " военных" << endl;
SetConsoleTextAttribute(h, 15);
int i = 0;
maxFrance = 3000000 - enemyCount;
int germanPower = (count / 10) * 1.2;
int francePower = enemyCount / 10;
int res = 1;
while (res != 0) {
count = count - francePower;
enemyCount = enemyCount - germanPower;
i++;
if (enemyCount < 0 || count < 0 || francePower < 0 || germanPower < 0) {
SetConsoleTextAttribute(h, 10);
cout << "Битва окончена. Подводим итоги";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << "." << endl;
SetConsoleTextAttribute(h, 15);
if (enemyCount < count) {
win = 1;
lose = 0;
}
else {
lose = 1;
win = 0;
}
res = 0;
}
else {
// cout << "F: " << francePower << " G: " << germanPower << endl;
// cout << "F: " << enemyCount << " G: " << count << endl;
SetConsoleTextAttribute(h, 10);
cout << "Начата попытка штурма номер " << i << endl;
SetConsoleTextAttribute(h, 3);
cout << "Осталось ваших военных: " << count << endl;
SetConsoleTextAttribute(h, 4);
cout << "Осталось вражеских военных: " << enemyCount << endl;
SetConsoleTextAttribute(h, 15);
Sleep(100);
germanPower = (count / 10) * 1.2;
francePower = enemyCount / 10;
}
}
if (win != 1) {
cout << "Битва проиграна, войска отступили на прежние границы, их боевой дух упал. \nЧто будете делать?";
do {
cout << "Выберите план нападения" << endl;
SetConsoleTextAttribute(h, 1);
cout << "1 - Капитуляция" << endl;
SetConsoleTextAttribute(h, 2);
cout << "2 - Мирный договор" << endl;
SetConsoleTextAttribute(h, 4);
cout << "3 - Оборона до последнего" << endl;
SetConsoleTextAttribute(h, 10);
cin >> res_choice;
SetConsoleTextAttribute(h, 15);
} while (res_choice < 1 || res_choice > 3);
if (res_choice == 1) {
SetConsoleTextAttribute(h, 1);
cout << "Германия капитулировала. Вы проиграли." << endl;
}
else if (res_choice == 2) {
SetConsoleTextAttribute(h, 2);
cout << "Мирный договор был подписан, границы не были тронуты, но экономику восстанавливать прийдётся ещё долго" << endl;
}
else if (res_choice == 3) {
SetConsoleTextAttribute(h, 1);
cout << "Битва началась непосредственно на территории Германии. Боевой дух сильно упал" << endl;
SetConsoleTextAttribute(h, 15);
int p = 0;
int finall = 0;
while (finall == 0) {
long long int germanPower = maxGerman / 10 * 0.5;
long long int francePower = maxFrance / 10;
maxGerman -= francePower;
maxFrance -= germanPower;
if (maxGerman <= 0 || maxFrance <= 0) {
cout << "Битва окончена.";
finall = 1;
}
else {
SetConsoleTextAttribute(h, 10);
cout << "Начата попытка штурма номер " << p << endl;
p++;
SetConsoleTextAttribute(h, 3);
cout << "Осталось ваших военных: " << maxGerman << endl;
SetConsoleTextAttribute(h, 4);
cout << "Осталось вражеских военных: " << maxFrance << endl;
SetConsoleTextAttribute(h, 15);
Sleep(1000);
}
}
}
}
else if (win == 1) {
cout << "Битва выиграна, враг принимает решение..." << endl;
int minEnemyChoice = 1;
int maxEnemyChoice = 3;
int k = maxEnemyChoice - minEnemyChoice + 1;
int enemyChoice = rand() % k + minEnemy;
if (enemyChoice == 1) {
SetConsoleTextAttribute(h, 2);
cout << "Франция капитулировала. Вы победили!" << endl;
SetConsoleTextAttribute(h, 15);
}
else if (enemyChoice == 2) {
SetConsoleTextAttribute(h, 3);
cout << "Подписан мирный договор. Ваши территории расширились. Вы победили!" << endl;
SetConsoleTextAttribute(h, 15);
}
else {
int p = 0;
SetConsoleTextAttribute(h, 4);
cout << "Противник отказался сдаваться, но его войска очень ослабли." << endl;
SetConsoleTextAttribute(h, 15);
int finall = 0;
while (finall == 0) {
long long int germanPower = maxGerman / 10;
long long int francePower = maxFrance / 10 * 0.5;
maxGerman -= francePower;
maxFrance -= germanPower;
if (maxGerman <= 0 || maxFrance <= 0) {
cout << "Битва окончена.";
finall = 1; // d
}
else {
SetConsoleTextAttribute(h, 10);
cout << "Начата попытка штурма номер " << p << endl;
p++;
SetConsoleTextAttribute(h, 3);
cout << "Осталось ваших военных: " << maxGerman << endl;
SetConsoleTextAttribute(h, 4);
cout << "Осталось вражеских военных: " << maxFrance << endl;
SetConsoleTextAttribute(h, 15);
Sleep(1000);
}
}
}
}
}
else {
int k = 2 - 1 + 1;
srand(time(0));
int majino = rand() % k + 1;
cout << "Наступление началось успешно, войска Союзников окружены и прижаты. Сила войск увеличена на 20%" << endl;
do {
cout << "Сколько военных будет выделено на Операцию? (Максимальная численность - " << maxGerman << ')' << endl;
cin >> count;
// cout << "MaxGerman: " << maxGerman << endl;
} while (count < 0 || count > maxGerman);
long long int maxGerman = 3000000 - count;
long long int minEnemy = 1000000;
int s = 3000000 - minEnemy + 1;
srand(time(0));
enemyCount = rand() % s + minEnemy;
SetConsoleTextAttribute(h, 4);
cout << "Враг выделил на эту операцию " << enemyCount << " военных" << endl;
SetConsoleTextAttribute(h, 15);
int i = 0;
int germanPower = (count / 10);
maxFrance = 3000000 - enemyCount;
if (majino == 1) {
germanPower = (count / 10) * 1.2;
cout << "Нападение проводится успешно, готовность к бою увеличена на 20%" << endl;
}
else {
germanPower = (count / 10) * 0.5;
cout << "Нападение привело к большим потерям из-за ошибок командования и разведки, готовность снижена на 50%" << endl;
}
int francePower = enemyCount / 10;
int res = 1;
while (res != 0) {
count = count - francePower;
enemyCount = enemyCount - germanPower;
i++;
if (enemyCount < 0 || count < 0 || francePower < 0 || germanPower < 0) {
SetConsoleTextAttribute(h, 10);
cout << "Битва окончена. Подводим итоги";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << "." << endl;
SetConsoleTextAttribute(h, 15);
if (enemyCount < count) {
win = 1;
lose = 0;
}
else {
lose = 1;
win = 0;
}
res = 0;
}
else {
// cout << "F: " << francePower << " G: " << germanPower << endl;
// cout << "F: " << enemyCount << " G: " << count << endl;
SetConsoleTextAttribute(h, 10);
cout << "Начата попытка штурма номер " << i << endl;
SetConsoleTextAttribute(h, 3);
cout << "Осталось ваших военных: " << count << endl;
SetConsoleTextAttribute(h, 4);
cout << "Осталось вражеских военных: " << enemyCount << endl;
SetConsoleTextAttribute(h, 15);
Sleep(100);
germanPower = (count / 10) * 1.2;
francePower = enemyCount / 10;
}
}
if (win != 1) {
cout << "Битва проиграна, войска отступили на прежние границы, их боевой дух упал. \nЧто будете делать?";
do {
cout << "Выберите план нападения" << endl;
SetConsoleTextAttribute(h, 1);
cout << "1 - Капитуляция" << endl;
SetConsoleTextAttribute(h, 2);
cout << "2 - Мирный договор" << endl;
SetConsoleTextAttribute(h, 4);
cout << "3 - Оборона до последнего" << endl;
SetConsoleTextAttribute(h, 10);
cin >> res_choice;
SetConsoleTextAttribute(h, 15);
} while (res_choice < 1 || res_choice > 3);
if (res_choice == 1) {
SetConsoleTextAttribute(h, 1);
cout << "Германия капитулировала. Вы проиграли." << endl;
}
else if (res_choice == 2) {
SetConsoleTextAttribute(h, 2);
cout << "Мирный договор был подписан, границы не были тронуты, но экономику восстанавливать прийдётся ещё долго" << endl;
}
else if (res_choice == 3) {
SetConsoleTextAttribute(h, 1);
cout << "Битва началась непосредственно на территории Германии. Боевой дух сильно упал" << endl;
SetConsoleTextAttribute(h, 15);
int p = 0;
int finall = 0;
while (finall == 0) {
long long int germanPower = maxGerman / 10 * 0.5;
long long int francePower = maxFrance / 10;
maxGerman -= francePower;
maxFrance -= germanPower;
if (maxGerman <= 0 || maxFrance <= 0) {
cout << "Битва окончена.";
finall = 1;
}
else {
SetConsoleTextAttribute(h, 10);
cout << "Начата попытка штурма номер " << p << endl;
p++;
SetConsoleTextAttribute(h, 3);
cout << "Осталось ваших военных: " << maxGerman << endl;
SetConsoleTextAttribute(h, 4);
cout << "Осталось вражеских военных: " << maxFrance << endl;
SetConsoleTextAttribute(h, 15);
Sleep(1000);
}
}
}
}
else if (win == 1) {
cout << "Битва выиграна, враг принимает решение..." << endl;
int minEnemyChoice = 1;
int maxEnemyChoice = 3;
int k = maxEnemyChoice - minEnemyChoice + 1;
int enemyChoice = rand() % k + minEnemy;
if (enemyChoice == 1) {
SetConsoleTextAttribute(h, 2);
cout << "Франция капитулировала. Вы победили!" << endl;
SetConsoleTextAttribute(h, 15);
}
else if (enemyChoice == 2) {
SetConsoleTextAttribute(h, 3);
cout << "Подписан мирный договор. Ваши территории расширились. Вы победили!" << endl;
SetConsoleTextAttribute(h, 15);
}
else {
int p = 0;
SetConsoleTextAttribute(h, 4);
cout << "Противник отказался сдаваться, но его войска очень ослабли." << endl;
SetConsoleTextAttribute(h, 15);
while (true) {
long long int germanPower = maxGerman / 10;
long long int francePower = maxFrance / 10 * 0.5;
maxGerman -= francePower;
maxFrance -= germanPower;
if (maxGerman <= 0 || maxFrance <= 0) {
cout << "Битва окончена.";
break;
}
else {
SetConsoleTextAttribute(h, 10);
cout << "Начата попытка штурма номер " << p << endl;
p++;
SetConsoleTextAttribute(h, 3);
cout << "Осталось ваших военных: " << maxGerman << endl;
SetConsoleTextAttribute(h, 4);
cout << "Осталось вражеских военных: " << maxFrance << endl;
SetConsoleTextAttribute(h, 15);
Sleep(1000);
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment