private static King SetupKing() { string kingName = Console.ReadLine(); King king = new King(kingName, new List <Subject>()); string[] royalGurards = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string guardName in royalGurards) { RoyalGuard guard = new RoyalGuard(guardName); king.AddSubject(guard); } string[] footmen = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string footmanName in footmen) { Footman footman = new Footman(footmanName); king.AddSubject(footman); } return(king); }
private ICollection <Guard> GetGuards() { List <Guard> guards = new List <Guard>(); string[] royalGuardNames = Console.ReadLine().Split(); foreach (string royalGuardName in royalGuardNames) { RoyalGuard royalGuard = new RoyalGuard(royalGuardName); guards.Add(royalGuard); this.king.GetAttackedEvent += royalGuard.RespondToAttack; } string[] footmanNames = Console.ReadLine().Split(); foreach (string footmanName in footmanNames) { Footman footman = new Footman(footmanName); guards.Add(footman); this.king.GetAttackedEvent += footman.RespondToAttack; } return(guards); }
public IAttackable AttackUnit(string name) { RoyalGuard guard = RoyalGuards.FirstOrDefault(g => g.Name == name); if (guard != null) { guard.ReceiveAttack(); if (!guard.IsAlive) { return(guard); } return(null); } Footman footman = Footmans.FirstOrDefault(g => g.Name == name); if (footman != null) { footman.ReceiveAttack(); if (!footman.IsAlive) { return(footman); } } return(null); }
static void Main(string[] args) { Paladin pal = new Paladin(); IMoveable adapt = new MoveAdapter(pal); adapt.Move(4, 5); Peasant worker = new Peasant(); GoldMiner miner = new GoldMiner(worker); miner.MineGold(); Map unitsMap = new Map { Title = "Unitsmap" }; unitsMap.AddComponent(pal); unitsMap.AddComponent(worker); Map anothermap = new Map { Title = "Another map" }; Footman ff = new Footman(); anothermap.AddComponent(ff); anothermap.AddComponent(unitsMap); anothermap.Draw(); }
public static void Main(string[] args) { var kingName = Console.ReadLine(); King king = new King(kingName); List <Soldier> army = new List <Soldier>(); var royalGuardsNames = Console.ReadLine() .Split(' '); foreach (var name in royalGuardsNames) { var currentGuard = new RoyalGuard(name); army.Add(currentGuard); king.UnderAttack += currentGuard.KingUnderAttack; } var footmnNames = Console.ReadLine() .Split(' '); foreach (var name in footmnNames) { var currentFootman = new Footman(name); army.Add(currentFootman); king.UnderAttack += currentFootman.KingUnderAttack; } var command = Console.ReadLine(); while (command != "End") { if (command == "Attack King") { king.OnUnderAttack(); } else { string soldierName = command .Split(' ') .LastOrDefault(); Soldier soldier = army.FirstOrDefault(s => s.Name == soldierName); if (!soldier.SurviveAttack()) { king.UnderAttack -= soldier.KingUnderAttack; army.Remove(soldier); } } command = Console.ReadLine(); } }
private static void AddFootmans(King king) { var footmansNames = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (var name in footmansNames) { var footman = new Footman(name); king.AddSlave(footman); } }
static void Main(string[] args) { var kingName = Console.ReadLine(); var king = new King(kingName); var units = new List <IUnit>(); var royalGuardsNames = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (var rgName in royalGuardsNames) { var royalGuard = new RoyalGuard(rgName); king.UnderAttack += royalGuard.OnKingAttack; royalGuard.UnderAttack += royalGuard.OnUnderAttack; units.Add(royalGuard); } var footmenNames = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (var fmName in footmenNames) { var footman = new Footman(fmName); king.UnderAttack += footman.OnKingAttack; footman.UnderAttack += footman.OnUnderAttack; units.Add(footman); } var input = ""; while ((input = Console.ReadLine()) != "End") { var cmdArgs = input.Split(); var command = cmdArgs[0]; switch (command) { case "Kill": var unitName = cmdArgs[1]; var unitToKill = units.FirstOrDefault(u => u.Name == unitName); unitToKill.OnUnderAttack(); if (unitToKill.IsDead) { king.UnderAttack -= unitToKill.OnKingAttack; units.Remove(unitToKill); } break; case "Attack": king.OnUnderAttack(); break; default: break; } } }
private static void ReadFootmans() { string[] footmans = Console.ReadLine().Split(); foreach (var footmanName in footmans) { Footman footman = new Footman(footmanName); king.KingAttacked += footman.ProtectKing; soldiers.Add(footman); } }
static void Main(string[] args) { King king = new King(Console.ReadLine()); List <Soldier> army = new List <Soldier>(); string[] royalGuards = Console.ReadLine().Split(); foreach (var royalGuard in royalGuards) { RoyalGuard guard = new RoyalGuard(royalGuard); army.Add(guard); king.UnderAttack += guard.KingUnderAttack; } string[] footmen = Console.ReadLine().Split(); foreach (var footman in footmen) { Footman footMan = new Footman(footman); army.Add(footMan); king.UnderAttack += footMan.KingUnderAttack; } string[] command = Console.ReadLine().Split(); while (command[0] != "End") { switch (command[0]) { case "Kill": Soldier soldier = army.FirstOrDefault(s => s.Name == command[1]); soldier.Health--; if (soldier.Health == 0) { king.UnderAttack -= soldier.KingUnderAttack; army.Remove(soldier); } break; case "Attack": king.OnUnderAttack(); break; default: break; } command = Console.ReadLine().Split(); } }
private void CreateFootmen() { var footmansNames = this.consoleReader.ReadLine().Split(); //if not null foreach (var footmanName in footmansNames) { var footman = new Footman(footmanName); footman.Dead += this.RemoveDeadServant; this.king.KingUnderAttack += footman.OnKingUnderAttack; this.servants.Add(footman); } }
public static void Main() { var troops = new TroopsRepository(); var king = new King(Console.ReadLine()); var guards = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var guarndName in guards) { var royalGuard = new RoyalGuard(guarndName); troops.AddTroop(royalGuard); royalGuard.TroopDeath += king.OnTroopDeath; royalGuard.TroopDeath += troops.OnTroopDeath; king.KingAttacked += royalGuard.OnKingAttack; } var footmen = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var footmanName in footmen) { var footman = new Footman(footmanName); troops.AddTroop(footman); footman.TroopDeath += king.OnTroopDeath; footman.TroopDeath += troops.OnTroopDeath; king.KingAttacked += footman.OnKingAttack; } var command = Console.ReadLine(); while (!command.Equals("End")) { var parameters = command.Split(); switch (parameters[0]) { case "Attack": king.RespondToAttack(); break; case "Kill": var soldierToRemove = troops.GetTroop(parameters[1]); soldierToRemove.RespondToAttack(); break; } command = Console.ReadLine(); } }
static void Main(string[] args) { var king = new King(Console.ReadLine()); var soldiers = new List <Soldier>(); var guardsNames = Console.ReadLine().Split(); var footmenNames = Console.ReadLine().Split(); foreach (var name in guardsNames) { var royalGuard = new RoyalGuard(name); soldiers.Add(royalGuard); king.UnderAttack += royalGuard.KingUnderAttack; } foreach (var name in footmenNames) { var footman = new Footman(name); soldiers.Add(footman); king.UnderAttack += footman.KingUnderAttack; } while (true) { var input = Console.ReadLine(); if (input == "End") { break; } var commandArgs = input.Split(); var command = commandArgs[0]; switch (command) { case "Kill": var soldierName = commandArgs[1]; var soldier = soldiers.FirstOrDefault(s => s.Name == soldierName); king.UnderAttack -= soldier.KingUnderAttack; soldiers.Remove(soldier); break; case "Attack": king.OnAttack(); break; default: break; } } }
public static void Main() { var soldiers = new ModifiedDictionary(); var king = new King(Console.ReadLine()); var royalGuardsNames = Console.ReadLine().Split().ToList(); foreach (var rgName in royalGuardsNames) { var royalGuard = new RoyalGuard(rgName); soldiers.Add(rgName, royalGuard); royalGuard.SoliderDeath += soldiers.HandleSoliderDeath; royalGuard.SoliderDeath += king.OnSoliderDeath; king.UnderAttack += royalGuard.KingUnderAttack; } var footmansNames = Console.ReadLine().Split().ToList(); foreach (var fmName in footmansNames) { var footman = new Footman(fmName); soldiers.Add(fmName, footman); footman.SoliderDeath += soldiers.HandleSoliderDeath; footman.SoliderDeath += king.OnSoliderDeath; king.UnderAttack += footman.KingUnderAttack; } var inputCommands = string.Empty; while ((inputCommands = Console.ReadLine()) != "End") { var commands = inputCommands.Split(); var command = commands[0]; switch (command) { case "Attack": king.OnUnderAttack(); break; case "Kill": var soliderToRemove = soldiers[commands[1]]; soliderToRemove.RespondToAttack(); break; } } }
public static void Main() { var soliders = new List <Solider>(); var king = new King(Console.ReadLine()); var royalGuardsNames = Console.ReadLine().Split().ToList(); foreach (var rgName in royalGuardsNames) { var royalGuard = new RoyalGuard(rgName); soliders.Add(royalGuard); king.UnderAttack += royalGuard.KingUnderAttack; } var footmansNames = Console.ReadLine().Split().ToList(); foreach (var fmName in footmansNames) { var footman = new Footman(fmName); soliders.Add(footman); king.UnderAttack += footman.KingUnderAttack; } var inputCommands = string.Empty; while ((inputCommands = Console.ReadLine()) != "End") { var commands = inputCommands.Split(); var command = commands[0]; switch (command) { case "Attack": king.OnUnderAttack(); break; case "Kill": var killedSolider = soliders.FirstOrDefault(s => s.Name == commands[1]); if (killedSolider != null) { king.UnderAttack -= killedSolider.KingUnderAttack; soliders.Remove(killedSolider); } break; } } }
private static IList <IKillable> GetFootMen(string[] footMenNames) { IList <IKillable> footMen = new List <IKillable>(); foreach (var element in footMenNames) { IKillable footMan = new Footman() { Name = element }; footMen.Add(footMan); } return(footMen); }
public static void Main() { var king = new King(Console.ReadLine()); ModifiedDictionary soldiersByName = new ModifiedDictionary(); var royalGuards = Console.ReadLine().Split(); foreach (var guardName in royalGuards) { RoyalGuard newGuard = new RoyalGuard(guardName); soldiersByName.Add(guardName, newGuard); newGuard.SoldierDeath += soldiersByName.HandleSoldierDeath; newGuard.SoldierDeath += king.OnSoldierDeath; king.UnderAttack += newGuard.OnKingUnderAttack; } var footmen = Console.ReadLine().Split(); foreach (var footmanName in footmen) { Footman newFootman = new Footman(footmanName); soldiersByName.Add(footmanName, newFootman); newFootman.SoldierDeath += soldiersByName.HandleSoldierDeath; newFootman.SoldierDeath += king.OnSoldierDeath; king.UnderAttack += newFootman.OnKingUnderAttack; } var line = Console.ReadLine().Split(); while (!line[0].Equals("End")) { var command = line[0]; var name = line[1]; switch (command) { case "Kill": Soldier soldierToRemove = soldiersByName[name]; soldierToRemove.RespondToAttack(); break; case "Attack": king.RespondToAttack(); break; } line = Console.ReadLine().Split(); } }
public static void Main() { var troops = new Dictionary <string, Troop>(); var king = new King(Console.ReadLine()); var guards = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var guarndName in guards) { var royalGuard = new RoyalGuard(guarndName); troops.Add(guarndName, royalGuard); king.KingAttacked += royalGuard.OnKingAttack; } var footmen = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var footmanName in footmen) { var footman = new Footman(footmanName); troops.Add(footmanName, footman); king.KingAttacked += footman.OnKingAttack; } var command = Console.ReadLine(); while (!command.Equals("End")) { var parameters = command.Split(); switch (parameters[0]) { case "Attack": king.RespondToAttack(); break; case "Kill": var soldierToRemove = troops[parameters[1]]; king.KingAttacked -= soldierToRemove.OnKingAttack; troops.Remove(parameters[1]); break; } command = Console.ReadLine(); } }
public static void Main(string[] args) { var army = new List <Soldier>(); var king = new King(Console.ReadLine()); var royalGuards = Console.ReadLine() .Split() .ToList(); foreach (var royalGuard in royalGuards) { var guard = new RoyalGuard(royalGuard); army.Add(guard); king.UnderAttack += guard.KingUnderAttack; } var footmen = Console.ReadLine() .Split() .ToList(); foreach (var footman in footmen) { var foot = new Footman(footman); army.Add(foot); king.UnderAttack += foot.KingUnderAttack; } var command = Console.ReadLine().Split(); while (command[0] != "End") { switch (command[0]) { case "Kill": var soldier = army.FirstOrDefault(s => s.Name == command[1]); king.UnderAttack -= soldier.KingUnderAttack; army.Remove(soldier); break; case "Attack": king.OnUnderAttack(); break; } command = Console.ReadLine().Split(); } }
public static void Main() { string kingName = Console.ReadLine(); string[] royalGuardNames = Console.ReadLine().Split().ToArray(); string[] footmenNames = Console.ReadLine().Split().ToArray(); King king = new King(kingName); List <IGuard> guards = new List <IGuard>(); for (int i = 0; i < royalGuardNames.Length; i++) { RoyalGuard royalGuard = new RoyalGuard(royalGuardNames[i]); king.Attack += royalGuard.HandleKingsAttack; guards.Add(royalGuard); } for (int i = 0; i < footmenNames.Length; i++) { Footman footman = new Footman(footmenNames[i]); king.Attack += footman.HandleKingsAttack; guards.Add(footman); } string command = Console.ReadLine(); while (command != "End") { if (command == "Attack King") { king.IsAttacked(); } else { string[] commandArgs = command.Split().ToArray(); string name = commandArgs[1]; IGuard toRemove = guards.FirstOrDefault(g => g.Name == name); king.Attack -= toRemove.HandleKingsAttack; guards.Remove(toRemove); } command = Console.ReadLine(); } }
public void Run() { this.king = new King(Console.ReadLine()); var royalGuards = Console.ReadLine().Split(); foreach (var royalGuard in royalGuards) { var guard = new RoyalGuard(royalGuard); this.army.Add(guard); this.king.UnderAttack += guard.KingUnderAttack; } var footmans = Console.ReadLine().Split(); foreach (var footman in footmans) { var foot = new Footman(footman); this.army.Add(foot); this.king.UnderAttack += foot.KingUnderAttack; } var command = Console.ReadLine().Split(); while (this.isRunning) { switch (command[0]) { case "Kill": var soldier = this.army.FirstOrDefault(s => s.Name == command[1]); this.king.UnderAttack -= soldier.KingUnderAttack; this.army.Remove(soldier); break; case "Attack": this.king.OnUnderAttack(); break; case "End": this.isRunning = false; break; } command = Console.ReadLine().Split(); } }
public static void Main() { var soldiers = new SoldiersList(); var king = new King(Console.ReadLine()); var royalGuardsNames = Console.ReadLine().Split(); foreach (string guardName in royalGuardsNames) { var currentRoyalGuard = new RoyalGuard(guardName, king); soldiers.Add(currentRoyalGuard); king.BeingAttacked += currentRoyalGuard.OnKingBeingAttacked; } var footmenNames = Console.ReadLine().Split(); foreach (string footManName in footmenNames) { var footMan = new Footman(footManName, king); soldiers.Add(footMan); king.BeingAttacked += footMan.OnKingBeingAttacked; } soldiers.ForEach(s => s.SoldierKilled += soldiers.OnSoldierKilled); var command = Console.ReadLine().Split(); while (!command[0].Equals("End")) { switch (command[0]) { case "Kill": var attackedSoldier = soldiers.FirstOrDefault(s => s.Name.Equals(command[1])); attackedSoldier.TakeAttack(); break; case "Attack": king.TakeAttack(); break; } command = Console.ReadLine().Split(); } }
void Update() { if (Input.GetMouseButtonDown(1)) { foreach (Footman footman in footmen) { footman.setNotActive(); } footmen.Clear(); } if (Input.GetMouseButtonDown(0)) { pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); dirRay = pos; dirRay.z = 0; dirRay = dirRay - pos; RaycastHit2D hit; if ((hit = Physics2D.Raycast(pos, dirRay))) { if (hit.collider.tag == "footman") { if (!Input.GetKey(KeyCode.LeftControl)) { foreach (Footman footman in footmen) { footman.setNotActive(); } footmen.Clear(); } Footman newFootman = hit.collider.gameObject.GetComponent <Footman>(); newFootman.setActive(); footmen.Add(newFootman); } } else { commandMove(pos); } } }
static void Main(string[] args) { var king = new King(Console.ReadLine()); var soldiersList = new List <IKillable>(); var royalGuards = Console.ReadLine().Split(' '); foreach (var royalGuardName in royalGuards) { var royalGuard = new RoyalGuard(royalGuardName); soldiersList.Add(royalGuard); king.GetAttacked += royalGuard.OnKingGetAttacked; } var footmen = Console.ReadLine().Split(' '); foreach (var footmanName in footmen) { var footman = new Footman(footmanName); soldiersList.Add(footman); king.GetAttacked += footman.OnKingGetAttacked; } string input; while ((input = Console.ReadLine()) != "End") { var inputData = input.Split(' '); if (inputData[0] == "Attack") { king.OnGetAttacked(new EventArgs()); } else { var soldierToBeKilled = soldiersList.Find(s => s.Name == inputData[1]); soldierToBeKilled.GetKillAttempted(); if (!soldierToBeKilled.IsAlive) { king.GetAttacked -= soldierToBeKilled.OnKingGetAttacked; } } } }
static void Main(string[] args) { var soldiers = new List <Soldier>(); var king = new King(Console.ReadLine()); var royalGuardsNames = Console.ReadLine().Split(); foreach (string guardName in royalGuardsNames) { var currentRoyalGuard = new RoyalGuard(guardName); soldiers.Add(currentRoyalGuard); king.BeingAttacked += currentRoyalGuard.OnKingBeingAttacked; } var footmenNames = Console.ReadLine().Split(); foreach (string footManName in footmenNames) { var footMan = new Footman(footManName); soldiers.Add(footMan); king.BeingAttacked += footMan.OnKingBeingAttacked; } var command = Console.ReadLine().Split(); while (!command[0].Equals("End")) { switch (command[0]) { case "Kill": Soldier deadSoldier = soldiers.FirstOrDefault(s => s.Name.Equals(command[1])); king.BeingAttacked -= deadSoldier.OnKingBeingAttacked; soldiers.Remove(deadSoldier); break; case "Attack": king.TakeAttack(); break; } command = Console.ReadLine().Split(); } }
public static void Main() { SoldierList soldiers = new SoldierList(); King king = new King(Console.ReadLine()); string[] royalGuardNames = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var name in royalGuardNames) { RoyalGuard rg = new RoyalGuard(name); rg.SoldierDead += soldiers.HandleDeadSoldier; rg.SoldierDead += king.OnSoldierDeath; soldiers.Add(rg); king.KingAttacked += rg.OnKingAttack; } string[] footmanNames = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var name in footmanNames) { Footman fm = new Footman(name); fm.SoldierDead += soldiers.HandleDeadSoldier; fm.SoldierDead += king.OnSoldierDeath; soldiers.Add(fm); king.KingAttacked += fm.OnKingAttack; } string command = string.Empty; while ((command = Console.ReadLine()) != "End") { var tokens = command.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (tokens[0] == "Attack") { king.RespondToAttack(); } else if (tokens[0] == "Kill") { string name = tokens[1]; IDefender soldier = soldiers.First(x => x.Name == name); soldier.TakeAttack(); } } }
public IAttackable KillUnit(string name) { RoyalGuard guard = RoyalGuards.FirstOrDefault(g => g.Name == name); if (guard != null) { guard.Die(); return(guard); } Footman footman = Footmans.FirstOrDefault(g => g.Name == name); if (footman != null) { footman.Die(); return(footman); } return(null); }
static void Main(string[] args) { string kingName = Console.ReadLine(); var king = new King(kingName); var guardsNames = Console.ReadLine().Split(); var footmenNames = Console.ReadLine().Split(); foreach (var name in guardsNames) { var royalGuard = new RoyalGuard(name); king.AddSoldier(royalGuard); } foreach (var name in footmenNames) { var footman = new Footman(name); king.AddSoldier(footman); } string input; while ((input = Console.ReadLine()) != "End") { var commandArgs = input.Split(); var command = commandArgs[0]; switch (command) { case "Kill": var soldierName = commandArgs[1]; var soldier = king.Soldiers.FirstOrDefault(s => s.Name == soldierName); soldier.TakeAttack(); break; case "Attack": king.OnAttack(); break; default: break; } } }
static void Main() { List <IMoodChangeable> soldiersList = new List <IMoodChangeable>(); King king = new King(Console.ReadLine()); string[] royalGuards = Console.ReadLine().Split(); for (int i = 0; i < royalGuards.Length; i++) { var guard = new RoyalGuard(royalGuards[i]); king.Attacked += guard.OnKingAttack; soldiersList.Add(guard); } string[] footmen = Console.ReadLine().Split(); for (int i = 0; i < footmen.Length; i++) { var footman = new Footman(footmen[i]); king.Attacked += footman.OnKingAttack; soldiersList.Add(footman); } string command = Console.ReadLine(); while (command != "End") { string[] commandArgs = command.Split(); switch (commandArgs[0]) { case "Attack": king.OnAttack(); break; case "Kill": IMoodChangeable currentSoldier = soldiersList.FirstOrDefault(s => s.Name == commandArgs[1]); king.Attacked -= currentSoldier.OnKingAttack; soldiersList.Remove(currentSoldier); break; } command = Console.ReadLine(); } }
static void Main(string[] args) { King king = new King(Console.ReadLine()); Army army = new Army(); //List<ISoldier> soldiers = new List<ISoldier>(); string[] royalTokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < royalTokens.Length; i++) { RoyalGuard t = new RoyalGuard(royalTokens[i]); army.Add(t); } string[] footmenTokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < footmenTokens.Length; i++) { Footman t = new Footman(footmenTokens[i]); army.Add(t); } for (int i = 0; i < 100; i++) { string[] commandTokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); if (commandTokens[0] == "End") { break; } if (commandTokens[0] == "Kill") { ISoldier t = army.soldiers.Find(x => x.Name == commandTokens[1]); t.TryKill(); //soldiers.RemoveAll(x => x.Name == commandTokens[1]); } if (commandTokens[0] == "Attack" && commandTokens[1] == "King") { king.Attacked(new KingAttackedEventArgs(army.soldiers));//вызов события } } Console.ReadKey(); }
public static void Main(string[] args) { List <Soldier> army = new List <Soldier>(); King king = new King(Console.ReadLine()); // Initialize RoyalKings string[] royalGuards = Console.ReadLine().Split(); foreach (var royalGuard in royalGuards) { RoyalGuard guard = new RoyalGuard(royalGuard); army.Add(guard); king.UnderAttack += guard.KingUnderAttack; } // Initialize FootMans string[] footmans = Console.ReadLine().Split(); foreach (var footman in footmans) { Footman foot = new Footman(footman); army.Add(foot); king.UnderAttack += foot.KingUnderAttack; } string[] command = Console.ReadLine().Split(); while (command[0] != "End") { switch (command[0]) { case "Kill": Soldier soldier = army.FirstOrDefault(s => s.Name == command[1]); king.UnderAttack -= soldier.KingUnderAttack; army.Remove(soldier); break; case "Attack": king.OnUnderAttack(); break; } command = Console.ReadLine().Split(); } }