Advertisement
ZhannaArch

3.8

May 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.82 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.                         NewFunction(operation, ref operandPoints, ref strength, ref points);
  48.  
  49.                         /*if (operation == "+")
  50.                         {
  51.                             int overhead = operandPoints - (10 - strength);
  52.                             overhead = overhead < 0 ? 0 : overhead;
  53.                             operandPoints -= overhead;
  54.                         }
  55.                         else
  56.                         {
  57.                             int overhead = strength - operandPoints;
  58.                             overhead = overhead < 0 ? overhead : 0;
  59.                             operandPoints += overhead;
  60.                         }
  61.  
  62.                         strength = operation == "+" ? strength + operandPoints : strength - operandPoints;
  63.                         points = operation == "+" ? points - operandPoints : points + operandPoints;*/
  64.                         break;
  65.                     case "ловкость":
  66.                         NewFunction(operation, ref operandPoints, ref agility, ref points);
  67.  
  68.                         /*if (operation == "+")
  69.                         {
  70.                             int overhead = operandPoints - (10 - agility);
  71.                             overhead = overhead < 0 ? 0 : overhead;
  72.                             operandPoints -= overhead;
  73.                         }
  74.                         else
  75.                         {
  76.                             int overhead = agility - operandPoints;
  77.                             overhead = overhead < 0 ? overhead : 0;
  78.                             operandPoints += overhead;
  79.                         }
  80.  
  81.                         agility = operation == "+" ? agility + operandPoints : agility - operandPoints;
  82.                         points = operation == "+" ? points - operandPoints : points + operandPoints;*/
  83.                         break;
  84.                     case "интелект":
  85.                         NewFunction(operation, ref operandPoints, ref intelligence, ref points);
  86.  
  87.                         /*if (operation == "+")
  88.                         {
  89.                             int overhead = operandPoints - (10 - intelligence);
  90.                             overhead = overhead < 0 ? 0 : overhead;
  91.                             operandPoints -= overhead;
  92.                         }
  93.                         else
  94.                         {
  95.                             int overhead = intelligence - operandPoints;
  96.                             overhead = overhead < 0 ? overhead : 0;
  97.                             operandPoints += overhead;
  98.                         }
  99.  
  100.                         intelligence = operation == "+" ? intelligence + operandPoints : intelligence - operandPoints;
  101.                         points = operation == "+" ? points - operandPoints : points + operandPoints;*/
  102.                         break;
  103.                 }
  104.             }
  105.  
  106.             Console.WriteLine("Вы распределили все очки. Введите возраст персонажа:");
  107.             string ageRaw = string.Empty;
  108.             do
  109.             {
  110.                 ageRaw = Console.ReadLine();
  111.             } while (int.TryParse(ageRaw, out age));
  112.  
  113.  
  114.             Console.Clear();
  115.             strengthVisual = string.Empty;
  116.             agilityVisual = string.Empty;
  117.             intelligenceVisual = string.Empty;
  118.             strengthVisual = strengthVisual.PadLeft(strength, '#').PadRight(10, '_');
  119.             agilityVisual = agilityVisual.PadLeft(agility, '#').PadRight(10, '_');
  120.             intelligenceVisual = intelligenceVisual.PadLeft(intelligence, '#').PadRight(10, '_');
  121.             Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтелект - [{3}]", age, strengthVisual, agilityVisual, intelligenceVisual);
  122.  
  123.         }
  124.  
  125.         static void NewFunction(string operation, ref int operandPoints, ref int param, ref int points)
  126.         {
  127.             if (operation == "+")
  128.             {
  129.                 int overhead = operandPoints - (10 - param);
  130.                 overhead = overhead < 0 ? 0 : overhead;
  131.                 operandPoints -= overhead;
  132.             }
  133.             else
  134.             {
  135.                 int overhead = param - operandPoints;
  136.                 overhead = overhead < 0 ? overhead : 0;
  137.                 operandPoints += overhead;
  138.             }
  139.             param = operation == "+" ? param + operandPoints : param - operandPoints;
  140.             points = operation == "+" ? points - operandPoints : points + operandPoints;
  141.         }
  142.     }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement