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.RegularExpressions;
- namespace FFE
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<string, List<int>> fighters = new Dictionary<string, List<int>>();
- // health = 0;
- // energy = 1;
- while (input != "Results")
- {
- string[] command = input.Split(":");
- if (command.Contains("Add"))
- {
- string fighterName = command[1];
- int fighterHealth = int.Parse(command[2]);
- int fighterEnergy = int.Parse(command[3]);
- if (!fighters.ContainsKey(fighterName))
- {
- fighters.Add(fighterName, new List<int> { fighterHealth, fighterEnergy });
- }
- else
- {
- fighters[fighterName][0] += fighterHealth;
- }
- }
- else if (command.Contains("Attack"))
- {
- string attackerName = command[1];
- string defenderName = command[2];
- int damage = int.Parse(command[3]);
- if (fighters.ContainsKey(attackerName) && fighters.ContainsKey(defenderName))
- {
- fighters[defenderName][0] -= damage;
- if (fighters[defenderName][0] <= 0)
- {
- fighters.Remove(defenderName);
- Console.WriteLine($"{defenderName} was disqualified!");
- }
- fighters[attackerName][1] -= 1;
- if (fighters[attackerName][1] == 0)
- {
- fighters.Remove(attackerName);
- Console.WriteLine($"{attackerName} was disqualified!");
- }
- }
- }
- else if (command.Contains("Delete"))
- {
- string fighterName = command[1];
- if (fighters.ContainsKey(fighterName))
- {
- fighters.Remove(fighterName);
- }
- if (command.Contains("All"))
- {
- fighters.Clear();
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine($"People count: {fighters.Count}");
- foreach (var user in fighters.OrderByDescending(x => x.Value[0]).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{user.Key} - {user.Value[0]} - {user.Value[1]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement