Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace IMJunior
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = 0, strength = 0, agility = 0, intelligence = 0, points = 25;
- string strengthVisual = string.Empty, agilityVisual = string.Empty, intelligenceVisual = string.Empty;
- Console.WriteLine("Добро пожаловать в меню выбора создания персонажа!");
- Console.WriteLine("У вас есть 25 очков, которые вы можете распределить по умениям");
- Console.WriteLine("Нажмите любую клавишу чтобы продолжить...");
- Console.ReadKey();
- while (points > 0)
- {
- ShowParameters(strengthVisual, agilityVisual, intelligenceVisual, age, strength, agility, intelligence, points);
- Console.WriteLine("Какую характеристику вы хотите изменить?");
- string subject = Console.ReadLine();
- Console.WriteLine(@"Что вы хотите сделать? +\-");
- string operation = Console.ReadLine();
- Console.WriteLine(@"Колличество поинтов которые следует {0}", operation == "+" ? "прибавить" : "отнять");
- int operandPoints = ReadInt();
- switch (subject.ToLower())
- {
- case "сила":
- SetPoint(ref points, ref strength, operation, operandPoints);
- break;
- case "ловкость":
- SetPoint(ref points, ref agility, operation, operandPoints);
- break;
- case "интелект":
- SetPoint(ref points, ref intelligence, operation, operandPoints);
- break;
- }
- }
- Console.WriteLine("Вы распределили все очки. Введите возраст персонажа:");
- age = ReadInt();
- ShowParameters(strengthVisual, agilityVisual, intelligenceVisual, age, strength, agility, intelligence, points);
- }
- static void SetPoint(ref int points, ref int parametrValue, string operation, int operandPoints)
- {
- if (operation == "+")
- {
- int overhead = operandPoints - (points > 10 ? 10 : points - parametrValue);
- overhead = overhead < 0 ? 0 : overhead;
- operandPoints -= overhead;
- }
- else
- {
- int overhead = parametrValue - operandPoints;
- overhead = overhead < 0 ? overhead : 0;
- operandPoints += overhead;
- }
- parametrValue = operation == "+" ? parametrValue + operandPoints : parametrValue - operandPoints;
- points = operation == "+" ? points - operandPoints : points + operandPoints;
- }
- static int ReadInt()
- {
- int result;
- while (!int.TryParse(Console.ReadLine(), out result)) { }
- return result;
- }
- static void ShowParameters(string strengthVisual, string agilityVisual, string intelligenceVisual, int age, int strength, int agility, int intelligence, int points)
- {
- Console.Clear();
- strengthVisual = string.Empty;
- agilityVisual = string.Empty;
- intelligenceVisual = string.Empty;
- strengthVisual = strengthVisual.PadLeft(strength, '#').PadRight(10, '_');
- agilityVisual = agilityVisual.PadLeft(agility, '#').PadRight(10, '_');
- intelligenceVisual = intelligenceVisual.PadLeft(intelligence, '#').PadRight(10, '_');
- if(points != 0)
- Console.WriteLine("Поинтов - {0}", points);
- Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтелект - [{3}]", age, strengthVisual, agilityVisual, intelligenceVisual);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement