コード例 #1
0
        public static Character CharacterFromFullDTO(FullCharacterDTO fullCharacterDTO)
        {
            var character = new Character();

            if (!string.IsNullOrWhiteSpace(fullCharacterDTO.id))
            {
                character._id = fullCharacterDTO.id;
            }
            if (!string.IsNullOrWhiteSpace(fullCharacterDTO.playerAccountName))
            {
                character.PlayerAccountName = fullCharacterDTO.playerAccountName;
            }
            character.Name = fullCharacterDTO.name;
            character.Race = fullCharacterDTO.race;

            if (fullCharacterDTO.abilities != null)
            {
                foreach (AbilityDTO abilityDTO in fullCharacterDTO.abilities)
                {
                    var ability = AbilityMapper.GetAbilityFromDTO(abilityDTO);
                    character.Abilities.Add(ability);
                }
            }

            character.Size         = fullCharacterDTO.size;
            character.SizeModifier = fullCharacterDTO.sizeModifier;

            character.Classes = new List <RpgClass>();
            if (fullCharacterDTO.classes != null)
            {
                foreach (RpgClassDTO classDTO in fullCharacterDTO.classes)
                {
                    var rpgClass = RpgClassMapper.GetRpgClassFromDTO(classDTO);
                    character.Classes.Add(rpgClass);
                }
            }

            return(character);
        }