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)
- {
- Console.Clear();
- VisualBar(strength, agility, intelligence, points, age, strengthVisual, agilityVisual, intelligenceVisual);
- Console.WriteLine("Какую характеристику вы хотите изменить?");
- string subject = Console.ReadLine();
- Console.WriteLine(@"Что вы хотите сделать? +\-");
- string operation = Console.ReadLine();
- Console.WriteLine(@"Колличество поинтов которые следует {0}", operation == "+" ? "прибавить" : "отнять");
- string operandPointsRaw = string.Empty;
- int operandPoints = 0;
- do
- {
- operandPointsRaw = Console.ReadLine();
- }
- while (int.TryParse(operandPointsRaw, out operandPoints) == false);
- switch (subject.ToLower())
- {
- case "сила":
- points = DistributionOfPoints(subject, operation, operandPoints, points, ref strength);
- break;
- case "ловкость":
- points = DistributionOfPoints(subject, operation, operandPoints, points, ref agility);
- break;
- case "интелект":
- points = DistributionOfPoints(subject, operation, operandPoints, points, ref intelligence);
- break;
- }
- }
- Console.WriteLine("Вы распределили все очки. Введите возраст персонажа:");
- string ageRaw = string.Empty;
- do
- {
- ageRaw = Console.ReadLine();
- }
- while (int.TryParse(ageRaw, out age) == false);
- Console.Clear();
- VisualBar(strength, agility, intelligence, points, age, strengthVisual, agilityVisual, intelligenceVisual);
- Console.ReadKey();
- }
- static void VisualBar(int strength, int agility, int intelligence, int points, int age, string strengthVisual, string agilityVisual, string intelligenceVisual)
- {
- 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, '_');
- Console.WriteLine("Поинтов - {0}", points);
- Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтелект - [{3}]", age, strengthVisual, agilityVisual, intelligenceVisual);
- }
- static int DistributionOfPoints(string subject, string operation, int operandPoints, int points, ref int characteristic)
- {
- if (operation == "+")
- {
- int overhead = operandPoints - (10 - characteristic);
- overhead = overhead < 0 ? 0 : overhead;
- operandPoints -= overhead;
- }
- else
- {
- int overhead = characteristic - operandPoints;
- overhead = overhead < 0 ? overhead : 0;
- operandPoints += overhead;
- }
- characteristic = operation == "+" ? characteristic + operandPoints : characteristic - operandPoints;
- return operation == "+" ? points - operandPoints : points + operandPoints;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement