Esempio n. 1
0
 public static void Log(LogLevel logLevel, DSAError error, [CallerMemberName] string callerMemberName = "", [CallerFilePath] string CallerFilePath = "", [CallerLineNumber] int callerLineNumber = 0)
 {
     if (error != null)
     {
         LogStrings.LogString(logLevel, error, callerMemberName, CallerFilePath, callerLineNumber);
     }
 }
Esempio n. 2
0
        private void TalentMissing(JSONCharakter json_charakter, Guid guid)
        {
            var talent = json_charakter.TalentGuidsNames.Where(x => x.Key == guid).FirstOrDefault();

            LogStrings.LogString(LogLevel.ErrorLog, "Talent Fehlt: " + talent.Key + " " + talent.Value);
        }
Esempio n. 3
0
        public void Load(JSONCharakter jsonCharakter, List <ITalent> talentListe)
        {
            #region Nullprüfungen
            if (jsonCharakter == null)
            {
                throw new ArgumentNullException(nameof(jsonCharakter));
            }
            else if (talentListe == null)
            {
                throw new ArgumentNullException(nameof(talentListe));
            }
            if (jsonCharakter.MotherLanguages == null)
            {
                jsonCharakter.MotherLanguages = new Dictionary <Guid, bool>();
            }
            if (jsonCharakter.DeductionTalent == null)
            {
                jsonCharakter.DeductionTalent = new Dictionary <Guid, Guid>();
            }
            #endregion
            CreateNew(jsonCharakter.ID);
            Name = jsonCharakter.Name;
            #region Attribute Laden
            foreach (var item in jsonCharakter.AttributeBaseValue.Keys)
            {
                Attribute.SetAKTValue(item, jsonCharakter.AttributeBaseValue[item]);
            }
            #endregion
            #region Values Laden
            if (jsonCharakter.SettableValues != null)
            {
                foreach (var item in jsonCharakter.SettableValues)
                {
                    var settableValue = Values.UsedValues.Where(x => x.Name == item.Key).FirstOrDefault();
                    if (settableValue != null && typeof(AbstractSettableValue).IsAssignableFrom(settableValue.GetType()))
                    {
                        Values.SetAKTValue((AbstractSettableValue)settableValue, item.Value);
                    }
                }
            }
            #endregion
            #region Resources Laden
            //kein Laden notwendig
            #endregion
            #region Traits Laden
            if (jsonCharakter.Traits != null)
            {
                foreach (var item in jsonCharakter.Traits)
                {
                    var trait = new Trait
                    {
                        TraitType   = item.TraitType,
                        Description = item.Description,
                        GP          = item.GP,
                        Title       = item.Title,
                        Value       = item.Value,
                        APEarned    = item.APEarned,
                        APInvest    = item.APInvest
                    };
                    foreach (var innerItems in item.AttributeValues)
                    {
                        trait.SetValue(innerItems.Key, innerItems.Value);
                    }
                    foreach (var innerItems in item.ValueValues)
                    {
                        var value = GetValue(innerItems.Key);
                        if (value != null)
                        {
                            trait.SetValue(value, innerItems.Value);
                        }
                    }
                    foreach (var innerItems in item.ResourceValues)
                    {
                        var res = GetResource(innerItems.Key);
                        if (res != null)
                        {
                            trait.SetValue(res, innerItems.Value);
                        }
                    }

                    foreach (var innerItems in item.TawBonus)
                    {
                        var talent = talentListe.Where(x => x.ID == innerItems.Key).FirstOrDefault();
                        if (talent != null)
                        {
                            trait.SetTaWBonus(talent, innerItems.Value);
                        }
                    }
                    foreach (var innerItems in item.AtBonus)
                    {
                        var talent = talentListe.Where(x => x.ID == innerItems.Key).FirstOrDefault();
                        if (talent != null && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                        {
                            trait.SetATBonus((AbstractTalentFighting)talent, innerItems.Value);
                        }
                    }
                    foreach (var innerItems in item.PaBonus)
                    {
                        var talent = talentListe.Where(x => x.ID == innerItems.Key).FirstOrDefault();
                        if (talent != null && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                        {
                            trait.SetPABonus((AbstractTalentFighting)talent, innerItems.Value);
                        }
                    }
                    if (item.BLBonus != null)
                    {
                        foreach (var innerItems in item.BLBonus)
                        {
                            var talent = talentListe.Where(x => x.ID == innerItems.Key).FirstOrDefault();
                            if (talent != null && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                            {
                                trait.SetBLBonus((AbstractTalentFighting)talent, innerItems.Value);
                            }
                        }
                    }

                    Traits.AddTrait(trait);
                }
            }
            #endregion
            #region Talente Laden
            foreach (var item in jsonCharakter.TalentTAW)
            {
                var talent = talentListe.Where(x => x.ID == item.Key).FirstOrDefault();
                if (talent != null)
                {
                    Talente.SetTAW(talent, item.Value);
                }
                else
                {
                    TalentMissing(jsonCharakter, item.Key);
                }
            }
            foreach (var item in jsonCharakter.TalentAT)
            {
                var talent = talentListe.Where(x => x.ID == item.Key).FirstOrDefault();
                if (talent != null && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                {
                    Talente.SetFightingValue(FightingValue.Attacke, (AbstractTalentFighting)talent, item.Value);
                }
                else
                {
                    TalentMissing(jsonCharakter, item.Key);
                }
            }
            foreach (var item in jsonCharakter.TalentPA)
            {
                var talent = talentListe.Where(x => x.ID == item.Key).FirstOrDefault();
                if (talent != null && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                {
                    Talente.SetFightingValue(FightingValue.Parade, (AbstractTalentFighting)talent, item.Value);
                }
                else
                {
                    TalentMissing(jsonCharakter, item.Key);
                }
            }
            if (jsonCharakter.TalentBL != null)
            {
                foreach (var item in jsonCharakter.TalentBL)
                {
                    var talent = talentListe.Where(x => x.ID == item.Key).FirstOrDefault();
                    if (talent != null && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                    {
                        Talente.SetFightingValue(FightingValue.Blocken, (AbstractTalentFighting)talent, item.Value);
                    }
                    else
                    {
                        TalentMissing(jsonCharakter, item.Key);
                    }
                }
            }
            foreach (var item in jsonCharakter.MotherLanguages)
            {
                var talent = talentListe.Where(x => x.ID == item.Key).FirstOrDefault();
                Talente.SetMother((TalentSpeaking)talent, item.Value);
            }
            foreach (var item in jsonCharakter.DeductionTalent)
            {
                try
                {
                    var talent           = talentListe.Where(x => x.ID == item.Key).FirstOrDefault();
                    var talentDeductions = talent.Deductions.Where(x => x.GetType().IsAssignableFrom(typeof(TalentDeductionTalent))).Cast <TalentDeductionTalent>().ToList();
                    var deduction        = talentDeductions.Where(x => x.Talent.ID == item.Value).FirstOrDefault();
                    Talente.SetDeduction(talent, deduction);
                }
                catch (Exception ex)
                {
                    LogStrings.LogString(LogLevel.ErrorLog, "Fehler beim Laden einer Deduction: " + item.Key + " " + item.Value);
                }
            }
            #endregion
            #region Descriptoren Laden
            foreach (var item in jsonCharakter.Descriptors)
            {
                this.Descriptions.AddDescripton(new Descriptor
                {
                    Priority         = item.Priority,
                    DescriptionText  = item.DescriptionText,
                    DescriptionTitle = item.DescriptionTitle
                });
            }
            #endregion
            #region Money
            #region Money
            if (jsonCharakter.Money != null)
            {
                var money = jsonCharakter.Money;
                Money.Bank = money.Bank;
                Money.D    = money.D;
                Money.H    = money.H;
                Money.K    = money.K;
                Money.S    = money.S;
            }
            #endregion
            #endregion
            #region Anderes Laden
            Other.APEarned   = jsonCharakter.AktAP;
            Other.APInvested = jsonCharakter.InvestAP;
            #endregion
        }
Esempio n. 4
0
 public static void Log(LogLevel logLevel, string message, [CallerMemberName] string callerMemberName = "", [CallerFilePath] string CallerFilePath = "", [CallerLineNumber] int callerLineNumber = 0)
 {
     LogStrings.LogString(logLevel, message, callerMemberName, CallerFilePath, callerLineNumber);
 }