public CustomInteractiveGameControl(InteractiveGameModel game, InteractiveGameVersionModel version)
        {
            this.Game    = game;
            this.Version = version;

            this.Loaded += CustomInteractiveGameControl_Loaded;
        }
Beispiel #2
0
        public static async Task <InteractiveGameListingModel> CreateInteractive2Game(MixerConnection connection, ChannelModel channel, UserModel user, string gameName, InteractiveSceneModel initialScene)
        {
            InteractiveGameModel game = new InteractiveGameModel()
            {
                name    = gameName,
                ownerId = user.id,
            };

            game = await connection.Interactive.CreateInteractiveGame(game);

            game.controlVersion = "2.0";
            game = await connection.Interactive.UpdateInteractiveGame(game);

            IEnumerable <InteractiveGameListingModel> gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel);

            InteractiveGameListingModel gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id));

            InteractiveGameVersionModel version = gameListing.versions.First();

            version.controls.scenes.Add(initialScene);
            version.controlVersion = "2.0";
            version = await connection.Interactive.UpdateInteractiveGameVersion(version);

            gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel);

            gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id));

            return(gameListing);
        }
        public PUBGDropMapInteractiveControl(InteractiveGameModel game, InteractiveGameVersionModel version)
            : base(game, version)
        {
            InitializeComponent();

            this.Initialize(this.LocationPointsCanvas);

            this.MaxTimeTextBox.Text   = this.maxTime.ToString();
            this.SparkCostTextBox.Text = this.sparkCost.ToString();

            this.MapComboBox.ItemsSource = this.maps;

            this.maps.Add(new PUBGMap()
            {
                Name = ErangelMapName, Map = "map1.png"
            });
            this.maps.Add(new PUBGMap()
            {
                Name = MiramarMapName, Map = "map2.png"
            });
            this.maps.Add(new PUBGMap()
            {
                Name = SanhokMapName, Map = "map3.png"
            });

            this.MapComboBox.SelectedIndex = 0;

            JObject settings = this.GetCustomSettings();

            if (settings.ContainsKey(MapSelectionSettingProperty))
            {
                this.MapComboBox.SelectedIndex = settings[MapSelectionSettingProperty].ToObject <int>();
            }
        }
Beispiel #4
0
        public BasicInteractiveButtonCommandEditorControl(CommandWindow window, InteractiveGameModel game, InteractiveGameVersionModel version, InteractiveButtonCommand command)
        {
            this.window  = window;
            this.game    = game;
            this.version = version;
            this.command = command;

            InitializeComponent();
        }
        public InteractiveButtonCommandDetailsControl(InteractiveGameModel game, InteractiveGameVersionModel version, InteractiveButtonCommand command)
        {
            this.Game    = game;
            this.Version = version;
            this.command = command;
            this.Control = command.Button;

            InitializeComponent();
        }
        public InteractiveButtonCommandDetailsControl(InteractiveGameModel game, InteractiveGameVersionModel version, InteractiveSceneModel scene, InteractiveButtonControlModel control)
        {
            this.Game    = game;
            this.Version = version;
            this.Scene   = scene;
            this.Control = control;

            InitializeComponent();
        }
        public BlackOps4DropMapInteractiveControl(InteractiveGameModel game, InteractiveGameVersionModel version)
            : base(game, version)
        {
            InitializeComponent();

            this.Initialize(this.LocationPointsCanvas);

            this.MaxTimeTextBox.Text   = this.maxTime.ToString();
            this.SparkCostTextBox.Text = this.sparkCost.ToString();
        }
        /// <summary>
        /// Updates the specified interactive game version.
        /// </summary>
        /// <param name="version">The interactive game version to update</param>
        /// <returns>The updated interactive game version</returns>
        public async Task <InteractiveGameVersionModel> UpdateInteractiveGameVersion(InteractiveGameVersionModel version)
        {
            Validator.ValidateVariable(version, "version");

            // Need to strip out all of the non-updateable fields in order for the API to not return a 403 error
            InteractiveGameVersionUpdateableModel updateableVersion = JsonHelper.ConvertToDifferentType <InteractiveGameVersionUpdateableModel>(version);

            updateableVersion.controls = version.controls;

            return(await this.PutAsync <InteractiveGameVersionModel>("interactive/versions/" + version.id, this.CreateContentFromObject(updateableVersion)));
        }
        public BasicInteractiveTextBoxCommandEditorControl(CommandWindow window, InteractiveGameListingModel game, InteractiveGameVersionModel version, InteractiveSceneModel scene,
                                                           InteractiveTextBoxControlModel textBox, BasicCommandTypeEnum commandType)
        {
            this.window      = window;
            this.game        = game;
            this.version     = version;
            this.scene       = scene;
            this.textBox     = textBox;
            this.commandType = commandType;

            InitializeComponent();
        }
Beispiel #10
0
        public BasicInteractiveButtonCommandEditorControl(CommandWindow window, InteractiveGameModel game, InteractiveGameVersionModel version, InteractiveSceneModel scene,
                                                          InteractiveButtonControlModel button, BasicCommandTypeEnum commandType)
        {
            this.window      = window;
            this.game        = game;
            this.version     = version;
            this.scene       = scene;
            this.button      = button;
            this.commandType = commandType;

            InitializeComponent();
        }
Beispiel #11
0
        public async Task <bool> Connect(InteractiveGameModel game, InteractiveGameVersionModel version)
        {
            this.Game    = game;
            this.Version = version;

            this.Scenes.Clear();
            this.Controls.Clear();
            this.ControlCommands.Clear();
            this.Participants.Clear();

            return(await this.AttemptConnect());
        }
Beispiel #12
0
 public async Task DisableAllControlsWithoutCommands(InteractiveGameVersionModel version)
 {
     // Disable all controls that do not have an associated Interactive Command or the Interactive Command is disabled
     foreach (InteractiveSceneModel scene in version.controls.scenes)
     {
         foreach (InteractiveControlModel control in scene.allControls)
         {
             InteractiveCommand command = this.GetInteractiveCommandForControl(version.gameId, control);
             control.disabled = (command == null || !command.IsEnabled);
         }
     }
     await ChannelSession.Connection.UpdateInteractiveGameVersion(version);
 }
        protected override async Task OnLoaded()
        {
            this.TextValueSpecialIdentifierTextBlock.Text = SpecialIdentifierStringBuilder.InteractiveTextBoxTextEntrySpecialIdentifierHelpText;

            if (this.command != null)
            {
                IEnumerable <InteractiveGameListingModel> games = await ChannelSession.Connection.GetOwnedInteractiveGames(ChannelSession.Channel);

                this.game = games.FirstOrDefault(g => g.name.Equals(this.command.GameID));
                if (this.game != null)
                {
                    this.version = this.game.versions.First();
                    this.version = await ChannelSession.Connection.GetInteractiveGameVersion(this.version);

                    this.scene   = this.version.controls.scenes.FirstOrDefault(s => s.sceneID.Equals(this.command.SceneID));
                    this.textBox = this.command.TextBox;
                }

                this.SparkCostTextBox.Text = this.command.TextBox.cost.ToString();
                this.UseChatModerationCheckBox.IsChecked = this.command.UseChatModeration;

                if (this.command.Actions.First() is ChatAction)
                {
                    this.actionControl = new ChatActionControl(null, (ChatAction)this.command.Actions.First());
                }
                else if (this.command.Actions.First() is SoundAction)
                {
                    this.actionControl = new SoundActionControl(null, (SoundAction)this.command.Actions.First());
                }
            }
            else
            {
                this.SparkCostTextBox.Text = this.textBox.cost.ToString();

                if (this.commandType == BasicCommandTypeEnum.Chat)
                {
                    this.actionControl = new ChatActionControl(null);
                }
                else if (this.commandType == BasicCommandTypeEnum.Sound)
                {
                    this.actionControl = new SoundActionControl(null);
                }
            }

            this.ActionControlControl.Content = this.actionControl;

            await base.OnLoaded();
        }
        public void GetInteractiveVersion()
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                IEnumerable <InteractiveGameListingModel> games = await connection.Interactive.GetOwnedInteractiveGames(channel);

                Assert.IsNotNull(games);
                Assert.IsTrue(games.Count() > 0);

                InteractiveGameVersionModel version = await connection.Interactive.GetInteractiveGameVersion(games.First().versions.First());

                Assert.IsNotNull(version);
            });
        }
