From ed26623e17e8dfcc036f88cca6de10d5a35697ec Mon Sep 17 00:00:00 2001 From: uzvkl Date: Mon, 20 May 2019 00:54:14 +0200 Subject: Reorganize Code delete ZoBotanica --- DSALib/Auxiliary/TalentEnumerableExtension.cs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'DSALib/Auxiliary/TalentEnumerableExtension.cs') diff --git a/DSALib/Auxiliary/TalentEnumerableExtension.cs b/DSALib/Auxiliary/TalentEnumerableExtension.cs index d83114c..6ec7fcc 100644 --- a/DSALib/Auxiliary/TalentEnumerableExtension.cs +++ b/DSALib/Auxiliary/TalentEnumerableExtension.cs @@ -1,33 +1,34 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using DSACore.DSA_Game.Characters; -using DSALib; +using DSACore.Auxiliary; +using DSALib.DSA_Game.Characters; +using DSALib.Models.Dsa; -namespace DSACore.Auxiliary +namespace DSALib.Auxiliary { public static class TalentEnumerableExtension { - public static string ProbenTest(this IEnumerable List, Character c, string talent, int erschwernis = 0) + public static string ProbenTest(this IEnumerable List, Character c, string talentName, int erschwernis = 0) { var output = new StringBuilder(); var sc = new SpellCorrect(); - var tTalent = List.OrderBy(x => sc.Compare(talent, x.Name)).First(); - if (sc.Compare(talent, tTalent.Name) > SpellCorrect.ErrorThreshold) - return $"{c.Name} kann nicht {talent}..."; + if (!List.TryMatch(out var iTalent, talentName)) + return $"{c.Name} kann nicht {talentName}..."; - var props = tTalent.GetEigenschaften(); // get the required properties - var tap = tTalent.Value; // get taw - var werte = props.Select(p => c.Eigenschaften[c.PropTable[p]]).ToList(); + var talent = (Talent) iTalent; + var props = talent.GetEigenschaften(); // get the required properties + var tap = talent.Value; // get taw + var werte = props.Select(p => c.Eigenschaften[c.PropTable[p]]).ToArray(); output.AppendFormat( "{0} würfelt: {1} \n{2} - {3} taw:{4} {5} \n", c.Name, - tTalent.Name, - tTalent.Probe, + talent.Name, + talent.Probe, string.Join("/", werte), - tTalent.Value, + talent.Value, erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); output.Append(" "); -- cgit v1.2.3-54-g00ecf