Exemplo n.º 1
0
        internal static PlayerServerViewModel BuildViewModelForTransferedPlayer(
            ArkServerContext context,
            IConfig config,
            string steamId,
            int[] playerIds,
            DemoMode demoMode,
            bool incProfile,
            bool incProfileDetailed,
            bool incCreatures,
            bool incCreaturesBaseStats,
            bool incCreaturesCloud,
            bool incCrops,
            bool incGenerators,
            bool incKibblesEggs,
            bool incTribeLog)
        {
            if (playerIds == null || playerIds.Length == 0)
            {
                return(null);
            }

            //there will be no player profile so most data cannot be set
            //a tribe where the player is a member may exist tho

            //note: potentially there could be multiple tribes with the same player, which player.Tribe protects us against. here we just select the first one which is not optimal
            var tribe = context.Tribes?.FirstOrDefault(x => playerIds.Any(y => x.MemberIds.Contains(y)));

            if (tribe == null)
            {
                return(null);
            }
            var playerId = playerIds.First(x => tribe.MemberIds.Contains(x));

            var vm = new PlayerServerViewModel
            {
                ClusterKey = context.Config.Key,
                SteamId    = steamId,
                TribeId    = tribe.Id,
                TribeName  = demoMode?.GetTribeName(tribe.Id) ?? tribe.Name,
                SavedAt    = tribe.SavedAt
            };

            if (demoMode != null)
            {
                vm.FakeSteamId = demoMode.GetSteamId(steamId);
            }

            if (incCreatures)
            {
                vm.Creatures.AddRange(BuildCreatureViewModelsForPlayerId(context, config, playerId, demoMode, incCreaturesBaseStats));
            }
            if (incKibblesEggs)
            {
                vm.KibblesAndEggs = BuildKibblesAndEggsViewModelsForPlayerId(context, playerId);
            }
            if (incCrops)
            {
                vm.CropPlots = BuildCropPlotViewModelsForPlayerId(context, playerId);
            }
            if (incGenerators)
            {
                vm.Generators = BuildGeneratorViewModelsForPlayerId(context, playerId);
            }
            if (incTribeLog)
            {
                vm.TribeLog = BuildTribeLogViewModelsForPlayerId(context, playerId, config.WebApp.TribeLogLimit, config.WebApp.TribeLogColors);
            }

            return(vm);
        }
Exemplo n.º 2
0
        internal static PlayerServerViewModel BuildViewModelForPlayer(
            ArkServerContext context,
            IConfig config,
            ArkPlayer player,
            DemoMode demoMode,
            bool incProfile,
            bool incProfileDetailed,
            bool incCreatures,
            bool incCreaturesBaseStats,
            bool incCreaturesCloud,
            bool incCrops,
            bool incGenerators,
            bool incKibblesEggs,
            bool incTribeLog)
        {
            var tribe = player.Tribe;
            var vm    = new PlayerServerViewModel
            {
                ClusterKey    = context.Config.Key,
                SteamId       = player.SteamId,
                FakeSteamId   = demoMode?.GetSteamId(player.SteamId),
                CharacterName = demoMode?.GetPlayerName(player.Id) ?? player.CharacterName,
                TribeId       = player.TribeId,
                TribeName     = tribe != null?demoMode?.GetTribeName(tribe.Id) ?? tribe?.Name : null,
                SavedAt       = player.SavedAt
            };

            if (incProfileDetailed)
            {
                vm.Latitude  = player.Location?.Latitude;
                vm.Longitude = player.Location?.Longitude;
                vm.TopoMapX  = player.Location?.TopoMapX;
                vm.TopoMapY  = player.Location?.TopoMapY;

                if (!player.IsExternalPlayer)
                {
                    vm.Gender       = player.Gender.ToString();
                    vm.Level        = player.CharacterLevel;
                    vm.EngramPoints = player.TotalEngramPoints;
                }
            }

            if (incCreatures)
            {
                vm.Creatures.AddRange(BuildCreatureViewModelsForPlayerId(context, config, player.Id, demoMode, incCreaturesBaseStats));
            }
            if (incKibblesEggs)
            {
                vm.KibblesAndEggs = BuildKibblesAndEggsViewModelsForPlayerId(context, player.Id);
            }
            if (incCrops)
            {
                vm.CropPlots = BuildCropPlotViewModelsForPlayerId(context, player.Id);
            }
            if (incGenerators)
            {
                vm.Generators = BuildGeneratorViewModelsForPlayerId(context, player.Id);
            }
            if (incTribeLog)
            {
                vm.TribeLog = BuildTribeLogViewModelsForPlayerId(context, player.Id, config.WebApp.TribeLogLimit, config.WebApp.TribeLogColors);
            }

            return(vm);
        }
Exemplo n.º 3
0
        internal static PlayerServerViewModel BuildViewModelForTransferedPlayer(
            ArkServerContext context,
            IConfig config,
            string steamId,
            int[] playerIds,
            DemoMode demoMode,
            bool incProfile,
            bool incProfileDetailed,
            bool incCreatures,
            bool incCreaturesBaseStats,
            bool incCreaturesCloud,
            bool incCrops,
            bool incGenerators,
            bool incKibblesEggs,
            bool incTribeLog)
        {
            if (playerIds == null || playerIds.Length == 0)
            {
                return(null);
            }

            //there will be no player profile so most data cannot be set
            //a tribe where the player is a member may exist tho

            var tribe = context.Tribes?.FirstOrDefault(x => playerIds.Any(y => x.MemberIds.Contains((int)y)));

            if (tribe == null)
            {
                return(null);
            }
            var playerId = playerIds.First(x => tribe.MemberIds.Contains((int)x));

            var vm = new PlayerServerViewModel
            {
                ClusterKey = context.Config.Key,
                SteamId    = steamId,
                TribeId    = tribe.Id,
                TribeName  = demoMode?.GetTribeName(tribe.Id) ?? tribe.Name,
                SavedAt    = tribe.SavedAt
            };

            if (demoMode != null)
            {
                vm.FakeSteamId = demoMode.GetSteamId(steamId);
            }

            if (incCreatures)
            {
                vm.Creatures.AddRange(BuildCreatureViewModelsForPlayerId(context, config, playerId, demoMode, incCreaturesBaseStats));
            }
            if (incKibblesEggs)
            {
                vm.KibblesAndEggs = BuildKibblesAndEggsViewModelsForPlayerId(context, playerId);
            }
            if (incCrops)
            {
                vm.CropPlots = BuildCropPlotViewModelsForPlayerId(context, playerId);
            }
            if (incGenerators)
            {
                vm.ElectricalGenerators = BuildElectricalGeneratorViewModelsForPlayerId(context, playerId);
            }
            if (incTribeLog)
            {
                vm.TribeLog = BuildTribeLogViewModelsForPlayerId(context, playerId, 100);
            }

            return(vm);
        }