Beispiel #1
0
        public static SkillsStats operator +(SkillsStats c1, SkillsStats c2)
        {
            if (c1.PlayerInfo != c2.PlayerInfo)
            {
                throw new Exception("cannot add skillstats");
            }

            var skills = new SkillsStats(c1.PlayerInfo);

            skills.Skills =
                new Dictionary <Skill.Skill, SkillStats>(skills.Skills.Concat(c1.Skills)
                                                         .ToDictionary(x => x.Key, x => x.Value));
            foreach (var skill in c2.Skills)
            {
                if (skills.Skills.ContainsKey(skill.Key))
                {
                    skills.Skills[skill.Key] += skill.Value;
                }
                else
                {
                    skills.Skills[skill.Key] = skill.Value;
                }
            }

            return(skills);
        }
Beispiel #2
0
        public object Clone()
        {
            var clone = new SkillsStats(PlayerInfo)
            {
                Skills = Skills.ToDictionary(i => i.Key, i => (SkillStats)i.Value.Clone())
            };

            return(clone);
        }