From d63ffc58db0f032cf7573b2a8a7720de2d5050ab Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Sun, 3 Jun 2018 23:16:17 +0200 Subject: -General restructuring -seperated talents and spells --- DiscoBot/Auxiliary/TalentEnumerableExtension.cs | 95 +++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 DiscoBot/Auxiliary/TalentEnumerableExtension.cs (limited to 'DiscoBot/Auxiliary/TalentEnumerableExtension.cs') diff --git a/DiscoBot/Auxiliary/TalentEnumerableExtension.cs b/DiscoBot/Auxiliary/TalentEnumerableExtension.cs new file mode 100644 index 0000000..3c5330b --- /dev/null +++ b/DiscoBot/Auxiliary/TalentEnumerableExtension.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DiscoBot.Auxiliary +{ + using DiscoBot.Audio; + using DiscoBot.Commands; + using DiscoBot.DSA_Game; + using DiscoBot.DSA_Game.Characters; + + public static class TalentEnumerableExtension + { + public static string ProbenTest(this IEnumerable List, Character c, string talent, 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) + { + SoundEffects.Play(Sound.Wrong).Wait(); + return $"{c.Name} kann nicht {talent}..."; + } + + var props = tTalent.GetEigenschaften(); // get the required properties + int tap = tTalent.Value; // get taw + var werte = props.Select(p => c.Eigenschaften[c.PropTable[p]]).ToList(); + + output.AppendFormat( + "{0} würfelt: {1} \n{2} - {3} taw:{4} {5} \n", + c.Name, + tTalent.Name, + tTalent.Probe, + string.Join("/", werte), + tTalent.Value, + erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis); + + output.Append(" "); + tap -= erschwernis; + int gesamtErschwernis = tap; + if (gesamtErschwernis < 0) + { + tap = 0; + for (int i = 0; i <= 2; i++) + { + // foreach property, dice and tap + int temp = Dice.Roll(); + int eigenschaft = c.Eigenschaften[c.PropTable[props[i]]]; + + if (eigenschaft + gesamtErschwernis < temp) + { + tap -= temp - (eigenschaft + gesamtErschwernis); + } + + output.Append($"[{temp}]"); // add to string + } + + if (tap >= 0) + { + tap = 1; + } + } + else + { + for (int i = 0; i <= 2; i++) + { + // foreach property, dice and tap + int temp = Dice.Roll(); + int eigenschaft = c.Eigenschaften[c.PropTable[props[i]]]; + + if (eigenschaft < temp) + { + tap -= temp - eigenschaft; + } + + output.Append($"[{temp}]"); // add to string + } + } + + tap = (tap == 0) ? 1 : tap; + + if (tap < 0) + { + //SoundEffects.Play(Sound.Wrong).Wait(); + } + + output.AppendFormat(" tap: {0,2}", tap); + + return output.ToString(); // return output + } + } +} -- cgit v1.2.3-54-g00ecf