public void EngineShouldGetRemoveCorrectRowPositions(string wheelString, int level)
        {
            var config              = new Configuration();
            var wheel               = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString.ToFormattedWheelString());
            var winPositions        = MainGameEngine.GenerateWinPositions(config.Payline, config.PayTable, wheel, 1, 1);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(winPositions);

            for (var widthIndex = 0; widthIndex < wheel.Width; widthIndex++)
            {
                for (var heightIndex = 0; heightIndex < Game.WheelHeight; heightIndex++)
                {
                    var index = (widthIndex * Game.WheelHeight) + heightIndex;
                    var removeRowPositions = CollapsingBonusEngine.GetRemoveRowPositions(winPositions, index);

                    var removeWinPositions = winPositions
                                             .Select(wp => wp.RowPositions[index] > 0 ? index % Game.WheelWidth : -1)
                                             .Where(wp => wp != -1)
                                             .Distinct();

                    var targetRowPositions = removeWinPositions;

                    Assert.IsTrue(!targetRowPositions.Except(removeRowPositions).Any());
                }
            }
        }
        public void EngineShouldGenerateCorrectCollapseWheel(int level)
        {
            var config              = new Configuration();
            var spinResult          = GenerateWinningSpinResult(level);
            var referenceWheel      = MainGameEngine.GetTargetWheel(level, config);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(spinResult.WinPositions);
            var collapsingRemoves   = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions);
            var newTopIndices       = CollapsingBonusEngine.GetCollapseTopIndices(referenceWheel, spinResult.TopIndices, collapsingRemoves);
            var collapsingAdds      = CollapsingBonusEngine.GetCollapseAddItems(referenceWheel, newTopIndices, collapsingRemoves);
            var collapsingWheel     = CollapsingBonusEngine.GenerateCollapsedWheel(spinResult.Wheel, collapsingRemoves, collapsingAdds);
            var newWheel            = spinResult.Wheel.Copy();

            foreach (var removeItem in collapsingRemoves)
            {
                var cleanReel = newWheel[removeItem.Key];

                foreach (var index in removeItem.Value.OrderByDescending(val => val))
                {
                    cleanReel.RemoveAt(index);
                }

                newWheel[removeItem.Key] = collapsingAdds[removeItem.Key].Concat(cleanReel).ToList();
            }

            foreach (var reelIndex in collapsingWheel.Reels.Select((Value, Index) => new { Value, Index }))
            {
                var referenceReel = newWheel[reelIndex.Index];

                Assert.IsTrue(!referenceReel.Except(reelIndex.Value).Any());
            }


            newWheel.Equals(collapsingWheel);
        }
Example #3
0
        public void EngineShouldGetRemoveCorrectRowPositions(string wheelString, int level)
        {
            var config       = new Configuration();
            var wheel        = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString.ToFormattedWheelString());
            var winPositions = MainGameEngine.GenerateWinPositions(
                config.Payline,
                config.PayTable,
                wheel,
                1,
                Game.Lines,
                config.BonusConfig.Collapse.Multipliers.First());
            var bonusPositions      = MainGameEngine.GenerateBonusPositions(wheel);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(winPositions, bonusPositions);

            for (var widthIndex = 0; widthIndex < wheel.Width; widthIndex++)
            {
                var removeRowPositions = CollapsingBonusEngine.GetRemoveRowPositions(winPositions, widthIndex);

                var removeWinPositions = winPositions
                                         .Select(wp => wp.RowPositions[widthIndex] - 1)
                                         .Where(wp => wp != -1)
                                         .Distinct();

                var targetRowPositions = removeWinPositions;

                Assert.IsTrue(!targetRowPositions.Except(removeRowPositions).Any());
            }
        }
Example #4
0
        public void EngineShouldRemoveCorrectWinPositions(string wheelString, int level)
        {
            var config       = new Configuration();
            var wheel        = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString.ToFormattedWheelString());
            var winPositions = MainGameEngine.GenerateWinPositions(
                config.Payline,
                config.PayTable,
                wheel,
                1,
                Game.Lines,
                config.BonusConfig.Collapse.Multipliers.First());
            var bonusPositions      = MainGameEngine.GenerateBonusPositions(wheel);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(winPositions, bonusPositions);

            foreach (var winPositionIndex in winPositions.Select((Value, Index) => new { Value, Index }))
            {
                var removedWinPosition = removedWinPositions.ElementAt(winPositionIndex.Index);

                Assert.AreEqual(winPositionIndex.Value.Line, removedWinPosition.Line);
            }

            foreach (var bonusPositionIndex in bonusPositions.Select((Value, Index) => new { Value, Index }))
            {
                Assert.AreEqual(bonusPositionIndex.Value.Line, 0);
            }
        }
