Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const string SwordStrikeCommand = "1";
- const string CrossbowShotCommand = "2";
- const string SwordStrikeFromShadowsCommand = "3";
- const string HideInShadowsAndHealthingCommand = "4";
- Random random = new Random();
- int heroLife = 400;
- int bossLife = 1000;
- int bossAttackMin = 50;
- int bossAttackMax = 200;
- bool isWorkingHideInShadows = false;
- string typeAttack;
- while (heroLife > 0 && bossLife > 0)
- {
- Console.WriteLine($"Жизни героя:{heroLife}\nЖизни босса:{bossLife}\nВыберите действие:\n{SwordStrikeCommand} <-- удар мечем.\n{CrossbowShotCommand} <-- выстрел из арбалета." +
- $"\n{SwordStrikeFromShadowsCommand} <-- удар мечем из тени.\n{HideInShadowsAndHealthingCommand} <-- спрятаться в тени.");
- typeAttack = Console.ReadLine();
- switch (typeAttack)
- {
- case SwordStrikeCommand:
- int swordStrike = 100;
- Console.WriteLine($"Удар мечем!");
- bossLife -= swordStrike;
- heroLife -= random.Next(bossAttackMin, bossAttackMax);
- Console.Clear();
- break;
- case CrossbowShotCommand:
- int crossbowShotAttackMin = 50;
- int crossbowShotAttackMax = 150;
- Console.WriteLine($"Выстрел из арбалета!");
- bossLife -= random.Next(crossbowShotAttackMin,crossbowShotAttackMax);
- heroLife -= random.Next(bossAttackMin, bossAttackMax);
- Console.Clear();
- break;
- case SwordStrikeFromShadowsCommand:
- int swordStrikeFromShadows = 300;
- if (isWorkingHideInShadows == true)
- {
- Console.WriteLine($"Удар мечем из тени!");
- bossLife -= swordStrikeFromShadows;
- heroLife -= random.Next(bossAttackMin, bossAttackMax);
- isWorkingHideInShadows = false;
- Console.Clear();
- }
- else
- {
- Console.WriteLine($"Атака не сработала!");
- heroLife -= random.Next(bossAttackMin, bossAttackMax);
- Console.Clear();
- }
- break;
- case HideInShadowsAndHealthingCommand:
- int hideInShadowsAndHealthing = 100;
- Console.WriteLine($"Герой спрятался в тени и восстановил 100 жизней!");
- heroLife += hideInShadowsAndHealthing;
- isWorkingHideInShadows = true;
- Console.Clear();
- break;
- }
- }
- if (bossLife <= 0 && heroLife <= 0)
- {
- Console.WriteLine("Ничья!");
- }
- else if (bossLife > 0)
- {
- Console.WriteLine("Босс побеждает!");
- }
- else if (heroLife > 0)
- {
- Console.WriteLine("Герой побеждает!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement