Advertisement
Guest User

4.8

a guest
May 21st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.15 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.                 ShowParameters(strengthVisual, agilityVisual, intelligenceVisual, age, strength, agility, intelligence, points);
  20.                 Console.WriteLine("Какую характеристику вы хотите изменить?");
  21.                 string subject = Console.ReadLine();
  22.  
  23.                 Console.WriteLine(@"Что вы хотите сделать? +\-");
  24.                 string operation = Console.ReadLine();
  25.  
  26.                 Console.WriteLine(@"Колличество поинтов которые следует {0}", operation == "+" ? "прибавить" : "отнять");
  27.  
  28.                 int operandPoints = ReadInt();
  29.  
  30.                 switch (subject.ToLower())
  31.                 {
  32.                     case "сила":
  33.                         SetPoint(ref points, ref strength, operation, operandPoints);
  34.                         break;
  35.                     case "ловкость":
  36.                         SetPoint(ref points, ref agility, operation, operandPoints);
  37.                         break;
  38.                     case "интелект":
  39.                         SetPoint(ref points, ref intelligence, operation, operandPoints);
  40.                         break;
  41.                 }
  42.             }
  43.  
  44.             Console.WriteLine("Вы распределили все очки. Введите возраст персонажа:");
  45.             age = ReadInt();
  46.  
  47.             ShowParameters(strengthVisual, agilityVisual, intelligenceVisual, age, strength, agility, intelligence, points);
  48.         }
  49.  
  50.         static void SetPoint(ref int points, ref int parametrValue, string operation, int operandPoints)
  51.         {
  52.             if (operation == "+")
  53.             {
  54.                 int overhead = operandPoints - (points > 10 ? 10 : points - parametrValue);
  55.                 overhead = overhead < 0 ? 0 : overhead;
  56.                 operandPoints -= overhead;
  57.             }
  58.             else
  59.             {
  60.                 int overhead = parametrValue - operandPoints;
  61.                 overhead = overhead < 0 ? overhead : 0;
  62.                 operandPoints += overhead;
  63.             }
  64.  
  65.             parametrValue = operation == "+" ? parametrValue + operandPoints : parametrValue - operandPoints;
  66.             points = operation == "+" ? points - operandPoints : points + operandPoints;
  67.         }
  68.  
  69.         static int ReadInt()
  70.         {
  71.             int result;
  72.             while (!int.TryParse(Console.ReadLine(), out result)) { }
  73.             return result;
  74.         }
  75.  
  76.         static void ShowParameters(string strengthVisual, string agilityVisual, string intelligenceVisual, int age, int strength, int agility, int intelligence, int points)
  77.         {
  78.             Console.Clear();
  79.             strengthVisual = string.Empty;
  80.             agilityVisual = string.Empty;
  81.             intelligenceVisual = string.Empty;
  82.             strengthVisual = strengthVisual.PadLeft(strength, '#').PadRight(10, '_');
  83.             agilityVisual = agilityVisual.PadLeft(agility, '#').PadRight(10, '_');
  84.             intelligenceVisual = intelligenceVisual.PadLeft(intelligence, '#').PadRight(10, '_');
  85.             if(points != 0)
  86.                 Console.WriteLine("Поинтов - {0}", points);
  87.             Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтелект - [{3}]", age, strengthVisual, agilityVisual, intelligenceVisual);
  88.         }
  89.  
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement