Beispiel #1
0
 public bool HasPermissionsTo(MixerRoleEnum checkRole)
 {
     if (checkRole == MixerRoleEnum.Subscriber && this.IsEquivalentToMixerSubscriber())
     {
         return(true);
     }
     return(this.PrimaryRole >= checkRole);
 }
Beispiel #2
0
 public static InteractiveAction CreateMoveUserToSceneAction(string sceneID, MixerRoleEnum requiredRole, string username = null)
 {
     return(new InteractiveAction(InteractiveActionTypeEnum.MoveUserToScene)
     {
         GroupName = sceneID,
         SceneID = sceneID,
         RoleRequirement = requiredRole,
         OptionalUserName = username,
     });
 }
Beispiel #3
0
 public CurrencyAction(UserCurrencyViewModel currency, CurrencyActionTypeEnum currencyActionType, string amount, string username = null,
                       MixerRoleEnum roleRequirement = MixerRoleEnum.User, bool deductFromUser = false)
     : this()
 {
     this.CurrencyID         = currency.ID;
     this.CurrencyActionType = currencyActionType;
     this.Amount             = amount;
     this.Username           = username;
     this.RoleRequirement    = roleRequirement;
     this.DeductFromUser     = deductFromUser;
 }
Beispiel #4
0
 public CurrencyAction(UserInventoryViewModel inventory, CurrencyActionTypeEnum currencyActionType, string itemName = null, string amount = null, string username = null,
                       MixerRoleEnum roleRequirement = MixerRoleEnum.User, bool deductFromUser = false)
     : this()
 {
     this.InventoryID        = inventory.ID;
     this.CurrencyActionType = currencyActionType;
     this.ItemName           = itemName;
     this.Amount             = amount;
     this.Username           = username;
     this.RoleRequirement    = roleRequirement;
     this.DeductFromUser     = deductFromUser;
 }
        private static MixerRoleEnum ConvertLegacyRoles(MixerRoleEnum legacyRole)
        {
            int legacyRoleID = (int)legacyRole;

            if ((int)MixerRoleEnum.Custom == legacyRoleID)
            {
                return(MixerRoleEnum.Custom);
            }
            else
            {
                return((MixerRoleEnum)(legacyRoleID * 10));
            }
        }
 private void TitleRoleComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     this.TitleMinimumMonthsTextBox.IsEnabled = false;
     this.TitleMinimumMonthsTextBox.Text      = string.Empty;
     if (this.TitleRoleComboBox.SelectedIndex >= 0)
     {
         MixerRoleEnum role = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.TitleRoleComboBox.SelectedItem);
         if (role == MixerRoleEnum.Follower || role == MixerRoleEnum.Subscriber)
         {
             this.TitleMinimumMonthsTextBox.IsEnabled = true;
             this.TitleMinimumMonthsTextBox.Text      = "0";
         }
     }
 }
        public void SetRoleBasedOnString(string role)
        {
            MixerRoleEnum mixerRole = EnumHelper.GetEnumValueFromString <MixerRoleEnum>(role);

            if (mixerRole > MixerRoleEnum.Banned)
            {
                this.MixerRole = mixerRole;
            }
            else
            {
                this.MixerRole  = MixerRoleEnum.Custom;
                this.CustomRole = role;
            }
        }
        public override ActionBase GetAction()
        {
            if (this.CurrencyTypeComboBox.SelectedIndex >= 0 && this.CurrencyActionTypeComboBox.SelectedIndex >= 0)
            {
                UserCurrencyViewModel  currency   = this.GetSelectedCurrency();
                UserInventoryViewModel inventory  = this.GetSelectedInventory();
                CurrencyActionTypeEnum actionType = EnumHelper.GetEnumValueFromString <CurrencyActionTypeEnum>((string)this.CurrencyActionTypeComboBox.SelectedItem);

                if (actionType == CurrencyActionTypeEnum.ResetForAllUsers || actionType == CurrencyActionTypeEnum.ResetForUser || !string.IsNullOrEmpty(this.CurrencyAmountTextBox.Text))
                {
                    if (actionType == CurrencyActionTypeEnum.AddToSpecificUser)
                    {
                        if (string.IsNullOrEmpty(this.CurrencyUsernameTextBox.Text))
                        {
                            return(null);
                        }
                    }

                    MixerRoleEnum roleRequirement = MixerRoleEnum.User;
                    if (actionType == CurrencyActionTypeEnum.AddToAllChatUsers || actionType == CurrencyActionTypeEnum.SubtractFromAllChatUsers)
                    {
                        if (this.CurrencyPermissionsAllowedComboBox.SelectedIndex < 0)
                        {
                            return(null);
                        }
                        roleRequirement = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.CurrencyPermissionsAllowedComboBox.SelectedItem);
                    }

                    if (currency != null)
                    {
                        return(new CurrencyAction(currency, actionType, this.CurrencyAmountTextBox.Text, username: this.CurrencyUsernameTextBox.Text,
                                                  roleRequirement: roleRequirement, deductFromUser: this.DeductFromUserToggleButton.IsChecked.GetValueOrDefault()));
                    }
                    else if (inventory != null)
                    {
                        if (actionType == CurrencyActionTypeEnum.ResetForAllUsers || actionType == CurrencyActionTypeEnum.ResetForUser)
                        {
                            return(new CurrencyAction(inventory, actionType));
                        }
                        else if (!string.IsNullOrEmpty(this.InventoryItemNameComboBox.Text))
                        {
                            return(new CurrencyAction(inventory, actionType, this.InventoryItemNameComboBox.Text, this.CurrencyAmountTextBox.Text,
                                                      username: this.CurrencyUsernameTextBox.Text, roleRequirement: roleRequirement, deductFromUser: this.DeductFromUserToggleButton.IsChecked.GetValueOrDefault()));
                        }
                    }
                }
            }
            return(null);
        }
        public async Task <GameOutcomeGroup> GetOutcomeGroup()
        {
            GameOutcomeGroup group     = null;
            string           groupName = null;

            if (this.RankGroupGrid.Visibility != Visibility.Visible)
            {
                MixerRoleEnum role = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.PreDefinedGroupNameTextBlock.Text);
                groupName = EnumHelper.GetEnumName(role);
                group     = new GameOutcomeGroup(role);
            }
            else if (this.RankTypeComboBox.SelectedIndex >= 0 && this.RankMinimumComboBox.SelectedIndex >= 0)
            {
                CurrencyRequirementViewModel rankRequirement = new CurrencyRequirementViewModel((UserCurrencyViewModel)this.RankTypeComboBox.SelectedItem, (UserRankViewModel)this.RankMinimumComboBox.SelectedItem);
                groupName = rankRequirement.GetCurrency().Name + " - " + rankRequirement.RankName;
                group     = new GameOutcomeGroup(rankRequirement);
            }
            else
            {
                await MessageBoxHelper.ShowMessageDialog("A group is missing the Rank Type & Rank Name");

                return(null);
            }

            if (group != null && !string.IsNullOrEmpty(groupName))
            {
                foreach (GameOutcomeProbabilityControl probabilityControl in this.outcomeProbabilityControls)
                {
                    group.Probabilities.Add(probabilityControl.GetOutcomeProbability());
                }

                if (group.Probabilities.Sum(p => p.Probability) > 100)
                {
                    await MessageBoxHelper.ShowMessageDialog("The group " + groupName + " can not have a combined probability of more than 100%");

                    return(null);
                }
            }

            return(group);
        }
        private async void AddTitleButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.Window.RunAsyncOperation(async() =>
            {
                if (string.IsNullOrEmpty(this.TitleNameTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("A name for the title must be specified");
                    return;
                }

                if (this.TitleRoleComboBox.SelectedIndex < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("A role for the title must be specified");
                    return;
                }

                int months = 0;

                MixerRoleEnum role = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.TitleRoleComboBox.SelectedItem);
                if (role == MixerRoleEnum.Follower || role == MixerRoleEnum.Subscriber)
                {
                    if (!int.TryParse(this.TitleMinimumMonthsTextBox.Text, out months) || months < 0)
                    {
                        await MessageBoxHelper.ShowMessageDialog("A valid amount of months for the title must be specified");
                        return;
                    }
                }

                if (this.titles.Any(t => t.Name.Equals(this.TitleNameTextBox.Text)))
                {
                    await MessageBoxHelper.ShowMessageDialog("A title with the same name already exists");
                    return;
                }

                if (this.titles.Any(t => t.Role.Equals(role)))
                {
                    UserTitleModel existingTitle = this.titles.FirstOrDefault(t => t.Role.Equals(role));
                    if (existingTitle.Role == MixerRoleEnum.Follower || existingTitle.Role == MixerRoleEnum.Subscriber)
                    {
                        if (existingTitle.Months == months)
                        {
                            await MessageBoxHelper.ShowMessageDialog("A title with the same role & months already exists");
                            return;
                        }
                    }
                    else
                    {
                        await MessageBoxHelper.ShowMessageDialog("A title with the same role already exists");
                        return;
                    }
                }

                ChannelSession.Settings.UserTitles.Add(new UserTitleModel(this.TitleNameTextBox.Text, role, months));

                this.TitleNameTextBox.Text           = string.Empty;
                this.TitleRoleComboBox.SelectedIndex = -1;
                this.TitleMinimumMonthsTextBox.Text  = string.Empty;

                this.RefreshTitleList();
            });
        }
