Advertisement
dxoraxs

Untitled

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