Advertisement
Vadim_Rogulev

Untitled

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