AlexRaynor

4.8 Clone Attacks

Sep 22nd, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace IMJunior
  4. {
  5.     class Program
  6.  
  7.         // Вынос в отдельные функции процедур увеличения и уменьшения характеристик
  8.  
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int age = 0, strength = 0, agility = 0, intelligence = 0, points = 25;
  13.             string strengthVisual = string.Empty, agilityVisual = string.Empty, intelligenceVisual = string.Empty;
  14.  
  15.             Console.WriteLine("Добро пожаловать в меню выбора создания персонажа!");
  16.             Console.WriteLine("У вас есть 25 очков, которые вы можете распределить по умениям");
  17.             Console.WriteLine("Нажмите любую клавишу чтобы продолжить...");
  18.             Console.ReadKey();
  19.  
  20.             while (points > 0)
  21.             {
  22.                 Console.Clear();
  23.                 strengthVisual = string.Empty;
  24.                 agilityVisual = string.Empty;
  25.                 intelligenceVisual = string.Empty;
  26.                 strengthVisual = strengthVisual.PadLeft(strength, '#').PadRight(10, '_');
  27.                 agilityVisual = agilityVisual.PadLeft(agility, '#').PadRight(10, '_');
  28.                 intelligenceVisual = intelligenceVisual.PadLeft(intelligence, '#').PadRight(10, '_');
  29.                 Console.WriteLine("Поинтов - {0}", points);
  30.                 Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтеллект - [{3}]", age, strengthVisual, agilityVisual, intelligenceVisual);
  31.  
  32.                 Console.WriteLine("Какую характеристику вы хотите изменить?");
  33.                 string subject = Console.ReadLine();
  34.  
  35.                 Console.WriteLine(@"Что вы хотите сделать? +\-");
  36.                 string operation = Console.ReadLine();
  37.  
  38.                 Console.WriteLine(@"Количество поинтов которые следует {0}", operation == "+" ? "прибавить" : "отнять");
  39.  
  40.                 string operandPointsRaw = string.Empty;
  41.                 int operandPoints = 0;
  42.                 do
  43.                 {
  44.                     operandPointsRaw = Console.ReadLine();
  45.                 } while (!int.TryParse(operandPointsRaw, out operandPoints));
  46.  
  47.                 switch (subject.ToLower())
  48.                 {
  49.                     case "сила":
  50.                         if (operation == "+")
  51.                         {
  52.                             increase(operandPoints, strength);
  53.                         }
  54.                         else
  55.                         {
  56.                             decrease(operandPoints, strength);
  57.                         }
  58.  
  59.                         strength = operation == "+" ? strength + operandPoints : strength - operandPoints;
  60.                         points = operation == "+" ? points - operandPoints : points + operandPoints;
  61.                         break;
  62.                     case "ловкость":
  63.                         if (operation == "+")
  64.                         {
  65.                             increase(operandPoints, agility);
  66.                         }
  67.                         else
  68.                         {
  69.                             decrease(operandPoints, agility);
  70.                         }
  71.  
  72.                         agility = operation == "+" ? agility + operandPoints : agility - operandPoints;
  73.                         points = operation == "+" ? points - operandPoints : points + operandPoints;
  74.                         break;
  75.                     case "интеллект":
  76.                         if (operation == "+")
  77.                         {
  78.                             increase(operandPoints, intelligence);
  79.                         }
  80.                         else
  81.                         {
  82.                             decrease(operandPoints, intelligence);
  83.                         }
  84.  
  85.                         intelligence = operation == "+" ? intelligence + operandPoints : intelligence - operandPoints;
  86.                         points = operation == "+" ? points - operandPoints : points + operandPoints;
  87.                         break;
  88.                 }
  89.             }
  90.  
  91.             Console.WriteLine("Вы распределили все очки. Введите возраст персонажа:");
  92.             string ageRaw = string.Empty;
  93.             do
  94.             {
  95.                 ageRaw = Console.ReadLine();
  96.             } while (int.TryParse(ageRaw, out age));
  97.  
  98.  
  99.             Console.Clear();
  100.             strengthVisual = string.Empty;
  101.             agilityVisual = string.Empty;
  102.             intelligenceVisual = string.Empty;
  103.             strengthVisual = strengthVisual.PadLeft(strength, '#').PadRight(10, '_');
  104.             agilityVisual = agilityVisual.PadLeft(agility, '#').PadRight(10, '_');
  105.             intelligenceVisual = intelligenceVisual.PadLeft(intelligence, '#').PadRight(10, '_');
  106.             Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтеллект - [{3}]", age, strengthVisual, agilityVisual, intelligenceVisual);
  107.  
  108.         }
  109.  
  110.         static void increase(int inc, int current)
  111.         {
  112.             int overhead = current - (10 - inc);
  113.             overhead = overhead < 0 ? 0 : overhead;
  114.             current -= overhead;
  115.         }
  116.  
  117.         static void decrease(int dec, int current)
  118.         {
  119.             int overhead = dec - current;
  120.             overhead = overhead < 0 ? overhead : 0;
  121.             current += overhead;
  122.         }
  123.     }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment