Advertisement
AlexVanchov

3

Apr 4th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Problem_3
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var heroes = new List<Hero>();
  11.             int n = int.Parse(Console.ReadLine());
  12.             for (int i = 0; i < n; i++)
  13.             {
  14.                 string character = Console.ReadLine();
  15.                 string[] charachterStats = character.Split(" ").ToArray();
  16.                 string name = charachterStats[0];
  17.                 int HP = int.Parse(charachterStats[1]);
  18.                 int MP = int.Parse(charachterStats[1]);
  19.  
  20.                 heroes.Add(new Hero(name, HP, MP));
  21.             }
  22.             while (true)
  23.             {
  24.                 string command = Console.ReadLine();
  25.                 if (command == "End")
  26.                 {
  27.                     break;
  28.                 }
  29.                 string[] arr = command.Split("-").ToArray();
  30.                 if (arr[0] == "CastSpell")
  31.                 {
  32.                     string name = arr[1];
  33.                     int manaCost = int.Parse(arr[2]);
  34.                     string nameSpell = arr[3];
  35.  
  36.                     if (heroes.FirstOrDefault(x=>x.Name == name).MP <= manaCost)
  37.                     {
  38.  
  39.                     }
  40.                 }
  41.  
  42.             }
  43.         }
  44.     }
  45.  
  46.     public class Hero
  47.     {
  48.         public Hero(string name, int hp, int mp)
  49.         {
  50.             this.Name = name;
  51.             this.HP = hp;
  52.             this.MP = mp;
  53.         }
  54.  
  55.         public string Name { get; set; }
  56.  
  57.         public int HP { get; set; }
  58.  
  59.         public int MP { get; set; }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement