public void AttackOpponent(Player player, string[] input, Timer globalTimer) { globalTimer.Change(Timeout.Infinite, Timeout.Infinite); try { StringBuilder inputString = new StringBuilder(); for (int i = 1; i < input.Length; i++) { inputString.Append(input[i]); inputString.Append(' '); } string inputName = inputString.ToString().Trim(); string[] monsterName = Monster.Name.Split(' '); if (monsterName.Last() == inputName || Monster.Name == inputName || Monster.Name.Contains(input.Last()) || Monster != null) { if (Monster.HitPoints > 0) { player.InCombat = true; Monster.InCombat = true; CombatHelper.StartCombat(player, Monster); if (player.HitPoints <= 0) { Messages.PlayerDeath(); } } else { string monsterDeadString = $"The {Monster.Name} is already dead."; OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), monsterDeadString); } } else { string noMonsterString = $"There is no {inputName} to attack."; OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), noMonsterString); } } catch (IndexOutOfRangeException) { OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), "You can't attack that."); } globalTimer.Change(TimeSpan.Zero, TimeSpan.FromSeconds(1)); }