private void AddToView(CashOutData cd) { Dispatcher.Invoke(() => { PreviousGames.Items.Add(cd); if (PreviousGames.Items.Count > 5) { PreviousGames.Items.RemoveAt(0); } var dbCashOut = new Cashout { GameId = cd.game_id, GameLink = cd.gameLink, Id = _gameDataContext.Cashout.NextId(), LastUpdate = DateTime.Now.ToFileTime(), Mines = cd.mines, RandomString = cd.random_string, Win = (long)cd.win, BalanceAfter = (GetBalance().balance *ConvertMultiplier).ToString("0.0", new CultureInfo("en-US")) }; _gameDataContext.Cashout.Insert(dbCashOut); }); }
private void OnLoss(BalanceData bal) { _losses++; _currentGuesses = 0; _isPreroll = true; var lss = new CashOutData { game_id = _gameData.id.ToString(), outcome = "LOSS", win = 0, wins = ((_wins / (_wins + _losses)) * 100).ToString("##.##"), }; foreach (var pickedNumber in _pickedNumbers) { lss.mines += pickedNumber; } _pickedNumbers.Clear(); AddToView(lss); if (_isPractice) { _currentBalance -= double.Parse((_currentBet).ToString("0.000000", new CultureInfo("en-US"))); _profit -= double.Parse((_currentBet / (decimal)ConvertMultiplier).ToString("0.000000", new CultureInfo("en-US"))); } if (!_gameIsStop) { if (_currentBet > 0) { _currentBet = _currentBet * (decimal)_multiplier; _beforePreroll = _currentBet; } if (_currentBet > 0) { _currentBet = 0; NewGame(); } else { if (_currentBet <= (decimal)bal.balance || bal.balance == 0) { if (_currentBet > _maxBet) { _currentBet = _baseBet; } NewGame(); } else { _gameIsStop = true; _isError = true; _title = "Betting Stopped"; _message = "The current bet is bigger than balance"; } } } else { _gameIsStop = true; _isError = true; _title = "Betting Stopped"; _message = "The game was ended"; } }