Beispiel #1
0
        public static FullCharacterDTO FullDTOFromCharacter(Character character)
        {
            var characterDTO = new FullCharacterDTO();

            characterDTO.id = character._id;
            characterDTO.playerAccountName = character.PlayerAccountName;
            characterDTO.name = character.Name;
            characterDTO.race = character.Race;

            foreach (Ability ability in character.Abilities)
            {
                var abilityDTO = AbilityMapper.GetDTOFromAbility(ability);
                characterDTO.abilities.Add(abilityDTO);
            }

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

            characterDTO.classes = new List <RpgClassDTO>();

            foreach (RpgClass rpgClass in character.Classes)
            {
                var rpgClassDTO = RpgClassMapper.GetDTOFromClass(rpgClass);
                characterDTO.classes.Add(rpgClassDTO);
            }

            return(characterDTO);
        }
Beispiel #2
0
        public static BasicCharacterDTO BasicDTOFromCharacter(Character character)
        {
            var characterDTO = new BasicCharacterDTO();

            characterDTO.id = character._id;
            characterDTO.playerAccountName = character.PlayerAccountName;
            characterDTO.name = character.Name;
            characterDTO.race = character.Race;

            characterDTO.classes = new List <RpgClassDTO>();

            foreach (RpgClass rpgClass in character.Classes)
            {
                var rpgClassDTO = RpgClassMapper.GetDTOFromClass(rpgClass);
                characterDTO.classes.Add(rpgClassDTO);
            }

            return(characterDTO);
        }
Beispiel #3
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);
        }