Exemplo n.º 1
0
        public void RandomSpin(int gameId, int level, string currencyCode, int numOfUsers, int numItrPerUser, decimal bet)
        {
            const int lines = Game.Lines;

            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 users               = SimulationHelper.GetUsers(gameId, numOfUsers, level);
            var spinBets            = SimulationHelper.GetUserBets(users, bet, lines);
            var spinRequestContext  = SimulationHelper.GetMockSpinRequestContext(gameId);
            var bonusRequestContext = SimulationHelper.GetMockBonusRequestContext(0, gameId);

            Parallel.ForEach(users,
                             () => new SummaryData(),
                             (key, state, summaryData) =>
            {
                var spinBet = spinBets[key.UserId];

                for (var ctr = 0; ctr < numItrPerUser; ctr++)
                {
                    var spinResult = module.ExecuteSpin(level, null, spinRequestContext).Value as SpinResult;

                    summaryData.Update(spinResult);

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

                        while (!bonus.IsCompleted)
                        {
                            var bonusResult = SimulationHelper.ExecuteBonus(level, bonus, bonusRequestContext, configuration).Value;

                            summaryData.UpdateBonus(bonusResult);

                            bonus = bonusResult.Bonus;
                        }
                    }
                }

                return(summaryData);
            },
                             summaryData =>
            {
                lock (totalSummaryData)
                {
                    totalSummaryData.Sum(summaryData);
                }
            });

            totalSummaryData.DisplayData(level, timeStart, targetRtpLevel);
            totalSummaryData.DisplayPayoutsData(bet, lines);

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

            Assert.True(isWithinRtp, $"RTP not matching. The result is {totalSummaryData.RtpData.OverallRtp}. Expected is {targetRtpLevel}");
        }
Exemplo n.º 2
0
        public void TestBets(int gameId, int level, string currencyCode, int numOfUsers, int numItrPerUser, decimal bet, int lines, int mp)
        {
            var timeStart        = DateTime.Now;
            var module           = GetModule();
            var targetRtpLevel   = Config.RtpLevels.FirstOrDefault(rl => rl.Level == level && rl.Multiplier == mp).Rtp;
            var totalSummaryData = new SummaryData();

            var users    = GenerateUsers(gameId, numOfUsers, level);
            var spinBets = GenerateUserBets(users, bet, 0, lines, mp);

            Parallel.ForEach(users,
                             () => new SummaryData(),
                             (key, state, summaryData) =>
            {
                var spinBet = spinBets[key.UserId];
                for (var i = 0; i < numItrPerUser; i++)
                {
                    var spinResult = new PandaSpinResult()
                    {
                        SpinBet = spinBet
                    }
                    .CreateWheel(Config.Wheel.Width, Config.Wheel.Height)
                    .GenerateRandomWheel(Config.Wheels, level, mp)

                    .CalculateWin(bet, mp);

                    summaryData.Update(spinResult);
                }

                return(summaryData);
            },
                             sdata => { lock (totalSummaryData) { totalSummaryData.Sum(sdata); } });

            totalSummaryData.DisplayData(level, timeStart, targetRtpLevel);
            totalSummaryData.DisplayPayoutsData(bet, lines);

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

            Assert.True(isWithinRtp, $"RTP not matching. The result is {totalSummaryData.RtpData.OverallRtp}.");
        }
Exemplo n.º 3
0
        public void TestAlchemyReels(int gameId, int level, string currencyCode, int numusers, int numItrPerUser, decimal bet, int lines, int mp)
        {
            var sdt = DateTime.Now;

            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <AlchemyReelsModule>();

            var alchemyReelsModule = new AlchemyReelsModule(logger);
            var maxWin             = 0m;

            AlchemyReelsCommon.CreateWheels(new List <int>()
            {
                3, 3, 3
            });

            var summData = new SummaryData();
            var users    = GenerateUsers(gameId, numusers, level);
            var sbs      = GenerateUserBets(users, bet, lines, mp);

            var requestContext = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

            var requestBonusContext = new RequestContext <BonusArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

            Parallel.ForEach(users,
                             () => new SummaryData(),
                             (key, state, sdata) =>
            {
                var sb = sbs[key.UserId];
                requestContext.Currency = new Currency()
                {
                    Id = sb.CurrencyId
                };
                requestContext.Parameters = new SpinArgs()
                {
                    LineBet = sb.LineBet, BettingLines = sb.Lines
                };
                requestContext.GameSetting = new GameSetting()
                {
                    GameSettingGroupId = sb.GameSettingGroupId
                };

                for (var i = 0; i < numItrPerUser; ++i)
                {
                    var sr = alchemyReelsModule.ExecuteSpin(level, new UserGameSpinData(), requestContext).Value as AlchemyReelsCollapsingSpinResult;

                    if (sr.Win > maxWin)
                    {
                        maxWin = sr.Win;
                    }

                    UpdateSummaryData(sdata, sr);
                    UpdateAlchemyReelsSummaryData(sdata, sr);

                    if (sr.HasBonus)
                    {
                        var bonusCreated = alchemyReelsModule.CreateBonus(sr);

                        var bonus = bonusCreated.Value;

                        bonus.SpinTransactionId = sr.TransactionId;
                        bonus.GameResult        = sr;

                        requestBonusContext.Currency = new Currency()
                        {
                            Id = sb.CurrencyId
                        };
                        requestBonusContext.Parameters = new BonusArgs()
                        {
                            Bonus = "CollapsingSpin"
                        };
                        requestBonusContext.GameSetting = new GameSetting()
                        {
                            GameSettingGroupId = sb.GameSettingGroupId
                        };

                        BonusResult bonusResult;
                        var step = bonus.CurrentStep;

                        do
                        {
                            var entity = new BonusEntity
                            {
                                UserId     = key.UserId,
                                GameId     = AlchemyReelsConfiguration.GameId,
                                Guid       = bonus.Guid.ToString("N"),
                                Data       = bonus.ToByteArray(),
                                BonusType  = bonus.GetType().Name,
                                Version    = 2,
                                IsOptional = bonus.IsOptional,
                                IsStarted  = bonus.IsStarted,
                                RoundId    = sr.RoundId
                            };

                            bonusResult = alchemyReelsModule.ExecuteBonus(level, entity, requestBonusContext).Value;
                            var alchemyFreeCollapsingSpinResult = bonusResult as AlchemyFreeCollapsingSpinResult;

                            UpdateSummaryDataCollapsing(sdata, alchemyFreeCollapsingSpinResult.SpinResult);
                            UpdateAlchemyReelsSummaryData(sdata, alchemyFreeCollapsingSpinResult.SpinResult);

                            bonus = bonusResult.Bonus;
                        }while (!bonusResult.IsCompleted && bonusResult.Bonus != null);
                    }
                }

                return(sdata);
            },
                             sdata =>
            {
                lock (summData)
                {
                    summData.Sum(sdata);
                }
            });

            DisplayAlchemyReelsSummaryData(level, bet, lines, summData, sdt, maxWin, null);
        }
Exemplo n.º 4
0
        public void TestDinoAge(int gameId, int level, string currencyCode, int numusers, int numItrPerUser, decimal bet, int lines, int mp)
        {
            var sdt = DateTime.Now;

            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <DinoAgeModule>();

            var DinoAgeModule = new DinoAgeModule(logger);
            var maxWin        = 0m;
            var summData      = new SummaryData();
            var users         = GenerateUsers(gameId, numusers, level);
            var sbs           = GenerateUserBets(users, bet, lines, mp);

            RequestContext <SpinArgs> requestContext = new RequestContext <SpinArgs>("", DinoAgeConfiguration.GameName, PlatformType.Web);

            RequestContext <BonusArgs> requestBonusContext = new RequestContext <BonusArgs>("", DinoAgeConfiguration.GameName, PlatformType.Web);

            Parallel.ForEach(users,
                             () => new SummaryData(),
                             (key, state, sdata) =>
            {
                var sb = sbs[key.UserId];
                requestContext.Currency = new Currency()
                {
                    Id = sb.CurrencyId
                };
                requestContext.Parameters = new SpinArgs()
                {
                    LineBet = sb.LineBet, BettingLines = sb.Lines
                };
                requestContext.GameSetting = new GameSetting()
                {
                    GameSettingGroupId = sb.GameSettingGroupId
                };

                for (var i = 0; i < numItrPerUser; ++i)
                {
                    var sr = DinoAgeModule.ExecuteSpin(level, new UserGameSpinData(), requestContext).Value as DinoAgeSpinResult;

                    if (sr.Win > maxWin)
                    {
                        maxWin = sr.Win;
                    }

                    UpdateSummaryData(sdata, sr);
                    UpdateDinoAgeSummaryData(sdata, sr);
                }

                return(sdata);
            },
                             sdata =>
            {
                lock (summData)
                {
                    summData.Sum(sdata);
                }
            });

            DisplayDinoAgeSummaryData(level, bet, lines, summData, sdt, maxWin, null);
        }