public override List <string> nextTurn() { if (turnList.Count == 0) { FillTurnList(); } var messages = new List <string>(); Game.Agents.Agent currentAgent = turnList.Dequeue(); KeyValuePair <string, string> action = new KeyValuePair <string, string>("", ""); try { if (currentAgent.GetAgentType().Equals("Player")) { action = currentAgent.GetAction(GetMonstersCondition(currentAgent.GetName()), GetPlayersCondition(currentAgent.GetName())); } else { action = currentAgent.GetAction(GetPlayersCondition(currentAgent.GetName()), GetMonstersCondition(currentAgent.GetName())); } } catch (NullReferenceException e) { Console.WriteLine(e.Message); messages.Add(currentAgent.GetName() + " has skipped their turn."); } if (action.Value.Equals("PhysAttack")) { Console.WriteLine(currentAgent.GetName() + " is physically attacking " + action.Key); messages.Add(currentAgent.GetName() + " is physically attacking " + action.Key); try { if (currentAgent.GetAgentType().Equals("Player")) { var damage = currentAgent.PhysAttack(); Console.WriteLine(damage); monsters.Find(x => x.GetName().Equals(action.Key)).TakeDamage(damage, "Physical", null); } else { var damage = currentAgent.PhysAttack(); Console.WriteLine(damage); playerList.Find(x => x.GetName().Equals(action.Key)).TakeDamage(damage, "Physical", null); } } catch (Exceptions.DeathException death) { if (death.getObject().GetAgentType().Equals("Player")) { deadPlayers.Add(death.getObject()); playerList.RemoveAt(playerList.IndexOf(death.getObject())); Console.WriteLine(death.Message); messages.Add(death.Message); } else { deadMonsters.Add(death.getObject()); monsters.RemoveAt(monsters.IndexOf(death.getObject())); Console.WriteLine(death.Message); messages.Add(death.Message); } checkCompletion(messages); } } else if (action.Value.Equals("MagAttack")) { Console.WriteLine(currentAgent.GetName() + " is attacking " + action.Key + " with magic"); messages.Add(currentAgent.GetName() + " is attacking " + action.Key + " with magic"); try { if (currentAgent.GetAgentType().Equals("Player")) { monsters.Find(x => x.GetName().Equals(action.Key)).TakeDamage(currentAgent.PhysAttack(), "Magical", null); } else { playerList.Find(x => x.GetName().Equals(action.Key)).TakeDamage(currentAgent.PhysAttack(), "Magical", null); } } catch (Exceptions.DeathException death) { if (death.getObject().GetAgentType().Equals("Player")) { deadPlayers.Add(death.getObject()); playerList.RemoveAt(playerList.IndexOf(death.getObject())); Console.WriteLine(death.Message); messages.Add(death.Message); } else { deadMonsters.Add(death.getObject()); monsters.RemoveAt(monsters.IndexOf(death.getObject())); Console.WriteLine(death.Message); messages.Add(death.Message); } checkCompletion(messages); } } else if (action.Value.Equals("Heal")) { Console.WriteLine(currentAgent.GetName() + " is healing " + action.Key + "."); messages.Add(currentAgent.GetName() + " is healing " + action.Key + "."); if (currentAgent.GetAgentType().Equals("Player")) { playerList.Find(x => x.GetName().Equals(action.Key)).GetHealed(currentAgent.Heal(), null); } else { monsters.Find(x => x.GetName().Equals(action.Key)).GetHealed(currentAgent.Heal(), null); } } else if (action.Value.Contains("Skill")) { var target = action.Key.Substring(0, action.Key.IndexOf(" ")); var type = action.Key.Substring(action.Key.IndexOf(" "), action.Key.Length - target.Length).Trim(); var skillname = action.Value.Substring(0, action.Value.IndexOf(" ")); try { if (type.Equals("Monster")) { var message = currentAgent.UseSkill(monsters.Find(x => x.GetName().Equals(target)), skillname); //Console.WriteLine(message); messages.Add(message); } else { var message = currentAgent.UseSkill(playerList.Find(x => x.GetName().Equals(target)), skillname); //Console.WriteLine(message); messages.Add(message); } } catch (Exceptions.DeathException death) { if (death.getObject().GetAgentType().Equals("Player")) { deadPlayers.Add(death.getObject()); playerList.RemoveAt(playerList.IndexOf(death.getObject())); Console.WriteLine(death.Message); messages.Add(death.Message); } else { deadMonsters.Add(death.getObject()); monsters.RemoveAt(monsters.IndexOf(death.getObject())); Console.WriteLine(death.Message); messages.Add(death.Message); } checkCompletion(messages); } } return(messages); }