Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace _02._Boss_Rush
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] command = Console.ReadLine().Split(':');
- Dictionary<string, int> health = new Dictionary<string, int>();
- Dictionary<string, int> energy = new Dictionary<string, int>();
- while (command[0] != "Results")
- {
- if (command[0] == "Add")
- {
- //Add:{personName}:{health}:{energy}":
- if (health.ContainsKey(command[1]))
- {
- health[command[1]] += int.Parse(command[2]);
- }
- else
- {
- health[command[1]] = int.Parse(command[2]);
- energy[command[1]] = int.Parse(command[3]);
- }
- }
- if (command[0] == "Attack")
- {
- //Attack:{attackerName}:{defenderName}:{damage}":
- if (health.ContainsKey(command[1]) && health.ContainsKey(command[2]))
- {
- health[command[2]] -= int.Parse(command[3]);
- if (health[command[2]] <= 0)
- {
- health.Remove(command[2]);
- energy.Remove(command[2]);
- Console.WriteLine($"{command[2]} was disqualified!");
- }
- energy[command[1]]--;
- if (energy[command[1]] <= 0)
- {
- health.Remove(command[1]);
- energy.Remove(command[1]);
- Console.WriteLine($"{command[1]} was disqualified!");
- }
- }
- }
- if (command[0] == "Delete")
- {
- if (command[1] == "All")
- {
- health.Clear();
- energy.Clear();
- }
- else
- {
- health.Remove(command[1]);
- energy.Remove(command[1]);
- }
- }
- command = Console.ReadLine().Split(':');
- }
- Console.WriteLine($"People count: {health.Count}");
- foreach (var item in health.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{item.Key} - {item.Value} - {energy[item.Key]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement