예제 #1
0
        private async Task <JackpotMatch> GetMatch(DatabaseModel.JackpotSetting settings, DatabaseModel.Match match, DatabaseModel.GameMode gameMode)
        {
            var items = await _betService.GetBettedItemsOnMatch(match.Id, gameMode.Id) ?? new List <Item>();

            return(new JackpotMatch(
                       match.RoundId.ToString(),
                       match.Hash,
                       match.Salt,
                       match.Percentage,
                       MatchStatusHelper.GetMatchStatusFromInt(match.Status),
                       await GetBets(items, match.Id, gameMode),
                       match.TimerStarted,
                       settings.ToJackpotMatchSetting()
                       ));
        }
예제 #2
0
        public async Task <JackpotMatchHistoryDetailed> GetMatchHistory(int roundId)
        {
            var match = await _repoServiceFactory.MatchRepoService.FindAsync(roundId);

            if (MatchStatusHelper.GetMatchStatusFromInt(match.Status) == MatchStatus.Open)
            {
                throw new Exception("Can't fetch history data on active round!");
            }

            var rakeItems = await _repoServiceFactory.RakeItemRepoService.FindAsync(match);

            var itemsBetted = await _betService.GetBettedItemsOnMatch(match.Id, match.GameModeId);

            var basic = await GetHistoryBasic(match);

            var historyDetailed = new JackpotMatchHistoryDetailed
            {
                Bets              = await GetBets(itemsBetted, match.Id, _gameMode),
                Created           = basic.Created,
                Hash              = basic.Hash,
                Percentage        = basic.Percentage,
                RoundId           = basic.RoundId,
                Salt              = basic.Salt,
                UserWinnerImgUrl  = basic.UserWinnerImgUrl,
                UserWinnerName    = basic.UserWinnerName,
                UserWinnerQuote   = basic.UserWinnerQuote,
                UserWinnerSteamId = basic.UserWinnerSteamId
            };

            foreach (var rakeItem in rakeItems)
            {
                foreach (var bet in historyDetailed.Bets)
                {
                    foreach (var betItem in bet.Items)
                    {
                        if (betItem.AssetId == rakeItem.AssetId && betItem.DescriptionId == rakeItem.DescriptionId)
                        {
                            betItem.TookAsRake = true;
                        }
                    }
                }
            }

            return(historyDetailed);
        }
예제 #3
0
        public async Task <DatabaseModel.Match> CreateNewMatchAsync(int roundId)
        {
            var settingRes = await _gameModeSettingService.GetSettingForType(GameModeType.JackpotCsgo);

            _currentMatchSettings = (DatabaseModel.JackpotSetting)settingRes ?? throw new NullReferenceException("The match setting is NULL!");

            _gameMode = await _repoServiceFactory.GameModeRepoService.Find(GameModeHelper.GetStringFromType(GameModeType.JackpotCsgo));

            var res = await base.CreateNewMatchAsync(roundId, _gameMode);

            var jackpotMatch = new JackpotMatch(
                roundId.ToString(),
                res.Hash,
                res.Salt,
                res.Percentage,
                MatchStatusHelper.GetMatchStatusFromInt(res.Status),
                new List <Bet>(),
                res.TimerStarted,
                new JackpotMatchSetting(
                    _currentMatchSettings.Rake,
                    TimeSpan.FromMilliseconds(_currentMatchSettings.TimmerInMilliSec),
                    _currentMatchSettings.ItemsLimit,
                    _currentMatchSettings.MaxItemAUserCanBet,
                    _currentMatchSettings.MinItemAUserCanBet,
                    _currentMatchSettings.MaxValueAUserCanBet,
                    _currentMatchSettings.MinValueAUserCanBet,
                    _currentMatchSettings.AllowCsgo,
                    _currentMatchSettings.AllowPubg,
                    TimeSpan.FromMilliseconds(_currentMatchSettings.DraftingTimeInMilliSec),
                    _currentMatchSettings.DraftingGraph
                    )
                );

            await _matchHubConnections.NewMatchCreated(jackpotMatch);

            _isClosed = false;
            return(res);
        }
예제 #4
0
        private bool ShouldCloseMatch(DatabaseModel.Match match, List <DatabaseModel.ItemBetted> itemBets, int currentBetCount)
        {
            if (MatchStatusHelper.GetMatchStatusFromInt(match.Status) == MatchStatus.Closed)
            {
                return(true);
            }

            var itemLimit = _currentMatchSettings.ItemsLimit;

            if (itemBets.Count + currentBetCount >= itemLimit && itemBets.Select(i => i.BetId).Distinct().Count() > 1)
            {
                return(true);
            }

            var jackPotTimespan = (TimeSpan.FromMilliseconds(_currentMatchSettings.TimmerInMilliSec));

            if (match.TimerStarted.HasValue && (DateTime.Now - (match.TimerStarted.Value + jackPotTimespan)).TotalMilliseconds > 0)
            {
                return(true);
            }

            return(false);
        }
예제 #5
0
 public void MatchIsOpenReturnsEnumSucces()
 {
     Assert.Equal(MatchStatus.Open, MatchStatusHelper.GetMatchStatusFromInt(1));
 }
예제 #6
0
 public void MatchIsClosedReturnsEnumSucces()
 {
     Assert.Equal(MatchStatus.Closed, MatchStatusHelper.GetMatchStatusFromInt(0));
 }