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); }
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); } }
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 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); } }