Example #5
0
        public void EngineShouldGetRemoveCorrectRowPositions(string wheelString, int level)
        {
            var config       = new Configuration();
            var wheel        = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString);
            var winPositions = MainGameEngine.GenerateWinPositions(
                config.Payline,
                config.PayTable,
                wheel,
                1,
                Game.Lines,
                1);
            var matchingSymbolPositions = MainGameEngine.GenerateMatchingSymbolPositions(config.SymbolCollapsePairs, winPositions.Select(wp => wp.Symbol).ToList(), wheel);
            var bombAndStopperPositions = MainGameEngine.GenerateBombAndStopperPositions(wheel, winPositions);
            var removedWinPositions     = CollapsingBonusEngine.GetRemoveWinPositions(winPositions);

            for (var widthIndex = 0; widthIndex < wheel.Width; widthIndex++)
            {
                var removeRowPositions = CollapsingBonusEngine.GetRemoveRowPositions(winPositions, matchingSymbolPositions, bombAndStopperPositions, widthIndex);

                var removeWinPositions = winPositions
                                         .Select(wp => wp.RowPositions[widthIndex] - 1)
                                         .Where(wp => wp != -1)
                                         .Distinct();
                var removeMatchingSymbolPositions = matchingSymbolPositions[widthIndex]
                                                    .Select(position => position - 1)
                                                    .Where(position => position != -1)
                                                    .Distinct();

                var targetRowPositions = removeWinPositions.Union(removeMatchingSymbolPositions);

                Assert.IsTrue(!targetRowPositions.Except(removeRowPositions).Any());
            }
        }
        public void EngineShouldRemoveCorrectWinPositionCount(string wheelString, int level)
        {
            var config              = new Configuration();
            var wheel               = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString.ToFormattedWheelString());
            var winPositions        = MainGameEngine.GenerateWinPositions(config.Payline, config.PayTable, wheel, 1, 1);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(winPositions);

            Assert.AreEqual(winPositions.Count, removedWinPositions.Count);
        }
        public void EngineShouldGenerateCorrectCollapseAddItems(int level)
        {
            var config              = new Configuration();
            var spinResult          = GenerateWinningSpinResult(level);
            var referenceWheel      = MainGameEngine.GetTargetWheel(level, config);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(spinResult.WinPositions);
            var collapsingRemoves   = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions);
            var newTopIndices       = CollapsingBonusEngine.GetCollapseTopIndices(referenceWheel, spinResult.TopIndices, collapsingRemoves);
            var collapsingAdds      = CollapsingBonusEngine.GetCollapseAddItems(referenceWheel, newTopIndices, collapsingRemoves);

            for (var widthIndex = 0; widthIndex < spinResult.Wheel.Width; widthIndex++)
            {
                var referenceReel = referenceWheel[widthIndex];
                var targetReel    = collapsingAdds[widthIndex];

                Assert.IsTrue(!targetReel.Except(referenceReel).Any());
            }
        }
        public void EngineShouldGenerateCorrectNewTopIndices(int level)
        {
            var config              = new Configuration();
            var spinResult          = GenerateNonWinningSpinResult(level);
            var referenceWheel      = MainGameEngine.GetTargetWheel(level, config);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(spinResult.WinPositions);
            var collapsingRemoves   = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions);
            var newTopIndices       = CollapsingBonusEngine.GetCollapseTopIndices(referenceWheel, spinResult.TopIndices, collapsingRemoves);

            for (var widthIndex = 0; widthIndex < spinResult.Wheel.Width; widthIndex++)
            {
                var previousTopIndex = spinResult.TopIndices[widthIndex];
                var currentTopIndex  = newTopIndices[widthIndex];

                var tempIndex           = previousTopIndex - collapsingRemoves[widthIndex].Count;
                var expectedNewTopIndex = tempIndex >= 0 ? tempIndex : referenceWheel[widthIndex].Count + tempIndex;

                Assert.AreEqual(expectedNewTopIndex, currentTopIndex);
            }
        }
Example #9
0
        public void EngineShouldGenerateCorrectCollapseAddItems(int level)
        {
            var config                  = new Configuration();
            var referenceWheel          = config.Wheels[level];
            var spinResult              = GenerateWinningSpinResult(level);
            var removedWinPositions     = CollapsingBonusEngine.GetRemoveWinPositions(spinResult.WinPositions);
            var matchingSymbolPositions = MainGameEngine.GenerateMatchingSymbolPositions(config.SymbolCollapsePairs, spinResult.WinPositions.Select(wp => wp.Symbol).ToList(), spinResult.Wheel);
            var bombAndStopperPositions = MainGameEngine.GenerateBombAndStopperPositions(spinResult.Wheel, spinResult.WinPositions);
            var collapsingRemoves       = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions, matchingSymbolPositions, bombAndStopperPositions);
            var newTopIndices           = CollapsingBonusEngine.GetCollapseTopIndices(referenceWheel, spinResult.TopIndices, collapsingRemoves);
            var collapsingAdds          = CollapsingBonusEngine.GetCollapseAddItems(referenceWheel, newTopIndices, collapsingRemoves);

            for (var widthIndex = 0; widthIndex < spinResult.Wheel.Width; widthIndex++)
            {
                var referenceReel = referenceWheel[widthIndex];
                var targetReel    = collapsingAdds[widthIndex];

                Assert.IsTrue(!targetReel.Except(referenceReel).Any());
            }
        }
        public void EngineShouldGetCorrectCollapseRemoveItems(string wheelString, int level)
        {
            var config              = new Configuration();
            var wheel               = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString.ToFormattedWheelString());
            var winPositions        = MainGameEngine.GenerateWinPositions(config.Payline, config.PayTable, wheel, 1, 1);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(winPositions);
            var collapsingRemoves   = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions);

            for (var widthIndex = 0; widthIndex < wheel.Width; widthIndex++)
            {
                var removeRowPositionsCollection = new List <int>();

                for (var heightIndex = 0; heightIndex < Game.WheelHeight; heightIndex++)
                {
                    var index = (widthIndex * Game.WheelHeight) + heightIndex;
                    var removeRowPositions = CollapsingBonusEngine.GetRemoveRowPositions(removedWinPositions, index);
                    removeRowPositionsCollection.AddRange(removeRowPositions);
                }

                Assert.IsTrue(!collapsingRemoves[widthIndex].Except(removeRowPositionsCollection).Any());
            }
        }
        public void EngineShouldGetCorrectCollapseRemoveItems(string wheelString, int level)
        {
            var config       = new Configuration();
            var wheel        = new Wheel(Game.WheelWidth, Game.WheelHeight, wheelString.ToFormattedWheelString());
            var winPositions = MainGameEngine.GenerateWinPositions(
                config.Payline,
                config.MainGamePayTable,
                wheel,
                1,
                Game.Lines,
                1);
            var bonusPositions      = MainGameEngine.GenerateBonusPositions(wheel);
            var removedWinPositions = CollapsingBonusEngine.GetRemoveWinPositions(winPositions, bonusPositions);
            var collapsingRemoves   = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions);

            for (var widthIndex = 0; widthIndex < wheel.Width; widthIndex++)
            {
                var removeRowPositions = CollapsingBonusEngine.GetRemoveRowPositions(removedWinPositions, widthIndex);

                Assert.IsTrue(!collapsingRemoves[widthIndex].Except(removeRowPositions).Any());
            }
        }
Example #12
0
        public void EngineShouldGenerateCorrectNewTopIndices(int level)
        {
            var config                  = new Configuration();
            var referenceWheel          = MainGameEngine.GetTargetWheel(level, config);
            var spinResult              = GenerateWinningNonBonusSpinResult(level);
            var removedWinPositions     = CollapsingBonusEngine.GetRemoveWinPositions(spinResult.WinPositions);
            var matchingSymbolPositions = MainGameEngine.GenerateMatchingSymbolPositions(config.SymbolCollapsePairs, spinResult.WinPositions.Select(wp => wp.Symbol).ToList(), spinResult.Wheel);
            var bombAndStopperPositions = MainGameEngine.GenerateBombAndStopperPositions(spinResult.Wheel, spinResult.WinPositions);
            var collapsingRemoves       = CollapsingBonusEngine.GetCollapseRemoveItems(removedWinPositions, matchingSymbolPositions, bombAndStopperPositions);
            var newTopIndices           = CollapsingBonusEngine.GetCollapseTopIndices(referenceWheel, spinResult.TopIndices, collapsingRemoves);

            for (var widthIndex = 0; widthIndex < spinResult.Wheel.Width; widthIndex++)
            {
                var previousTopIndex = spinResult.TopIndices[widthIndex];
                var currentTopIndex  = newTopIndices[widthIndex];

                var tempIndex           = previousTopIndex - collapsingRemoves[widthIndex].Count;
                var expectedNewTopIndex = tempIndex >= 0 ? tempIndex : referenceWheel[widthIndex].Count + tempIndex;

                Assert.AreEqual(expectedNewTopIndex, currentTopIndex);
            }
        }