Beispiel #11
0
 public GameOutcomeGroup(MixerRoleEnum role) : this()
 {
     this.Role = role;
 }
Beispiel #12
0
 public RequirementViewModel(MixerRoleEnum userRole, int cooldown)
     : this()
 {
     this.Role.MixerRole  = userRole;
     this.Cooldown.Amount = cooldown;
 }
Beispiel #13
0
 public PreMadeChatCommand(string name, List <string> commands, int cooldown, MixerRoleEnum userRole)
     : base(name, commands, new RequirementViewModel(userRole: userRole, cooldown: cooldown))
 {
     this.Requirements.Role.MixerRole = userRole;
 }
 public InteractiveAction(InteractiveActionTypeEnum interactiveType, string groupName = null, string sceneID = null, MixerRoleEnum roleRequirement = MixerRoleEnum.User)
     : this()
 {
     this.InteractiveType = interactiveType;
     this.GroupName       = groupName;
     this.SceneID         = sceneID;
     this.RoleRequirement = roleRequirement;
 }
Beispiel #15
0
 public bool ExceedsPermissions(MixerRoleEnum checkRole)
 {
     return(this.PrimaryRole > checkRole);
 }
 public async Task <Dictionary <uint, DateTimeOffset?> > CheckIfUsersHaveRole(ChannelModel channel, IEnumerable <UserModel> users, MixerRoleEnum role)
 {
     return(await this.RunAsync(this.Connection.Channels.CheckIfUsersHaveRole(channel, users, EnumHelper.GetEnumName(role))));
 }
Beispiel #17
0
 public static InteractiveAction CreateMoveAllUsersToGroupAction(string groupName, MixerRoleEnum requiredRole)
 {
     return(new InteractiveAction(InteractiveActionTypeEnum.MoveAllUsersToGroup)
     {
         GroupName = groupName,
         RoleRequirement = requiredRole,
     });
 }
Beispiel #18
0
 public static InteractiveAction CreateMoveAllUsersToSceneAction(string sceneID, MixerRoleEnum requiredRole)
 {
     return(new InteractiveAction(InteractiveActionTypeEnum.MoveAllUsersToScene)
     {
         GroupName = sceneID,
         SceneID = sceneID,
         RoleRequirement = requiredRole,
     });
 }
 public async Task <IEnumerable <UserWithGroupsModel> > GetUsersWithRoles(ChannelModel channel, MixerRoleEnum role)
 {
     return(await this.RunAsync(this.Connection.Channels.GetUsersWithRoles(channel, role.ToString()), logNotFoundException : false));
 }
 public RoleRequirementViewModel(MixerRoleEnum mixerRole)
 {
     this.MixerRole = mixerRole;
 }
Beispiel #21
0
 public UserTitleModel(string name, MixerRoleEnum role, int months = 0)
 {
     this.Name   = name;
     this.Role   = role;
     this.Months = months;
 }
 public InteractiveUserGroupViewModel(MixerRoleEnum associatedUserRole)
     : this((associatedUserRole != MixerRoleEnum.User) ? EnumHelper.GetEnumName(associatedUserRole) : DefaultName)
 {
     this.AssociatedUserRole = associatedUserRole;
 }