summaryrefslogtreecommitdiff
path: root/DiscoBot
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot')
-rw-r--r--DiscoBot/Audio/AudioModule.cs28
-rw-r--r--DiscoBot/Audio/AudioService.cs70
-rw-r--r--DiscoBot/Audio/Sound.cs16
-rw-r--r--DiscoBot/Audio/Soundeffects.cs93
-rw-r--r--DiscoBot/Audio/Voice.cs69
-rw-r--r--DiscoBot/Auxiliary/Calculator/Argument.cs38
-rw-r--r--DiscoBot/Auxiliary/Calculator/ISolvable.cs10
-rw-r--r--DiscoBot/Auxiliary/Calculator/Operator.cs50
-rw-r--r--DiscoBot/Auxiliary/Calculator/Ops.cs13
-rw-r--r--DiscoBot/Auxiliary/Calculator/StringSolver.cs207
-rw-r--r--DiscoBot/Auxiliary/CommandExtension.cs (renamed from DiscoBot/ToRework/CommandExtension.cs)79
-rw-r--r--DiscoBot/Auxiliary/CommandInfo.cs32
-rw-r--r--DiscoBot/Auxiliary/Dice.cs37
-rw-r--r--DiscoBot/Auxiliary/Extensions.cs33
-rw-r--r--DiscoBot/Auxiliary/Permissions.cs32
-rw-r--r--DiscoBot/Auxiliary/RandomMisc.cs44
-rw-r--r--DiscoBot/Auxiliary/SpellCorrect.cs120
-rw-r--r--DiscoBot/Auxiliary/TalentEnumerableExtension.cs102
-rw-r--r--DiscoBot/Commands/CommandTypes.cs13
-rw-r--r--DiscoBot/Commands/FileHandler.cs38
-rw-r--r--DiscoBot/Commands/Gm.cs187
-rw-r--r--DiscoBot/Commands/HeldList.cs191
-rw-r--r--DiscoBot/Commands/Help.cs99
-rw-r--r--DiscoBot/Commands/LebenUndAstral.cs198
-rw-r--r--DiscoBot/Commands/List.cs62
-rw-r--r--DiscoBot/Commands/MiscCommands.cs206
-rw-r--r--DiscoBot/Commands/NpcCommands.cs39
-rw-r--r--DiscoBot/Commands/ProbenTest.cs91
-rw-r--r--DiscoBot/DSA_Game/Characters/Character.cs303
-rw-r--r--DiscoBot/DSA_Game/Characters/NPC.cs112
-rw-r--r--DiscoBot/DSA_Game/Characters/SaveChar.cs45
-rw-r--r--DiscoBot/DSA_Game/Dsa.cs72
-rw-r--r--DiscoBot/DSA_Game/Save/Properties.cs88
-rw-r--r--DiscoBot/DSA_Game/Save/SaveCommand.cs82
-rw-r--r--DiscoBot/DSA_Game/Save/Session.cs60
-rw-r--r--DiscoBot/DiscoBot.csproj31
-rw-r--r--DiscoBot/Program.cs100
-rw-r--r--DiscoBot/Properties/AssemblyInfo.cs3
-rw-r--r--DiscoBot/ToRework/Permissions.cs43
39 files changed, 321 insertions, 2815 deletions
diff --git a/DiscoBot/Audio/AudioModule.cs b/DiscoBot/Audio/AudioModule.cs
index f8834f3..add4bf0 100644
--- a/DiscoBot/Audio/AudioModule.cs
+++ b/DiscoBot/Audio/AudioModule.cs
@@ -1,33 +1,21 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Threading.Tasks;
-
-using DiscoBot;
-using DiscoBot.Audio;
-using DiscoBot.Auxiliary;
-using DiscoBot.Commands;
-
+using System.Threading.Tasks;
using Discord;
using Discord.Commands;
namespace DiscoBot.Audio
{
- using DiscoBot.DSA_Game;
-
public class AudioModule : ModuleBase
{
// Scroll down further for the AudioService.
// Like, way down
- private readonly AudioService _service;
+ private readonly AudioService service;
// Remember to add an instance of the AudioService
// to your IServiceCollection when you initialize your bot
public AudioModule(AudioService service)
{
- _service = service;
- Dsa.Service = service;
+ this.service = service;
+ //Dsa.Service = service;
}
// You *MUST* mark these commands with 'RunMode.Async'
@@ -35,7 +23,7 @@ namespace DiscoBot.Audio
[Command("_join", RunMode = RunMode.Async)]
public async Task JoinCmd()
{
- await _service.JoinAudio(Context.Guild, (Context.User as IVoiceState).VoiceChannel);
+ await service.JoinAudio(Context.Guild, (Context.User as IVoiceState).VoiceChannel);
}
// Remember to add preconditions to your commands,
@@ -44,13 +32,13 @@ namespace DiscoBot.Audio
[Command("_leave", RunMode = RunMode.Async)]
public async Task LeaveCmd()
{
- await _service.LeaveAudio(Context.Guild);
+ await service.LeaveAudio(Context.Guild);
}
[Command("_play", RunMode = RunMode.Async)]
public async Task PlayCmd([Remainder] string song)
{
- if (Dsa.GeneralContext == null)
+ /*if (Dsa.GeneralContext == null)
{
Dsa.GeneralContext = this.Context;
}
@@ -71,7 +59,7 @@ namespace DiscoBot.Audio
await _service.SendAudioAsync(Context.Guild, Context.Channel, song);
}
- SoundEffects.Play(song);
+ SoundEffects.Play(song);*/
}
}
} \ No newline at end of file
diff --git a/DiscoBot/Audio/AudioService.cs b/DiscoBot/Audio/AudioService.cs
index 6e01980..a198eb2 100644
--- a/DiscoBot/Audio/AudioService.cs
+++ b/DiscoBot/Audio/AudioService.cs
@@ -1,34 +1,27 @@
-namespace DiscoBot.Audio
-{
- using System.Collections.Concurrent;
- using System.Diagnostics;
- using System.IO;
- using System.Threading.Tasks;
-
- using DiscoBot.DSA_Game;
-
- using Discord;
- using Discord.Audio;
+using System;
+using System.Collections.Concurrent;
+using System.Diagnostics;
+using System.IO;
+using System.Threading.Tasks;
+using Discord;
+using Discord.Audio;
+namespace DiscoBot.Audio
+{
public class AudioService
{
- private readonly ConcurrentDictionary<ulong, IAudioClient> connectedChannels = new ConcurrentDictionary<ulong, IAudioClient>();
+ private readonly ConcurrentDictionary<ulong, IAudioClient> connectedChannels =
+ new ConcurrentDictionary<ulong, IAudioClient>();
public async Task JoinAudio(IGuild guild, IVoiceChannel target)
{
- if (this.connectedChannels.TryGetValue(guild.Id, out var client))
- {
- return;
- }
+ if (connectedChannels.TryGetValue(guild.Id, out var client)) return;
- if (target.Guild.Id != guild.Id)
- {
- return;
- }
+ if (target.Guild.Id != guild.Id) return;
var audioClient = await target.ConnectAsync();
- if (this.connectedChannels.TryAdd(guild.Id, audioClient))
+ if (connectedChannels.TryAdd(guild.Id, audioClient))
{
// If you add a method to log happenings from this service,
// you can uncomment these commented lines to make use of that.
@@ -38,11 +31,9 @@
public async Task LeaveAudio(IGuild guild)
{
- if (this.connectedChannels.TryRemove(guild.Id, out var client))
- {
+ if (connectedChannels.TryRemove(guild.Id, out var client))
await client.StopAsync();
- //await Log(LogSeverity.Info, $"Disconnected from voice on {guild.Name}.");
- }
+ //await Log(LogSeverity.Info, $"Disconnected from voice on {guild.Name}.");
}
public async Task SendAudioAsync(IGuild guild, IMessageChannel channel, string path)
@@ -54,28 +45,31 @@
return;
}
- if (this.connectedChannels.TryGetValue(guild.Id, out var client))
- {
+ if (connectedChannels.TryGetValue(guild.Id, out var client))
//await Log(LogSeverity.Debug, $"Starting playback of {path} in {guild.Name}");
- using (var ffmpeg = this.CreateStream(path))
+ using (var ffmpeg = CreateStream(path))
using (var stream = client.CreatePCMStream(AudioApplication.Music))
{
- try { await ffmpeg.StandardOutput.BaseStream.CopyToAsync(stream); }
- finally { await stream.FlushAsync(); }
+ try
+ {
+ await ffmpeg.StandardOutput.BaseStream.CopyToAsync(stream);
+ }
+ finally
+ {
+ await stream.FlushAsync();
+ }
}
- }
}
- public async Task SendAudioAsync(string path, int Volume)
+ public async Task SendAudioAsync(string path, int volume)
{
// Your task: Get a full path to the file if the value of 'path' is only a filename.
if (!File.Exists(path) && false)
- {
//await channel.SendMessageAsync("File does not exist.");
return;
- }
- if (this.connectedChannels.TryGetValue(Dsa.GeneralContext.Guild.Id, out var client))
+ throw new NotImplementedException("get channel data from server");
+ /*if (this.connectedChannels.TryGetValue())
{
//await Log(LogSeverity.Debug, $"Starting playback of {path} in {guild.Name}");
using (var ffmpeg = this.CreateStream(path))
@@ -84,10 +78,10 @@
try { await ffmpeg.StandardOutput.BaseStream.CopyToAsync(stream); }
finally { await stream.FlushAsync(); }
}
- }
+ }*/
}
- private Process CreateStream(string path)
+ private static Process CreateStream(string path)
{
return Process.Start(new ProcessStartInfo
{
@@ -98,4 +92,4 @@
});
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Audio/Sound.cs b/DiscoBot/Audio/Sound.cs
index a9a2768..85023c8 100644
--- a/DiscoBot/Audio/Sound.cs
+++ b/DiscoBot/Audio/Sound.cs
@@ -1,18 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.Audio
+namespace DiscoBot.Audio
{
public class Sound
{
public Sound(string name, string url, int volume)
{
- this.Name = name;
- this.Url = url;
- this.Volume = volume;
+ Name = name;
+ Url = url;
+ Volume = volume;
}
public string Name { get; }
@@ -21,4 +15,4 @@ namespace DiscoBot.Audio
public int Volume { get; }
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Audio/Soundeffects.cs b/DiscoBot/Audio/Soundeffects.cs
deleted file mode 100644
index f3a014c..0000000
--- a/DiscoBot/Audio/Soundeffects.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-namespace DiscoBot.Audio
-{
- using System;
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.Commands;
- using DiscoBot.DSA_Game;
-
- /*public enum Sound
- {
- Bell,
- Ding,
- Nooo,
- Monsterkill,
- Finish,
- Wrong,
- Magic,
- Stupid,
- Police,
- Roblox
- }*/
-
- public static class SoundEffects
- {
- public static int MaxVolume { get; set; } = 50;
-
- public static void Play(string s)
- {
- string url = string.Empty;
- int volume = 255;
-
- var tSound = DSA_Game.Save.Properties.Sounds.OrderBy(x => SpellCorrect.CompareEasy(s, x.Name)).First();
-
- url = s;
-
- switch (s)
- {
- case "Bell":
- case "Ding":
- url = "https://www.myinstants.com/media/sounds/boxing-bell.mp3";
- break;
- case "Finish":
- url = "https://www.myinstants.com/media/sounds/finishhim.swf.mp3";
- break;
- case "Magic":
- url = "https://www.myinstants.com/media/sounds/dream-harp-sound-effect.mp3";
- break;
- case "Monsterkill":
- url = "https://www.myinstants.com/media/sounds/announcer_kill_monster_01.mp3";
- break;
- case "Nooo":
- url = "https://www.myinstants.com/media/sounds/nooo.swf.mp3";
- break;
- case "Roblox":
- url = "https://www.myinstants.com/media/sounds/roblox-death-sound_ytkBL7X.mp3";
- break;
- case "Stupid":
- url = "https://www.myinstants.com/media/sounds/stupid_dum_03.mp3";
- volume = 10;
- break;
- case "Police":
- url = "https://www.myinstants.com/media/sounds/sound-of-the-police.mp3";
- break;
- case "Wrong":
- url = "https://www.myinstants.com/media/sounds/wrong-answer-sound-effect.mp3";
- volume = 50;
- break;
- }
-
-
-
- if (SpellCorrect.CompareEasy(s, tSound.Name) < SpellCorrect.ErrorThreshold)
- {
- url = tSound.Url;
- volume = tSound.Volume;
- }
-
- volume = (int)(volume * (MaxVolume / 100.0));
-
-
- if (url != string.Empty)
- {
- // await Dsa.Service.SendAudioAsync(url, vol);
- Voice.Send(url, volume);
- return;
- }
-
- throw new Exception("Ton Existiert nicht");
- }
- }
-}
diff --git a/DiscoBot/Audio/Voice.cs b/DiscoBot/Audio/Voice.cs
index 379f65b..c2a3097 100644
--- a/DiscoBot/Audio/Voice.cs
+++ b/DiscoBot/Audio/Voice.cs
@@ -1,42 +1,34 @@
-namespace DiscoBot.Audio
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Threading.Tasks;
+using DiscoBot.Auxiliary;
+using Discord;
+using Discord.Audio;
+using Discord.Commands;
+
+namespace DiscoBot.Audio
{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord;
- using Discord.Audio;
- using Discord.Commands;
- using Discord.WebSocket;
-
public class Voice : ModuleBase
{
public static IAudioClient Client { get; set; }
public static void Send(string path, int volume = 256)
{
- if (Client == null)
- {
- throw new NullReferenceException("Bot befindet sich nicht in einem Sprachchannel");
- }
+ if (Client == null) throw new NullReferenceException("Bot befindet sich nicht in einem Sprachchannel");
// Create FFmpeg using the previous example
var ffmpeg = CreateStream(path, volume);
var output = ffmpeg.StandardOutput.BaseStream;
var barInvoker = new BackgroundWorker();
barInvoker.DoWork += delegate
- {
- var discord = Client.CreatePCMStream(AudioApplication.Music);
- output.CopyToAsync(discord);
+ {
+ var discord = Client.CreatePCMStream(AudioApplication.Music);
+ output.CopyToAsync(discord);
- discord.FlushAsync();
- };
+ discord.FlushAsync();
+ };
barInvoker.RunWorkerAsync();
}
@@ -44,7 +36,7 @@
[Command("join", RunMode = RunMode.Async)]
public async Task JoinChannelAsync(IVoiceChannel channel = null)
{
- var msg = this.Context.Message;
+ var msg = Context.Message;
// Get the audio channel
channel = channel ?? (msg.Author as IGuildUser)?.VoiceChannel;
@@ -67,37 +59,22 @@
if (Client != null)
{
- SoundEffects.Play("Nooo");
await Client.StopAsync();
Client = null;
}
}
- [Command("volume")]
- public void SetVolume(int volume)
- {
- if (volume <= 100 && volume >= 0)
- {
- SoundEffects.MaxVolume = volume;
- }
- }
[Command("play", RunMode = RunMode.Async)]
public async Task PlayAudioAsync(string path)
{
- if (Client == null)
- {
- await this.Context.Channel.SendMessageAsync("Erst Joinen!");
- }
+ if (Client == null) await Context.Channel.SendMessageAsync("Erst Joinen!");
- SoundEffects.Play(path);
+ //SoundEffects.Play(path);
var sounds = Enum.GetValues(typeof(Sound));
var soundList = new List<Sound>();
- foreach (var sound in sounds)
- {
- soundList.Add((Sound)sound);
- }
+ foreach (var sound in sounds) soundList.Add((Sound) sound);
var sc = new SpellCorrect();
}
@@ -109,9 +86,9 @@
FileName = "ffmpeg",
Arguments = $"-i {path} -ac 2 -f s16le -ar 48000 -ab 620000 -vol {vol} pipe:1",
UseShellExecute = false,
- RedirectStandardOutput = true,
+ RedirectStandardOutput = true
};
return Process.Start(ffmpeg);
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/Calculator/Argument.cs b/DiscoBot/Auxiliary/Calculator/Argument.cs
deleted file mode 100644
index 2379bfe..0000000
--- a/DiscoBot/Auxiliary/Calculator/Argument.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-namespace DiscoBot.Auxiliary.Calculator
-{
- using System;
-
- /// <summary>
- /// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int.
- /// </summary>
- public class Argument : ISolvable
- {
- private readonly int value;
-
- public Argument(string value)
- {
- // check whether the value given is an empty string
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("Argument kann nicht mit einem leeren string instanziert werden. ", nameof(value));
- }
-
- if (!int.TryParse(value, out int result))
- {
- throw new ArgumentException($"Kann {value} nicht in Integer konvertieren");
- }
-
- this.value = result;
- }
-
- public int Solve()
- {
- return this.value;
- }
-
- public override string ToString()
- {
- return this.value.ToString();
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/Calculator/ISolvable.cs b/DiscoBot/Auxiliary/Calculator/ISolvable.cs
deleted file mode 100644
index a869bdb..0000000
--- a/DiscoBot/Auxiliary/Calculator/ISolvable.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace DiscoBot.Auxiliary.Calculator
-{
- /// <summary>
- /// Object has to be able to return an integer as it's value
- /// </summary>
- public interface ISolvable
- {
- int Solve();
- }
-}
diff --git a/DiscoBot/Auxiliary/Calculator/Operator.cs b/DiscoBot/Auxiliary/Calculator/Operator.cs
deleted file mode 100644
index 0928ec2..0000000
--- a/DiscoBot/Auxiliary/Calculator/Operator.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-
-namespace DiscoBot.Auxiliary.Calculator
-{
- /// <summary>
- /// The Operator Class represents a binary operator with tow Arguments and an Operation type
- /// </summary>
- public class Operator : ISolvable
- {
- private readonly ISolvable arg1, arg2;
-
- public Operator(ISolvable arg1, ISolvable arg2, Ops operatorType)
- {
- this.arg1 = arg1;
- this.arg2 = arg2;
- this.OperatorType = operatorType;
- }
-
- public Ops OperatorType { get; set; }
-
- public int Solve()
- {
- int result;
- switch (this.OperatorType)
- {
- case Ops.Dice:
- result = Dice.Roll(this.arg1.Solve(), this.arg2.Solve());
- break;
- case Ops.Multiply:
- result = this.arg1.Solve() * this.arg2.Solve();
- break;
- case Ops.Add:
- result = this.arg1.Solve() + this.arg2.Solve();
- break;
- case Ops.Subtract:
- result = this.arg1.Solve() - this.arg2.Solve();
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
-
- return result;
- }
-
- public override string ToString()
- {
- return $"({this.arg1} {this.OperatorType} {this.arg2})";
- }
- }
-}
diff --git a/DiscoBot/Auxiliary/Calculator/Ops.cs b/DiscoBot/Auxiliary/Calculator/Ops.cs
deleted file mode 100644
index 62c1309..0000000
--- a/DiscoBot/Auxiliary/Calculator/Ops.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace DiscoBot.Auxiliary.Calculator
-{
- /// <summary>
- /// The Different Operations, witch can be performed in execution-order
- /// </summary>
- public enum Ops
- {
- Dice,
- Multiply,
- Subtract,
- Add
- }
-}
diff --git a/DiscoBot/Auxiliary/Calculator/StringSolver.cs b/DiscoBot/Auxiliary/Calculator/StringSolver.cs
deleted file mode 100644
index 6e5b3a9..0000000
--- a/DiscoBot/Auxiliary/Calculator/StringSolver.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-namespace DiscoBot.Auxiliary.Calculator
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
- /// <summary>
- /// The StringSolver divides the calculation string into operations and SubStringSolvers if the string contains parentheses
- /// </summary>
- public class StringSolver : ISolvable
- {
- public readonly string input;
- public readonly List<object> arguments = new List<object>();
-
- public StringSolver(string input)
- {
- this.input = input;
- }
-
- public override string ToString()
- {
- return "(0+" + this.input.Replace(" ", string.Empty).ToLower() + ")";
- }
-
- public int Solve()
- {
- string workInput = "0+" + this.input.Replace(" ", string.Empty).ToLower();
- workInput = ExpandParentheses(workInput);
-
- // Create a List of the different parts of the calculation, e.g.:{"0", "+", "(5+6)", "d", "3"}.
- this.AtomizeOperations(workInput);
-
- // traverse the List in order of Operation to Create the binary operation tree .
- this.NestOperations();
-
- // the List now contains only the top operation node, witch can be solved recursively,
- return ((ISolvable)this.arguments.First()).Solve();
- }
-
- public static string GetInner(ref string input) // extract the inner bracket an remove the section from the input string
- {
- int depth = 0;
- for (var index = 1; index < input.Length; index++)
- {
- char c = input[index];
- switch (c)
- {
- case '(':
- depth++;
- break;
- case ')':
- if (depth == 0)
- {
- var split = input.Substring(1, index - 1);
- input = input.Substring(index + 1);
- return split.Equals(string.Empty) ? "0" : split;
- }
- else
- {
- depth--;
- }
-
- break;
- }
- }
-
- return string.Empty;
- }
-
- public static Ops GetOps(char c)
- {
- switch (c)
- {
- case 'd':
- case 'w':
- return Ops.Dice;
- case '+':
- return Ops.Add;
- case '-':
- return Ops.Subtract;
- case '*':
- return Ops.Multiply;
- default:
- return Ops.Multiply;
- }
- }
-
- public static string ExpandParentheses(string input) // insert * between Parentheses and digits
- {
- for (int i = 0; i < input.Length - 1; i++)
- {
- if (input[i + 1] == '(' && char.IsNumber(input[i]))
- {
- input = input.Insert(i + 1, "*");
- }
- }
-
- for (int i = 1; i < input.Length; i++)
- {
- if (input[i - 1] == ')' && char.IsNumber(input[i]))
- {
- input = input.Insert(i, "*");
- }
- }
-
- return input;
- }
-
- public void AtomizeOperations(string workInput)
- {
- for (var index = 0; index < workInput.Length; index++)
- {
- char c = workInput[index];
-
- if (char.IsNumber(c))
- {
- // if char number, check if at end of string, else continue looping
- if (index == workInput.Length - 1)
- {
- // if at end of string; add remaining number to arguments
- this.arguments.Add(new Argument(workInput.Substring(0, index + 1)));
- }
-
- continue;
- }
-
- switch (c)
- {
- case ')':
- throw new ArgumentException($"Unmögliche Anordnung von Klammern");
- case '(':
- this.arguments.Add(new StringSolver(GetInner(ref workInput)));
- index = -1;
- break;
- default:
- if (index > 0)
- {
- this.arguments.Add(new Argument(workInput.Substring(0, index)));
- }
-
- this.arguments.Add(GetOps(c));
- workInput = workInput.Remove(0, index + 1);
- index = -1;
- break;
- }
- }
- }
-
- public void NestOperations()
- {
- foreach (Ops currentOp in Enum.GetValues(typeof(Ops)))
- {
- // cycle through operators in operational order
- for (var index = 0; index < this.arguments.Count; index++)
- {
- var arg = this.arguments[index];
-
- if (arg.GetType() != typeof(Ops))
- {
- continue;
- }
-
- // arg is of type Ops
- var op = (Ops)arg;
-
- if (op != currentOp)
- {
- continue;
- }
-
- // arg describes the current operation
- this.HandleSpecialFormatting(ref index, op); // Deal with special needs...
-
- // replace the previous current and next Element in the List with one Operation object
- var temp = new Operator((ISolvable)this.arguments[index - 1], (ISolvable)this.arguments[index + 1], op);
- this.arguments[index - 1] = temp;
- this.arguments.RemoveRange(index, 2);
- index--;
- }
- }
- }
-
- public void HandleSpecialFormatting(ref int index, Ops op)
- {
- var arg1 = this.arguments[index - 1];
- if (arg1.GetType() == typeof(Ops))
- {
- if (op == Ops.Dice)
- {
- this.arguments.Insert(index++, new Argument("1")); // w6 -> 1w6
- }
-
- if (op == Ops.Subtract)
- {
- this.arguments.Insert(index++, new Argument("0")); // +-3 -> +0-3
- }
- }
-
- var arg2 = this.arguments[index + 1]; // 3+-5 -> 3+(0-5)
- if (arg2.GetType() == typeof(Ops))
- {
- this.arguments[index + 1] = new Operator(new Argument("0"), (ISolvable)this.arguments[index + 2], (Ops)arg2);
- this.arguments.RemoveAt(index + 2);
- }
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/ToRework/CommandExtension.cs b/DiscoBot/Auxiliary/CommandExtension.cs
index 098e35f..ad9f323 100644
--- a/DiscoBot/ToRework/CommandExtension.cs
+++ b/DiscoBot/Auxiliary/CommandExtension.cs
@@ -1,33 +1,31 @@
-namespace DiscoBot.Auxiliary
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Discord;
+using Discord.Commands;
+
+namespace DiscoBot.Auxiliary
{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- using Discord;
- using Discord.Commands;
-
public static class CommandExtension
{
- private static WebClient client;
+ private static WebClient _client;
public static async Task ReplyTimedAsync(this ModuleBase m, string message, TimeSpan time)
{
var token = message.GetHashCode();
- var send = m.Context.Channel.SendMessageAsync($"#{token}\n```xl\n{message}```", false);
+ var send = m.Context.Channel.SendMessageAsync($"#{token}\n```xl\n{message}```");
var barInvoker = new BackgroundWorker();
barInvoker.DoWork += delegate
- {
- Thread.Sleep(time);
- Delete(token, m);
- };
+ {
+ Thread.Sleep(time);
+ Delete(token, m);
+ };
await send;
barInvoker.RunWorkerAsync();
@@ -39,35 +37,23 @@
Task.WaitAll(messagesAsync.ToArray());
var list = messagesAsync.ToEnumerable().ToList();
var messages = new List<IMessage>();
- foreach (var task in list)
- {
- messages.AddRange(task.ToList());
- }
-
- var test = messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot).Select(c=>c );
- var waiters = new List<Task>();
- foreach (var message in test)
- {
- waiters.Add((message as IUserMessage).DeleteAsync());
- }
- Task.WaitAll(waiters.ToArray());
+ foreach (var task in list) messages.AddRange(task.ToList());
+
+ var test = messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot).Select(c => c);
+ Task.WaitAll(test.Select(message => (message as IUserMessage)?.DeleteAsync()).ToArray());
}
public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, bool directMessage = false)
{
var sb = new StringBuilder();
- foreach (string re in message)
+ foreach (var re in message)
{
if (sb.Length + re.Length > 1798)
{
if (directMessage)
- {
await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```");
- }
else
- {
await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
- }
sb.Clear();
}
@@ -76,23 +62,18 @@
}
if (directMessage)
- {
await m.Context.User.SendMessageAsync("```xl\n" + sb + "\n```");
- }
else
- {
await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
- }
}
public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, TimeSpan time)
{
var sb = new StringBuilder();
- foreach (string re in message)
+ foreach (var re in message)
{
if (sb.Length + re.Length > 1798)
{
-
await m.ReplyTimedAsync(sb.ToString(), time);
@@ -105,15 +86,13 @@
await m.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
}
- public static async Task SendWebFile(this IMessageChannel channel, string url = "https://i.imgur.com/0iHEycJ.png")
+ public static async Task SendWebFile(this IMessageChannel channel,
+ string url = "https://i.imgur.com/0iHEycJ.png")
{
- if (client == null)
- {
- client = new WebClient();
- }
+ if (_client == null) _client = new WebClient();
- Stream stream = client.OpenRead(url);
+ var stream = _client.OpenRead(url);
await channel.SendFileAsync(stream, url.Split('/').Last());
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/CommandInfo.cs b/DiscoBot/Auxiliary/CommandInfo.cs
deleted file mode 100644
index dfed417..0000000
--- a/DiscoBot/Auxiliary/CommandInfo.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.Auxiliary
-{
- public struct CommandInfo
- {
- public CommandInfo(string name, string brief, string[] description, string scope)
- {
- this.Name = name;
- this.Scope = scope;
- this.Brief = brief;
- this.Description = description;
- }
-
- public string Name { get; }
-
- public string Scope { get; }
-
- public string Brief { get; }
-
- public string[] Description { get; }
-
- public string GetDescription()
- {
- return this.Description.Aggregate((s, c) => s + c);
- }
- }
-}
diff --git a/DiscoBot/Auxiliary/Dice.cs b/DiscoBot/Auxiliary/Dice.cs
index 0cd9656..f0f4def 100644
--- a/DiscoBot/Auxiliary/Dice.cs
+++ b/DiscoBot/Auxiliary/Dice.cs
@@ -1,44 +1,25 @@
-namespace DiscoBot.Auxiliary
-{
- using System;
- using System.Linq;
-
- using Discord.Commands;
+using System;
+namespace DiscoBot.Auxiliary
+{
public static class Dice // roll it!
{
- private static readonly System.Random Rnd = new System.Random();
+ private static readonly Random Rnd = new Random();
public static int Roll(int d = 20)
{
return Rnd.Next(d) + 1;
}
- public static int Roll(string input)
- {
- var strings = input.ToLower().Split(new[] { 'w', 'd' }, 2, StringSplitOptions.RemoveEmptyEntries).ToList();
- int count = Convert.ToInt32(strings[0]);
- int d = Convert.ToInt32(strings[0]);
-
- if (strings.Count != 2)
- {
- throw new ArgumentException($"{input}: erfüllt nicht die Formatvogaben( Anzahl d Augenzahl)");
- }
-
- return Roll(count, d);
- }
public static int Roll(int count, int d)
{
- if (d <= 0)
- {
- return 0;
- }
+ if (d <= 0) return 0;
- int sum = 0;
- for (int i = 0; i < Math.Abs(count); i++)
+ var sum = 0;
+ for (var i = 0; i < Math.Abs(count); i++)
{
- var roll = Dice.Roll(d);
+ var roll = Roll(d);
sum += roll;
}
@@ -47,4 +28,4 @@
return sum;
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/Extensions.cs b/DiscoBot/Auxiliary/Extensions.cs
deleted file mode 100644
index fad5dd8..0000000
--- a/DiscoBot/Auxiliary/Extensions.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-namespace DiscoBot.Auxiliary
-{
- public static class StringExtension
- {
- //This mehod extends string. It adds spaces until a fixed length is reached.
- //If the original string is already longer, it is returner unmodified.
- public static string AddSpaces(this string str, int length)
- {
- string temp = str;
- for(int i = str.Length; i < length; i++)
- {
- temp += " ";
- }
- return temp;
- }
-
-
-
- //This mehod extends string.
- //It adds spaces at the HEAD of a string until a fixed length is reached.
- //If the original string is already longer, it is returner unmodified.
- public static string AddSpacesAtHead(this string str, int length)
- {
- string temp = "";
- for (int i = str.Length; i < length; i++)
- {
- temp += " ";
- }
- return temp + str;
- }
- }
-
-}
diff --git a/DiscoBot/Auxiliary/Permissions.cs b/DiscoBot/Auxiliary/Permissions.cs
new file mode 100644
index 0000000..3ec4a2e
--- /dev/null
+++ b/DiscoBot/Auxiliary/Permissions.cs
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using System.Linq;
+using Discord.Commands;
+using Discord.WebSocket;
+
+namespace DiscoBot.Auxiliary
+{
+ public static class Permissions
+ {
+ public static bool Check(ICommandContext c, string role)
+ {
+ return ((SocketGuildUser) c.User).Roles.ToList().Exists(v => v.Name.Equals(role));
+ }
+
+ public static bool Check(ICommandContext c, IEnumerable<string> roles)
+ {
+ return roles.Any(role => ((SocketGuildUser) c.User).Roles.ToList().Exists(v => v.Name.Equals(role)));
+ }
+
+ public static bool Test(ICommandContext c, string role)
+ {
+ if (Check(c, role)) return true;
+ c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
+ return false;
+ }
+
+ public static void Test(ICommandContext c, string[] roles)
+ {
+ if (!Check(c, roles)) c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
+ }
+ }
+} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/RandomMisc.cs b/DiscoBot/Auxiliary/RandomMisc.cs
index 7ba625e..205b3a7 100644
--- a/DiscoBot/Auxiliary/RandomMisc.cs
+++ b/DiscoBot/Auxiliary/RandomMisc.cs
@@ -1,52 +1,36 @@
-namespace DiscoBot.Auxiliary
-{
- using System;
- using System.Linq;
- using System.Text;
+using System;
+using System.Linq;
+using System.Text;
+namespace DiscoBot.Auxiliary
+{
public static class RandomMisc
{
- private static readonly Random Rand = new Random();
-
- // use: 4w6 +4
public static string Roll(string input)
{
var output = new StringBuilder();
var strings = input.Split('w', 'd').ToList();
- int count = Convert.ToInt32(strings[0]);
+ var count = Convert.ToInt32(strings[0]);
strings = strings[1].Split(' ').ToList();
- int d = Convert.ToInt32(strings[0]);
+ var d = Convert.ToInt32(strings[0]);
if (strings.Count > 0)
{
}
- int sum = 0;
- for (int i = 0; i < count; i++)
+ var sum = 0;
+ for (var i = 0; i < count; i++)
{
var roll = Dice.Roll(d);
sum += roll;
output.Append("[" + roll + "] ");
}
-
- if (strings.Count > 1)
- {
- sum += Convert.ToInt32(strings[1]);
- output.Append("sum: " + sum);
- }
- return output.ToString();
- }
+ if (strings.Count <= 1) return output.ToString();
+ sum += Convert.ToInt32(strings[1]);
+ output.Append("sum: " + sum);
- public static double Random(double stdDev = 1, double mean = 0)
- {
- double u1 = Rand.NextDouble(); // uniform(0,1) random doubles
- double u2 = Rand.NextDouble();
- double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
- Math.Sin(2.0 * Math.PI * u2); // random normal(0,1)
- double randNormal =
- mean + stdDev * randStdNormal; // random normal(mean,stdDev^2)
- return randNormal;
+ return output.ToString();
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/SpellCorrect.cs b/DiscoBot/Auxiliary/SpellCorrect.cs
index 01cce62..c4bd4bf 100644
--- a/DiscoBot/Auxiliary/SpellCorrect.cs
+++ b/DiscoBot/Auxiliary/SpellCorrect.cs
@@ -1,9 +1,8 @@
-namespace DiscoBot.Auxiliary
-{
- using System;
- using System.Diagnostics;
- using System.Linq;
+using System;
+using System.Diagnostics;
+namespace DiscoBot.Auxiliary
+{
public class SpellCorrect : StringComparer
{
public const int ErrorThreshold = 94100;
@@ -15,44 +14,25 @@
public static int CompareEasy(string x, string y)
{
- if (string.IsNullOrEmpty(x))
- {
- throw new ArgumentException("message", nameof(x));
- }
+ if (string.IsNullOrEmpty(x)) throw new ArgumentException("message", nameof(x));
- if (string.IsNullOrEmpty(y))
- {
- throw new ArgumentException("message", nameof(y));
- }
+ if (string.IsNullOrEmpty(y)) throw new ArgumentException("message", nameof(y));
- if (x.Equals(y))
- {
- return 0;
- }
+ if (x.Equals(y)) return 0;
x = x.ToLower();
y = y.ToLower();
- if (x.Equals(y))
- {
- return 1;
- }
+ if (x.Equals(y)) return 1;
var subs = y.Split(' ', '/');
- int score = subs.Count();
- foreach (string s in subs)
- {
+ var score = subs.Length;
+ foreach (var s in subs)
if (s.Equals(x))
- {
score--;
- }
- }
- if (score < subs.Count())
- {
- return score + 1;
- }
+ if (score < subs.Length) return score + 1;
- return 100000 - (int)(CompareExact(x, y) * 1000.0);
+ return 100000 - (int) (CompareExact(x, y) * 1000.0);
/*if (y.Contains(x))
return 6;*/
}
@@ -70,78 +50,56 @@
public static double CompareExact(string s, string q)
{
-
s = s.ToLower();
q = q.ToLower();
int i, j;
- const double Match = 3.0;
- const double Gap = -2.0;
- const double Mismatch = -2.0;
+ const double match = 3.0;
+ const double gap = -2.0;
+ const double mismatch = -2.0;
double decay;
- double[,] matrix = new double[s.Length + 1, q.Length + 1];
- double max = 0.0;
+ var matrix = new double[s.Length + 1, q.Length + 1];
+ var max = 0.0;
matrix[0, 0] = 0.0;
-
+
for (i = 1; i < s.Length; i++)
- {
- // matrix[i, 0] = 0.0;
- matrix[i, 0] = i * Gap;
- }
+ // matrix[i, 0] = 0.0;
+ matrix[i, 0] = i * gap;
- for (i = 1; i < q.Length; i++)
- {
- matrix[0, i] = 0.0;
- }
+ for (i = 1; i < q.Length; i++) matrix[0, i] = 0.0;
for (i = 1; i <= s.Length; i++)
+ for (j = 1; j <= q.Length; j++)
{
- for (j = 1; j <= q.Length; j++)
- {
- decay = j / (double)(s.Length * 1000);
- double add = s[i - 1] == q[j - 1] ? (Match - decay) : Mismatch;
- double score = matrix[i - 1, j - 1] + add;
+ decay = j / (double) (s.Length * 1000);
+ var add = s[i - 1] == q[j - 1] ? match - decay : mismatch;
+ var score = matrix[i - 1, j - 1] + add;
- if (score < (matrix[i - 1, j] + Gap))
- {
- score = matrix[i - 1, j] + Gap;
- }
+ if (score < matrix[i - 1, j] + gap) score = matrix[i - 1, j] + gap;
- if (score < (matrix[i, j - 1] + Gap))
- {
- score = matrix[i, j - 1] + Gap;
- }
+ if (score < matrix[i, j - 1] + gap) score = matrix[i, j - 1] + gap;
- if (i > 1 && j > 1)
+ if (i > 1 && j > 1)
+ if (s[i - 1] == q[j - 2] && s[i - 2] == q[j - 1])
{
- if (s[i - 1] == q[j - 2] && s[i - 2] == q[j - 1])
- {
- add = (3 / 2.0) * Match - decay;
- if (score < matrix[i - 2, j - 2] + add)
- {
- score = matrix[i - 2, j - 2] + add;
- }
- }
+ add = 3 / 2.0 * match - decay;
+ if (score < matrix[i - 2, j - 2] + add) score = matrix[i - 2, j - 2] + add;
}
-
- // if (score < 0)
- // {
- // score = 0;
- // }
- if (max < score && i == s.Length)
- {
- max = score;
- }
+ // if (score < 0)
+ // {
+ // score = 0;
+ // }
+
+ if (max < score && i == s.Length) max = score;
- matrix[i, j] = score;
- }
+ matrix[i, j] = score;
}
return max;
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Auxiliary/TalentEnumerableExtension.cs b/DiscoBot/Auxiliary/TalentEnumerableExtension.cs
deleted file mode 100644
index df01de3..0000000
--- a/DiscoBot/Auxiliary/TalentEnumerableExtension.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using DSALib;
-
-
-namespace DiscoBot.Auxiliary
-{
- using DiscoBot.Audio;
- 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)
- {
- try
- {
- SoundEffects.Play("Stupid");
- }
- catch { }
- 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)
- {
- try
- {
- SoundEffects.Play("Wrong");
- }
- catch { }
- }
-
- output.AppendFormat(" tap: {0,2}", tap);
-
- return output.ToString(); // return output
- }
- }
-}
diff --git a/DiscoBot/Commands/CommandTypes.cs b/DiscoBot/Commands/CommandTypes.cs
deleted file mode 100644
index c1d0954..0000000
--- a/DiscoBot/Commands/CommandTypes.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace DiscoBot.Commands
-{
- public enum CommandTypes
- {
- Talent,
- Eigenschaft,
- Angriff,
- Parade,
- Fernkampf,
- KeinChar,
- Zauber
- }
-}
diff --git a/DiscoBot/Commands/FileHandler.cs b/DiscoBot/Commands/FileHandler.cs
index 0b87b15..17928c8 100644
--- a/DiscoBot/Commands/FileHandler.cs
+++ b/DiscoBot/Commands/FileHandler.cs
@@ -1,45 +1,25 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Linq;
- using System.Net;
- using System.Threading.Tasks;
-
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
- using DSALib;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Discord.Commands;
+namespace DiscoBot.Commands
+{
public class FileHandler : ModuleBase
{
//[Command("send"), Summary("fügt Helden hinzu")]
public async Task AddChar()
{
- var msg = this.Context.Message;
- if (msg.Attachments == null)
- {
- throw new ArgumentException("Es wurde keine Datei angehängt");
- }
+ var msg = Context.Message;
+ if (msg.Attachments == null) throw new ArgumentException("Es wurde keine Datei angehängt");
var attachments = msg.Attachments.ToList();
if (!attachments.Any(x => x.Filename.EndsWith(".xml")))
- {
throw new ArgumentException("Es wurde kein xml Held mitgeschickt");
- }
foreach (var attachment in attachments.Where(x => x.Filename.EndsWith(".xml")))
- {
- using (var client = new WebClient())
- {
- client.DownloadFile(attachment.Url, "helden\\" + attachment.Filename);
- }
-
- Dsa.Chars.Add(new Character("helden\\" + attachment.Filename));
- (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0))
- .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v));
- }
+ throw new NotImplementedException("send File to Server");
}
}
} \ No newline at end of file
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs
deleted file mode 100644
index 483e9d2..0000000
--- a/DiscoBot/Commands/Gm.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using DiscoBot.DSA_Game.Characters;
-
-namespace DiscoBot.Commands
-{
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord.Commands;
- using DSALib.Characters;
-
- public class Iam : ModuleBase
- {
-
- //[Command("Iam"), Summary("Wechselt den Character")]
- [Alias("iam", "I_am", "i_am", "IchBin", "ichbin", "Ichbin", "Ich_bin", "ich_bin", "Ich", "ich", "I", "i")]
- public Task Change_Character(params string[] givenName) // use fancy parameters
- {
- string res;
- string name;
-
- if (givenName.Length == 0 || (givenName.Length == 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am"))))
- {
- res = " \nDu bist " + Dsa.Session.Relation[this.Context.User.Username] + "!\n \n";
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- if (givenName.Length > 1 && (givenName[0].ToLower().Equals("bin") || givenName[0].ToLower().Equals("am")) )
- {
- name = givenName.Skip(1).Aggregate((s, c) => s + c); // (Skip(1)) don't use the first element; Aggregate: take source s and do operation s = s+c for all elements
- }
- else
- {
- name = givenName.Aggregate((s, c) => s + c);
- }
-
- if (name.ToLower().Equals("man") || name.ToLower().Equals("help"))
- {
- return this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("ich bin") + "\n```");
-
- }
-
- var character = Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(name, x.Name)).First(); // usage of compareEasy
-
- Dsa.Session.Relation[this.Context.User.Username] = character.Name;
- res = " \nWillkommen " + character.Name + "!\n \n";
-
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
- }
-
-
- public class Gm : ModuleBase
- {
- public static string CheckCommand(string name, CommandTypes command, string waffe, int erschwernis = 0)
- {
- var comp = new SpellCorrect();
- var chr = Dsa.Chars.OrderBy(x => comp.Compare(name, x.Name)).First();
-
- switch (command)
- {
- case CommandTypes.Talent:
- return chr.TestTalent(waffe, erschwernis);
- case CommandTypes.Eigenschaft:
- return chr.TestEigenschaft(waffe, erschwernis);
- case CommandTypes.Angriff:
- return chr.Angriff(waffe, erschwernis);
- case CommandTypes.Parade:
- return chr.Parade(waffe, erschwernis);
- case CommandTypes.Fernkampf:
- return chr.Fernkampf(waffe, erschwernis);
- case CommandTypes.Zauber:
- return chr.TestZauber(waffe, erschwernis);
- }
-
- return $"{name} verwendet {waffe}";
- }
-
- //[Command("gm"), Summary("Führt eine probe aus")]
- [Alias("GM", "as", "As", "als")]
- public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string cmdText = "", int modifier = 0)
- {
- if (!Permissions.Test(this.Context, "Meister")) return;
-
- command = command.ToLower();
-
- string res;
- string temp = string.Empty;
- ICharacter cha = Dsa.Chars.OrderBy(x =>
- SpellCorrect.CompareEasy(name, x.Name)).First();
- switch (command)
- {
- case "le":
- case "leben":
- case "lp":
- LE le = new LE();
- temp = string.Empty;
-
- if (modifier != 0)
- {
- temp = modifier.ToString();
- }
-
- res = cha.get_LE_Text(cmdText.Trim() + temp);
-
- break;
- case "ae":
- case "asp":
- case "astral":
- AE ae = new AE();
- temp = string.Empty;
-
- if (modifier != 0)
- {
- temp = modifier.ToString();
- }
-
- res = cha.get_AE_Text(cmdText.Trim() + temp);
-
- break;
- default:
- res = this.Test(name, command, cmdText, modifier);
- break;
- }
-
-
- if (Dsa.GeneralContext != null && Dsa.GeneralContext.Channel.Id != this.Context.Channel.Id)
- {
- await Dsa.GeneralContext.Channel.SendMessageAsync("```xl\n" + res + "\n```");
- }
-
- await this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- private string Test(string name, string command, string waffe, int erschwernis = 0)
- {
- string res;
- switch (command.ToLower())
- {
- case "f":
- case "fern":
- case "fernkampf":
- res = CheckCommand(name, CommandTypes.Fernkampf, waffe, erschwernis);
- break;
- case "t":
- case "ta":
- case "talent":
- case "talente":
- res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
- break;
- case "e":
- case "ei":
- case "eigenschaft":
- res = CheckCommand(name, CommandTypes.Eigenschaft, waffe, erschwernis);
- break;
- case "z":
- case "za":
- case "zauber":
- case "magie":
- case "m":
- res = CheckCommand(name, CommandTypes.Talent, waffe, erschwernis);
- break;
- case "a":
- case "at":
- case "an":
- case "angrif":
- case "angriff":
- res = CheckCommand(name, CommandTypes.Angriff, waffe, erschwernis);
- break;
- case "p":
- case "pa":
- case "parade":
- res = CheckCommand(name, CommandTypes.Parade, waffe, erschwernis);
- break;
- default:
- res = $"Kommando {command} nicht gefunden";
- break;
- }
-
- return res;
- }
- }
-}
diff --git a/DiscoBot/Commands/HeldList.cs b/DiscoBot/Commands/HeldList.cs
deleted file mode 100644
index a8f26e0..0000000
--- a/DiscoBot/Commands/HeldList.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
-
- public class Held : ModuleBase
- {
- //[Command("held"), Summary("gibt Heldenwerte aus")]
- [Alias("Held", "Wert", "Werte", "werte", "char", "Char")]
- public async Task ListAsync([Summary("Werte")] params string[] prop_list)
- {
- var res = new List<string>();
-
- var character = ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])));
-
- int first_column_width = 18;
-
- int persist = 0;
-
- if (prop_list.Length == 0 || prop_list[0].ToLower().StartsWith("all") || prop_list[0].ToLower().StartsWith("brief") || prop_list[0].ToLower().StartsWith("zettel"))
- {
- persist = 1;
-
- res.Add(character.Name + ":\n");
- //Eigenschaften
- res.AddRange(
- character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
- res.Add("");
- //LE/AE
- res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
- if (character.Astralpunkte_Basis > 0)
- {
- res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- }
- res.Add("");
- //Kampfwerte
- res.Add("".AddSpaces(first_column_width) + " AT/PA");
- res.AddRange(
- character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2)));
- res.Add("");
- //Fernkampf
- res.Add("".AddSpaces(first_column_width) + " FK");
- res.AddRange(
- character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
- res.Add("");
- //Vorteile
- res.AddRange(
- character.Vorteile
- .Select(s => s.Name + "\t " + s.Value));
- res.Add("");
- //Talente
- res.AddRange(
- character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
- res.Add("");
- //evtl Zauber
- if (character.Zauber.Count > 0)
- {
- res.AddRange(
- character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
- }
-
- }
- else if (prop_list[0].ToLower().StartsWith("man") || prop_list[0].ToLower().StartsWith("help") || prop_list[0].ToLower().StartsWith("hilf"))
- {
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("Held") + "\n```");
- return;
- }
- else
- {
-
- res.Add(character.Name + ":\n");
-
- foreach (string prop in prop_list)
- {
-
- switch (prop.ToLower())
- {
- case "e":
- case "eig":
- case "eigenschaft":
- case "eigenschaften":
- res.AddRange(
- character.Eigenschaften.Take(8).Select(s => s.Key + ":\t " + s.Value));
- break;
- case "stat":
- case "stats":
- res.AddRange(
- character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
- res.Add("");
- res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
- if (character.Astralpunkte_Basis > 0)
- {
- res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- }
- break;
- case "le":
- res.Add("LE:\t " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
- break;
- case "ae":
- res.Add("AE:\t " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- break;
- case "t":
- case "ta":
- case "talent":
- case "talente":
- res.AddRange(
- character.Talente.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
- break;
- case "zauber":
- case "z":
- res.AddRange(
- character.Zauber.Select(s => (s.Name.AddSpaces(first_column_width) + " " + s.Value).AddSpaces(first_column_width + 5) + " " + s.Probe));
- break;
- case "w":
- case "waffe":
- case "waffen":
- case "kampf":
- case "kampfwert":
- case "kampfwerte":
- res.Add("".AddSpaces(first_column_width) + " AT/PA");
- res.AddRange(
- character.Kampftalente.Select(s => s.Name.AddSpaces(first_column_width) + " " + s.At.ToString().AddSpacesAtHead(2) + "/" + s.Pa.ToString().AddSpacesAtHead(2)));
- break;
- case "f":
- case "fern":
- res.Add("".AddSpaces(first_column_width) + " FK");
- res.AddRange(
- character.Talente.Where(x => x.IstFernkampftalent()).Select(s => s.Name.AddSpaces(first_column_width) + " " + (character.Eigenschaften["fk"] + s.Value).ToString().AddSpacesAtHead(2)));
- break;
- case "v":
- case "vt":
- case "vor":
- case "vorteil":
- case "vorteile":
- case "nachteil":
- case "nachteile":
- res.AddRange(
- character.Vorteile
- .Select(s => s.Name + "\t " + s.Value));
- break;
-
- default:
- res.Add($"Kommando {prop} nicht gefunden");
- break;
- }
-
- res.Add("");
- }
-
- }
-
-
- //var sb = new StringBuilder();
- //foreach (string re in res)
- //{
- // if (sb.Length + re.Length > 1798)
- // {
- // if (persist == 1)
- // {
- // await this.ReplyAsync("```xl\n" + sb.ToString() + "\n```");
- // }
- // else
- // {
- // await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
- // }
- // sb.Clear();
- //}
-
- //sb.AppendLine(re);
- //}
- if (persist == 1)
- {
- await this.ReplyAsync(res, true);
- }
- else
- {
- await this.ReplyAsync(res, TimeSpan.FromSeconds(90));
- }
- }
- }
-}
diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs
deleted file mode 100644
index 4c378c9..0000000
--- a/DiscoBot/Commands/Help.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System.Linq;
-
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Security.Cryptography;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord.Commands;
-
- using Newtonsoft.Json;
-
- using CommandInfo = DiscoBot.Auxiliary.CommandInfo;
-
- public class Help : ModuleBase
- {
- static Help()
- {
- /*TextReader stream = new StreamReader(@"..\..\Help.json"); // Load command-description file
- var reader = new JsonTextReader(stream); // create stream reader
-
- reader.Read(); // step into structure, until the array starts
- reader.Read();
- reader.Read();
-
- try
- {
- var test = new JsonSerializer().Deserialize<List<CommandInfo>>(reader); // Deserialize Data and create CommandInfo Struct
-
- Commands.AddRange(test); // Add new CommandInfos to List
- }
- catch (Exception e)
- {
- // ignored
- }*/
- }
-
- //public static List<CommandInfo> Commands { get; } = new List<CommandInfo>();
-
-
- public static string Get_Specific_Help(string command)
- {
- // return command specific help
- var com = DSA_Game.Save.Properties.CommandInfos.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
- return com.GetDescription();
- }
-
- public static string Get_Generic_Help()
- {
- string res = "";
- foreach (var com in DSA_Game.Save.Properties.CommandInfos)
- {
- int first_column_width = 8;
- res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief;
-
- if (com.Description.Length > 1)
- {
- res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name + "\" gibt genauere Informationen)";
- }
-
- res += "\n\n";
- }
- return res;
- }
-/*
-
- //[Command("help"), Summary("prints the help menu.")]
- [Alias("Help", "man", "Man", "Hilfe", "hilfe", "h")]
- public async Task ShowHelpAsync(params string[] command_list)
- {
- var command = "";
- if (command_list.Length > 0) {
- command = command_list.Aggregate((s, c) => s + " " + c);
- }
-
- if (command.Equals(string.Empty)) // return generic Help
- {
- string res = Get_Generic_Help();
-
- //await this.ReplyAsync("```\n[hilfreiche Erklärungen]\nAuflistung aller Commands mit !list commands\n```");
- await this.ReplyAsync("```xl\n" + res +"\n```");
- return;
- }
-
-
-
- // return command specific help
- //var com = Commands.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
-
- //await this.ReplyAsync("```xl\n" + com.GetDescription() + "\n```");
- await this.ReplyAsync("```xl\n" + Get_Specific_Help(command) + "\n```");
- }*/
- }
-}
diff --git a/DiscoBot/Commands/LebenUndAstral.cs b/DiscoBot/Commands/LebenUndAstral.cs
deleted file mode 100644
index 2406c70..0000000
--- a/DiscoBot/Commands/LebenUndAstral.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
- using DSALib.Characters;
-
- public class LE : ModuleBase
- {
- //[Command("LE"), Summary("Ändert aktuellen Lebenspunktestand")]
- [Alias("le", "leben", "LP", "lp", "Le", "Lp")]
-
- public async Task LEAsync([Summary("LE Modifier")] string prop = "", string s = "")
- {
- //This is the string that will be printed
- string res = "";
-
- if (prop.ToLower().Equals("help") || prop.ToLower().Equals("man"))
- {
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("LE") + "\n```");
- return;
- }
-
- //In case the input is badly formated
- prop = prop.Trim() + s.Trim();
-
-
- //Get the actual text
- res += Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(Dsa.Session.Relation[this.Context.User.Username], x.Name)).First().get_LE_Text(prop);
-
-
- await this.ReplyAsync("```xl\n" + res + "\n```");
- }
- }
-
- public class AE : ModuleBase
- {
- //[Command("AE"), Summary("Ändert aktuellen Astralpunktestand")]
- [Alias("ae", "astral", "ASP", "Asp", "asp", "Astral")]
-
- public async Task AEAsync([Summary("AE Modifier")] string prop = "", string s = "")
- {
- //This is the string that will be printed
- string res = "";
-
- if (prop.ToLower().Equals("help") || prop.ToLower().Equals("man"))
- {
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("AE") + "\n```");
- return;
- }
-
- //Incase the input is badly formated
- prop = prop.Trim() + s.Trim();
-
-
- //Get the actual text
- res += Dsa.Chars.OrderBy(x => SpellCorrect.CompareEasy(Dsa.Session.Relation[this.Context.User.Username], x.Name)).First().get_AE_Text(prop);
-
-
-
- await this.ReplyAsync("```xl\n" + res + "\n```");
- }
- }
-
- public static class StatExtension
- {
- public static string get_LE_Text(this ICharacter c, string prop)
- {
- string res = "";
- var comp = new SpellCorrect();
- var character = c;
-
- res += (character.Name + ":\n");
-
- //If there is actual input we process it
- if (prop.Length > 0)
- {
- res += "LE: ";
- res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis + " -> ";
-
- // Apply a change to current value
- if (prop.StartsWith("+") || prop.StartsWith("-"))
- {
- //Allow overflowing the max
- if (prop.StartsWith("++"))
- {
- character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
- }
- else
- {
- int temp = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop) - character.Lebenspunkte_Basis;
- //Stop from overflow overflow
- if (temp > 0 && prop.StartsWith("+"))
- {
- character.Lebenspunkte_Aktuell = (character.Lebenspunkte_Basis > character.Lebenspunkte_Aktuell) ? character.Lebenspunkte_Basis : character.Lebenspunkte_Aktuell;
- res += " Maximale Lebenspunkte sind erreicht ";
- }
- //Simply apply change
- else
- {
- character.Lebenspunkte_Aktuell = character.Lebenspunkte_Aktuell + Convert.ToInt32(prop);
- }
- }
-
- res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
- }
- else
- {
- // Set to new value regardless of original
- character.Lebenspunkte_Aktuell = Convert.ToInt32(prop);
-
- res += character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis;
- }
- }
- //If no value is passed, the curent value is displayed
- else
- {
- res += ("LE: " + character.Lebenspunkte_Aktuell + "/" + character.Lebenspunkte_Basis);
- }
-
- return res;
- }
- public static string get_AE_Text(this ICharacter c, string prop)
- {
- string res = "";
- var comp = new SpellCorrect();
- var character = c;
-
- res += (character.Name + ":\n");
-
- //If there is actual input we process it
- if (prop.Length > 0)
- {
-
- res += "AE: ";
- res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis + " -> ";
-
- // Apply a change to current value
- if (prop.StartsWith("+") || prop.StartsWith("-"))
- {
- //Allow overflowing the max
- if (prop.StartsWith("++"))
- {
- character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop.Substring(1, prop.Length - 1));
- }
- else
- {
- int temp = character.Astralpunkte_Aktuell + Convert.ToInt32(prop) - character.Astralpunkte_Basis;
- //Stop from overflow overflow
- if (temp > 0 && prop.StartsWith("+"))
- {
- character.Astralpunkte_Aktuell = (character.Astralpunkte_Basis > character.Astralpunkte_Aktuell) ? character.Astralpunkte_Basis : character.Astralpunkte_Aktuell;
- res += " Maximale Astralpunkte sind erreicht ";
- }
- //Simply apply change
- else
- {
- character.Astralpunkte_Aktuell = character.Astralpunkte_Aktuell + Convert.ToInt32(prop);
- }
- }
-
- if (character.Astralpunkte_Aktuell < 0)
- {
- res += "Nicht genügend Astralpunkte! ";
- character.Astralpunkte_Aktuell = 0;
- }
-
- res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
-
- }
- //Set to new value regardless of original
- else
- {
- character.Astralpunkte_Aktuell = Convert.ToInt32(prop);
-
- res += character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis;
- }
- }
- //If no value is passed, the curent value is displayed
- else
- {
- res += ("AE: " + character.Astralpunkte_Aktuell + "/" + character.Astralpunkte_Basis);
- }
-
-
- return res;
- }
- }
-}
-
-
-
diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs
deleted file mode 100644
index e77362e..0000000
--- a/DiscoBot/Commands/List.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
-
- public class List : ModuleBase
- {
- //[Command("list"), Summary("gibt eine Auflistung aus")]
- public async Task ListAsync([Summary("Aktion")] string prop)
- {
- var res = new List<string>();
-
- int persist = 0;
-
- switch (prop.ToLower())
- {
- case "man":
- case "help":
- await this.ReplyAsync("```xl\n" + Help.Get_Specific_Help("List") + "\n```");
- return;
- // break;
- case "chars":
- res.AddRange(Dsa.Chars.Select(x => x.Name));
- break;
- case "commands":
- // res.AddRange(Help.Commands.Select(x => x.Name));
- res.Add(Help.Get_Generic_Help());
- break;
- case "play":
- case "sound":
- case "sounds":
- res.AddRange(
- Enum.GetNames(typeof(Sound)));
- break;
-
- default:
- res.Add($"Kommando {prop} nicht gefunden");
- break;
- }
-
-
- if (persist == 1)
- {
- await this.ReplyAsync(res);
- }
- else
- {
- await this.ReplyAsync(res, TimeSpan.FromSeconds(90));
- }
- }
- }
-}
diff --git a/DiscoBot/Commands/MiscCommands.cs b/DiscoBot/Commands/MiscCommands.cs
index 53bc42c..2bc2fad 100644
--- a/DiscoBot/Commands/MiscCommands.cs
+++ b/DiscoBot/Commands/MiscCommands.cs
@@ -1,153 +1,110 @@
using System;
using System.Collections.Generic;
-using System.Runtime.Remoting.Contexts;
+using System.IO;
+using System.Linq;
using System.Text;
-
+using System.Threading.Tasks;
using DiscoBot.Auxiliary;
-
using Discord;
using Discord.Commands;
-using Discord.WebSocket;
namespace DiscoBot.Commands
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Net.Mime;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game;
-
- using Discord;
- using Discord.Commands;
-
public class MiscCommands : ModuleBase
{
- [Command("r"), Summary("Würfelt ")]
+ [Command("r")]
+ [Summary("Würfelt ")]
[Alias("R", "Roll", "roll", "Würfle")]
- public Task RollAsync([Remainder, Summary("Weapon")] string roll)
+ public Task RollAsync([Remainder] [Summary("Weapon")] string roll)
{
//return this.ReplyAsync("```xl\n" + new Auxiliary.Calculator.StringSolver(roll).Solve() + "\n```");
- return this.ReplyAsync("```xl\n" + RandomMisc.Roll(roll) + "\n```");
- }
-
- [Command("rd"), Summary("Würfel Dennis ")]
- public Task RollDennisAsync([Remainder, Summary("Weapon")] string roll)
- {
- return this.ReplyAsync("```xl\n" + new Auxiliary.Calculator.StringSolver(roll).Solve() + "\n```");
+ return ReplyAsync("```xl\n" + RandomMisc.Roll(roll) + "\n```");
}
- [Command("general"), Summary("Set General ")]
- public Task SetGeneralAsync([Remainder, Summary("Set General")] int i = 0)
- {
- Dsa.GeneralContext = this.Context;
- return this.Context.Channel.SendMessageAsync($"```xl\n Der Dachs hat in '{this.Context.Channel.Name}' ein Zuhause gefunden. Gm Nachrichten werden nun auch in diesem Channel gepostet. \n```");
- }
- [Command("say"), Summary("Echos a message.")]
+ [Command("say")]
+ [Summary("Echos a message.")]
[Alias("s")]
- public Task SayAsync([Remainder, Summary("The text to echo")] string echo)
+ public Task SayAsync([Remainder] [Summary("The text to echo")]
+ string echo)
{
- return this.ReplyAsync(echo);
+ return ReplyAsync(echo);
}
- [Command("liebe"), Summary("Echos a message.")]
+ [Command("liebe")]
+ [Summary("Echos a message.")]
[Alias("Liebe", "<3", "love")]
public async Task LoveAsync()
{
- Random rand = new Random();
- var user = Context.Channel.GetUsersAsync().ToList().Result.ToList().First().Where(x=>x.Status!= UserStatus.Offline).OrderBy(x => rand.Next()).First();
- await this.ReplyAsync(":heart: :heart: :heart: Verteilt die Liebe! :heart: :heart: :heart: \n Besondere Liebe geht an " + user.Username);
+ var rand = new Random();
+ var user = Context.Channel.GetUsersAsync().ToList().Result.ToList().First()
+ .Where(x => x.Status != UserStatus.Offline).OrderBy(x => rand.Next()).First();
+ await ReplyAsync(
+ ":heart: :heart: :heart: Verteilt die Liebe! :heart: :heart: :heart: \n Besondere Liebe geht an " +
+ user.Username);
//await this.ReplyAsync("!liebe");
}
- [Command("maul"), Summary("Echos a message.")]
+ [Command("maul")]
+ [Summary("Echos a message.")]
public Task MaulAsync()
{
- return this.ReplyAsync("Maul...? Du meintest doch sicher Maulwürfe oder? \n:heart: :heart: :heart: \nGanz viel Liebe für Maulwürfe !\n:heart: :heart: :heart:");
-
+ return ReplyAsync(
+ "Maul...? Du meintest doch sicher Maulwürfe oder? \n:heart: :heart: :heart: \nGanz viel Liebe für Maulwürfe !\n:heart: :heart: :heart:");
}
- [Command("report"), Summary("Report a Tweet")]
- public async Task ReportAsync([Remainder, Summary("Link")] string link)
- {
- var content = new System.Net.Http.StringContent(link);
-
- using (HttpClient client = new HttpClient())
- {
- var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
- }
- await this.ReplyAsync($"Dein report wurde hinzugefügt");
- }
-
- [Command("match"), Summary("Tinder.")]
- [Alias("mach","pass", "passt")]
+ [Command("match")]
+ [Summary("Tinder.")]
+ [Alias("mach", "pass", "passt")]
public Task TinderAsync(string s1, string s2)
{
+ var rand = new Random((s1 + s2).GetHashCode());
- var sc = new SpellCorrect();
- var rand = new System.Random((s1+s2).GetHashCode());
-
- var wert = Math.Log10(Math.Floor(1000.0 * (SpellCorrect.CompareExact(s1, s2) + rand.NextDouble() * 10.0)) / 1000.0);
- wert = ((wert * 100.0) < 100.0 ? wert * 100.0 : 100.0 - wert);
+ var wert = Math.Log10(Math.Floor(1000.0 * (SpellCorrect.CompareExact(s1, s2) + rand.NextDouble() * 10.0)) /
+ 1000.0);
+ wert = wert * 100.0 < 100.0 ? wert * 100.0 : 100.0 - wert;
wert = wert < 0 ? -wert : wert;
- return this.ReplyAsync($"Ihr passt zu {Math.Floor(100.0 * wert )/ 100.0}% zusammen");
-
+ return ReplyAsync($"Ihr passt zu {Math.Floor(100.0 * wert) / 100.0}% zusammen");
}
- [Command("reddit"), Summary("Reddit.")]
+ [Command("reddit")]
+ [Summary("Reddit.")]
public Task RedditAsync()
{
- return this.ReplyAsync($"Ein Archiv der Vergangenen Aktionen findet man hier: https://www.reddit.com/r/ReconquistaInternet/");
-
+ return ReplyAsync(
+ "Ein Archiv der Vergangenen Aktionen findet man hier: https://www.reddit.com/r/ReconquistaInternet/");
}
- [Command("compare"), Summary("Echos a message.")]
+ [Command("compare")]
+ [Summary("Echos a message.")]
public async Task KickAsync()
{
//await this.Context.Guild.DownloadUsersAsync();
- var users = Context.Guild.GetUsersAsync(CacheMode.AllowDownload);
+ var users = Context.Guild.GetUsersAsync();
var test = File.ReadAllLines("RG.txt");
await users;
var us = users.Result.Select(x => x.Username);
-
+
var lines = test.Where(x => !x.Equals(string.Empty)).ToList();
-
+
var sc = new SpellCorrect();
var res = new List<string>();
- foreach (string line in lines)
+ foreach (var line in lines)
{
var best = us.OrderBy(user => sc.Compare(user, line)).First();
double fit = sc.Compare(best, line);
- if (fit < SpellCorrect.ErrorThreshold - 20000)
- {
- if (fit.Equals(0))
- {
- res.Add($"@\t{best} !!! => {line}");
- }
- else
- {
- res.Add($"-\t{best} hat Ähnlichkeit mit: {line}");
- }
- }
+ if (!(fit < SpellCorrect.ErrorThreshold - 20000)) continue;
+ res.Add(fit.Equals(0) ? $"@\t{best} !!! => {line}" : $"-\t{best} hat Ähnlichkeit mit: {line}");
}
var sb = new StringBuilder();
- foreach (string re in res)
+ foreach (var re in res)
{
if (sb.Length + re.Length > 1798)
{
@@ -158,47 +115,43 @@ namespace DiscoBot.Commands
sb.AppendLine(re);
}
- if(Permissions.Check(this.Context, new []{"Admin", "Mod"}))
- await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+ if (Permissions.Check(Context, new[] {"Admin", "Mod"}))
+ await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
//await this.ReplyAsync($"{count} Duplikate gefunden");
-
}
- [Command("clear"), Summary("Cleans up messages.")]
+ [Command("clear")]
+ [Summary("Cleans up messages.")]
public async Task DeleteAsync(int count)
{
var messagesAsync = Context.Channel.GetMessagesAsync(count);
- Task.WaitAll(messagesAsync.ToArray());
- var list = messagesAsync.ToEnumerable().ToList();
- var messages = new List<IMessage>();
- foreach (var task in list)
+ if (messagesAsync != null)
{
- messages.AddRange(task.ToList());
- }
+ Task.WaitAll(messagesAsync.ToArray());
+ var list = messagesAsync.ToEnumerable().ToList();
+ var messages = new List<IMessage>();
+ foreach (var task in list) messages.AddRange(task.ToList());
- if (Permissions.Check(Context, new[] { "Admin", "Mod", "Meister" }))
- {
-
- var waiters = new List<Task>();
- foreach (var message in messages)
+ if (Permissions.Check(Context, new[] {"Admin", "Mod", "Meister"}))
{
- waiters.Add((message as IUserMessage).DeleteAsync());
- }
+ var waiters = new List<Task>();
+ foreach (var message in messages) waiters.Add(((IUserMessage) message).DeleteAsync());
- Task.WaitAll(waiters.ToArray());
+ Task.WaitAll(waiters.ToArray());
+ }
}
-
}
- [Command("check"), Summary("Echos a message.")]
+ [Command("check")]
+ [Summary("Echos a message.")]
[Alias("Check")]
public async Task CheckAsync(string quarry)
{
- var perm = new List<string> { "Admin", "Mod", "Privatpolizei" };
+ var perm = new List<string> {"Admin", "Mod", "Privatpolizei"};
- Permissions.Test(this.Context, perm.ToArray());
+ Permissions.Test(Context, perm.ToArray());
var test = File.ReadAllLines("RG.txt");
@@ -210,38 +163,27 @@ namespace DiscoBot.Commands
var fit = sc.Compare(count, quarry);
- string Antwort;
+ string antwort;
- if (fit < SpellCorrect.ErrorThreshold - 20000)
- {
- Antwort= $"```xl\nAuf anderem Server Match gefunden: {count}";
- }
- else
- {
- Antwort = $"```xl\nAuf anderem Server Kein Match gefunden: {quarry}";
- }
+ antwort = fit < SpellCorrect.ErrorThreshold - 20000
+ ? $"```xl\nAuf anderem Server Match gefunden: {count}"
+ : $"```xl\nAuf anderem Server Kein Match gefunden: {quarry}";
- var users = Context.Guild.GetUsersAsync(CacheMode.AllowDownload);
+ var users = Context.Guild.GetUsersAsync();
await users;
var us = users.Result.Select(x => x.Username);
-
+
sc = new SpellCorrect();
count = us.OrderBy(line => sc.Compare(quarry, line)).First();
fit = sc.Compare(count, quarry);
- if (fit < SpellCorrect.ErrorThreshold - 20000)
- {
- Antwort = Antwort + $"\nAuf unserem Server Match gefunden: {count}\n```";
- }
- else
- {
- Antwort = Antwort + $"\nAuf unserem Server Kein Match gefunden: {quarry} \n```";
- }
-
- await ReplyAsync(Antwort);
+ antwort = fit < SpellCorrect.ErrorThreshold - 20000
+ ? $"{antwort}\nAuf unserem Server Match gefunden: {count}\n```"
+ : $"{antwort}\nAuf unserem Server Kein Match gefunden: {quarry} \n```";
+ await ReplyAsync(antwort);
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Commands/NpcCommands.cs b/DiscoBot/Commands/NpcCommands.cs
deleted file mode 100644
index b314494..0000000
--- a/DiscoBot/Commands/NpcCommands.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System;
- using System.Linq;
- using System.Threading.Tasks;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.Characters;
- using DiscoBot.DSA_Game;
- using DiscoBot.DSA_Game.Characters;
-
- using Discord.Commands;
-
- public class NpcCommands : ModuleBase
- {
- //[Command("npc"), Summary("Erstellt ein NPC")]
- [Alias("Npc", "NPc", "NPC", "nPC")]
- public Task RandomAsync([Summary("Create Random")] string npcName, int mean = 9, int stDv = 1)
- {
- Dsa.Chars.Add(new Npc(npcName, mean, stDv));
- return this.ReplyAsync($"{npcName} wurde zufällig generiert");
- }
-
- //[Command("npc"), Summary("Erstellt ein NPC")]
- [Alias("Npc", "NPc", "NPC", "nPC")]
- public Task CopyAsync([Summary("Create Copy")] string npcName, string source, int stDv = 1)
- {
- if (Dsa.Chars.Exists(x => x.Name.Equals(npcName)))
- {
- throw new Exception("Char gibt es schon");
- }
-
- var comp = new SpellCorrect();
- var chr = Dsa.Chars.OrderBy(x => comp.Compare(x.Name, source)).First();
- Dsa.Chars.Add(new Character(chr as Character, npcName, stDv));
- return this.ReplyAsync($"{npcName} wurde als variierte Kopie von {source} erstellt");
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/Commands/ProbenTest.cs b/DiscoBot/Commands/ProbenTest.cs
deleted file mode 100644
index 77a10ad..0000000
--- a/DiscoBot/Commands/ProbenTest.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-namespace DiscoBot.Commands
-{
- using System.Threading.Tasks;
-
- using DiscoBot.DSA_Game;
-
- using Discord.Commands;
-
- public class ProbenTest : ModuleBase
- {
- //[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
- [Alias("T", "Talent", "talent", "versuche")]
- public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)
- {
- string res;
- try
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation[this.Context.User.Username],
- CommandTypes.Talent,
- talent,
- erschwernis);
- }
- catch
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation["Tardis"],
- CommandTypes.Talent,
- talent,
- erschwernis);
- }
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- //[Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
- [Alias("Z", "zauber", "z")]
- public Task ZauberAsync([Summary("Zaubername")] string zauber, int erschwernis = 0)
- {
- string res;
- try
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation[this.Context.User.Username],
- CommandTypes.Zauber,
- zauber,
- erschwernis);
- }
- catch
- {
- res = Gm.CheckCommand(
- Dsa.Session.Relation["Tardis"],
- CommandTypes.Zauber,
- zauber,
- erschwernis);
- }
-
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- //[Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
- [Alias("E", "Eigenschaft", "eigenschaft", "eigen")]
- public Task EigenschaftAsync([Summary("Eigenschaftskürzel und Erschwernis")] string talent, int erschwernis = 0)
- {
- var chr = Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username]));
- string res = chr.TestEigenschaft(talent, erschwernis);
- return this.ReplyAsync("```xl\n" + res + "\n```");
- }
-
- //[Command("a"), Summary("Würfelt ein Angriff")]
- [Alias("A", "At", "at", "Angriff", "angriff", "attackiere_mit", "attacke", "Attacke")]
- public Task AngriffAsync([Summary("Weapon")] string weapon, int erschwernis = 0)
- {
- return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Angriff(weapon, erschwernis) + "\n```");
- }
-
- //[Command("p"), Summary("Würfelt eine Parade Probe")]
- [Alias("P", "Parade", "parade", "pariere_mit")]
- public Task ParadeAsync([Summary("Parade Weapon")] string talent, int erschwernis = 0)
- {
- return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Parade(talent, erschwernis) + "\n```");
- }
-
- //[Command("f"), Summary("Führt eine Fernkampfprobe aus")]
- [Alias("F", "fern", "Fern", "Schuss", "schuss", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
- public Task FernkampfAsync([Summary("Fernkampfwaffe")] string waffe, int erschwernis = 0)
- {
- return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Fernkampf(waffe, erschwernis) + "\n```");
- }
- }
-}
diff --git a/DiscoBot/DSA_Game/Characters/Character.cs b/DiscoBot/DSA_Game/Characters/Character.cs
deleted file mode 100644
index 81c11fc..0000000
--- a/DiscoBot/DSA_Game/Characters/Character.cs
+++ /dev/null
@@ -1,303 +0,0 @@
-using DSALib;
-using DSALib.Characters;
-
-namespace DiscoBot.DSA_Game.Characters
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml;
-
- using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
-
- public class Character : Being, ICharacter
- {
- public Character()
- {
- this.PropTable.Add("MU", "Mut"); // routing
- this.PropTable.Add("KL", "Klugheit");
- this.PropTable.Add("IN", "Intuition");
- this.PropTable.Add("CH", "Charisma");
- this.PropTable.Add("FF", "Fingerfertigkeit");
- this.PropTable.Add("GE", "Gewandtheit");
- this.PropTable.Add("KO", "Konstitution");
- this.PropTable.Add("KK", "Körperkraft");
-
- }
-
- public Character(string path) : this()
- {
- this.Load(path); // load
- this.Post_process(); // calculate derived values
- }
-
- public Character(Character c, string name, int stDv = 2) : this()
- {
- this.Name = name;
- foreach (var i in c.Eigenschaften)
- {
- this.Eigenschaften.Add(i.Key, i.Value + (int)Math.Round(RandomMisc.Random(stDv)));
- }
-
- foreach (var i in c.Vorteile)
- {
- this.Vorteile.Add(new Vorteil(i.Name, i.Value + (int)Math.Round(RandomMisc.Random(stDv))));
- }
-
- foreach (var i in c.Talente)
- {
- this.Talente.Add(new Talent(i.Name, i.Probe, i.Value + (int)Math.Round(RandomMisc.Random(stDv))));
- }
-
- foreach (var i in c.Zauber)
- {
- this.Zauber.Add(new Zauber(i.Name, i.Probe, i.Value + (int)Math.Round(RandomMisc.Random(stDv)), i.Complexity, i.Representation));
- }
-
- foreach (var i in c.Kampftalente)
- {
- this.Kampftalente.Add(new KampfTalent(i.Name, i.At + (int)Math.Round(RandomMisc.Random(stDv)), i.Pa + (int)Math.Round(RandomMisc.Random(stDv))));
- }
-
- this.Post_process(); // calculate derived values
- }
-
- public Dictionary<string, int> Eigenschaften { get; set; } = new Dictionary<string, int>(); // char properties
-
- public List<Talent> Talente { get; set; } = new List<Talent>(); // list of talent objects (talents)
-
- public List<Zauber> Zauber { get; set; } = new List<Zauber>(); // list of spell objects
-
- public List<KampfTalent> Kampftalente { get; set; } = new List<KampfTalent>(); // list of combat objects
-
- public List<Vorteil> Vorteile { get; set; } = new List<Vorteil>();
-
- public Dictionary<string, string> PropTable { get; set; } = new Dictionary<string, string>(); // -> Körperkraft
-
- public string TestTalent(string talent, int erschwernis = 0) // Talentprobe
- {
- return this.Talente.ProbenTest(this, talent, erschwernis);
- }
-
- public string TestZauber(string zauber, int erschwernis = 0) // Talentprobe
- {
- return this.Zauber.ProbenTest(this, zauber, erschwernis);
- }
-
- public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
- {
- var output = new StringBuilder();
- var prop = this.PropTable[eigenschaft.ToUpper()];
- int tap = this.Eigenschaften[prop];
- output.AppendFormat(
- "{0}-Eigenschaftsprobe ew:{1} {2} \n",
- prop,
- tap,
- erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
- int roll = Dice.Roll();
- output.Append($"Gewürfelt: {roll} übrig: {tap - roll - erschwernis}");
- return output.ToString();
- }
-
- public string Angriff(string talent, int erschwernis = 0) // pretty self explanatory
- {
- var output = new StringBuilder();
- var sc = new SpellCorrect();
- var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
- if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
- {
- try
- {
- SoundEffects.Play("Wrong");
- }
- catch { }
-
- return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
- }
-
- int tap = attack.At;
- output.AppendFormat(
- "{0}-Angriff taw:{1} {2} \n",
- attack.Name,
- tap,
- erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
-
- int temp = Dice.Roll();
- output.Append(temp - erschwernis);
- return output.ToString();
- }
-
- public string Parade(string talent, int erschwernis = 0)
- {
- var output = new StringBuilder();
- var sc = new SpellCorrect();
- var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
-
- if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
- {
- try
- {
- SoundEffects.Play("Wrong");
- }
- catch { }
- return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
- }
-
- int tap = attack.Pa;
- output.AppendFormat(
- "{0}-Parade taw:{1} {2}\n",
- attack.Name,
- tap,
- erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
-
- int temp = Dice.Roll();
- output.Append(temp - erschwernis);
- return output.ToString();
- }
-
- public string Fernkampf(string talent, int erschwernis = 0)
- {
- var output = new StringBuilder();
- var sc = new SpellCorrect();
- int fk = this.Eigenschaften["fk"];
- var attack = this.Talente.OrderBy(x => sc.Compare(talent, x.Name)).First();
- if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
- {
- try
- {
- SoundEffects.Play("Wrong");
- }
- catch { }
- return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
- }
-
- int tap = attack.Value;
- output.AppendFormat(
- "{0} taw:{1} {2} \n",
- attack.Name,
- tap,
- erschwernis.Equals(0) ? string.Empty : "Erschwernis: " + erschwernis);
- tap -= erschwernis;
- int temp = Dice.Roll();
- tap -= temp > fk ? temp - fk : 0;
- output.Append($"W20: {temp} tap: {tap}");
- return output.ToString();
- }
-
- private void Post_process()
- {
- var LE_Wert = this.Eigenschaften["Lebensenergie"];
- var AE_Wert = this.Eigenschaften.First(s => s.Key.Contains("Astralenergie")).Value;
-
- //var KL_Wert = this.Eigenschaften.First(s => s.Key.Contains("Klugheit")).Value;
- var MU_Wert = this.Eigenschaften.First(s => s.Key.Contains("Mut")).Value;
- var IN_Wert = this.Eigenschaften.First(s => s.Key.Contains("Intuition")).Value;
- var CH_Wert = this.Eigenschaften.First(s => s.Key.Contains("Charisma")).Value;
- var KK_Wert = this.Eigenschaften["Körperkraft"];
- var KO__Wert = this.Eigenschaften["Konstitution"];
-
- this.Astralpunkte_Basis = 0;
-
- this.Ausdauer_Basis = 0;
-
- this.Lebenspunkte_Basis = LE_Wert + (int)(KO__Wert + (KK_Wert / 2.0) + 0.5);
-
- if (this.Vorteile.Exists(x => x.Name.ToLower().Contains("zauberer")))
- {
- this.Astralpunkte_Basis = AE_Wert + (int)((MU_Wert + IN_Wert + CH_Wert) / 2.0 + 0.5);
- }
-
- this.Lebenspunkte_Aktuell = this.Lebenspunkte_Basis;
- this.Astralpunkte_Aktuell = this.Astralpunkte_Basis;
- this.Ausdauer_Aktuell = this.Ausdauer_Basis;
-
- }
-
-
- private void Load(string path)
- {
- var reader = new XmlTextReader(path);
- while (reader.Read())
- {
- // read until he hits keywords
- if (reader.NodeType != XmlNodeType.Element)
- {
- continue;
- }
-
- switch (reader.Name)
- {
- case "Wesen":
- reader.Skip();
- break;
- case "held":
- this.Name = reader.GetAttribute("name"); // name
- break;
- case "eigenschaft":
- this.Eigenschaften.Add(
- reader.GetAttribute("name") ?? throw new InvalidOperationException(),
- Convert.ToInt32(reader.GetAttribute("value")) + Convert.ToInt32(reader.GetAttribute("mod")));
- break;
- case "vt":
- reader.Read();
- while (reader.Name.Equals("vorteil"))
- {
- try
- {
- this.Vorteile.Add(new Vorteil(
- reader.GetAttribute("name"),
- // Convert.ToInt32(reader.GetAttribute("value"))));
- reader.GetAttribute("value")));
- }
- catch
- {
- this.Vorteile.Add(new Vorteil(reader.GetAttribute("name")));
- }
-
- reader.Read();
- }
-
- break;
- case "talentliste":
- reader.Read();
- while (reader.Name.Equals("talent"))
- {
- this.Talente.Add(
- new Talent(
- reader.GetAttribute("name"),
- reader.GetAttribute("probe")?.Remove(0, 2).Trim(')'),
- Convert.ToInt32(reader.GetAttribute("value"))));
- reader.Read();
- }
-
- break;
- case "zauberliste":
- reader.Read();
- while (reader.Name.Equals("zauber"))
- {
- this.Zauber.Add(
- new Zauber(
- reader.GetAttribute("name"),
- reader.GetAttribute("probe")?.Remove(0, 2).Trim(')'),
- Convert.ToInt32(reader.GetAttribute("value")),
- reader.GetAttribute("k").ToCharArray()[0],
- reader.GetAttribute("repraesentation")));
- reader.Read();
- }
-
- break;
- case "kampfwerte":
- string atName = reader.GetAttribute("name");
- reader.Read();
- int at = Convert.ToInt32(reader.GetAttribute("value"));
- reader.Read();
- int pa = Convert.ToInt32(reader.GetAttribute("value"));
- this.Kampftalente.Add(new KampfTalent(atName, at, pa));
- break;
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/DSA_Game/Characters/NPC.cs b/DiscoBot/DSA_Game/Characters/NPC.cs
deleted file mode 100644
index b1b8e82..0000000
--- a/DiscoBot/DSA_Game/Characters/NPC.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-namespace DiscoBot.Characters
-{
- using System;
-
- using DiscoBot.Auxiliary;
- using DiscoBot.DSA_Game.Characters;
- using DSALib.Characters;
-
- public class Npc : Being, ICharacter
- {
- private readonly int mean, stDv;
-
- public Npc(string name, int mean, int stDv)
- {
- this.mean = mean;
- this.stDv = stDv;
- this.Name = name;
- }
-
- public string TestTalent(string talent, int tap = 3)
- {
- for (int i = 0; i <= 2; i++)
- {
- // foreach property, dice and tap
- int temp = Dice.Roll();
- int eigenschaft = (int)Math.Round(RandomMisc.Random(this.stDv, this.mean));
-
- if (eigenschaft < temp)
- {
- tap -= temp - eigenschaft;
- }
- }
-
- if (tap >= 0)
- {
- return $"{this.Name} vollführt {talent} erfolgreich";
- }
-
-
- return $"{this.Name} scheitert an {talent}";
- }
-
- public string TestEigenschaft(string eigenschaft, int erschwernis = 0)
- {
- int temp = Dice.Roll();
- int prop = (int)Math.Round(RandomMisc.Random(this.stDv, this.stDv));
-
- if (temp + erschwernis < prop)
- {
- return $"{this.Name} vollführt {eigenschaft} erfolgreich";
- }
-
- return $"{this.Name} scheitert an {eigenschaft}";
- }
-
- public string Angriff(string waffe, int erschwernis = 0)
- {
- int temp = Dice.Roll();
-
- if (temp == 1)
- {
- return $"{this.Name} greift kritisch mit {waffe} an";
- }
-
- if (temp < erschwernis)
- {
- return $"{this.Name} greift mit {waffe} an";
- }
-
- return $"{this.Name} haut mit {waffe} daneben";
- }
-
- public string Parade(string waffe, int erschwernis = 0)
- {
- int temp = Dice.Roll();
-
- if (temp == 1)
- {
- return $"{this.Name} pariert mit {waffe} meisterlich";
- }
-
- if (temp < erschwernis)
- {
- return $"{this.Name} pariert mit {waffe} an";
- }
-
- return $"{this.Name} schafft es nicht mit {waffe} zu parieren";
- }
-
- public string Fernkampf(string waffe, int erschwernis = 0)
- {
- int temp = Dice.Roll();
-
- if (temp == 1)
- {
- return $"{this.Name} trifft kritisch mit {waffe}";
- }
-
- if (temp < erschwernis)
- {
- return $"{this.Name} greift mit {waffe} an";
- }
-
- return $"{this.Name} schießt mit {waffe} daneben";
- }
-
- public string TestZauber(string zauber, int erschwernis)
- {
- return TestTalent(zauber, erschwernis);
- }
- }
-}
diff --git a/DiscoBot/DSA_Game/Characters/SaveChar.cs b/DiscoBot/DSA_Game/Characters/SaveChar.cs
deleted file mode 100644
index 272f516..0000000
--- a/DiscoBot/DSA_Game/Characters/SaveChar.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.DSA_Game.Characters
-{
- using Discord;
- using DSALib.Characters;
-
- public class SaveChar
- {
- public string Name { get; set; }
-
- public int Lebenspunkte_Aktuell { get; set; }
-
- public int Ausdauer_Aktuell { get; set; }
-
- public int Astralpunkte_Aktuell { get; set; }
-
- public static SaveChar FromICharacter(ICharacter c)
- {
- return new SaveChar
- {
- Astralpunkte_Aktuell = c.Astralpunkte_Aktuell,
- Ausdauer_Aktuell = c.Ausdauer_Aktuell,
- Lebenspunkte_Aktuell = c.Lebenspunkte_Aktuell,
- Name = c.Name
- };
- }
- }
-
-
- public static class ICharExtension
- {
- public static void Update(this ICharacter c, SaveChar s)
- {
- c.Astralpunkte_Aktuell = s.Astralpunkte_Aktuell;
- c.Ausdauer_Aktuell = s.Ausdauer_Aktuell;
- c.Lebenspunkte_Aktuell = s.Lebenspunkte_Aktuell;
- c.Name = s.Name;
- }
- }
-}
diff --git a/DiscoBot/DSA_Game/Dsa.cs b/DiscoBot/DSA_Game/Dsa.cs
deleted file mode 100644
index fd60c9a..0000000
--- a/DiscoBot/DSA_Game/Dsa.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using DSALib;
-using DSALib.Characters;
-
-namespace DiscoBot.DSA_Game
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
-
- using DiscoBot.Audio;
- using DiscoBot.Commands;
- using DiscoBot.DSA_Game.Characters;
- using DiscoBot.DSA_Game.Save;
-
- using Discord.Commands;
-
- public static class Dsa
- {
- private static Session s_session;
-
- public static ICommandContext GeneralContext { get; set; }
-
- public static AudioService Service { get; set; }
-
- public static List<ICharacter> Chars { get; set; } = new List<ICharacter>(); // list of all characters
-
- public static List<Talent> Talente { get; set; } = new List<Talent>();
-
- public static Session Session
- {
- get
- {
- s_session.Chars = Chars.Select(x => SaveChar.FromICharacter(x)).ToList();
- return s_session;
- }
-
- set
- {
- s_session = value;
- foreach (var x in value.Chars)
- {
- Chars.Find(c => c.Name.Equals(x.Name)).Update(x);
- }
- }
- }
-
- public static void Startup()
- {
- //new DiscoBot.Auxiliary.Calculator.StringSolver("1d100 - (1d200 + 1) * -50000").Solve();
- /*Session = new Session();*/
- // relation.Add("Papo", "Pump aus der Gosse");
- foreach (var filename in Directory.GetFiles("helden", "*.xml"))
- {
- Chars.Add(new Character(filename));
- (Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0))
- .Where(c => !Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Talente.Add(v));
- }
-
- Properties.Deserialize();
- Properties.Serialize();
-
- Talente = Talente.OrderBy(x => x.Name).ToList();
- Session = new Session
- {
- Chars = Chars.Select(x => SaveChar.FromICharacter(x)).ToList(),
- GeneralContext = GeneralContext
- };
- Session.Save();
- }
- }
-} \ No newline at end of file
diff --git a/DiscoBot/DSA_Game/Save/Properties.cs b/DiscoBot/DSA_Game/Save/Properties.cs
deleted file mode 100644
index 67d30b0..0000000
--- a/DiscoBot/DSA_Game/Save/Properties.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.DSA_Game.Save
-{
- using System.Collections;
- using System.IO;
- using System.Reflection;
- using System.Runtime.CompilerServices;
-
- using DiscoBot.Audio;
- using DiscoBot.Auxiliary;
- using DiscoBot.Commands;
-
- using Discord;
-
- using Newtonsoft.Json;
-
- public static class Properties
- {
- private static Dictionary<string, object> objects;
-
- static Properties()
- {
- objects = new Dictionary<string, object>();
- /*this.objects.Add("Sounds", new List<Sound>());
- this.objects.Add("CommandInfos", new List<CommandInfo>());*/
- }
-
- public static List<CommandInfo> CommandInfos { get => objects["CommandInfo"] as List<CommandInfo>; set => objects["CommandInfo"] = value; } // use Properties.Commandinfos to access the abstract Object array
-
- public static List<Sound> Sounds { get => objects["Sound"] as List<Sound>; set => objects["Sound"] = value; }
-
- public static void Deserialize(string path = @"..\..\Properties")
- {
-
- var files = Directory.GetFiles(path, "*.json");
-
- foreach (string file in files)
- {
- try
- {
- string name = file.Split('\\').Last().Split('.')[0].Replace('-', '.');
- string data = File.ReadAllText(file);
- Type type = Type.GetType(name);
- if (data.StartsWith("["))
- {
- type = typeof(List<>).MakeGenericType(type);
- }
-
- var o = JsonConvert.DeserializeObject(data, type);
- objects.Add(name.Split('.').Last(), o);
- }
- catch (Exception e)
- {
- // ignored
- var log = new LogMessage(LogSeverity.Warning, "Properties", $"Laden von Save-File {file} fehlgeschlagen.", e);
- Console.WriteLine(log);
- }
-
- }
-
- }
-
- public static void Serialize(string path = @"..\..\Properties\")
- {
- try
- {
- foreach (var o in objects)
- {
- string assembly = o.Value is IList list ? ((IList)list)[0]?.GetType().FullName : o.Value.GetType().FullName;
-
- var name = path + assembly.Replace('.', '-') + ".json";
- File.WriteAllText(name, JsonConvert.SerializeObject(o.Value, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
- }
- }
- catch (Exception e)
- {
- // ignored
- var log = new LogMessage(LogSeverity.Warning, "Properties", $"Speichern von Save-File fehlgeschlagen.", e);
- Console.WriteLine(log);
- }
- }
- }
-}
diff --git a/DiscoBot/DSA_Game/Save/SaveCommand.cs b/DiscoBot/DSA_Game/Save/SaveCommand.cs
deleted file mode 100644
index 1f160ec..0000000
--- a/DiscoBot/DSA_Game/Save/SaveCommand.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.DSA_Game.Save
-{
- using System.Diagnostics;
- using System.IO;
- using System.Net;
- using System.Net.Http;
-
- using DiscoBot.Auxiliary;
-
- using Discord.Commands;
-
- public class SaveCommand : ModuleBase
- {
- [Command("load"), Summary("Load Session")]
- [Alias("session")]
- public async Task LoadSessionAsync([Remainder, Summary("Session Name")] string name = "")
- {
- if (name.Equals("?") || name.Equals(string.Empty))
- {
- await this.ReplyAsync($"Gespeicherte Sessions:");
- await this.ReplyAsync(this.ListSessions());
- return;
- }
-
- var path = DSA_Game.Save.Session.DirectoryPath + @"\" + name;
-
- var files = Directory.GetFiles(path);
- var session = files.OrderByDescending(x => Convert.ToInt32(x.Split('-').Last().Split('.').First())).First();
- Dsa.Session = Session.Load(session);
-
- await this.ReplyAsync($"{name} wurde geladen");
- }
-
- [Command("save", RunMode = RunMode.Async), Summary("Save Session")]
- public async Task SessionSaveAsync([Remainder, Summary("Session Name")] string name = "")
- {
- //var sendFile = this.Context.Channel.SendWebFile("https://cdn.discordapp.com/attachments/377123019673567232/465615882048110603/giphy.gif");
-
- if (name.Equals("?") || name.Equals(string.Empty))
- {
- await this.ReplyAsync($"Gespeicherte Sessions:");
- await this.ReplyAsync(this.ListSessions());
- return;
- }
-
- var path = DSA_Game.Save.Session.DirectoryPath + @"\" + name;
- if (Directory.Exists(path))
- {
- var files = Directory.GetFiles(path);
- int current = files.Max(x => Convert.ToInt32(x.Split('-').Last().Split('.').First()));
- Dsa.Session.SessionName = name;
- Dsa.Session.Save(path + "\\" + name + $"-{++current}.json");
- }
- else
- {
- Directory.CreateDirectory(path);
- Dsa.Session.SessionName = name;
- Dsa.Session.Save(path + "\\" + name + $"-0.json");
- }
-
- await this.ReplyAsync($"{name} wurde gespeichert");
- //await sendFile;
- }
-
- private string[] ListSessions()
- {
- string[] dirs = Directory.GetDirectories(Session.DirectoryPath).OrderByDescending(x => new DirectoryInfo(x).LastAccessTime.Ticks).ToArray();
- for (int i = 0; i < dirs.Length; i++)
- {
- dirs[i] += "; " + new DirectoryInfo(dirs[i]).LastAccessTime;
- }
-
- return dirs;
- }
- }
-}
diff --git a/DiscoBot/DSA_Game/Save/Session.cs b/DiscoBot/DSA_Game/Save/Session.cs
deleted file mode 100644
index 578fa50..0000000
--- a/DiscoBot/DSA_Game/Save/Session.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.DSA_Game.Save
-{
- using System.IO;
- using System.Runtime.CompilerServices;
-
- using DiscoBot.DSA_Game.Characters;
-
- using Discord;
- using Discord.Commands;
-
- using Newtonsoft.Json;
-
- public class Session
- {
- public static string DirectoryPath { get; set; } = @"..\..\sessions";
-
- public ICommandContext GeneralContext { get; set; }
-
- public Dictionary<string, string> Relation { get; set; } = new Dictionary<string, string>(); // dictionary to match the char
-
- public List<SaveChar> Chars { get; set; } = new List<SaveChar>(); // list of all characters
-
- public string SessionName { get; set; }
-
- public static Session Load(string path = @"..\..\session.json")
- {
- try
- {
- return JsonConvert.DeserializeObject<Session>(File.ReadAllText(path)); // Deserialize Data and create Session Object
- }
- catch (Exception e)
- {
- // ignored
- var log = new LogMessage(LogSeverity.Warning, "Properties", $"Laden von Save-File {path} fehlgeschlagen.", e);
- Console.WriteLine(log);
- return null;
- }
- }
-
- public void Save(string path = @"..\..\session.json")
- {
- try
- {
- File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
- }
- catch (Exception e)
- {
- var log = new LogMessage(LogSeverity.Warning, "Properties", $"Speichern von Save-File {path} fehlgeschlagen.", e);
- Console.WriteLine(log);
- // ignored
- }
- }
- }
-}
diff --git a/DiscoBot/DiscoBot.csproj b/DiscoBot/DiscoBot.csproj
index d25a5e9..28f81a8 100644
--- a/DiscoBot/DiscoBot.csproj
+++ b/DiscoBot/DiscoBot.csproj
@@ -97,38 +97,14 @@
<Compile Include="Audio\AudioModule.cs" />
<Compile Include="Audio\AudioService.cs" />
<Compile Include="Audio\Sound.cs" />
- <Compile Include="Auxiliary\Calculator\Argument.cs" />
- <Compile Include="Auxiliary\Calculator\ISolvable.cs" />
- <Compile Include="Auxiliary\Calculator\Operator.cs" />
- <Compile Include="Auxiliary\Calculator\Ops.cs" />
- <Compile Include="Auxiliary\Calculator\StringSolver.cs" />
- <Compile Include="Auxiliary\CommandInfo.cs" />
- <Compile Include="Auxiliary\Extensions.cs" />
- <Compile Include="DSA_Game\Characters\Character.cs" />
- <Compile Include="DSA_Game\Characters\NPC.cs" />
- <Compile Include="DSA_Game\Characters\SaveChar.cs" />
- <Compile Include="Commands\Help.cs" />
+ <Compile Include="Auxiliary\CommandExtension.cs" />
<Compile Include="Auxiliary\Dice.cs" />
- <Compile Include="Auxiliary\TalentEnumerableExtension.cs" />
- <Compile Include="Commands\LebenUndAstral.cs" />
- <Compile Include="Commands\HeldList.cs" />
- <Compile Include="Audio\Soundeffects.cs" />
- <Compile Include="ToRework\Permissions.cs" />
+ <Compile Include="Auxiliary\Permissions.cs" />
<Compile Include="Commands\MiscCommands.cs" />
<Compile Include="Auxiliary\SpellCorrect.cs" />
- <Compile Include="DSA_Game\Save\Properties.cs" />
- <Compile Include="DSA_Game\Save\SaveCommand.cs" />
- <Compile Include="DSA_Game\Save\Session.cs" />
- <Compile Include="ToRework\CommandExtension.cs" />
- <Compile Include="Commands\CommandTypes.cs" />
<Compile Include="Commands\FileHandler.cs" />
- <Compile Include="Commands\Gm.cs" />
- <Compile Include="Commands\List.cs" />
- <Compile Include="Commands\NpcCommands.cs" />
- <Compile Include="Commands\ProbenTest.cs" />
<Compile Include="Audio\Voice.cs" />
<Compile Include="Auxiliary\RandomMisc.cs" />
- <Compile Include="DSA_Game\Dsa.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
@@ -152,6 +128,9 @@
<Name>DSALib</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="ToRework" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
diff --git a/DiscoBot/Program.cs b/DiscoBot/Program.cs
index 5dc69c1..6ddac5d 100644
--- a/DiscoBot/Program.cs
+++ b/DiscoBot/Program.cs
@@ -1,123 +1,105 @@
using System;
+using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
-
+using DiscoBot.Audio;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
-using Microsoft.Extensions.DependencyInjection;
-
namespace DiscoBot
{
- using System.IO;
-
- using DiscoBot.Audio;
- using DiscoBot.DSA_Game;
-
public class Program
{
- private CommandService commands;
private DiscordSocketClient client;
+ private CommandService commands;
private IServiceProvider services;
- public static void Main(string[] args) => new Program().StartAsync().GetAwaiter().GetResult();
+ public static void Main(string[] args)
+ {
+ new Program().StartAsync().GetAwaiter().GetResult();
+ }
public async Task StartAsync()
{
- Dsa.Startup();
-
- this.client = new DiscordSocketClient();
- this.commands = new CommandService();
-
+ client = new DiscordSocketClient();
+ commands = new CommandService();
- string token = File.ReadAllText("Token");
+ var token = File.ReadAllText("Token");
//Properties.Settings.Default.Token;
-
+
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
- await this.InstallCommandsAsync();
+ await InstallCommandsAsync();
+
+ await client.LoginAsync(TokenType.Bot, token);
+ await client.StartAsync();
- await this.client.LoginAsync(TokenType.Bot, token);
- await this.client.StartAsync();
-
await Task.Delay(-1);
}
public Task InstallCommandsAsync()
{
// Hook the MessageReceived Event into our Command Handler
- this.client.MessageReceived += this.HandleCommandAsync;
-
+ client.MessageReceived += HandleCommandAsync;
+
// Discover all of the commands in this assembly and load them.
- return this.commands.AddModulesAsync(Assembly.GetEntryAssembly());
+ return commands.AddModulesAsync(Assembly.GetEntryAssembly());
}
public async Task HandleCommandAsync(SocketMessage messageParam)
{
// Don't process the command if it was a System Message
- if (!(messageParam is SocketUserMessage message))
- {
- return;
- }
+ if (!(messageParam is SocketUserMessage message)) return;
// Create a number to track where the prefix ends and the command begins
- int argPos = 0;
+ var argPos = 0;
// Determine if the message is a command, based on if it starts with '!' or a mention prefix
- if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(this.client.CurrentUser, ref argPos)))
- {
- return;
- }
+ if (!(message.HasCharPrefix('!', ref argPos) ||
+ message.HasMentionPrefix(client.CurrentUser, ref argPos))) return;
+
-
// Create a Command Context
- var context = new CommandContext(this.client, message);
-
+ var context = new CommandContext(client, message);
+
// Execute the command. (result does not indicate a return value,
// rather an object stating if the command executed successfully)
- var result = await this.commands.ExecuteAsync(context, argPos, this.services);
+ var result = await commands.ExecuteAsync(context, argPos, services);
if (result.Error == CommandError.UnknownCommand)
- {
- await context.Channel.SendMessageAsync(SendCommand(message.Author.Username, message.Content, "https://localhost:44365/api/Commands"));
- }
- else if (!result.IsSuccess)
- {
- await context.Channel.SendMessageAsync(result.ErrorReason);
- }
+ await context.Channel.SendMessageAsync(SendCommand(message.Author.Username, message.Content,
+ "https://kobert.dev/api/dsa/commands"));
+ else if (!result.IsSuccess) await context.Channel.SendMessageAsync(result.ErrorReason);
}
- private string SendCommand(string name, string command, string url)
+ private static string SendCommand(string name, string command, string url)
{
- var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
+ var httpWebRequest = (HttpWebRequest) WebRequest.Create(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
- command = command.Remove(0,1);
- var args = command.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);
+ command = command.Remove(0, 1);
+ var args = command.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
+
+ var content = string.Empty;
+ if (args.Length > 1) content = "\"" + args.Skip(1).Aggregate((s, n) => s + "\", \"" + n) + "\"";
- string content = string.Empty;
- if (args.Length > 1)
- {
- content = "\"" + args.Skip(1).Aggregate((s, n) => ( s + "\", \"" + n)) + "\"";
- }
+ var json = "{\"Name\":\"" + name + "\"," +
+ "\"CmdIdentifier\":\"" + args.First() + "\"," +
+ "\"CmdTexts\": [" + content + "] }";
- string json = "{\"Name\":\"" + name + "\"," +
- "\"CmdIdentifier\":\"" + args.First() + "\"," +
- "\"CmdTexts\": ["+ content+"] }";
-
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
- var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
+ var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
return streamReader.ReadToEnd();
@@ -130,4 +112,4 @@ namespace DiscoBot
Voice.Client.StopAsync();
}
}
-}
+} \ No newline at end of file
diff --git a/DiscoBot/Properties/AssemblyInfo.cs b/DiscoBot/Properties/AssemblyInfo.cs
index 1ff6b8f..b0c2901 100644
--- a/DiscoBot/Properties/AssemblyInfo.cs
+++ b/DiscoBot/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
@@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/DiscoBot/ToRework/Permissions.cs b/DiscoBot/ToRework/Permissions.cs
deleted file mode 100644
index 4d73146..0000000
--- a/DiscoBot/ToRework/Permissions.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.Auxiliary
-{
- using Discord.Commands;
- using Discord.WebSocket;
-
- public static class Permissions
- {
- public static bool Check(ICommandContext c, string role)
- {
- return ((SocketGuildUser)c.User).Roles.ToList().Exists(v => v.Name.Equals(role));
- }
-
- public static bool Check(ICommandContext c, string[] roles)
- {
- return roles.Any(role => ((SocketGuildUser)c.User).Roles.ToList().Exists(v => v.Name.Equals(role)));
- }
-
- public static bool Test(ICommandContext c, string role)
- {
- if (!Check(c, role))
- {
- c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
- return false;
- }
-
- return true;
- }
-
- public static void Test(ICommandContext c, string[] roles)
- {
- if (!Check(c, roles))
- {
- c.Channel.SendMessageAsync("```xl\n Keine ausreichenden Berechtigungen\n```").Wait();
- }
- }
- }
-}