public void EngineShouldContinueCollapsingBonusResultOnWinSpin(int level)
        {
            var collapsingSpinResult = GenerateWinningCollapsingSpinResult(level);
            var collapsingBonus      = CollapsingBonusEngine.CreateCollapsingSpinBonus(collapsingSpinResult);

            collapsingBonus.UpdateBonus(collapsingSpinResult);
            var collapsingBonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingBonus, collapsingSpinResult);

            Assert.IsTrue(!collapsingBonusResult.IsCompleted);
        }
        public void EngineShouldCreateCollapsingBonusResultWithSameSpinTransactionId(int level)
        {
            var collapsingSpinResult = GenerateWinningCollapsingSpinResult(level);
            var collapsingBonus      = CollapsingBonusEngine.CreateCollapsingSpinBonus(collapsingSpinResult);

            collapsingBonus.UpdateBonus(collapsingSpinResult);
            var collapsingBonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingBonus, collapsingSpinResult);

            Assert.IsTrue(collapsingBonusResult.SpinTransactionId == collapsingSpinResult.SpinTransactionId);
        }
        public void EngineShouldCreateCollapsingBonusResultWithSameGameResultAndBonus(int level)
        {
            var collapsingSpinResult = GenerateWinningCollapsingSpinResult(level);
            var collapsingBonus      = CollapsingBonusEngine.CreateCollapsingSpinBonus(collapsingSpinResult);

            collapsingBonus.UpdateBonus(collapsingSpinResult);
            var collapsingBonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingBonus, collapsingSpinResult);

            Assert.AreSame(collapsingBonusResult.Bonus, collapsingBonus);
        }
        public void EngineShouldCreateBonusResponseXmlOfCollapsingBonusResult(int level)
        {
            var collapsingSpinResult = GenerateWinningCollapsingSpinResult(level);
            var collapsingBonus      = CollapsingBonusEngine.CreateCollapsingSpinBonus(collapsingSpinResult);

            collapsingBonus.UpdateBonus(collapsingSpinResult);
            var collapsingBonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingBonus, collapsingSpinResult);

            var responseXml = collapsingBonusResult.ToResponseXml(ResponseXmlFormat.History);

            Assert.IsNotNull(responseXml);
        }
        public void EngineShouldCreateBonusXElementOfCollapsingBonusResult(int level)
        {
            var collapsingSpinResult = GenerateWinningCollapsingSpinResult(level);
            var collapsingBonus      = CollapsingBonusEngine.CreateCollapsingSpinBonus(collapsingSpinResult);

            collapsingBonus.UpdateBonus(collapsingSpinResult);
            var collapsingBonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingBonus, collapsingSpinResult);

            var xElement = collapsingBonusResult.ToXElement();

            Assert.IsNotNull(xElement);
        }
        public void EngineShouldReadResponseXmlOfCollapsingBonusResult(int level)
        {
            var collapsingSpinResult = GenerateWinningCollapsingSpinResult(level);
            var collapsingBonus      = CollapsingBonusEngine.CreateCollapsingSpinBonus(collapsingSpinResult);

            collapsingBonus.UpdateBonus(collapsingSpinResult);
            var collapsingBonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingBonus, collapsingSpinResult);

            var xElement = collapsingBonusResult.ToXElement();

            Assert.DoesNotThrow(() =>
            {
                using (var xmlReader = xElement.CreateReader())
                {
                    var responseXml = new BonusXml();
                    responseXml.ReadXml(xmlReader);
                }
            });
        }
Exemple #7
0
        public void TestFreeGameFullCycle(int gameId, int level, string reelStripId)
        {
            var timeStart           = DateTime.Now;
            var module              = SimulationHelper.GetModule(gameId);
            var configuration       = new Configuration();
            var targetRtpLevel      = Math.Round(configuration.RtpLevels.FirstOrDefault(rl => rl.Level == level).Rtp, 2);
            var totalSummaryData    = new SummaryData();
            var spinRequestContext  = SimulationHelper.GetMockSpinRequestContext(gameId);
            var bonusRequestContext = SimulationHelper.GetMockBonusRequestContext(0, gameId);
            var targetWheel         = MainGameEngine.GetTargetWheel(level, configuration, reelStripId);
            var userGameKey         = new UserGameKey()
            {
                UserId = -1,
                GameId = gameId,
                Level  = level
            };

            var spinBet = MainGameEngine.GenerateSpinBet(spinRequestContext);
            var wheel   = new Wheel(Game.WheelWidth, Game.WheelHeight)
            {
                ReelStripsId = reelStripId
            };

            for (var reel1 = 0; reel1 < targetWheel[0].Count; reel1++)
            {
                for (var reel2 = 0; reel2 < targetWheel[1].Count; reel2++)
                {
                    for (var reel3 = 0; reel3 < targetWheel[2].Count; reel3++)
                    {
                        for (var reel4 = 0; reel4 < targetWheel[3].Count; reel4++)
                        {
                            for (var reel5 = 0; reel5 < targetWheel[4].Count; reel5++)
                            {
                                wheel.Reels[0] = SimulationHelper.GetReelRange(targetWheel[0], reel1);
                                wheel.Reels[1] = SimulationHelper.GetReelRange(targetWheel[1], reel2);
                                wheel.Reels[2] = SimulationHelper.GetReelRange(targetWheel[2], reel3);
                                wheel.Reels[3] = SimulationHelper.GetReelRange(targetWheel[3], reel4);
                                wheel.Reels[4] = SimulationHelper.GetReelRange(targetWheel[4], reel5);

                                var topIndices = new List <int> {
                                    reel1, reel2, reel3, reel4, reel5
                                };
                                var avalancheMultiplier = configuration.BonusConfig.FreeSpin.Multipliers.First();
                                var winPositions        = MainGameEngine.GenerateWinPositions(configuration.Payline, configuration.PayTable, wheel, spinBet.LineBet, spinBet.Lines, avalancheMultiplier);
                                var bonusPositions      = MainGameEngine.GenerateBonusPositions(wheel);

                                var spinResult = new SpinResult(spinBet, wheel, topIndices, winPositions, bonusPositions, avalancheMultiplier)
                                {
                                    PlatformType = spinRequestContext.Platform,
                                    Level        = level
                                };

                                totalSummaryData.Update(spinResult);

                                if (spinResult.HasBonus)
                                {
                                    var bonus = module.CreateBonus(spinResult).Value;

                                    if (bonus is FreeSpinBonus)
                                    {
                                        bonus = CollapsingBonusEngine.CreateCollapsingSpinBonus(spinResult);
                                    }

                                    var collapsingSpinBonus = bonus as CollapsingSpinBonus;

                                    while (!bonus.IsCompleted)
                                    {
                                        var previousSpinResult = collapsingSpinBonus.PreviousGameResult == null ? collapsingSpinBonus.SpinResult : collapsingSpinBonus.PreviousSpinResult;

                                        var referenceWheel       = MainGameEngine.GetTargetWheel(level, configuration, previousSpinResult.Wheel.ReelStripsId);
                                        var collapsingSpinResult = CollapsingBonusEngine.CreateCollapsingSpinResult(
                                            previousSpinResult,
                                            referenceWheel,
                                            configuration.BonusConfig.FreeSpin.Multipliers,
                                            configuration.Payline,
                                            configuration.PayTable);

                                        collapsingSpinBonus.UpdateBonus(collapsingSpinResult);
                                        var bonusResult = CollapsingBonusEngine.CreateCollapsingBonusResult(collapsingSpinBonus, collapsingSpinResult);

                                        totalSummaryData.UpdateBonus(bonusResult);

                                        bonus = bonusResult.Bonus;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            totalSummaryData.DisplayData(level, timeStart, targetRtpLevel);
            var resultOverallRtp = Math.Round(totalSummaryData.RtpData.OverallRtp, 2);

            var isWithinRtp = totalSummaryData.RtpData.OverallRtp >= targetRtpLevel - 0.5m && totalSummaryData.RtpData.OverallRtp <= targetRtpLevel + 0.5m;

            Assert.True(isWithinRtp, $"RTP not matching. The result is {resultOverallRtp}. Expected is {targetRtpLevel}");
        }