Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Fundamentals
- {
- class Program
- {
- static void Main(string[] args)
- {
- var team = Console.ReadLine().Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- var input = string.Empty;
- while ((input = Console.ReadLine()) != "Battle")
- {
- var tokens = input.Split().ToList();
- var command = tokens[0];
- if (command == "Loot")
- {
- var player = tokens[1];
- if (!team.Contains(player))
- {
- team.Add(player);
- Console.WriteLine($"{player} has been added to the inventory.");
- }
- //else
- //{
- //Console.WriteLine($"{player} is already part of the team.");
- //}
- }
- else if (command == "Disenchant")
- {
- var player = tokens[1];
- //if (!team.Contains(player))
- //{
- //Console.WriteLine($"{player} is not part of the team.");
- //}
- if(team.Contains(player))
- {
- team.Remove(player);
- Console.WriteLine($"{player} has been disenchanted.");
- }
- }
- else if (command == "Upgrade")
- {
- List<string> players = tokens[1].Split('/').ToList();
- string firstPlayer = players[0];
- string secondPlayer = players[1];
- if (team.Contains(firstPlayer))
- {
- //team.Select(p => p.Replace(firstPlayer, secondPlayer));
- team[team.FindIndex(i => i.Equals(firstPlayer))] = firstPlayer + " ~ " + secondPlayer;
- Console.WriteLine($"{firstPlayer} has been upgraded to {firstPlayer} ~ {secondPlayer}.");
- }
- //else
- //{
- //Console.WriteLine($"{firstPlayer} is not part of the team.");
- //}
- }
- if (team.Count == 0)
- {
- Console.WriteLine("The inventory is empty.");
- break;
- }
- }
- if (team.Count != 0)
- {
- Console.WriteLine("Red Paladin's inventory :");
- foreach (var item in team)
- {
- Console.WriteLine($"--> {item}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement