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