summaryrefslogtreecommitdiff
path: root/dsa/DSALib/Characters/Critter.cs
blob: dcedccba1df5b5da26cd960ede77c81594317b65 (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
using System;
using System.Collections.Generic;
using System.IO;
using DiscoBot.DSA_Game.Characters;
using DSALib.Models.Dsa;
using Newtonsoft.Json;

namespace DSALib.Characters
{
    public class Critter : Being, ICombatant
    {
        public CritterAttack lastAttack;

        public Critter(int gw, int gs, int rs, int mr, int ko, int pa, string ini, List<CritterAttack> critterAttacks)
        {
            Gw = gw;
            Gs = gs;
            Rs = rs;
            Mr = mr;
            Ko = ko;
            Pa = pa;
            Ini = ini;
            CritterAttacks = critterAttacks;
            lastAttack = CritterAttacks[new Random().Next(critterAttacks.Count)];
        }

        public Critter()
        {
        }

        public int Rs { get; set; }

        public int Mr { get; set; }

        public int Ko { get; set; }

        public int Pa { get; set; }

        public int Gs { get; set; }

        public int Gw { get; set; }

        public string Ini { get; set; }

        public string Comment { get; set; }

        public List<CritterAttack> CritterAttacks { get; set; }

        public string Angriff(string talent, int erschwernis = 0)
        {
            throw new NotImplementedException();
        }

        public string Parade(string talent, int erschwernis = 0)
        {
            throw new NotImplementedException();
        }

        public static Critter Load(string path)
        {
            try
            {
                return
                    JsonConvert.DeserializeObject<Critter>(
                        File.ReadAllText(path)); // Deserialize Data and create Session Object
            }
            catch (Exception e)
            {
                Console.WriteLine($"Laden von Save-File {path} fehlgeschlagen." + e);
                return null;
            }
        }

        public void Save(string path = @"..\..\Critters\")
        {
            try
            {
                File.WriteAllText(path + Name + ".json",
                    JsonConvert.SerializeObject(this,
                        Formatting.Indented)); // Deserialize Data and create CommandInfo Struct
            }
            catch (Exception e)
            {
                Console.WriteLine($"Speichern von Save-File {path} fehlgeschlagen." + e);
            }
        }
    }
}