Exemple #1
0
        public RouletteGameEditorControlViewModel(RouletteGameCommand command)
        {
            this.existingCommand = command;

            this.MinimumParticipants = this.existingCommand.MinimumParticipants;
            this.TimeLimit           = this.existingCommand.TimeLimit;
            this.UserPayout          = (this.existingCommand.UserSuccessOutcome.RolePayouts[UserRoleEnum.User] * 100);
            this.SubscriberPayout    = (this.existingCommand.UserSuccessOutcome.RolePayouts[UserRoleEnum.Subscriber] * 100);
            this.ModPayout           = (this.existingCommand.UserSuccessOutcome.RolePayouts[UserRoleEnum.Mod] * 100);
            this.IsNumberRange       = this.existingCommand.IsNumberRange;
            if (this.existingCommand.IsNumberRange)
            {
                IEnumerable <int> numberBetTypes = this.existingCommand.ValidBetTypes.Select(b => int.Parse(b));
                this.NumberRangeMinimum = numberBetTypes.Min();
                this.NumberRangeMaximum = numberBetTypes.Max();
            }
            else
            {
                this.SelectableBetTypes = string.Join(Environment.NewLine, this.existingCommand.ValidBetTypes);
            }

            this.StartedCommand = this.existingCommand.StartedCommand;

            this.UserJoinCommand         = this.existingCommand.UserJoinCommand;
            this.NotEnoughPlayersCommand = this.existingCommand.NotEnoughPlayersCommand;

            this.UserSuccessCommand  = this.existingCommand.UserSuccessOutcome.Command;
            this.UserFailCommand     = this.existingCommand.UserFailOutcome.Command;
            this.GameCompleteCommand = this.existingCommand.GameCompleteCommand;
        }
Exemple #2
0
        public RouletteGameEditorControl(RouletteGameCommand command)
        {
            InitializeComponent();

            this.existingCommand = command;
            this.viewModel       = new RouletteGameEditorControlViewModel(command);
        }
Exemple #3
0
        public override void SaveGameCommand()
        {
            int.TryParse(this.MinimumParticipantsTextBox.Text, out int minimumParticipants);
            int.TryParse(this.TimeLimitTextBox.Text, out int timeLimit);

            double.TryParse(this.UserPayoutTextBox.Text, out double userPayout);
            double.TryParse(this.SubscriberPayoutTextBox.Text, out double subscriberPayout);
            double.TryParse(this.ModPayoutTextBox.Text, out double modPayout);

            HashSet <string> validBetTypes = new HashSet <string>();

            if (this.IsNumberRangeToggleButton.IsChecked.GetValueOrDefault())
            {
                int.TryParse(this.NumberRangeMinimumTextBox.Text, out int minNumber);
                int.TryParse(this.NumberRangeMaximumTextBox.Text, out int maxNumber);
                for (int i = minNumber; i <= maxNumber; i++)
                {
                    validBetTypes.Add(i.ToString());
                }
            }
            else
            {
                foreach (string betType in this.SelectableBetTypesTextBox.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    validBetTypes.Add(betType.ToLower());
                }
            }

            userPayout       = userPayout / 100.0;
            subscriberPayout = subscriberPayout / 100.0;
            modPayout        = modPayout / 100.0;

            Dictionary <MixerRoleEnum, double> successRolePayouts = new Dictionary <MixerRoleEnum, double>()
            {
                { MixerRoleEnum.User, userPayout }, { MixerRoleEnum.Subscriber, subscriberPayout }, { MixerRoleEnum.Mod, modPayout }
            };
            Dictionary <MixerRoleEnum, int> roleProbabilities = new Dictionary <MixerRoleEnum, int>()
            {
                { MixerRoleEnum.User, 0 }, { MixerRoleEnum.Subscriber, 0 }, { MixerRoleEnum.Mod, 0 }
            };

            GameCommandBase newCommand = new RouletteGameCommand(this.CommandDetailsControl.GameName, this.CommandDetailsControl.ChatTriggers,
                                                                 this.CommandDetailsControl.GetRequirements(), minimumParticipants, timeLimit, this.IsNumberRangeToggleButton.IsChecked.GetValueOrDefault(), validBetTypes,
                                                                 this.startedCommand, this.userJoinCommand, new GameOutcome("Success", successRolePayouts, roleProbabilities, this.userSuccessCommand),
                                                                 new GameOutcome("Failure", 0, roleProbabilities, this.userFailCommand), this.gameCompleteCommand);

            if (this.existingCommand != null)
            {
                ChannelSession.Settings.GameCommands.Remove(this.existingCommand);
                newCommand.ID = this.existingCommand.ID;
            }
            ChannelSession.Settings.GameCommands.Add(newCommand);
        }
Exemple #4
0
        public override void SaveGameCommand(string name, IEnumerable <string> triggers, RequirementViewModel requirements)
        {
            HashSet <string> validBetTypes = new HashSet <string>();

            if (this.IsNumberRange)
            {
                for (int i = this.NumberRangeMinimum; i <= this.NumberRangeMaximum; i++)
                {
                    validBetTypes.Add(i.ToString());
                }
            }
            else
            {
                foreach (string betType in this.SelectableBetTypes.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    validBetTypes.Add(betType.ToLower());
                }
            }

            this.UserPayout       = this.UserPayout / 100.0;
            this.SubscriberPayout = this.SubscriberPayout / 100.0;
            this.ModPayout        = this.ModPayout / 100.0;

            Dictionary <MixerRoleEnum, double> successRolePayouts = new Dictionary <MixerRoleEnum, double>()
            {
                { MixerRoleEnum.User, this.UserPayout }, { MixerRoleEnum.Subscriber, this.SubscriberPayout }, { MixerRoleEnum.Mod, this.ModPayout = this.ModPayout }
            };
            Dictionary <MixerRoleEnum, int> roleProbabilities = new Dictionary <MixerRoleEnum, int>()
            {
                { MixerRoleEnum.User, 0 }, { MixerRoleEnum.Subscriber, 0 }, { MixerRoleEnum.Mod, 0 }
            };

            GameCommandBase newCommand = new RouletteGameCommand(name, triggers, requirements, this.MinimumParticipants, this.TimeLimit, this.IsNumberRange, validBetTypes,
                                                                 this.StartedCommand, this.UserJoinCommand, new GameOutcome("Success", successRolePayouts, roleProbabilities, this.UserSuccessCommand),
                                                                 new GameOutcome("Failure", 0, roleProbabilities, this.UserFailCommand), this.GameCompleteCommand, this.NotEnoughPlayersCommand);

            if (this.existingCommand != null)
            {
                ChannelSession.Settings.GameCommands.Remove(this.existingCommand);
                newCommand.ID = this.existingCommand.ID;
            }
            ChannelSession.Settings.GameCommands.Add(newCommand);
        }
Exemple #5
0
 public RouletteGameEditorControl(RouletteGameCommand command)
     : this()
 {
     this.existingCommand = command;
 }