Esempio n. 1
0
        /// <summary>
        /// Set an image source for a specific wheel symbol.
        /// Trying to set the image source twice for the same
        /// symbol will cause an exception.
        /// </summary>
        protected void SetImageSource(Types.Enums.WheelSymbol symbol, string imageSource)
        {
            if (_imageSources.ContainsKey(symbol))
            {
                throw new ArgumentException(nameof(SetImageSource));
            }

            _imageSources.Add(symbol, imageSource);
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieves the image source corresponding to the
        /// specified wheel symbol.
        /// Trying to retrieve the source for a wheel symbol for which
        /// no source has been specificed will cause an exception.
        /// </summary>
        public string GetImageSource(Types.Enums.WheelSymbol symbol)
        {
            if (_imageSources.ContainsKey(symbol))
            {
                return(_imageSources[symbol]);
            }

            throw new ArgumentException(nameof(GetImageSource));
        }
Esempio n. 3
0
        /// <summary>
        /// Retrieves the probability for generating the specified symbol.
        /// An exception is thrown if the probability for the specified
        /// wheel symbol is not set.
        /// </summary>
        public int GetProbability(Types.Enums.WheelSymbol symbol)
        {
            if (!_probabilitySettings.ContainsKey(symbol))
            {
                throw new ArgumentException(nameof(GetProbability));
            }

            return(_probabilitySettings[symbol]);
        }
Esempio n. 4
0
        /// <summary>
        /// Set the probability for generating the specified symbol.
        /// An exception is thrown if the probability percentage is out-of-range.
        /// Note that updating a probability will affect other probabilities,
        /// since the sum of probability percentages is kept constant at 100.
        /// </summary>
        public void SetProbability(Types.Enums.WheelSymbol symbol, int percentage)
        {
            if (percentage < 0 || percentage > 100)
            {
                throw new ArgumentException(nameof(SetProbability));
            }

            SetProbabilityAndKeepConsistent(symbol, percentage);
            OnPropertyChanged(nameof(ProbabilitySettings));
        }
Esempio n. 5
0
        /// <summary>
        /// Updates the specified probability, and adjusts other probabilities
        /// such that the sum of probability percentages is kept constant at 100.
        /// </summary>
        private void SetProbabilityAndKeepConsistent(Types.Enums.WheelSymbol symbolChanged, int percentage)
        {
            int change = percentage - _probabilitySettings[symbolChanged];

            _probabilitySettings[symbolChanged] = percentage;

            // Adjust other probabilities with a total of "change"
            foreach (Types.Enums.WheelSymbol symbol in Enum.GetValues(typeof(Types.Enums.WheelSymbol)))
            {
                if (symbol != symbolChanged && change != 0)
                {
                    // Can we CHANGE probability for this symbol with the full change?
                    int potentialNewProb = _probabilitySettings[symbol] - change;
                    if (potentialNewProb <= 100 && potentialNewProb >= 0)
                    {
                        _probabilitySettings[symbol] = potentialNewProb;
                        change = 0;
                    }
                    else
                    {
                        // We actually decreased, so INCREASE probability for this symbol up to 100
                        if (change < 0 && _probabilitySettings[symbol] < 100)
                        {
                            change = change + (100 - _probabilitySettings[symbol]);
                            _probabilitySettings[symbol] = 100;
                        }

                        // We actually increased, so DECREASE probability for this symbol down to 0
                        if (change > 0 && _probabilitySettings[symbol] > 0)
                        {
                            change = change - _probabilitySettings[symbol];
                            _probabilitySettings[symbol] = 0;
                        }
                    }
                }
            }
        }
Esempio n. 6
0
 public int InitialWinnings(Types.Enums.WheelSymbol symbol, int noOfSymbols)
 {
     return(_initialSettings.InitialWinnings(symbol, noOfSymbols));
 }
Esempio n. 7
0
 public int InitialProbability(Types.Enums.WheelSymbol symbol)
 {
     return(_initialSettings.InitialProbability(symbol));
 }