summaryrefslogtreecommitdiff
path: root/DiscoBot/Auxiliary
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-06-03 23:16:17 +0200
committerTrueDoctor <d-kobert@web.de>2018-06-03 23:16:17 +0200
commitd63ffc58db0f032cf7573b2a8a7720de2d5050ab (patch)
treed9a656651251bbd1eec233265ef824bf4b0389f0 /DiscoBot/Auxiliary
parent256154e2ab4244e7267ffc21959a4ce65c982783 (diff)
-General restructuring
-seperated talents and spells
Diffstat (limited to 'DiscoBot/Auxiliary')
-rw-r--r--DiscoBot/Auxiliary/KampfTalent.cs18
-rw-r--r--DiscoBot/Auxiliary/Talent.cs37
-rw-r--r--DiscoBot/Auxiliary/TalentEnumerableExtension.cs95
-rw-r--r--DiscoBot/Auxiliary/Vorteil.cs18
4 files changed, 95 insertions, 73 deletions
diff --git a/DiscoBot/Auxiliary/KampfTalent.cs b/DiscoBot/Auxiliary/KampfTalent.cs
deleted file mode 100644
index 05b7c9e..0000000
--- a/DiscoBot/Auxiliary/KampfTalent.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace DiscoBot.Auxiliary
-{
- public class KampfTalent
- {
- public KampfTalent(string name, int at, int pa)
- {
- this.Name = name;
- this.At = at;
- this.Pa = pa;
- }
-
- public string Name { get; set; }
-
- public int At { get; set; }
-
- public int Pa { get; set; }
- }
-}
diff --git a/DiscoBot/Auxiliary/Talent.cs b/DiscoBot/Auxiliary/Talent.cs
deleted file mode 100644
index e93aa18..0000000
--- a/DiscoBot/Auxiliary/Talent.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-namespace DiscoBot.Auxiliary
-{
- using System;
-
- public class Talent // talent objekt
- {
- public Talent(string name, string probe, int value)
- {
- this.Name = name;
- this.Probe = probe;
- this.Value = value;
- }
-
- public string Name { get; set; }
-
- public string Probe { get; set; }
-
- public int Value { get; set; }
-
- public string[] GetEigenschaften() // turn XX/XX/XX into string[]{XX,XX,XX}
- {
- var temp = this.Probe.Split('/');
- for (var index = 0; index < temp.Length; index++)
- {
- temp[index] = temp[index].Replace("/", string.Empty);
- }
-
- return temp;
- }
-
- public int CheckName(string quarry)
- {
- var sc = (StringComparer)new SpellCorrect();
- return sc.Compare(quarry, this.Name);
- }
- }
-}
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<Talent> 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
+ }
+ }
+}
diff --git a/DiscoBot/Auxiliary/Vorteil.cs b/DiscoBot/Auxiliary/Vorteil.cs
deleted file mode 100644
index 57f2020..0000000
--- a/DiscoBot/Auxiliary/Vorteil.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace DiscoBot.Auxiliary
-{
- public class Vorteil // talent objekt
- {
- public Vorteil(string name, string value = "")
- {
- this.Name = name;
- this.Value = value;
- // this.Choice = choice;
- }
-
- public string Name { get; set; }
-
- public string Value { get; set; }
-
- //public string Choice { get; set; }
- }
-}