Example #1
0
        public override void DeleteByView(TraitView view)
        {
            var trait = traitRepository.Get(view.ID);

            attributRepository.Delete(trait.Id);
            resourceRepository.Delete(trait.Id);
            valueRepository.Delete(trait.Id);
            talentRepository.Delete(trait.Id);
            traitRepository.Delete(trait.Id);
            talentRepository.Submit();
        }
Example #2
0
        public override void SetByView(TraitView view)
        {
            var trait = traitRepository.Get(view.ID);

            trait.Name        = view.Name;
            trait.Description = view.Description;
            trait.Type        = (int)view.Type;
            trait.GP          = view.GP;
            trait.Value       = view.Value;

            trait.APGain     = view.APGain;
            trait.APInvested = view.APInvest;

            trait.ModifyDate = DateTime.Now;
            if (view.CreationDate != default(DateTime))
            {
                trait.CreationDate = view.CreationDate;
            }

            traitRepository.Update(trait);
            traitRepository.Submit();

            attributRepository.SetList(view.AttributList, trait.Id);
            attributRepository.Submit();

            resourceRepository.SetList(view.ResourceList, trait.Id);
            resourceRepository.Submit();

            valueRepository.SetList(view.ValueList, trait.Id);
            valueRepository.Submit();

            talentRepository.SetList(view.TalentList, trait.Id);
            talentRepository.Submit();

            skillRepository.SetList(view.SkillList, trait.Id);
            skillRepository.Submit();
        }
        protected string GenerateLongDescription(TraitView trait)
        {
            var ret = trait.Description;

            foreach (var pair in trait.AttributList)
            {
                var value = pair.Value;
                ret = GenerateLongDescriptionHelper(value, ret, Helper.GetShort(pair.ID));
            }
            foreach (var pair in trait.ValueList)
            {
                var value = pair.Value;
                var type  = DSAUtil.GetType(pair.ID);
                var item  = charakter.Values.GetItemByType(type);
                ret = GenerateLongDescriptionHelper(value, ret, item.ShortName);
            }
            foreach (var pair in trait.ResourceList)
            {
                var value = pair.Value;
                var type  = DSAUtil.GetType(pair.ID);
                var item  = charakter.Resources.GetByType(type);
                ret = GenerateLongDescriptionHelper(value, ret, item.ShortName);
            }

            foreach (var pair in trait.TalentList)
            {
                var talent = charakter.Talente.Get(pair.ID);

                if (pair.TAW != 0)
                {
                    ret = GenerateLongDescriptionHelper(pair.TAW, ret, talent.Name + " TAW");
                }
                if (pair.AT != null && pair.AT != 0 && typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
                {
                    ret = GenerateLongDescriptionHelper((int)pair.AT, ret, talent.Name + " AT");
                }

                if (pair.PA != null && pair.PA != 0 && (typeof(TalentClose).IsAssignableFrom(talent.GetType()) || typeof(TalentWeaponless).IsAssignableFrom(talent.GetType())))
                {
                    ret = GenerateLongDescriptionHelper((int)pair.PA, ret, talent.Name + " PA");
                }

                if (pair.BL != null && pair.BL != 0 && (typeof(TalentClose).IsAssignableFrom(talent.GetType()) || typeof(TalentWeaponless).IsAssignableFrom(talent.GetType())))
                {
                    ret = GenerateLongDescriptionHelper((int)pair.BL, ret, talent.Name + " BL");
                }
            }

            var adventurePointString = "Abenteuerpunkte";

            if (trait.APGain != 0)
            {
                ret = ret + " " + trait.APGain + adventurePointString;
            }
            if (trait.APInvest != 0)
            {
                ret = ret + " " + " -" + trait.APInvest + adventurePointString;
            }

            return(ret);
        }
 public abstract void DeleteByView(TraitView view);
 public abstract void SetByView(TraitView view);
Example #6
0
        private TraitView GetView(T_Trait trait)
        {
            var attributList = new List <IDValueView <CharakterAttribut> >();
            var sqlAttribut  = attributRepository.GetList(trait.Id);

            foreach (var item in sqlAttribut)
            {
                attributList.Add(new IDValueView <CharakterAttribut>
                {
                    ID    = (CharakterAttribut)item.AttributID,
                    Value = item.Value,
                    Name  = Enum.GetName(typeof(CharakterAttribut), item.AttributID),
                });
            }

            var resourceList = new List <IDValueView <string> >();
            var sqlresource  = resourceRepository.GetList(trait.Id);

            foreach (var item in sqlresource)
            {
                var innerType = DSAUtil.GetType(item.Type);
                var innerItem = this.charakter.Resources.GetByType(innerType);

                resourceList.Add(new IDValueView <string>
                {
                    ID    = item.Type,
                    Value = item.Value,
                    Name  = innerItem.Name
                });
            }

            var valueList = new List <IDValueView <string> >();
            var sqlvalue  = valueRepository.GetList(trait.Id);

            foreach (var item in sqlvalue)
            {
                var innerType = DSAUtil.GetType(item.Type);
                var innerItem = this.charakter.Values.GetItemByType(innerType);

                valueList.Add(new IDValueView <string>
                {
                    ID    = item.Type,
                    Value = item.Value,
                    Name  = innerItem.Name
                });
            }

            var talentList    = new List <TalentView>();
            var sqltalentList = talentRepository.GetList(trait.Id);

            foreach (var item in sqltalentList)
            {
                var talentGuid = new Guid(item.TalentID);
                var talent     = charakter.Talente.Get(talentGuid);
                talentList.Add(new TalentView()
                {
                    ID   = talentGuid,
                    AT   = item.AT,
                    PA   = item.PA,
                    BL   = item.BL,
                    TAW  = item.TAW,
                    Name = talent.Name
                });
            }

            var view = new TraitView
            {
                ID          = trait.Id,
                APGain      = trait.APGain,
                APInvest    = trait.APInvested,
                Description = trait.Description,
                GP          = trait.GP,
                Name        = trait.Name,
                Type        = (TraitType)trait.Type,
                Value       = trait.Value,

                ModifyDate   = trait.ModifyDate,
                CreationDate = trait.CreationDate,

                AttributList = attributList,
                ResourceList = resourceList,
                TalentList   = talentList,
                ValueList    = valueList,
                SkillList    = GetSkillList(trait)
            };

            view.LongDescription = this.GenerateLongDescription(view);
            return(view);
        }