Benjail

4.8

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