/// <summary> /// Amend the auto-run data with the specified wheel symbols, /// which is the outcome of a single spin. This update is /// done with thread-safe access to data. /// </summary> private void AddToAutoRunData(WheelSymbolList symbols) { lock (_lock) { if (!_autoRunData.ContainsKey(symbols.NumericKey)) { _autoRunData.Add(symbols.NumericKey, 0); } _autoRunData[symbols.NumericKey]++; } }
/// <summary> /// Calculate winnings for a single game outcome. /// </summary> public int CalculateWinnings(WheelSymbolList symbols) { int winningsAmount = 0; foreach (var item in symbols.WheelSymbolCounts) { int newWinnings = _logicWinningsSetup.GetWinnings(item.Symbol, item.Count); winningsAmount = newWinnings > winningsAmount ? newWinnings : winningsAmount; } return(winningsAmount); }
public ModelAutoPlay( ILogicCalculateWinnings logicCalculateWinnings, ILogicSymbolGenerator logicSymbolGenerator, int noOfRunsInAutoPlay, int updateThreshold) { CurrentAutoPlayState = Enums.AutoPlayState.BeforeFirstInteraction; NoOfRuns = noOfRunsInAutoPlay; PercentCompleted = 0; PercentPayback = 100; _updateThreshold = updateThreshold; _autoRunData = new Dictionary <int, int>(); _symbols = new WheelSymbolList(); _autoCommand = new AutoPlayControllerCommand(this); _logicCalculateWinnings = logicCalculateWinnings; _logicSymbolGenerator = logicSymbolGenerator; _progressHandler = new Progress <int>(i => { OnPropertyChanged(nameof(PercentCompleted)); }); _cancellationTokenSource = null; }
public ModelNormalPlay( ILogicCalculateWinnings logicCalculateWinnings, ILogicSymbolGenerator logicSymbolGenerator, int initialCredits, int noOfRotationsPerSpin, int rotationDelayMilliSecs) : base(new List <IPropertySource>()) { _noOfRotationsPerSpin = noOfRotationsPerSpin; _rotationDelayMilliSecs = rotationDelayMilliSecs; _noOfCredits = initialCredits; _symbols = new WheelSymbolList(); CurrentNormalPlayState = Enums.NormalPlayState.BeforeFirstInteraction; _spinCommand = new SpinControllerCommand(this); _addCreditCommand = new AddCreditsControllerCommand(this); _logicCalculateWinnings = logicCalculateWinnings; _logicSymbolGenerator = logicSymbolGenerator; AddCommandDependency(nameof(IModelNormalPlay.CurrentNormalPlayState), _spinCommand); AddCommandDependency(nameof(IModelNormalPlay.CurrentNormalPlayState), _addCreditCommand); }