Beispiel #15
0
        public async Task <IEnumerable <InteractiveGameModel> > GetAllConnectableGames(bool forceRefresh = false)
        {
            if (forceRefresh || this.lastRefresh < DateTimeOffset.Now)
            {
                this.lastRefresh = DateTimeOffset.Now.AddMinutes(1);
                this.games.Clear();

                this.games.AddRange(await ChannelSession.Connection.GetOwnedInteractiveGames(ChannelSession.Channel));
                games.RemoveAll(g => g.name.Equals("Soundwave Interactive Soundboard"));

                foreach (InteractiveSharedProjectModel project in ChannelSession.Settings.CustomInteractiveProjectIDs)
                {
                    InteractiveGameVersionModel version = await ChannelSession.Connection.GetInteractiveGameVersion(project.VersionID);

                    if (version != null)
                    {
                        InteractiveGameModel game = await ChannelSession.Connection.GetInteractiveGame(version.gameId);

                        if (game != null)
                        {
                            games.Add(game);
                        }
                    }
                }

                foreach (InteractiveSharedProjectModel project in InteractiveSharedProjectModel.AllMixPlayProjects)
                {
                    InteractiveGameVersionModel version = await ChannelSession.Connection.GetInteractiveGameVersion(project.VersionID);

                    if (version != null)
                    {
                        InteractiveGameModel game = await ChannelSession.Connection.GetInteractiveGame(version.gameId);

                        if (game != null)
                        {
                            game.name += " (MixPlay)";
                            games.Add(game);
                        }
                    }
                }
            }

            return(games);
        }
        private async Task RefreshSelectedGame()
        {
            if (!ChannelSession.Settings.InteractiveUserGroups.ContainsKey(this.selectedGame.id))
            {
                ChannelSession.Settings.InteractiveUserGroups[this.selectedGame.id] = new List <InteractiveUserGroupViewModel>();
            }

            foreach (MixerRoleEnum role in UserViewModel.SelectableBasicUserRoles())
            {
                if (!ChannelSession.Settings.InteractiveUserGroups[this.selectedGame.id].Any(ug => ug.AssociatedUserRole == role))
                {
                    ChannelSession.Settings.InteractiveUserGroups[this.selectedGame.id].Add(new InteractiveUserGroupViewModel(role));
                }
            }

            this.selectedGameVersion = await this.Window.RunAsyncOperation(async() =>
            {
                return(await ChannelSession.Connection.GetInteractiveGameVersion(this.selectedGame.versions.First()));
            });

            this.interactiveScenes.Clear();
            if (this.selectedGameVersion != null)
            {
                foreach (InteractiveSceneModel scene in this.selectedGameVersion.controls.scenes)
                {
                    this.interactiveScenes.Add(scene);
                }
            }

            if (this.selectedScene != null && this.interactiveScenes.Any(s => s.sceneID.Equals(this.selectedScene.sceneID)))
            {
                this.InteractiveScenesComboBox.SelectedItem = this.interactiveScenes.First(s => s.sceneID.Equals(this.selectedScene.sceneID));
            }
            else
            {
                this.InteractiveScenesComboBox.SelectedIndex = 0;
            }

            this.GroupsButton.IsEnabled  = true;
            this.ConnectButton.IsEnabled = true;
        }
        public async Task <IEnumerable <InteractiveGameModel> > GetAllConnectableGames()
        {
            List <InteractiveGameModel> games = new List <InteractiveGameModel>();

            games.AddRange(await ChannelSession.Connection.GetOwnedInteractiveGames(ChannelSession.Channel));
            games.RemoveAll(g => g.name.Equals("Soundwave Interactive Soundboard"));

            foreach (InteractiveSharedProjectModel project in ChannelSession.Settings.CustomInteractiveProjectIDs)
            {
                InteractiveGameVersionModel version = await ChannelSession.Connection.GetInteractiveGameVersion(project.VersionID);

                if (version != null)
                {
                    InteractiveGameModel game = await ChannelSession.Connection.GetInteractiveGame(version.gameId);

                    if (game != null)
                    {
                        games.Add(game);
                    }
                }
            }

            foreach (InteractiveSharedProjectModel project in InteractiveSharedProjectModel.AllMixPlayProjects)
            {
                InteractiveGameVersionModel version = await ChannelSession.Connection.GetInteractiveGameVersion(project.VersionID);

                if (version != null)
                {
                    InteractiveGameModel game = await ChannelSession.Connection.GetInteractiveGame(version.gameId);

                    if (game != null)
                    {
                        game.name += " (MixPlay)";
                        games.Add(game);
                    }
                }
            }

            return(games);
        }
        public async Task UploadLinkedInteractiveGame(MixerConnection connection)
        {
            InteractiveGameListingModel linkedGame = null;

            using (StreamReader reader = new StreamReader(File.OpenRead(this.LinkedInteractiveGameJSONFilePath)))
            {
                string fileContents = await reader.ReadToEndAsync();

                linkedGame = SerializerHelper.DeserializeObjectFromString <InteractiveGameListingModel>(fileContents);
            }

            InteractiveGameVersionModel version = linkedGame.versions[0];

            version = await connection.Interactive.GetInteractiveGameVersion(version);

            version.controls.scenes = new List <InteractiveSceneModel>();
            foreach (SceneViewModel scene in this.Scenes)
            {
                version.controls.scenes.Add(scene.GetSceneData());
            }

            version = await connection.Interactive.UpdateInteractiveGameVersion(version);
        }
 public async Task UpdateInteractiveGameVersion(InteractiveGameVersionModel version)
 {
     await this.RunAsync(this.Connection.Interactive.UpdateInteractiveGameVersion(version));
 }
        private async Task RefreshSelectedGame()
        {
            if (!ChannelSession.Settings.InteractiveUserGroups.ContainsKey(this.selectedGame.id))
            {
                ChannelSession.Settings.InteractiveUserGroups[this.selectedGame.id] = new List <InteractiveUserGroupViewModel>();
            }

            foreach (MixerRoleEnum role in UserViewModel.SelectableBasicUserRoles())
            {
                if (!ChannelSession.Settings.InteractiveUserGroups[this.selectedGame.id].Any(ug => ug.AssociatedUserRole == role))
                {
                    ChannelSession.Settings.InteractiveUserGroups[this.selectedGame.id].Add(new InteractiveUserGroupViewModel(role));
                }
            }

            this.selectedGameVersion = await this.Window.RunAsyncOperation(async() =>
            {
                IEnumerable <InteractiveGameVersionModel> versions = await ChannelSession.Connection.GetInteractiveGameVersions(this.selectedGame);
                if (versions != null && versions.Count() > 0)
                {
                    return(await ChannelSession.Connection.GetInteractiveGameVersion(versions.First()));
                }
                return(null);
            });

            this.GroupsButton.IsEnabled = false;
            if (this.selectedGame.id == InteractiveSharedProjectModel.FortniteDropMap.GameID)
            {
                this.SetCustomInteractiveGame(new DropMapInteractiveControl(DropMapTypeEnum.Fortnite, this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.PUBGDropMap.GameID)
            {
                this.SetCustomInteractiveGame(new DropMapInteractiveControl(DropMapTypeEnum.PUBG, this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.RealmRoyaleDropMap.GameID)
            {
                this.SetCustomInteractiveGame(new DropMapInteractiveControl(DropMapTypeEnum.RealmRoyale, this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.BlackOps4DropMap.GameID)
            {
                this.SetCustomInteractiveGame(new DropMapInteractiveControl(DropMapTypeEnum.BlackOps4, this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.ApexLegendsDropMap.GameID)
            {
                this.SetCustomInteractiveGame(new DropMapInteractiveControl(DropMapTypeEnum.ApexLegends, this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.SuperAnimalRoyaleDropMap.GameID)
            {
                this.SetCustomInteractiveGame(new DropMapInteractiveControl(DropMapTypeEnum.SuperAnimalRoyale, this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.MixerPaint.GameID)
            {
                this.SetCustomInteractiveGame(new MixerPaintInteractiveControl(this.selectedGame, this.selectedGameVersion));
            }
            else if (this.selectedGame.id == InteractiveSharedProjectModel.FlySwatter.GameID)
            {
                this.SetCustomInteractiveGame(new FlySwatterInteractiveControl(this.selectedGame, this.selectedGameVersion));
            }
            else
            {
                this.GroupsButton.IsEnabled = true;

                this.CustomInteractiveContentControl.Visibility = Visibility.Collapsed;
                this.InteractiveControlsGridView.Visibility     = Visibility.Visible;

                this.CustomInteractiveContentControl.Content = null;

                this.interactiveScenes.Clear();
                if (this.selectedGameVersion != null)
                {
                    foreach (InteractiveSceneModel scene in this.selectedGameVersion.controls.scenes)
                    {
                        this.interactiveScenes.Add(scene);
                    }
                }

                if (this.selectedScene != null && this.interactiveScenes.Any(s => s.sceneID.Equals(this.selectedScene.sceneID)))
                {
                    this.InteractiveScenesComboBox.SelectedItem = this.interactiveScenes.First(s => s.sceneID.Equals(this.selectedScene.sceneID));
                }
                else
                {
                    this.InteractiveScenesComboBox.SelectedIndex = 0;
                }

                this.InteractiveScenesComboBox.IsEnabled = true;
                this.GroupsButton.IsEnabled = true;
            }

            this.ConnectButton.IsEnabled = true;

            if (ChannelSession.Interactive.IsConnected())
            {
                await this.InteractiveGameConnected();
            }
        }
 public async Task <InteractiveGameVersionModel> GetInteractiveGameVersion(InteractiveGameVersionModel version)
 {
     return(await this.RunAsync(this.Connection.Interactive.GetInteractiveGameVersion(version)));
 }
 /// <summary>
 /// Deletes the specified interactive game version.
 /// </summary>
 /// <param name="version">The interactive game version to delete</param>
 /// <returns>Whether the operation succeeded</returns>
 public async Task <bool> DeleteInteractiveGameVersion(InteractiveGameVersionModel version)
 {
     Validator.ValidateVariable(version, "version");
     return(await this.DeleteAsync("interactive/versions/" + version.id));
 }
Beispiel #23
0
        public DropMapInteractiveControl(DropMapTypeEnum dropMapType, InteractiveGameModel game, InteractiveGameVersionModel version)
            : base(game, version)
        {
            InitializeComponent();

            this.MapComboBox.ItemsSource = this.maps;

            this.maps.Add(new PUBGMap()
            {
                Name = ErangelMapName, Map = "map1.png"
            });
            this.maps.Add(new PUBGMap()
            {
                Name = MiramarMapName, Map = "map2.png"
            });
            this.maps.Add(new PUBGMap()
            {
                Name = SanhokMapName, Map = "map3.png"
            });
            this.maps.Add(new PUBGMap()
            {
                Name = VikendiMapName, Map = "map4.png"
            });

            this.dropMapType = dropMapType;

            JObject settings = this.GetCustomSettings();

            if (settings.ContainsKey(MaxTimeSettingProperty))
            {
                this.maxTime = settings[MaxTimeSettingProperty].ToObject <int>();
            }
            if (settings.ContainsKey(SparkCostSettingProperty))
            {
                this.sparkCost = settings[SparkCostSettingProperty].ToObject <int>();
            }

            this.MapImage.SizeChanged += MapImage_SizeChanged;
        }
Beispiel #24
0
        private async Task FinalizeNewUser()
        {
            if (this.scorpBotData != null)
            {
                // Import Ranks
                int    rankEnabled   = this.scorpBotData.GetIntSettingsValue("currency", "enabled");
                string rankName      = this.scorpBotData.GetSettingsValue("currency", "name", "Rank");
                int    rankInterval  = this.scorpBotData.GetIntSettingsValue("currency", "onlinepayinterval");
                int    rankAmount    = this.scorpBotData.GetIntSettingsValue("currency", "activeuserbonus");
                int    rankMaxAmount = this.scorpBotData.GetIntSettingsValue("currency", "maxlimit");
                if (rankMaxAmount <= 0)
                {
                    rankMaxAmount = int.MaxValue;
                }
                int    rankOnFollowBonus    = this.scorpBotData.GetIntSettingsValue("currency", "onfollowbonus");
                int    rankOnSubBonus       = this.scorpBotData.GetIntSettingsValue("currency", "onsubbonus");
                int    rankSubBonus         = this.scorpBotData.GetIntSettingsValue("currency", "subbonus");
                string rankCommand          = this.scorpBotData.GetSettingsValue("currency", "command", "");
                string rankCommandResponse  = this.scorpBotData.GetSettingsValue("currency", "response", "");
                string rankUpCommand        = this.scorpBotData.GetSettingsValue("currency", "Currency1RankUpMsg", "");
                int    rankAccumulationType = this.scorpBotData.GetIntSettingsValue("currency", "ranksrectype");

                UserCurrencyViewModel rankCurrency       = null;
                UserCurrencyViewModel rankPointsCurrency = null;
                if (!string.IsNullOrEmpty(rankName))
                {
                    if (rankAccumulationType == 1)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName.Equals("Points") ? "Hours" : rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName.Equals("Points") ? "Hours" : rankName),
                            AcquireInterval   = 60,
                            AcquireAmount     = 1,
                            MaxAmount         = rankMaxAmount,
                        };

                        if (rankInterval >= 0 && rankAmount >= 0)
                        {
                            rankPointsCurrency = new UserCurrencyViewModel()
                            {
                                Name = "Points",
                                SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                                AcquireInterval   = rankInterval,
                                AcquireAmount     = rankAmount,
                                MaxAmount         = rankMaxAmount,
                                OnFollowBonus     = rankOnFollowBonus,
                                OnSubscribeBonus  = rankOnSubBonus,
                                SubscriberBonus   = rankSubBonus,
                                ModeratorBonus    = rankSubBonus
                            };

                            ChannelSession.Settings.Currencies[rankPointsCurrency.ID] = rankPointsCurrency;
                        }
                    }
                    else if (rankInterval >= 0 && rankAmount >= 0)
                    {
                        rankCurrency = new UserCurrencyViewModel()
                        {
                            Name = rankName,
                            SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rankName),
                            AcquireInterval   = rankInterval,
                            AcquireAmount     = rankAmount,
                            MaxAmount         = rankMaxAmount,
                            OnFollowBonus     = rankOnFollowBonus,
                            OnSubscribeBonus  = rankOnSubBonus,
                            SubscriberBonus   = rankSubBonus,
                            ModeratorBonus    = rankSubBonus
                        };
                    }
                }

                // Import Currency
                int    currencyEnabled   = this.scorpBotData.GetIntSettingsValue("currency2", "enabled");
                string currencyName      = this.scorpBotData.GetSettingsValue("currency2", "name", "Currency");
                int    currencyInterval  = this.scorpBotData.GetIntSettingsValue("currency2", "onlinepayinterval");
                int    currencyAmount    = this.scorpBotData.GetIntSettingsValue("currency2", "activeuserbonus");
                int    currencyMaxAmount = this.scorpBotData.GetIntSettingsValue("currency2", "maxlimit");
                if (currencyMaxAmount <= 0)
                {
                    currencyMaxAmount = int.MaxValue;
                }
                int    currencyOnFollowBonus   = this.scorpBotData.GetIntSettingsValue("currency2", "onfollowbonus");
                int    currencyOnSubBonus      = this.scorpBotData.GetIntSettingsValue("currency2", "onsubbonus");
                int    currencySubBonus        = this.scorpBotData.GetIntSettingsValue("currency2", "subbonus");
                string currencyCommand         = this.scorpBotData.GetSettingsValue("currency2", "command", "");
                string currencyCommandResponse = this.scorpBotData.GetSettingsValue("currency2", "response", "");

                UserCurrencyViewModel currency = null;
                if (!string.IsNullOrEmpty(currencyName) && currencyInterval >= 0 && currencyAmount >= 0)
                {
                    currency = new UserCurrencyViewModel()
                    {
                        Name          = currencyName, SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(currencyName), AcquireInterval = currencyInterval,
                        AcquireAmount = currencyAmount, MaxAmount = currencyMaxAmount, OnFollowBonus = currencyOnFollowBonus, OnSubscribeBonus = currencyOnSubBonus,
                    };
                    ChannelSession.Settings.Currencies[currency.ID] = currency;

                    if (!string.IsNullOrEmpty(currencyCommand) && !string.IsNullOrEmpty(currencyCommandResponse))
                    {
                        currencyCommandResponse = currencyCommandResponse.Replace("$points2", "$" + currency.UserAmountSpecialIdentifier);
                        currencyCommandResponse = currencyCommandResponse.Replace("$currencyname2", currency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(currencyCommand, currencyCommandResponse));
                    }
                }

                foreach (ScorpBotViewer viewer in this.scorpBotData.Viewers)
                {
                    ChannelSession.Settings.UserData[viewer.ID] = new UserDataViewModel(viewer);

                    if (rankPointsCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankPointsCurrency, (int)viewer.RankPoints);
                    }

                    if (rankCurrency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rankCurrency, (rankPointsCurrency != null) ? (int)viewer.Hours : (int)viewer.RankPoints);
                    }

                    if (currency != null)
                    {
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(currency, (int)viewer.Currency);
                    }
                }

                if (rankCurrency != null)
                {
                    ChannelSession.Settings.Currencies[rankCurrency.ID] = rankCurrency;

                    foreach (ScorpBotRank rank in this.scorpBotData.Ranks)
                    {
                        rankCurrency.Ranks.Add(new UserRankViewModel(rank.Name, rank.Amount));
                    }

                    if (!string.IsNullOrEmpty(rankCommand) && !string.IsNullOrEmpty(rankCommandResponse))
                    {
                        rankCommandResponse = rankCommandResponse.Replace(" / Raids: $raids", "");
                        rankCommandResponse = rankCommandResponse.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankCommandResponse = rankCommandResponse.Replace("$currencyname", rankCurrency.Name);
                        this.scorpBotData.Commands.Add(new ScorpBotCommand(rankCommand, rankCommandResponse));
                    }

                    if (!string.IsNullOrEmpty(rankUpCommand))
                    {
                        rankUpCommand = rankUpCommand.Replace("$rank", "$" + rankCurrency.UserRankNameSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$points", "$" + rankCurrency.UserAmountSpecialIdentifier);
                        rankUpCommand = rankUpCommand.Replace("$currencyname", rankCurrency.Name);

                        ScorpBotCommand scorpCommand = new ScorpBotCommand("rankup", rankUpCommand);
                        ChatCommand     chatCommand  = new ChatCommand(scorpCommand);

                        rankCurrency.RankChangedCommand = new CustomCommand("User Rank Changed");
                        rankCurrency.RankChangedCommand.Actions.AddRange(chatCommand.Actions);
                    }
                }

                foreach (ScorpBotCommand command in this.scorpBotData.Commands)
                {
                    command.ProcessData(currency, rankCurrency);
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
                }

                foreach (ScorpBotTimer timer in this.scorpBotData.Timers)
                {
                    ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
                }

                foreach (string quote in this.scorpBotData.Quotes)
                {
                    ChannelSession.Settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                if (ChannelSession.Settings.UserQuotes.Count > 0)
                {
                    ChannelSession.Settings.QuotesEnabled = true;
                }

                if (this.scorpBotData.GetBoolSettingsValue("settings", "filtwordsen"))
                {
                    foreach (string filteredWord in this.scorpBotData.FilteredWords)
                    {
                        ChannelSession.Settings.FilteredWords.Add(filteredWord);
                    }
                    ChannelSession.Settings.ModerationFilteredWordsExcempt = this.scorpBotData.GetUserRoleSettingsValue("settings", "FilteredWordsPerm");
                }

                if (this.scorpBotData.GetBoolSettingsValue("settings", "chatcapschecknowarnregs"))
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.User;
                }
                else if (this.scorpBotData.GetBoolSettingsValue("settings", "chatcapschecknowarnsubs"))
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.Subscriber;
                }
                else if (this.scorpBotData.GetBoolSettingsValue("settings", "chatcapschecknowarnmods"))
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.Mod;
                }
                else
                {
                    ChannelSession.Settings.ModerationChatTextExcempt = MixerRoleEnum.Streamer;
                }

                ChannelSession.Settings.ModerationCapsBlockIsPercentage = !this.scorpBotData.GetBoolSettingsValue("settings", "chatcapsfiltertype");
                if (ChannelSession.Settings.ModerationCapsBlockIsPercentage)
                {
                    ChannelSession.Settings.ModerationCapsBlockCount = this.scorpBotData.GetIntSettingsValue("settings", "chatperccaps");
                }
                else
                {
                    ChannelSession.Settings.ModerationCapsBlockCount = this.scorpBotData.GetIntSettingsValue("settings", "chatmincaps");
                }

                ChannelSession.Settings.ModerationBlockLinks        = this.scorpBotData.GetBoolSettingsValue("settings", "chatlinkalertsdel");
                ChannelSession.Settings.ModerationBlockLinksExcempt = this.scorpBotData.GetUserRoleSettingsValue("settings", "chatlinkalertsdelperm");
            }

            if (this.streamlabsChatBotData != null)
            {
                UserCurrencyViewModel rank = new UserCurrencyViewModel()
                {
                    Name = "Rank",
                    SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("rank"),
                    AcquireInterval   = 60,
                    AcquireAmount     = 1
                };

                foreach (StreamlabsChatBotRank slrank in this.streamlabsChatBotData.Ranks)
                {
                    rank.Ranks.Add(new UserRankViewModel(slrank.Name, slrank.Requirement));
                }

                UserCurrencyViewModel currency = new UserCurrencyViewModel()
                {
                    Name = "Points",
                    SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier("points"),
                    AcquireInterval   = 1,
                    AcquireAmount     = 1
                };

                ChannelSession.Settings.Currencies[rank.ID]     = rank;
                ChannelSession.Settings.Currencies[currency.ID] = currency;

                this.AddCurrencyRankCommands(rank);
                this.AddCurrencyRankCommands(currency);

                foreach (StreamlabsChatBotViewer viewer in this.streamlabsChatBotData.Viewers)
                {
                    UserModel user = await ChannelSession.Connection.GetUser(viewer.Name);

                    if (user != null)
                    {
                        viewer.ID = user.id;
                        ChannelSession.Settings.UserData[viewer.ID] = new UserDataViewModel(viewer);
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(rank, viewer.Hours);
                        ChannelSession.Settings.UserData[viewer.ID].SetCurrencyAmount(currency, viewer.Points);
                    }
                }

                foreach (StreamlabsChatBotCommand command in this.streamlabsChatBotData.Commands)
                {
                    command.ProcessData(currency, rank);
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));
                }

                foreach (StreamlabsChatBotTimer timer in this.streamlabsChatBotData.Timers)
                {
                    StreamlabsChatBotCommand command = new StreamlabsChatBotCommand()
                    {
                        Command = timer.Name, Response = timer.Response, Enabled = timer.Enabled
                    };
                    command.ProcessData(currency, rank);
                    ChannelSession.Settings.ChatCommands.Add(new ChatCommand(command));

                    timer.Actions = command.Actions;

                    ChannelSession.Settings.TimerCommands.Add(new TimerCommand(timer));
                }

                foreach (string quote in this.streamlabsChatBotData.Quotes)
                {
                    ChannelSession.Settings.UserQuotes.Add(new UserQuoteViewModel(quote));
                }

                if (ChannelSession.Settings.UserQuotes.Count > 0)
                {
                    ChannelSession.Settings.QuotesEnabled = true;
                }
            }

            if (this.soundwaveData != null && this.soundwaveProfiles != null && this.soundwaveProfiles.Count(p => p.AddProfile) > 0)
            {
                if (this.soundwaveData.StaticCooldown)
                {
                    ChannelSession.Settings.CooldownGroups[SoundwaveInteractiveCooldownGroupName] = this.soundwaveData.StaticCooldownAmount / 1000;
                }

                InteractiveGameListingModel soundwaveGame = this.interactiveGames.FirstOrDefault(g => g.name.Equals(SoundwaveInteractiveGameName));
                if (soundwaveGame != null)
                {
                    InteractiveGameVersionModel version = soundwaveGame.versions.FirstOrDefault();
                    if (version != null)
                    {
                        InteractiveGameVersionModel soundwaveGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(version);

                        if (soundwaveGameVersion != null)
                        {
                            InteractiveSceneModel soundwaveGameScene = soundwaveGameVersion.controls.scenes.FirstOrDefault();
                            if (soundwaveGameScene != null)
                            {
                                foreach (string profile in this.soundwaveProfiles.Where(p => p.AddProfile).Select(p => p.Name))
                                {
                                    // Add code logic to create Interactive Game on Mixer that is a copy of the Soundwave Interactive game, but with buttons filed in with name and not disabled
                                    InteractiveSceneModel       profileScene = InteractiveGameHelper.CreateDefaultScene();
                                    InteractiveGameListingModel profileGame  = await ChannelSession.Connection.CreateInteractiveGame(ChannelSession.Channel, ChannelSession.User, profile, profileScene);

                                    InteractiveGameVersionModel gameVersion = profileGame.versions.FirstOrDefault();
                                    if (gameVersion != null)
                                    {
                                        InteractiveGameVersionModel profileGameVersion = await ChannelSession.Connection.GetInteractiveGameVersion(gameVersion);

                                        if (profileGameVersion != null)
                                        {
                                            profileScene = profileGameVersion.controls.scenes.First();

                                            for (int i = 0; i < this.soundwaveData.Profiles[profile].Count(); i++)
                                            {
                                                SoundwaveButton soundwaveButton = this.soundwaveData.Profiles[profile][i];
                                                InteractiveButtonControlModel soundwaveControl = (InteractiveButtonControlModel)soundwaveGameScene.allControls.FirstOrDefault(c => c.controlID.Equals(i.ToString()));

                                                InteractiveButtonControlModel button = InteractiveGameHelper.CreateButton(soundwaveButton.name, soundwaveButton.name, soundwaveButton.sparks);
                                                button.position = soundwaveControl.position;

                                                RequirementViewModel requirements = new RequirementViewModel();
                                                requirements.Cooldown.Amount = soundwaveButton.cooldown;
                                                if (this.soundwaveData.StaticCooldown)
                                                {
                                                    requirements.Cooldown.Type      = CooldownTypeEnum.Group;
                                                    requirements.Cooldown.GroupName = SoundwaveInteractiveCooldownGroupName;
                                                }
                                                InteractiveButtonCommand command = new InteractiveButtonCommand(profileGame, profileScene, button, InteractiveButtonCommandTriggerType.MouseDown, requirements);

                                                SoundAction action = new SoundAction(soundwaveButton.path, soundwaveButton.volume);
                                                command.Actions.Add(action);

                                                ChannelSession.Settings.InteractiveCommands.Add(command);
                                                profileScene.buttons.Add(button);
                                            }

                                            await ChannelSession.Connection.UpdateInteractiveGameVersion(profileGameVersion);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            await ChannelSession.SaveSettings();
        }
 public DropMapInterativeGameControl(InteractiveGameModel game, InteractiveGameVersionModel version) : base(game, version)
 {
 }
Beispiel #26
0
        /// <summary>
        /// Creates an interactive client using the specified connection to the specified channel and game.
        /// </summary>
        /// <param name="connection">The connection to use</param>
        /// <param name="channel">The channel to connect to</param>
        /// <param name="interactiveGame">The game to use</param>
        /// <param name="version">The version of the game to use</param>
        /// <param name="shareCode">The share code used to connect to a game shared with you</param>
        /// <returns>The interactive client for the specified channel and game</returns>
        public static async Task <InteractiveClient> CreateFromChannel(MixerConnection connection, ChannelModel channel, InteractiveGameModel interactiveGame, InteractiveGameVersionModel version, string shareCode)
        {
            Validator.ValidateVariable(connection, "connection");
            Validator.ValidateVariable(channel, "channel");
            Validator.ValidateVariable(interactiveGame, "interactiveGame");
            Validator.ValidateVariable(version, "version");

            OAuthTokenModel authToken = await connection.GetOAuthToken();

            IEnumerable <string> interactiveConnections = await connection.Interactive.GetInteractiveHosts();

            return(new InteractiveClient(channel, interactiveGame, version, shareCode, authToken, interactiveConnections));
        }
 public MixerPaintInteractiveControl(InteractiveGameModel game, InteractiveGameVersionModel version)
     : base(game, version)
 {
     InitializeComponent();
 }
Beispiel #28
0
        private InteractiveClient(ChannelModel channel, InteractiveGameModel interactiveGame, InteractiveGameVersionModel version, string shareCode, OAuthTokenModel authToken, IEnumerable <string> interactiveConnections)
        {
            Validator.ValidateVariable(channel, "channel");
            Validator.ValidateVariable(interactiveGame, "interactiveGame");
            Validator.ValidateVariable(version, "version");
            Validator.ValidateVariable(authToken, "authToken");
            Validator.ValidateList(interactiveConnections, "interactiveConnections");

            this.Channel                = channel;
            this.InteractiveGame        = interactiveGame;
            this.Version                = version;
            this.ShareCode              = shareCode;
            this.interactiveConnections = interactiveConnections;

            this.oauthAccessToken = authToken.accessToken;
        }
Beispiel #29
0
        /// <summary>
        /// Creates an interactive client using the specified connection to the specified channel and game.
        /// </summary>
        /// <param name="connection">The connection to use</param>
        /// <param name="channel">The channel to connect to</param>
        /// <param name="interactiveGame">The game to use</param>
        /// <param name="version">The version of the game to use</param>
        /// <returns>The interactive client for the specified channel and game</returns>
        public static async Task <InteractiveClient> CreateFromChannel(MixerConnection connection, ChannelModel channel, InteractiveGameModel interactiveGame, InteractiveGameVersionModel version)
        {
            Validator.ValidateVariable(connection, "connection");
            Validator.ValidateVariable(channel, "channel");
            Validator.ValidateVariable(interactiveGame, "interactiveGame");
            Validator.ValidateVariable(version, "version");

            return(await InteractiveClient.CreateFromChannel(connection, channel, interactiveGame, version, null));
        }
        public static async Task <InteractiveGameListingModel> CreateTestGame(MixerConnection connection, ChannelModel channel)
        {
            UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection);

            IEnumerable <InteractiveGameListingModel> gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel);

            InteractiveGameListingModel previousTestGame = gameListings.FirstOrDefault(g => g.name.Equals(InteractiveServiceUnitTests.InteractiveGameName));

            if (previousTestGame != null)
            {
                await InteractiveServiceUnitTests.DeleteTestGame(connection, previousTestGame);
            }

            InteractiveGameModel game = new InteractiveGameModel()
            {
                name    = InteractiveServiceUnitTests.InteractiveGameName,
                ownerId = user.id,
            };

            game = await connection.Interactive.CreateInteractiveGame(game);

            Assert.IsNotNull(game);
            Assert.IsTrue(game.id > 0);

            game.controlVersion = "2.0";
            game = await connection.Interactive.UpdateInteractiveGame(game);

            Assert.IsNotNull(game);
            Assert.IsTrue(game.id > 0);

            gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel);

            Assert.IsNotNull(gameListings);
            Assert.IsTrue(gameListings.Count() > 0);

            InteractiveGameListingModel gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id));

            Assert.IsNotNull(gameListing);

            InteractiveGameVersionModel version      = gameListing.versions.First();
            InteractiveSceneModel       defaultScene = new InteractiveSceneModel()
            {
                sceneID = "default",
            };

            defaultScene.buttons.Add(InteractiveClientUnitTests.CreateTestButton());
            defaultScene.joysticks.Add(InteractiveClientUnitTests.CreateTestJoystick());

            version.controls.scenes.Add(defaultScene);
            version.controlVersion = "2.0";
            version = await connection.Interactive.UpdateInteractiveGameVersion(version);

            gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel);

            Assert.IsNotNull(gameListings);
            Assert.IsTrue(gameListings.Count() > 0);

            gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id));
            Assert.IsNotNull(gameListing);

            return(gameListing);
        }