summaryrefslogtreecommitdiff
path: root/DiscoBot/Commands/List.cs
blob: 601178c5f854d7a3afed31eab15b012c236184d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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>();

            var character = ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])));


            switch (prop.ToLower())
            {
                case "chars":
                case "Chars":
                    res.AddRange(Dsa.Chars.Select(x => x.Name));
                    break;
                case "e":
                case "eig":
                case "eigenschaft":
                case "eigenschaften":
                case "stat":
                case "stats":
                    res.Add(character.Name + ":");
                    res.AddRange(
                    //character.Eigenschaften.Select(s => s.Key + ":\t " + s.Value));
                    character.Eigenschaften.Take(9).Select(s => s.Key + ":\t " + s.Value));
                    res.Add("LE:\t " + character.Lebenspunkte);
                    break;
                case "t":
                case "ta":
                case "talent":
                case "zauber":
                    res.Add(character.Name + ":");
                    res.AddRange(
                        character.Talente.Select(s => s.Name + "\t " + s.Value + "\t " + s.Probe));
                    break;
                case "w":
                case "waffe":
                case "waffen":
                    res.Add(character.Name + ":");
                    res.AddRange(
                        character.Kampftalente.Select(s => s.Name));
                    break;
                case "fern":
                    res.Add(character.Name + ":");
                    res.AddRange(
                        character.Talente.Select(s => s.Name));
                    break;
                case "sound":
                case "sounds":
                    res.AddRange(
                        Enum.GetNames(typeof(Sound)));
                    break;
                case "v":
                case "vt":
                case "vor":
                case "vorteil":
                    res.Add(character.Name + ":");
                    res.AddRange(
                        character.Vorteile
                        .Select(s => s.Name + "\t " + s.Value));// (s.Value == 0 ? string.Empty : s.Value.ToString())));
                    break;

                default:
                    res.Add($"Kommando {prop} nicht gefunden");
                    break;
            }
            
            var sb = new StringBuilder();
            foreach (string re in res)
            {
                if (sb.Length + re.Length > 1798)
                {
                    await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
                    sb.Clear();
                }

                sb.AppendLine(re);
            }

            await this.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
        }
    }
}