Advertisement
centner_dc

Ex1

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