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 DictMoreExc3
- {
- class Program
- {
- static void Main(string[] args)
- {
- var league = new Dictionary<string, Dictionary<string, int>>();
- var PlayersAndPoints = new Dictionary<string, int>();
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "Season end")
- {
- foreach (var item in league.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{item.Key}: {item.Value.Values.Sum()} skill");
- foreach (var item2 in item.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"- {item2.Key} <::> {item2.Value}");
- }
- }
- break;
- }
- if (command.Contains("->"))
- {
- var split = command.Split(new string[] { " -> " }, StringSplitOptions.None);
- string name = split[0];
- string role = split[1];
- int points = int.Parse(split[2]);
- if (!league.ContainsKey(name))
- {
- league.Add(name, new Dictionary<string, int>());
- league[name].Add(role, points);
- PlayersAndPoints.Add(name, points);
- }
- if (league.ContainsKey(name))
- {
- if (league[name].ContainsKey(role))
- {
- if (league[name][role] < points)
- {
- league[name][role] = points;
- PlayersAndPoints[name] = points;
- }
- }
- else
- {
- league[name].Add(role, points);
- PlayersAndPoints[name] += points;
- }
- }
- }
- if (command.Contains("vs"))
- {
- var split = command.Split(new string[] { " vs " }, StringSplitOptions.None);
- string attacker = split[0];
- string attacked = split[1];
- string currentRole = string.Empty;
- bool succesfulAttack = false;
- if (league.ContainsKey(attacker) && league.ContainsKey(attacked))
- {
- foreach (var item in league[attacker].Keys)
- {
- foreach (var item2 in league[attacked].Keys)
- {
- if (item == item2)
- {
- succesfulAttack = true;
- currentRole += item;
- break;
- }
- }
- if (succesfulAttack == true)
- {
- break;
- }
- }
- }
- if (succesfulAttack == true)
- {
- if (league[attacked].Values.Sum() > league[attacker].Values.Sum())
- {
- league.Remove(attacker);
- }
- else if (league[attacked].Values.Sum() < league[attacker].Values.Sum())
- {
- league.Remove(attacked);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement