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();
- strengthVisual = string.Empty;
- agilityVisual = string.Empty;
- intelligenceVisual = string.Empty;
- Pad(ref strengthVisual, strength);
- Pad(ref agilityVisual, agility);
- Pad(ref intelligenceVisual, intelligence);
- Console.WriteLine("Поинтов - {0}", points);
- PrintSubjects(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;
- TryParse(operandPointsRaw, out operandPoints);
- switch (subject.ToLower())
- {
- case "сила":
- Operation(ref strength, ref operandPoints, operation);
- CountSubject(ref strength, ref operandPoints, operation);
- CountPoints(ref points, ref operandPoints, operation);
- break;
- case "ловкость":
- Operation(ref agility, ref operandPoints, operation);
- CountSubject(ref agility, ref operandPoints, operation);
- CountPoints(ref points, ref operandPoints, operation);
- break;
- case "интелект":
- Operation(ref intelligence, ref operandPoints, operation);
- CountSubject(ref intelligence, ref operandPoints, operation);
- CountPoints(ref points, ref operandPoints, operation);
- break;
- }
- }
- Console.WriteLine("Вы распределили все очки. Введите возраст персонажа:");
- string ageRaw = string.Empty;
- TryParse(ageRaw, out age);
- Console.Clear();
- strengthVisual = string.Empty;
- agilityVisual = string.Empty;
- intelligenceVisual = string.Empty;
- Pad(ref strengthVisual, strength);
- Pad(ref agilityVisual, agility);
- Pad(ref intelligenceVisual, intelligence);
- PrintSubjects(age, strengthVisual, agilityVisual, intelligenceVisual);
- }
- static void PrintSubjects(int age, string strengthVisual, string agilityVisual, string intelligenceVisual)
- {
- Console.WriteLine("Возраст - {0}\nСила - [{1}]\nЛовкость - [{2}]\nИнтелект - [{3}]",
- age, strengthVisual, agilityVisual, intelligenceVisual);
- }
- static void TryParse(string value, out int number)
- {
- do
- {
- value = Console.ReadLine();
- } while (!int.TryParse(value, out number));
- }
- static void Operation (ref int subject, ref int operandPoints, string operation)
- {
- if (operation == "+")
- {
- int overhead = operandPoints - (10 - subject);
- overhead = overhead < 0 ? 0 : overhead;
- operandPoints -= overhead;
- }
- else
- {
- int overhead = subject - operandPoints;
- overhead = overhead < 0 ? overhead : 0;
- operandPoints += overhead;
- }
- }
- static void CountPoints(ref int points, ref int operandPoints, string operation)
- {
- points = operation == "+" ? points - operandPoints : points + operandPoints;
- }
- static void CountSubject(ref int subject, ref int operandPoints, string operation)
- {
- subject = operation == "+" ? subject + operandPoints : subject - operandPoints;
- }
- static void Pad(ref string subjectVisual, int subject)
- {
- subjectVisual = subjectVisual.PadLeft(subject, '#').PadRight(10, '_');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement