Exemplo n.º 1
0
        public void TestCreateFreeGameBonus()
        {
            // Arrange
            var user    = new UserGameKey(-1, 3);
            var result1 = new CleopatraSpinResult(user)
            {
                BonusPositions = new List <BonusPosition> {
                    new BonusPosition {
                        Line = 1, Multiplier = 1, RowPositions = new List <int> {
                            0, 2, 2, 2, 0
                        }
                    }
                },
                Bonus = new Stake(Guid.NewGuid(), 2)
                {
                    Count = 4
                }
            };

            // action
            var bonus1 = module.CreateBonus(result1);
            var state1 = ((CleopatraBonus)bonus1.Value).State;

            // Assert
            Assert.AreEqual(result1.Bonus.Guid, bonus1.Value.Guid);
            Assert.AreEqual(true, state1 is FreeSpinState);
            Assert.AreEqual(true, ((FreeSpinState)state1).Count == 4);
        }
Exemplo n.º 2
0
        public void TestExecuteBonus()
        {
            // Arrange
            var user    = new UserGameKey(-1, 3);
            var spinBet = new SpinBet(user, PlatformType.None)
            {
                Lines   = 50,
                LineBet = 1.0m
            };
            var result1 = new CleopatraSpinResult(user)
            {
                BonusPositions = new List <BonusPosition> {
                    new BonusPosition {
                        Line = 1, Multiplier = 1, RowPositions = new List <int> {
                            0, 2, 2, 2, 0
                        }
                    }
                },
                Bonus = new Stake(Guid.NewGuid(), 2)
                {
                    Count = 1
                }
            };

            result1.SpinBet = spinBet;
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var requestContext = new RequestContext <SpinArgs>("simulation", "Cleopatra", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
                Game  = new Game {
                    Id = 51
                }
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "Cleopatra", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonus1 = module.CreateBonus(result1).Value;

            var entity1 = new BonusEntity
            {
                UserId       = userSession.UserId,
                GameId       = requestContext.Game.Id,
                Guid         = bonus1.Guid.ToString("N"),
                Data         = Model.Utility.Extension.ToByteArray(bonus1),
                BonusType    = bonus1.GetType().Name,
                Version      = 3,
                IsOptional   = bonus1.IsOptional,
                IsStarted    = bonus1.IsStarted,
                RoundId      = 1,
                BetReference = ""
            };

            // action
            var freeSpinResult1 = module.ExecuteBonus(1, entity1, requestBonusContext).Value as CleopatraBonusSpinResult;

            // assert
            Assert.NotNull(freeSpinResult1);
            Assert.AreEqual(freeSpinResult1.SpinResult.HasBonus == false, ((CleopatraBonus)freeSpinResult1.Bonus).State is FreeSpinState);
            Assert.AreEqual(freeSpinResult1.GameResultType, GameResultType.FreeSpinResult);
        }
Exemplo n.º 3
0
        private static SummaryData ExecuteBonus(int level, RequestContext <BonusArgs> requestContext, CleopatraSpinResult result)
        {
            var bonus          = module.CreateBonus(result);
            var cleopatraBonus = bonus.Value as CleopatraBonus;
            var summData       = new SummaryData();
            var bonusContext   = new BonusStateContext(level, cleopatraBonus);

            do
            {
                var bonusSpinResult = bonusContext.SetState(cleopatraBonus.State).Transform(requestContext);
                if (bonusSpinResult.SpinResult.HasBonus)
                {
                    summData.FgSarchophagusHit++;
                }
                switch (bonusSpinResult.GameResultType)
                {
                case Model.GameResultType.FreeSpinResult:
                    summData.FSpinCounter++;
                    summData.FSTotalWin += bonusSpinResult.Win;
                    break;

                case Model.GameResultType.RevealResult:
                    summData.FgSarchophagusWin += bonusSpinResult.Win;
                    break;

                default:
                    throw new InvalidOperationException();
                }

                if (bonusSpinResult.IsCompleted)
                {
                    break;
                }
                cleopatraBonus.State = bonusContext.GetState();
            } while (true);

            return(summData);
        }