Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Reflection;
- namespace Clight_19
- {
- class Program
- {
- static void Main()
- {
- const string SimpleAttack = "1";
- const string MiddleAttack = "2";
- const string StrongAttack = "3";
- const string MegaAttack = "4";
- Random random = new Random();
- string userInput = "";
- bool isCorrectInput = false;
- int fightingStep = 1;
- int bossHealth = 200;
- int bossDamage = 10;
- int playerHealth = 100;
- int playerDamage = 10;
- int minIncrementalDamage = 2;
- int maxIncrementalDamage = 10;
- int currentDamage;
- float MiddleAttackFactor = 1.2f;
- float StrongAttackFactor = 2f;
- float MegaAttackFactor = 3;
- bool canHit;
- bool isSuccessfulMegaAttack;
- byte minPercentage = 0;
- byte maxPercentage = 100;
- byte probabilityStrongAttackOfPercentages = 85;
- byte probabilitySuccessfulMegaAttackOfPercentages = 60;
- int playerPower;
- int maxPlayerPower = 10;
- int requiredPowerForMegaAttack = 5;
- int restorePowerByStep = 2;
- float powerFactor;
- playerPower = maxPlayerPower;
- while (playerHealth > 0 && bossHealth > 0)
- {
- Console.Clear();
- Console.WriteLine($"Ход боя: {fightingStep}\n");
- Console.WriteLine($"Здоровье игрока: {playerHealth}");
- Console.WriteLine($"Сила игрока: {playerPower}\n");
- Console.WriteLine($"Здоровье босса: {bossHealth}\n");
- Console.WriteLine($"{SimpleAttack} - Простой удар. Слабый, но восстанавливает силы.");
- Console.WriteLine($"{MiddleAttack} - Средняя атака.");
- Console.WriteLine($"{StrongAttack} - Сильная атака. Зависит от силы игрока. Вероятность промахнуться.");
- Console.WriteLine($"{MegaAttack} - Мега атака. Если сила игрока > {requiredPowerForMegaAttack}. Вероятность нанести себе урон.\n");
- if (playerPower > 0)
- {
- isCorrectInput = false;
- while (isCorrectInput == false)
- {
- isCorrectInput = true;
- Console.Write("Выберете номер удара: ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case SimpleAttack:
- bossHealth -= playerDamage;
- playerPower += restorePowerByStep;
- Console.WriteLine($"Ваш удар нанёс {playerDamage} урона. Возобновление силы +{restorePowerByStep}.");
- break;
- case MiddleAttack:
- currentDamage = playerDamage + (int)(random.Next(minIncrementalDamage, ++maxIncrementalDamage) * MiddleAttackFactor);
- bossHealth -= currentDamage;
- playerPower -= restorePowerByStep;
- Console.WriteLine($"Ваш удар нанёс {currentDamage} урона.");
- break;
- case StrongAttack:
- canHit = random.Next(minPercentage, ++maxPercentage) <= probabilityStrongAttackOfPercentages;
- if (canHit)
- {
- powerFactor = maxPlayerPower / playerPower;
- currentDamage = playerDamage + (int)(random.Next(minIncrementalDamage, ++maxIncrementalDamage)
- * StrongAttackFactor * powerFactor);
- bossHealth -= currentDamage;
- playerPower -= restorePowerByStep;
- Console.WriteLine($"Ваш удар нанёс {currentDamage} урона.");
- }
- else
- {
- playerPower += restorePowerByStep;
- Console.WriteLine($"Промахнулись. Возобновление силы +{restorePowerByStep}");
- }
- break;
- case MegaAttack:
- if (playerPower > requiredPowerForMegaAttack)
- {
- isSuccessfulMegaAttack = random.Next(minPercentage, ++maxPercentage) <= probabilitySuccessfulMegaAttackOfPercentages;
- if (isSuccessfulMegaAttack == false)
- {
- playerHealth -= playerDamage;
- currentDamage = (int)(playerDamage * MegaAttackFactor);
- bossHealth -= currentDamage;
- playerPower -= restorePowerByStep;
- Console.WriteLine($"Нанесён урон {currentDamage} не только боссу, но и себе {playerDamage}.");
- }
- else
- {
- currentDamage = (int)(playerDamage * MegaAttackFactor);
- bossHealth -= currentDamage;
- playerPower -= restorePowerByStep;
- Console.WriteLine($"Ваш удар нанёс {currentDamage} урона.");
- }
- }
- else
- {
- playerPower += restorePowerByStep;
- Console.WriteLine($"Вам не хватило сил нанести удар. Возобновление силы +{restorePowerByStep}");
- }
- break;
- default:
- isCorrectInput = false;
- Console.WriteLine("Не корректно введён номер.");
- break;
- }
- }
- }
- else
- {
- playerPower += restorePowerByStep;
- Console.WriteLine($"Вам не хватило сил нанести удар. Возобновление силы +{restorePowerByStep}");
- }
- playerPower = Math.Clamp(playerPower, 0, maxPlayerPower);
- playerHealth -= bossDamage;
- Console.WriteLine($"Босс нанёс вам {bossDamage} урона.");
- if (playerHealth <= 0 && bossHealth <= 0)
- {
- Console.WriteLine("\nНичья.");
- }
- else if (playerHealth <= 0)
- {
- Console.WriteLine("\nВы убиты.");
- }
- else if (bossHealth <= 0)
- {
- Console.WriteLine("\nВы победили.");
- }
- Console.Write("\nДля продолжения нажмите любую клавишу.");
- Console.ReadKey();
- fightingStep++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement