Ejemplo n.º 1
0
        private Player MapPlayerDto(PlayerDTO playerDto)
        {
            ResourceSet resSet = ResourceSetFactory.FromDto(playerDto.ResourceSet);

            var player = new Player(playerDto.Id, playerDto.Username, playerDto.WorldSeed, resSet);

            foreach (var unitDto in playerDto.Units)
            {
                var unit = UnitFactory.FromDto(unitDto);
                if (unit == null)
                {
                    continue;
                }

                player.Units.Add(unit);
            }

            foreach (var resProvDto in playerDto.ResourceProviders)
            {
                var resProv = ResProvFactory.FromDto(resProvDto);
                if (resProv == null)
                {
                    continue;
                }

                player.ResourceProviders.Add(resProv);
            }

            player.MapEntities();
            return(player);
        }