Beispiel #1
0
        private void UpdateGamesGroup(GameGroupLayoutCollection topGames, dynamic navigationPlanJson, string groupName)
        {
            var topGamesDefaultLayout = topGames.FirstOrDefault(group => string.IsNullOrEmpty(group.PlayerStatus));


            var obj = navigationPlanJson as JObject;

            var topGamesArray = new JArray();

            if (topGamesDefaultLayout != null)
            {
                foreach (var game in topGamesDefaultLayout.Games)
                {
                    topGamesArray.Add(new JValue(game.Id));
                }
            }


            var prop = obj.Property(groupName);

            if (prop == null)
            {
                prop = new JProperty(groupName, topGamesArray);
                obj.Add(prop);
            }
            else
            {
                prop.Value = topGamesArray;
            }
        }
Beispiel #2
0
        private void UpdateGamesGroup(GameGroupLayoutCollection gameGroupLayouts, string parentElementName, string childElementName)
        {
            if (lobby_data_ndl == null)
            {
                return;
            }

            var originalGroupElements = lobby_data_ndl.Elements(parentElementName).ToArray();


            var arenasXmlElement = lobby_data_ndl.Element(XmlNames.arenas);

            foreach (var gameGroupLayout in gameGroupLayouts)
            {
                var originalGroupXmlElement = originalGroupElements.FirstOrDefault(e => 0 == string.Compare(e.GetAttributeValue(XmlNames.playerStatus, ""), gameGroupLayout.PlayerStatus ?? ""));
                var newGroupXmlElement      = new XElement(parentElementName);

                if (originalGroupXmlElement != null)
                {
                    originalGroupXmlElement.CopyAttributesTo(newGroupXmlElement);
                }


                newGroupXmlElement.AddOrUpdateAttributeValue(XmlNames.buildaction, XmlValues.copy);

                if (!string.IsNullOrEmpty(gameGroupLayout.PlayerStatus))
                {
                    newGroupXmlElement.AddOrUpdateAttributeValue(XmlNames.playerStatus, gameGroupLayout.PlayerStatus);
                }

                foreach (var game in gameGroupLayout.Games)
                {
                    newGroupXmlElement.Add(new XComment(game.Name));

                    var gameXmlElement = new XElement(childElementName);
                    gameXmlElement.Add(new XAttribute(XmlNames.gameType, game.Id));
                    newGroupXmlElement.Add(gameXmlElement);
                }


                if (originalGroupXmlElement != null)
                {
                    originalGroupXmlElement.AddBeforeSelf(newGroupXmlElement);
                    originalGroupXmlElement.Remove();
                }
                else
                {
                    arenasXmlElement.AddBeforeSelf(newGroupXmlElement);
                }
            }
        }
Beispiel #3
0
        private void LoadGamesGroupCollection(string description, GameGroupLayoutCollection source, GameGroupLayoutCollectionViewModel destination)
        {
            foreach (var layout in source)
            {
                var viewModel = new GameGroupLayoutViewModel(new PlayerStatusTypeViewModel(PlayerStatusType.FromId(layout.PlayerStatus), _skinDefinition.Triggers));

                foreach (var game in layout.Games)
                {
                    AddGameToCollection(game.Id, viewModel.Games, description);
                }

                destination.Add(viewModel);
            }
        }
Beispiel #4
0
        private void FillGamesGroupCollection(GameGroupLayoutCollection gamesGroupsLayoutCollection, SkinDefinitionContext skinDefinitionContext, dynamic gamesGroup)
        {
            if (gamesGroup == null)
            {
                return;
            }

            var gameGroupLayout = new GameGroupLayout();

            foreach (var gameType in gamesGroup)
            {
                gameGroupLayout.Games.Add(skinDefinitionContext.GetGame(ConvertDynamicValue <int>(gameType)));
            }

            gamesGroupsLayoutCollection.Add(gameGroupLayout);
        }
Beispiel #5
0
        private void FillGamesGroupCollection(GameGroupLayoutCollection gameGroupLayoutCollection, SkinDefinitionContext skinDefinitionContext, string xmlCollectionElementName, string xmlItemElementName)
        {
            var gamesGroupsElements = _navigationPlanXml.Root.Element(XmlNames.lobby_data_ndl)
                                      ?.Elements(xmlCollectionElementName)
                                      .ToArray();



            foreach (var gameGroupXmlElement in gamesGroupsElements)
            {
                var gameGroupLayout = new GameGroupLayout(gameGroupXmlElement.GetAttributeValue(XmlNames.playerStatus));


                foreach (var itemXmlElement in gameGroupXmlElement.Elements(xmlItemElementName))
                {
                    gameGroupLayout.Games.Add(skinDefinitionContext.GetGame(itemXmlElement.GetAttributeValue <int>(XmlNames.gameType)));
                }

                gameGroupLayoutCollection.Add(gameGroupLayout);
            }
        }