Ejemplo n.º 1
0
        public bool IsLineBetValid(Game game, SpinBet bet)
        {
            var isValid = game.IsBetAllLines && bet.Lines == game.Lines ||
                          bet.Lines > 0 && bet.Lines <= game.Lines;

            return(isValid);
        }
Ejemplo n.º 2
0
 public bool IsCoinValid(string coinsDenomination, SpinBet bet)
 {
     return(coinsDenomination.Split(';')
            .Select(decimal.Parse)
            .ToList()
            .Any(s => s == bet.LineBet));
 }
Ejemplo n.º 3
0
        public void TestFreeSpinFeatgure()
        {
            // arrange
            var freeSpin = new FreeSpin(1, 0);
            var user     = new UserGameKey(-1, 30);
            var bet      = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new FreeSpinAction(1, PlatformType.None, bet, () =>
            {
                return(new List <IReadOnlyList <int> >
                {
                    new int[] { 1, 1, 1 },
                    new int[] { 2, 2, 2, 2 },
                    new int[] { 3, 3, 3, 3 },
                    new int[] { 4, 4, 4, 4 },
                    new int[] { 5, 5, 5 }
                });
            });

            // action
            var bikiniBeachState = FreeSpinReducer.Dispatch(freeSpin, action);
            var result           = bikiniBeachState.Result;

            // Assert
            Assert.IsTrue(bikiniBeachState.State is Finish);
            Assert.AreEqual(result.Wheel[0], new[] { 1, 1, 1 });
            Assert.AreEqual(result.Wheel[1], new[] { 10, 10, 10 });
            Assert.AreEqual(result.Wheel[2], new[] { 3, 3, 3 });
            Assert.AreEqual(result.Wheel[3], new[] { 4, 4, 4 });
            Assert.AreEqual(result.Wheel[4], new[] { 5, 5, 5 });
        }
Ejemplo n.º 4
0
        public void TestHoneyFeatgure()
        {
            // arrange
            var honeyItem = new HoneyItem(4, 1, new Prize(3, 0), new Prize(1, 0), 0);
            var user      = new UserGameKey(-1, 103);
            var bet       = new SpinBet(user, PlatformType.None)
            {
                Lines      = 25,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new Domain.Action(1, user, bet, 1, PlatformType.None);

            // action
            var state      = HoneyReducer.dispatch(action, honeyItem);
            var honeyState = state.BonusState as Honey;

            // Assert

            Assert.AreEqual(3, honeyState.Item.Count);
            Assert.AreEqual(1, honeyState.Item.CurrentStep);
            Assert.AreEqual(2, honeyState.Item.Pot.Count);
            Assert.AreEqual(1, honeyState.Item.Pot.CurrentStep);
            Assert.AreEqual(1, honeyState.Item.BeeHive.Count);
            Assert.AreEqual(0, honeyState.Item.BeeHive.CurrentStep);
            Assert.AreEqual(false, honeyState.Item.IsCompleted);
            Assert.IsTrue(state.Result.Win > 0);
        }
Ejemplo n.º 5
0
 public bool IsMultiplierValid(string coinsMultiplier, SpinBet bet)
 {
     return(coinsMultiplier
            .Split(';')
            .Select(int.Parse)
            .ToList()
            .Any(s => s == bet.Multiplier));
 }
        public void TestReSpinFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 32);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 10,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "FortuneKoi", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneKoiBonus {
                SpinBet = bet
            });
            var state = new ReSpinState(new List <int[]>
            {
                new int[] { },
                new int[] { 7, 7, 7 },
                new int[] { },
                new int[] { },
                new int[] { }
            }, new bool[] { false, true, false, false, false });

            //Action
            var response    = state.Handle(requestBonusContext, bonusContext);
            var result      = response.result;
            var responseXml = xmlhelper.Serialize(result.ToResponseXml(ResponseXmlFormat.None));
            var element     = XElement.Parse(responseXml, LoadOptions.PreserveWhitespace);

            // Assert
            Assert.IsNotNull(element);
            Assert.IsTrue(element.Element("data").Element("spin").Element("wheels") != null);
            Assert.AreEqual(result.Win, decimal.Parse(element.Element("win").Value));
            Assert.AreEqual(result.Win > 0, element.Element("data").Element("spin").Element("winposition").Descendants().Count() > 0);
            if (result.SpinResult.HasBonus)
            {
                Assert.IsNotNull(element.Element("data").Element("spin").Element("bonus"));
                Assert.IsTrue(string.IsNullOrEmpty(element.Element("data").Element("spin").Element("bonusposition").Value) == false);
                Assert.IsNotNull(element.Element("data").Element("spin").Element("bonusposition"));
                Assert.IsTrue(element.Element("data").Element("spin").Element("bonusposition").Descendants().Count() > 0);
            }
        }
Ejemplo n.º 7
0
        public void TestFreeSpinFeature()
        {
            // arrange
            var wheel = new DragonRichesWheel
            {
                Reels          = new List <int[]>(),
                CoinCollapsing = new DragonRichesWheel.CoinCollapse()
            };
            var holdSpinItem = new FreeSpin(new State(6, 0), 0);
            var user         = new UserGameKey(-1, 104);
            var bet          = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new FreeSpinAction(1, PlatformType.None, bet, () => new List <IReadOnlyList <int> >
            {
                new List <int> {
                    1, 1, 1
                },
                new List <int> {
                    2, 2, 2
                },
                new List <int> {
                    3, 3, 3
                },
                new List <int> {
                    4, 4, 4
                },
                new List <int> {
                    5, 5, 5,
                }
            });

            // action
            var dragonState = FreeSpinReducer.Dispatch(holdSpinItem, action);

            // Assert
            if (dragonState.State is FreeSpin)
            {
                var freeSpinState = dragonState.State as FreeSpin;
                var scatters      = dragonState.Result.Wheel.Reels.Sum(ele => ele.Count(item => item == 9));
                Assert.AreEqual(freeSpinState.State.Count >= 5, true);
                Assert.AreEqual(false, freeSpinState.IsCompleted);
                Assert.AreEqual(scatters >= 3, freeSpinState.State.Count >= 12);
            }
            if (dragonState.State is HoldFreeSpin)
            {
                var holdFreeSpinState = dragonState.State as HoldFreeSpin;
                Assert.AreEqual(3, holdFreeSpinState.HoldSpin.State.Count == 3);
                Assert.AreEqual(3, holdFreeSpinState.FreeSpin.State.Count == 5);
                Assert.AreEqual(true, dragonState.Result.Wheel.Reels.Sum(ele => ele.Count(item => item == 12)) >= 6);
                Assert.AreEqual(false, holdFreeSpinState.IsCompleted);
            }
        }
Ejemplo n.º 8
0
        public void TestExplodingFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 109);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "FortuneChimes", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneChimesBonus {
                SpinBet = bet
            });
            var bonusPositions = new List <BonusPosition> {
                new BonusPosition {
                    RowPositions = new List <int> {
                        1, 1, 1, 0, 0
                    }
                }
            };
            var wheel = new FortuneChimesWheel
            {
                Reels = new List <int[]> {
                    new[] { 1, -1, -1 }, new[] { 1, -1, -1 }, new[] { 1, -1, -1 }, new[] { -1, -1, -1 }, new[] { -1, -1, -1 }
                },
                Indices = new int[] { 1, 2, 3, 4, 5 }
            };
            var reSpinCollapse = new ReSpinCollapse(bonusPositions, wheel, new List <int[]> {
                new int[0], new int[0], new int[0], new int[] { -1, -2, -3 }, new int[] { -1, -2, -3 }
            });
            var state = new ReSpinState(reSpinCollapse);

            //Action
            var response = state.Handle(requestBonusContext, bonusContext);

            // Assert
            Assert.AreEqual(response.result.Win > 0, response.nextState is ReSpinState);
            Assert.AreEqual(response.result.Win > 0, !response.nextState.IsCompleted);
            Assert.AreEqual(response.result.Win == 0, response.nextState is Finish);
        }
Ejemplo n.º 9
0
        public void TestHoneyFreeSpinFeature()
        {
            // arrange
            var honeyItem         = new HoneyItem(4, 3, new Prize(0, 0), new Prize(1, 0), 0);
            var freeSpinItem      = new BonusItem(3, 3, new Prize(2, 0), 1);
            var honeyFreeSpinItem = new BearHoneyFreeSpin(honeyItem, freeSpinItem);
            var user = new UserGameKey(-1, 103);
            var bet  = new SpinBet(user, PlatformType.None)
            {
                Lines      = 25,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new Domain.Action(1, user, bet, 1, PlatformType.None);

            // action
            var state = HoneyFreeSpinReducer.dispatch(action, honeyFreeSpinItem);

            // Assert
            Assert.AreEqual(false, state.BonusState.IsHoney);
            if (state.BonusState.IsHoneyFreeSpin)
            {
                var honeyFreeSpinState = state.BonusState as HoneyFreeSpin;
                var honey    = honeyFreeSpinState.Item.Honey;
                var freeSpin = honeyFreeSpinState.Item.FreeSpin;
                Assert.AreEqual(4, honey.Id);
                Assert.AreEqual(3, honey.Multiplier);
                Assert.AreEqual(0, honey.Pot.Count);
                Assert.AreEqual(1, honey.Pot.CurrentStep);
                Assert.AreEqual(1, honey.BeeHive.Count);
                Assert.AreEqual(0, honey.BeeHive.CurrentStep);
                Assert.AreEqual(false, honey.IsCompleted);

                Assert.AreEqual(3, freeSpin.Id);
                Assert.AreEqual(3, freeSpin.Multiplier);
                Assert.AreEqual(2, freeSpin.Prize.Count);
                Assert.AreEqual(0, freeSpin.Prize.CurrentStep);
                Assert.AreEqual(false, freeSpin.IsCompleted);
            }

            if (state.BonusState.IsFreeSpin)
            {
                var freeSpin = state.BonusState as FreeSpin;
                Assert.AreEqual(3, freeSpin.Item.Id);
                Assert.AreEqual(3, freeSpin.Item.Multiplier);
                Assert.AreEqual(2, freeSpin.Item.Prize.Count);
                Assert.AreEqual(0, freeSpin.Item.Prize.CurrentStep);
                Assert.AreEqual(false, freeSpin.Item.IsCompleted);
                Assert.AreEqual(state.Result.Win + freeSpinItem.CumulativeWin, freeSpin.Item.CumulativeWin);
            }
        }
Ejemplo n.º 10
0
        public void TestReSpinFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 32);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 10,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "FortuneKoi", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new FortuneKoiBonus {
                SpinBet = bet
            });
            var state = new ReSpinState(new List <int[]> {
                new [] { 0, 1, 2 },
                new [] { 0, 7, 1 },
                new [] { 4, 5, 6 },
                new [] { 1, 2, 3 },
                new [] { 6, 5, 4 }
            },
                                        new bool[] { false, true, false, false, false });

            //Action
            var response   = state.Handle(requestBonusContext, bonusContext);
            var spinResult = response.result.SpinResult;
            var wheel      = spinResult.Wheel;

            // Assert
            Assert.AreEqual(spinResult.HasBonus, !response.nextState.IsCompleted);
            Assert.AreEqual(wheel[2].Any(item => item == 7) || wheel[3].Any(item => item == 7), response.nextState is ReSpinState);
            Assert.AreEqual(wheel[2].All(item => item < 7) && wheel[3].All(item => item < 7), response.nextState is Finish);
        }
Ejemplo n.º 11
0
        public void TestHoldFreeSpinFeature()
        {
            // arrange
            var coins = new DragonRichesWheel.CoinCollapse();

            coins.Add(new DragonRichesWheel.CoinUnfilled(new[] { new Coin(), new Coin(1), new Coin(5) }));
            coins.Add(new DragonRichesWheel.CoinUnfilled(new[] { new Coin(), new Coin(1), new Coin(5) }));
            coins.Add(new DragonRichesWheel.CoinUnfilled(new[] { new Coin(), new Coin(1), new Coin(5) }));
            coins.Add(new DragonRichesWheel.CoinUnfilled(new[] { new Coin(), new Coin(1), new Coin(5) }));
            coins.Add(new DragonRichesWheel.CoinUnfilled(new[] { new Coin(), new Coin(), new Coin() }));
            coins.TotalItems = 8;
            var user = new UserGameKey(-1, 104);
            var bet  = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new HoldFreeSpinAction(1, PlatformType.None, bet);

            var holdSpinItem = new HoldFreeSpin(
                holdSpin: new HoldSpin(
                    new State(3, 0),
                    new List <int[]>
            {
                new int[3],
                new int[3],
                new int[3],
                new int[3],
                new int[3]
            }, coins),
                freeSpin: new FreeSpin(new State(5, 1), 1)
                );

            // action
            var dragonState   = HoldFreeSpinReducer.Dispatch(holdSpinItem, action);
            var holdSpinState = dragonState.State as HoldFreeSpin;
            var wheel         = dragonState.Result.Wheel;

            // Assert
            Assert.NotNull(holdSpinState);
            Assert.AreEqual(holdSpinState.HoldSpin.State.Count >= 2, true);

            Assert.AreEqual(5, holdSpinState.FreeSpin.State.Count);
            Assert.AreEqual(wheel.CoinCollapsing.TotalItems, wheel.Coins.Sum(reward => reward.Count(item => item > 0)));
            Assert.IsTrue(dragonState.Result.Win == 0);
            Assert.AreEqual(false, holdSpinState.IsCompleted);
        }
Ejemplo n.º 12
0
        public void TestFreeSpinFeature()
        {
            // arrange
            var freeSpinItem = new BonusItem(3, 3, new Prize(15, 0), 0);
            var user         = new UserGameKey(-1, 103);
            var bet          = new SpinBet(user, PlatformType.None)
            {
                Lines      = 25,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new Domain.Action(1, user, bet, 1, PlatformType.None);

            // action
            var state = FreeSpinReducer.dispatch(action, freeSpinItem);

            // Assert
            Assert.AreEqual(false, state.BonusState.IsHoney);
            if (state.BonusState.IsFreeSpin)
            {
                var freeSpinState = state.BonusState as FreeSpin;
                Assert.AreEqual(3, freeSpinState.Item.Id);
                Assert.AreEqual(3, freeSpinState.Item.Multiplier);
                Assert.AreEqual(true, freeSpinState.Item.IsStarted);
                Assert.AreEqual(14, freeSpinState.Item.Prize.Count);
                Assert.AreEqual(1, freeSpinState.Item.Prize.CurrentStep);
                Assert.AreEqual(false, freeSpinState.Item.IsCompleted);
            }

            if (state.BonusState.IsHoneyFreeSpin)
            {
                var honeyFreeSpinState = state.BonusState as HoneyFreeSpin;
                Assert.AreEqual(4, honeyFreeSpinState.Item.Honey.Id);
                Assert.AreEqual(3, honeyFreeSpinState.Item.Honey.Multiplier);
                Assert.AreEqual(state.Result.Bonus.Count, honeyFreeSpinState.Item.Honey.Pot.Count);
                Assert.AreEqual(true, honeyFreeSpinState.Item.Honey.Pot.Count > 0 && honeyFreeSpinState.Item.Honey.Pot.Count < 6);
                Assert.AreEqual(0, honeyFreeSpinState.Item.Honey.Pot.CurrentStep);
                Assert.AreEqual(1, honeyFreeSpinState.Item.Honey.BeeHive.Count);
                Assert.AreEqual(0, honeyFreeSpinState.Item.Honey.BeeHive.CurrentStep);
                Assert.AreEqual(state.Result.Bonus.Count + 1, honeyFreeSpinState.Item.Honey.TotalSpin);
                Assert.AreEqual(14, honeyFreeSpinState.Item.FreeSpin.Prize.Count);
                Assert.AreEqual(1, honeyFreeSpinState.Item.FreeSpin.Prize.CurrentStep);
                Assert.AreEqual(3, honeyFreeSpinState.Item.FreeSpin.Multiplier);
                Assert.AreEqual(false, honeyFreeSpinState.Item.IsCompleted);
            }
        }
Ejemplo n.º 13
0
        private Dictionary <int, SpinBet> GenerateUserBets(List <UserGameKey> keys, decimal bet, int credits, int lines, int mp)
        {
            var sbs = new Dictionary <int, SpinBet>();

            foreach (var k in keys)
            {
                var sb = new SpinBet(k, PlatformType.None)
                {
                    LineBet    = bet,
                    Credits    = credits,
                    Lines      = lines,
                    Multiplier = mp
                };
                sbs[k.UserId] = sb;
            }

            return(sbs);
        }
Ejemplo n.º 14
0
        public void TestSarchophagusFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 51);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 50,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "Cleopatra", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new CleopatraBonus {
                SpinBet = bet
            });
            var state = new SarchophagusState(new PreSpin(1, 0));

            //Action
            var response    = state.Handle(requestBonusContext, bonusContext);
            var result      = response.result;
            var responseXml = xmlhelper.Serialize(result.ToResponseXml(ResponseXmlFormat.None));
            var element     = XElement.Parse(responseXml, LoadOptions.PreserveWhitespace);

            // Assert
            Assert.IsNotNull(element);
            Assert.AreEqual(result.Win > 0, element.Element("win") != null);
            Assert.AreEqual(result.Win, decimal.Parse(element.Element("win").Value));
            Assert.AreEqual(result.Win > 0, element.Element("data").Element("spin").Element("winposition") != null);
            Assert.AreEqual("", element.Element("data").Element("spin").Element("winposition").Value);
        }
Ejemplo n.º 15
0
        public void TestReSpinFreeSpinFeatgure()
        {
            // arrange
            var freeSpin = new ReSpinFreeSpin(1, 0, 1, new List <int[]>
            {
                new int[] { 9, 9, 9 },
                new int[] { 9, -1, -1, -1 },
                new int[] { 9, 9, 9, -1 },
                new int[] { -1, 11, -1, -1 },
                new int[] { -1, 1, -1 },
            }, new FreeSpin(1, 0));
            var user = new UserGameKey(-1, 80);
            var bet  = new SpinBet(user, PlatformType.None)
            {
                Lines      = 40,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new ReSpinAction(1, PlatformType.None, bet, () =>
            {
                return(new List <IReadOnlyList <int> >
                {
                    new int[] { 1, 1, 1 },
                    new int[] { 2, 2, 2, 2 },
                    new int[] { 3, 3, 3, 3 },
                    new int[] { 4, 4, 4, 4 },
                    new int[] { 5, 5, 5 }
                });
            });

            // action
            var geniesLuckState = ReSpinFreeSpinReducer.Dispatch(freeSpin, action);
            var result          = geniesLuckState.Result;

            // Assert
            Assert.IsTrue(geniesLuckState.State is FreeSpin);
            Assert.AreEqual(result.Wheel[0], new[] { 9, 9, 9 });
            Assert.AreEqual(result.Wheel[1], new[] { 9, 2, 2, 2 });
            Assert.AreEqual(result.Wheel[2], new[] { 9, 9, 9, 3 });
            Assert.AreEqual(result.Wheel[3], new[] { 4, 11, 4, 4 });
            Assert.AreEqual(result.Wheel[4], new[] { 5, 5, 5 });
            Assert.IsTrue(result.Win > 0);
        }
Ejemplo n.º 16
0
        public void TestSmashingWildRtp(double ratio)
        {
            var spinBet = new SpinBet(new UserGameKey(-1, 93), PlatformType.None)
            {
                LineBet = 1, Multiplier = 1, Lines = 25
            };
            var totalBet = 0.0m;
            var totalWin = 0.0m;
            var profile  = new Dictionary <int, decimal>();

            for (var iter = 0; iter < 1000000; iter++)
            {
                totalBet += 25m;
                var result = GameReduce.wolvesSmashing(1, ratio, spinBet);
                Assert.IsTrue(result.Win > 0);
                totalWin += result.Win;
            }
            Console.WriteLine(String.Format("RTP.Total            : {0,12:0.0000000000}", 100 * totalWin / totalBet));
        }
Ejemplo n.º 17
0
        public void TestReSpinWithWildExpendAllReelFeatgure()
        {
            // arrange
            var freeSpin = new FreeSpin(new[] { 0, 1, 2, 3, 0 });
            var user     = new UserGameKey(-1, 30);
            var bet      = new SpinBet(user, PlatformType.None)
            {
                Lines      = 20,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new FreeSpinAction(1, PlatformType.None, bet);

            // action
            var sevenWondersState = FreeSpinReducer.Dispatch(freeSpin, action);

            // Assert
            Assert.AreEqual(sevenWondersState.State is Finish, true);
        }
Ejemplo n.º 18
0
        public void TestSwimWearFeatgure()
        {
            // arrange
            var swimWear = new SwimWear(1, 0);
            var user     = new UserGameKey(-1, 80);
            var bet      = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new SwimWearAction(1, PlatformType.None, bet);

            // action
            var bikiniBeachState = SwimWearReducer.Dispatch(swimWear, action);
            var result           = bikiniBeachState.Result;

            // Assert
            Assert.IsTrue(bikiniBeachState.State is Finish);
            Assert.IsTrue(result.Win > 0);
        }
Ejemplo n.º 19
0
        public void TestBodyPartFeatgure()
        {
            // arrange
            var bodyPart = new BodyPart(1, 0, new Item[6]);
            var user     = new UserGameKey(-1, 3);
            var bet      = new SpinBet(user, PlatformType.None)
            {
                Lines      = 30,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new BodyPartChooseAction(1, PlatformType.None, bet, 1);

            // action
            var bikiniBeachState = BodyPartReducer.Dispatch(bodyPart, action);
            var result           = bikiniBeachState.Result;

            // Assert
            Assert.IsTrue(bikiniBeachState.State is Finish);
            Assert.AreEqual(result.Win, result.Wheel.Items[0].Prize);
        }
Ejemplo n.º 20
0
        public void TestReSpinWithWildExpendAtSecondReelFeatgure()
        {
            // arrange
            var freeSpin = new FreeSpin(new[] { 0, 1, 0, 0, 0 });
            var user     = new UserGameKey(-1, 30);
            var bet      = new SpinBet(user, PlatformType.None)
            {
                Lines      = 20,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var action = new FreeSpinAction(1, PlatformType.None, bet);

            // action
            var sevenWondersState = FreeSpinReducer.Dispatch(freeSpin, action);
            var result            = sevenWondersState.Result;
            var wheel             = result.Wheel.Reels;

            // Assert
            Assert.AreEqual(sevenWondersState.State is Finish, wheel[2].All(ele => ele != 7) && wheel[3].All(ele => ele != 7));
            Assert.AreEqual(sevenWondersState.State is FreeSpin, wheel[2].Any(ele => ele == 7) || wheel[3].Any(ele => ele == 7));
        }
Ejemplo n.º 21
0
        public void TestFreeSpinFeature()
        {
            // arrange
            var user        = new UserGameKey(-1, 51);
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var bet = new SpinBet(user, PlatformType.None)
            {
                Lines      = 50,
                LineBet    = 1.0m,
                Multiplier = 1
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "Cleopatra", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonusContext = new BonusStateContext(1, new CleopatraBonus {
                SpinBet = bet
            });
            var state = new FreeSpinState(1, 0);

            //Action
            var reponse = state.Handle(requestBonusContext, bonusContext);

            // Assert
            Assert.AreEqual(!reponse.result.SpinResult.HasBonus, reponse.nextState.IsCompleted);
            Assert.AreEqual(!reponse.result.SpinResult.HasBonus, reponse.nextState is FreeSpinState);
            Assert.AreEqual(reponse.result.SpinResult.HasBonus, reponse.nextState is SarchophagusState);
        }
Ejemplo n.º 22
0
        private decimal TestCollapsingPayout(string strwheel, decimal betperline, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var alchemyReelsModule = new AlchemyReelsModule(null);
            var maxWin             = 0m;
            var totalWin           = 0m;
            var maxIndexPosition   = new List <int>();
            var requestContext     = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);
            var summData           = new SummaryData();

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

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            string[] arrstr = strwheel.Split(',');
            int[]    arr    = Array.ConvertAll(arrstr, int.Parse);

            var ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = AlchemyReelsConfiguration.GameId,
                Level  = 1
            };

            var sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = AlchemyReelsConfiguration.BettingLines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            var sr = new AlchemyReelsCollapsingSpinResult()
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = AlchemyReelsConfiguration.BettingLines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(AlchemyReelsConfiguration.Width, AlchemyReelsConfiguration.Height, arr)
            };

            sr.TopIndices = new List <int>()
            {
                6, 6, 49
            };

            totalWin = AlchemyReelsCommon.CalculateWin(sr);

            Console.WriteLine();
            Console.WriteLine("--- POSITION TABLE ---");
            foreach (AlchemyReelTableWin tw in sr.TableWins)
            {
                Console.WriteLine(String.Format("[WIN:{0} SYM:{1} COUNT:{2}]", tw.Win, tw.Card, tw.Count));
            }

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

                var bonus = bonusCreated.Value;

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

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

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

                BonusResult bonusResult;
                int         step = bonus.CurrentStep;

                do
                {
                    var entity = new BonusEntity
                    {
                        UserId     = ugk.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(AlchemyReelsConfiguration.LevelOne, entity, requestBonusContext).Value;
                    var alchemyFreeCollapsingSpinResult = bonusResult as AlchemyFreeCollapsingSpinResult;

                    var win = alchemyFreeCollapsingSpinResult.Win;

                    if (win > 0)
                    {
                        totalWin += win;
                    }

                    var maxTopIndices = alchemyFreeCollapsingSpinResult.SpinResult.TopIndices.ToList();

                    if (totalWin > maxWin)
                    {
                        maxWin = totalWin;

                        maxIndexPosition = maxTopIndices;
                    }

                    Console.WriteLine("--- POSITION TABLE ---");
                    foreach (AlchemyReelTableWin tw in alchemyFreeCollapsingSpinResult.SpinResult.TableWins)
                    {
                        Console.WriteLine(String.Format("[WIN:{0} SYM:{1} COUNT:{2}]", tw.Win, tw.Card, tw.Count));
                    }

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

            Console.WriteLine($"Win            : {totalWin}");
            return(totalWin);
        }
Ejemplo n.º 23
0
        private decimal TestPayout(string strwheel, decimal betperline, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var alchemyReelsModule = new AlchemyReelsModule(null);
            var requestContext     = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

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

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            var arrstr = strwheel.Split(',');
            var arr    = Array.ConvertAll(arrstr, int.Parse);

            var ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = AlchemyReelsConfiguration.GameId,
                Level  = 1
            };

            var sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = AlchemyReelsConfiguration.BettingLines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            var sr = new AlchemyReelsCollapsingSpinResult()
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = AlchemyReelsConfiguration.BettingLines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(AlchemyReelsConfiguration.Width, AlchemyReelsConfiguration.Height, arr)
            };

            var win = AlchemyReelsCommon.CalculateWin(sr);

            Console.WriteLine("--- WIN POSITION ---");
            foreach (AlcheryReelsWinPosition wp in sr.WinPositions)
            {
                Console.WriteLine(String.Format("[LINE:{0} MUL:{1} WIN:{2}]", wp.Line, wp.Multiplier, wp.Win));
            }

            Console.WriteLine();
            Console.WriteLine("--- WIN TABLE ---");
            foreach (AlchemyReelTableWin tw in sr.TableWins)
            {
                Console.WriteLine(String.Format("[CARD:{0} COUNT:{1} WILD:{2}]", tw.Card, tw.Count, tw.Wild));
            }

            return(win);
        }
Ejemplo n.º 24
0
        private decimal TestCollapsingPayout(string strwheel, decimal betperline, string strIndices, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var PandaWarriorModule = new PandaWarriorModule(null);
            var maxWin             = 0m;
            var totalWin           = 0m;
            var maxIndexPosition   = new List <int>();
            var requestContext     = new RequestContext <SpinArgs>("", PandaWarriorConfiguration.GameName, PlatformType.Web);
            var summData           = new SummaryData();

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            string[] arrstr = strwheel.Split(',');
            int[]    arr    = Array.ConvertAll(arrstr, int.Parse);

            string[] arrIndices = strIndices.Split(',');
            int[]    indices    = Array.ConvertAll(arrIndices, int.Parse);

            var ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = PandaWarriorConfiguration.GameId,
                Level  = 1
            };

            var sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = PandaWarriorConfiguration.Lines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            var sr = new PandaWarriorCollapsingSpinResult()
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = PandaWarriorConfiguration.Lines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(PandaWarriorConfiguration.Width, PandaWarriorConfiguration.Height, arr)
            };

            sr.TopIndices = new List <int>(indices);

            totalWin = PandaWarriorCommon.CalculateWin(sr);

            Console.WriteLine();
            Console.WriteLine("--- WIN POSITION ---");
            foreach (PandaWarriorWinPosition wp in sr.WinPositions)
            {
                Console.WriteLine(String.Format("[LINE:{0} MUL:{1} WIN:{2}]", wp.Line, wp.Multiplier, wp.Win));
            }

            Console.WriteLine();
            Console.WriteLine("--- WIN TABLE ---");
            foreach (PandaWarriorTableWin tw in sr.TableWins)
            {
                Console.WriteLine(String.Format("[CARD:{0} COUNT:{1} WILD:{2}]", tw.Card, tw.Count, tw.Wild));
            }

            if (PandaWarriorCommon.CheckFreeSpin(sr.Wheel))
            {
                sr.IsBonus                = true;
                sr.IsFreeSpin             = true;
                sr.InitialBonusPositions  = PandaWarriorFreeSpinFeature.CreatePosition(sr);
                sr.CurrentStep            = 1;
                sr.CurrentFreeSpinCounter = PandaWarriorConfiguration.FreeSpinCount;
                sr.NumOfFreeSpin          = PandaWarriorConfiguration.FreeSpinCount;
            }
            else if (sr.Collapse)
            {
                sr.IsBonus = true;
            }

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

                var bonus = bonusCreated.Value;

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

                var requestBonusContext = new RequestContext <BonusArgs>("", PandaWarriorConfiguration.GameName, PlatformType.Web)
                {
                    Currency = new Currency()
                    {
                        Id = sb.CurrencyId
                    },
                    Parameters = new BonusArgs()
                    {
                        Bonus = "CollapsingSpin"
                    },
                    GameSetting = new GameSetting()
                    {
                        GameSettingGroupId = sb.GameSettingGroupId
                    }
                };

                BonusResult bonusResult;
                int         step = bonus.CurrentStep;

                do
                {
                    var entity = new BonusEntity
                    {
                        UserId     = ugk.UserId,
                        GameId     = PandaWarriorConfiguration.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 = PandaWarriorModule.ExecuteBonus(PandaWarriorConfiguration.LevelOne, entity, requestBonusContext).Value;
                    var collapsingBonusResult = bonusResult as PandaWarriorCollapsingBonusResult;

                    var win = collapsingBonusResult.Win;

                    if (win > 0)
                    {
                        totalWin += win;
                    }

                    var maxTopIndices = collapsingBonusResult.SpinResult.TopIndices.ToList();

                    if (totalWin > maxWin)
                    {
                        maxWin = totalWin;

                        maxIndexPosition = maxTopIndices;
                    }

                    Console.WriteLine("--- WIN POSITION ---");
                    foreach (PandaWarriorWinPosition wp in sr.WinPositions)
                    {
                        Console.WriteLine(String.Format("[LINE:{0} MUL:{1} WIN:{2}]", wp.Line, wp.Multiplier, wp.Win));
                    }

                    Console.WriteLine();
                    Console.WriteLine("--- WIN TABLE ---");
                    foreach (PandaWarriorTableWin tw in sr.TableWins)
                    {
                        Console.WriteLine(String.Format("[CARD:{0} COUNT:{1} WILD:{2}]", tw.Card, tw.Count, tw.Wild));
                    }

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

            Console.WriteLine($"Win            : {totalWin}");
            return(totalWin);
        }
Ejemplo n.º 25
0
        public void TestAlchemyReelsFullCycle(int level, List <int> rows)
        {
            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;
            var profile            = new Dictionary <decimal, int>();
            var maxIndexPosition   = new List <int>();

            AlchemyReelsCommon.CreateWheels(rows);

            var summData = new SummaryData();

            for (var reel0 = 0; reel0 < AlchemyReelsConfiguration.Wheels[level].Reels[0].Count; reel0++)
            {
                for (var reel1 = 0; reel1 < AlchemyReelsConfiguration.Wheels[level].Reels[1].Count; reel1++)
                {
                    for (var reel2 = 0; reel2 < AlchemyReelsConfiguration.Wheels[level].Reels[2].Count; reel2++)
                    {
                        var totalWin = (decimal)0;

                        var ugk = new UserGameKey()
                        {
                            UserId = -1,
                            GameId = AlchemyReelsConfiguration.GameId,
                            Level  = 1
                        };

                        var sb = new SpinBet(ugk, PlatformType.None)
                        {
                            LineBet    = 1,
                            Credits    = 0,
                            Lines      = AlchemyReelsConfiguration.BettingLines,
                            Multiplier = 1
                        };

                        var requestContext      = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);
                        var requestBonusContext = new RequestContext <BonusArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);
                        requestContext.Currency = new Currency()
                        {
                            Id = sb.CurrencyId
                        };
                        requestContext.Parameters = new SpinArgs()
                        {
                            LineBet = sb.LineBet, BettingLines = sb.Lines
                        };
                        requestContext.GameSetting = new GameSetting()
                        {
                            GameSettingGroupId = sb.GameSettingGroupId
                        };

                        var wheel = new Wheel(rows);
                        wheel.Reels[0] = GetRange(AlchemyReelsConfiguration.Wheels[level].Reels[0], reel0, wheel.Rows[0]);
                        wheel.Reels[1] = GetRange(AlchemyReelsConfiguration.Wheels[level].Reels[1], reel1, wheel.Rows[1]);
                        wheel.Reels[2] = GetRange(AlchemyReelsConfiguration.Wheels[level].Reels[2], reel2, wheel.Rows[2]);

                        var sr = new AlchemyReelsCollapsingSpinResult()
                        {
                            SpinBet = new SpinBet(ugk, PlatformType.None)
                            {
                                Lines      = AlchemyReelsConfiguration.BettingLines,
                                Multiplier = 1,
                                LineBet    = 1m
                            },

                            Wheel = wheel
                        };

                        sr.Wheel      = wheel;
                        sr.TopIndices = new List <int>()
                        {
                            reel0, reel1, reel2
                        };

                        AlchemyReelsCommon.CalculateWin(sr);

                        totalWin = sr.Win;

                        UpdateSummaryData(summData, sr);
                        UpdateAlchemyReelsSummaryData(summData, 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     = ugk.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;

                                var win = alchemyFreeCollapsingSpinResult.Win;

                                if (win > 0)
                                {
                                    totalWin += win;
                                }

                                var maxTopIndices = alchemyFreeCollapsingSpinResult.SpinResult.TopIndices.ToList();

                                if (totalWin > maxWin)
                                {
                                    maxWin = totalWin;

                                    maxIndexPosition = maxTopIndices;
                                }

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

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

                        if (!profile.ContainsKey(totalWin))
                        {
                            profile.Add(totalWin, 1);
                        }
                        else
                        {
                            profile.TryGetValue(totalWin, out int count);
                            profile.Remove(totalWin);
                            profile.Add(totalWin, count + 1);
                        }
                    }
                }
            }

            DisplayAlchemyReelsSummaryData(level, 1, 10, summData, sdt, maxWin, maxIndexPosition);
            if (profile != null)
            {
                foreach (var item in profile.OrderByDescending(p => p.Key))
                {
                    Console.WriteLine($"Win            : {item.Key}; {item.Value}");
                }
            }
        }
Ejemplo n.º 26
0
        public void TestExecuteBonus()
        {
            // Arrange
            var user    = new UserGameKey(-1, 3);
            var spinBet = new SpinBet(user, PlatformType.None)
            {
                Lines   = 30,
                LineBet = 1.0m
            };
            var result1 = new BikiniBeachResult()
            {
                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
                }
            };
            var result2 = new BikiniBeachResult()
            {
                BonusPositions = new List <BonusPosition> {
                    new BonusPosition {
                        Line = 1, Multiplier = 1, RowPositions = new List <int> {
                            0, 2, 2, 2, 0
                        }
                    }
                },
                Bonus = new Stake(Guid.NewGuid(), 3)
                {
                    Count = 1
                }
            };
            var result3 = new BikiniBeachResult()
            {
                BonusPositions = new List <BonusPosition> {
                    new BonusPosition {
                        Line = 1, Multiplier = 1, RowPositions = new List <int> {
                            0, 2, 2, 2, 0
                        }
                    }
                },
                Bonus = new Stake(Guid.NewGuid(), 4)
                {
                    Count = 1
                }
            };

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

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonus1 = module.CreateBonus(result1).Value;
            var bonus2 = module.CreateBonus(result2).Value;
            var bonus3 = module.CreateBonus(result3).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 = ""
            };
            var entity2 = new BonusEntity
            {
                UserId       = userSession.UserId,
                GameId       = requestContext.Game.Id,
                Guid         = bonus2.Guid.ToString("N"),
                Data         = Model.Utility.Extension.ToByteArray(bonus2),
                BonusType    = bonus2.GetType().Name,
                Version      = 3,
                IsOptional   = bonus2.IsOptional,
                IsStarted    = bonus2.IsStarted,
                RoundId      = 1,
                BetReference = ""
            };
            var entity3 = new BonusEntity
            {
                UserId       = userSession.UserId,
                GameId       = requestContext.Game.Id,
                Guid         = bonus3.Guid.ToString("N"),
                Data         = Model.Utility.Extension.ToByteArray(bonus3),
                BonusType    = bonus3.GetType().Name,
                Version      = 3,
                IsOptional   = bonus3.IsOptional,
                IsStarted    = bonus3.IsStarted,
                RoundId      = 1,
                BetReference = ""
            };

            // action
            var freeSpinResult1 = module.ExecuteBonus(1, entity1, requestBonusContext).Value as BikiniBeachBonusSpinResult;
            var freeSpinResult2 = module.ExecuteBonus(1, entity2, requestBonusContext).Value as BikiniBeachBonusSpinResult;
            var freeSpinResult3 = module.ExecuteBonus(1, entity3, requestBonusContext).Value as BikiniBeachBonusSpinResult;

            // assert
            Assert.NotNull(freeSpinResult1);
            Assert.NotNull(freeSpinResult2);
            Assert.NotNull(freeSpinResult3);

            Assert.AreEqual(freeSpinResult1.SpinResult.HasBonus == false, ((BikiniBeachBonus)freeSpinResult1.Bonus).State is Finish);
            Assert.AreEqual(freeSpinResult2.SpinResult.HasBonus == false, ((BikiniBeachBonus)freeSpinResult1.Bonus).State is Finish);
            Assert.AreEqual(freeSpinResult3.SpinResult.HasBonus == false, ((BikiniBeachBonus)freeSpinResult1.Bonus).State is Finish);
            Assert.AreEqual(freeSpinResult1.GameResultType, GameResultType.FreeSpinResult);
            Assert.AreEqual(freeSpinResult2.GameResultType, GameResultType.RevealResult);
            Assert.AreEqual(freeSpinResult3.GameResultType, GameResultType.RevealResult);
        }
Ejemplo n.º 27
0
        public void TestFaFaZhuFullCycle(int level, List <int> rows)
        {
            var sdt             = DateTime.Now;
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <FaFaZhuModule>();

            var FaFaZhuModule = new FaFaZhuModule(logger);
            var maxWin        = 0m;
            Dictionary <decimal, int> profile = new Dictionary <decimal, int>();
            List <int> maxIndexPosition       = new List <int>();
            var        summData     = new SummaryData();
            var        reel1Pointer = 0;
            var        reel2Pointer = 0;
            var        reel3Pointer = 0;

            for (var reel0 = 0; reel0 < FaFaZhuConfiguration.VirtualReels[level][0]; reel0++)
            {
                for (var reel1 = 0; reel1 < FaFaZhuConfiguration.VirtualReels[level][1]; reel1++)
                {
                    for (var reel2 = 0; reel2 < FaFaZhuConfiguration.VirtualReels[level][2]; reel2++)
                    {
                        var totalWin = (decimal)0;

                        UserGameKey ugk = new UserGameKey()
                        {
                            UserId = -1,
                            GameId = FaFaZhuConfiguration.GameId,
                            Level  = 1
                        };

                        SpinBet sb = new SpinBet(ugk, PlatformType.None)
                        {
                            LineBet    = 1,
                            Credits    = 0,
                            Lines      = FaFaZhuConfiguration.BettingLines,
                            Multiplier = 1
                        };

                        RequestContext <SpinArgs>  requestContext      = new RequestContext <SpinArgs>("", FaFaZhuConfiguration.GameName, PlatformType.Web);
                        RequestContext <BonusArgs> requestBonusContext = new RequestContext <BonusArgs>("", FaFaZhuConfiguration.GameName, PlatformType.Web);
                        requestContext.Currency = new Currency()
                        {
                            Id = sb.CurrencyId
                        };
                        requestContext.Parameters = new SpinArgs()
                        {
                            LineBet = sb.LineBet, BettingLines = sb.Lines
                        };
                        requestContext.GameSetting = new GameSetting()
                        {
                            GameSettingGroupId = sb.GameSettingGroupId
                        };

                        var wheel = new Wheel(rows);

                        for (int i = 1; i < FaFaZhuConfiguration.Wheels[level].Reels[0].Count - 1; i++)
                        {
                            if (reel0 < FaFaZhuConfiguration.CumulativeWeightReels[level][0][i - 1])
                            {
                                reel1Pointer = i;

                                wheel.Reels[0] = FaFaZhuCommon.GetRange(FaFaZhuConfiguration.Wheels[level].Reels[0], reel1Pointer, wheel.Rows[0]);

                                break;
                            }
                        }

                        for (int j = 1; j < FaFaZhuConfiguration.Wheels[level].Reels[1].Count - 1; j++)
                        {
                            if (reel1 < FaFaZhuConfiguration.CumulativeWeightReels[level][1][j - 1])
                            {
                                reel2Pointer = j;

                                wheel.Reels[1] = FaFaZhuCommon.GetRange(FaFaZhuConfiguration.Wheels[level].Reels[1], reel2Pointer, wheel.Rows[1]);

                                break;
                            }
                        }

                        for (int k = 1; k < FaFaZhuConfiguration.Wheels[level].Reels[2].Count - 1; k++)
                        {
                            if (reel2 < FaFaZhuConfiguration.CumulativeWeightReels[level][2][k - 1])
                            {
                                reel3Pointer = k;

                                wheel.Reels[2] = FaFaZhuCommon.GetRange(FaFaZhuConfiguration.Wheels[level].Reels[2], reel3Pointer, wheel.Rows[2]);

                                break;
                            }
                        }

                        FaFaZhuSpinResult sr = new FaFaZhuSpinResult(ugk)
                        {
                            SpinBet = new SpinBet(ugk, PlatformType.None)
                            {
                                Lines      = FaFaZhuConfiguration.BettingLines,
                                Multiplier = 1,
                                LineBet    = 1m
                            },

                            WheelActual = wheel
                        };

                        sr.WheelActual = wheel;

                        FaFaZhuCommon.CalculateWin(sr);

                        totalWin = sr.Win;

                        UpdateSummaryData(summData, sr);
                        UpdateFaFaZhuSummaryData(summData, sr);

                        if (!profile.ContainsKey(totalWin))
                        {
                            profile.Add(totalWin, 1);
                        }
                        else
                        {
                            profile.TryGetValue(totalWin, out int count);
                            profile.Remove(totalWin);
                            profile.Add(totalWin, count + 1);
                        }
                    }
                }
            }

            DisplayFaFaZhuSummaryData(level, 1, 10, summData, sdt, maxWin, maxIndexPosition);
            if (profile != null)
            {
                foreach (var item in profile.OrderByDescending(p => p.Key))
                {
                    Console.WriteLine($"Win            : {item.Key}; {item.Value}");
                }
            }
        }
Ejemplo n.º 28
0
        public void TestExecuteBonus()
        {
            // Arrange
            var user    = new UserGameKey(-1, 109);
            var spinBet = new SpinBet(user, PlatformType.None)
            {
                Lines   = 30,
                LineBet = 1.0m
            };
            var wheel = new FortuneChimesWheel
            {
                Reels = new List <int[]>
                {
                    new int[] { 1, 1, 1 },
                    new int[] { 2, 10, 2 },
                    new int[] { 3, 10, 3 },
                    new int[] { 4, 10, 4 },
                    new int[] { 5, 5, 5 },
                },
                Indices = new int[] { 0, 0, 0, 0, 0 }
            };
            var result1 = new FortuneChimesSpinResult(user)
            {
                Wheel          = wheel,
                BonusPositions = new List <BonusPosition> {
                    new BonusPosition {
                        Line = 1, Multiplier = 1, RowPositions = new List <int> {
                            0, 2, 2, 2, 0
                        }
                    }
                },
                Bonus = new Stake(Guid.NewGuid(), 3)
                {
                    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 = 109
                }
            };
            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 FortuneChimesBonusSpinResult;

            // assert
            Assert.NotNull(freeSpinResult1);
            Assert.AreEqual(freeSpinResult1.GameResultType, GameResultType.FreeSpinResult);
        }
Ejemplo n.º 29
0
        private decimal TestPayout(string strwheel, decimal betperline, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var sdt = DateTime.Now;

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

            var chessRoyaleModule = new ChessRoyaleModule(logger);

            var        totalWin         = 0m;
            List <int> maxIndexPosition = new List <int>();
            RequestContext <SpinArgs> requestContext = new RequestContext <SpinArgs>("", ChessRoyaleConfiguration.GameName, PlatformType.Web);
            var summData = new SummaryData();

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            string[] arrstr = strwheel.Split(',');
            int[]    arr    = Array.ConvertAll(arrstr, int.Parse);

            UserGameKey ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = ChessRoyaleConfiguration.GameId,
                Level  = 1
            };

            SpinBet sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = ChessRoyaleConfiguration.Lines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            ChessRoyaleSpinResult sr = new ChessRoyaleSpinResult(ugk)
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = ChessRoyaleConfiguration.Lines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(ChessRoyaleConfiguration.Width, ChessRoyaleConfiguration.Height, arr)
            };


            totalWin = ChessRoyaleCommon.CalculateWin(sr, 1);

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

                var bonus = bonusCreated.Value;

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

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

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

                BonusResult bonusResult;
                int         step = bonus.CurrentStep;

                do
                {
                    var entity = new BonusEntity
                    {
                        UserId     = ugk.UserId,
                        GameId     = ChessRoyaleConfiguration.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 = chessRoyaleModule.ExecuteBonus(ChessRoyaleConfiguration.LevelOne, entity, requestBonusContext).Value;
                    var chessRoyaleFreeSpinResult = bonusResult as ChessRoyaleFreeSpinResult;

                    var win = chessRoyaleFreeSpinResult.Win;

                    if (win > 0)
                    {
                        totalWin += win;
                    }

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

            Console.WriteLine($"Win            : {totalWin}");
            return(totalWin);
        }
Ejemplo n.º 30
0
        private decimal TestPayout(string strwheel, decimal betperline, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var sdt = DateTime.Now;

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

            var FountainOfFortuneModule = new FountainOfFortuneModule(logger);

            var        maxWin           = 0m;
            var        totalWin         = 0m;
            List <int> maxIndexPosition = new List <int>();
            RequestContext <SpinArgs> requestContext = new RequestContext <SpinArgs>("", FountainOfFortuneConfiguration.GameName, PlatformType.Web);
            var summData = new SummaryData();

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            string[] arrstr = strwheel.Split(',');
            int[]    arr    = Array.ConvertAll(arrstr, int.Parse);

            UserGameKey ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = FountainOfFortuneConfiguration.GameId,
                Level  = 1
            };

            SpinBet sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = FountainOfFortuneConfiguration.Lines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            FountainOfFortuneSpinResult sr = new FountainOfFortuneSpinResult(ugk)
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = FountainOfFortuneConfiguration.Lines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(FountainOfFortuneConfiguration.Width, FountainOfFortuneConfiguration.Height, arr)
            };


            totalWin = FountainOfFortuneCommon.CalculateWin(sr, 1);

            Console.WriteLine($"Win            : {totalWin}");
            return(totalWin);
        }