Advertisement
MrVeiran

Clone Attack

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