示例#1
0
        public ReportDTO Calculate(List <List <SlotSymbolOffset> > reelsOutput)
        {
            ReportDTO dto = new ReportDTO {
                HitTotal        = 0,
                PayoffAmount    = 0,
                PaylineHitTotal = 0,
                SpinTotal       = 0
            };

            foreach (IPayline pL in paylineList)
            {
                foreach (PayMatchAmount pMA in payMatchAmountList)
                {
                    ReportDTO dtoPL = pL.Calculate(pMA, reelsOutput);
                    dto.PayoffAmount    = dto.PayoffAmount + dtoPL.PayoffAmount;
                    dto.PaylineHitTotal = dto.PaylineHitTotal + dtoPL.PaylineHitTotal;
                }
            }
            if (dto.PaylineHitTotal != 0)
            {
                dto.HitTotal = 1;
            }
            dto.SpinTotal = 1;
            return(dto);
        }
示例#2
0
        public ReportDTO SpinManyTimes()
        {
            ReportDTO dto = new ReportDTO
            {
                HitTotal        = 0,
                PayoffAmount    = 0,
                PaylineHitTotal = 0,
                SpinTotal       = 0
            };

            List <Task <ReportDTO> > dtoList = new List <Task <ReportDTO> >();

            slotMachineList.ToArray();
            foreach (var m in slotMachineList)
            {
                dtoList.Add(SpinInstanceManyTimesAsync(m));
            }

            Task.WaitAll(dtoList.ToArray());
            foreach (var dtoI in dtoList)
            {
                dto.PayoffAmount    += dtoI.Result.PayoffAmount;
                dto.HitTotal        += dtoI.Result.HitTotal;
                dto.PaylineHitTotal += dtoI.Result.PaylineHitTotal;
                dto.SpinTotal       += dtoI.Result.SpinTotal;
            }
            return(dto);
        }
示例#3
0
        public ReportDTO Calculate(PayMatchAmount match, List <List <SlotSymbolOffset> > reelOutputs)
        {
            ReportDTO dto = new ReportDTO
            {
                HitTotal        = 0,
                PayoffAmount    = 0,
                PaylineHitTotal = 0,
                SpinTotal       = 0
            };
            bool wasHit = true;
            List <SlotSymbolOffset> matchesOffset = new List <SlotSymbolOffset>();
            List <bool>             isMatchList   = new List <bool>();

            matchesOffset = match.ExactMatch.Zip(verticalOffsets, (me, v) => new SlotSymbolOffset(v, me)).ToList <SlotSymbolOffset>();
            isMatchList   = matchesOffset.Zip(reelOutputs, (m, r) =>
            {
                bool wasHitReel = false;
                foreach (SlotSymbolOffset so in r)
                {
                    if (so.Offset == m.Offset && so.Symbol == m.Symbol)
                    {
                        wasHitReel = true;
                        break;
                    }
                }

                return(wasHitReel);
            }).ToList <bool>();
            foreach (bool m in isMatchList)
            {
                wasHit = m && wasHit;
            }
            if (wasHit == true)
            {
                dto.PayoffAmount    = match.Amount;
                dto.PaylineHitTotal = 1;
            }
            else
            {
                dto.PayoffAmount = -match.Amount;
            }


            return(dto);
        }
示例#4
0
        ReportDTO SpinInstanceManyTimes(SlotMachine slotMachineInstance)
        {
            ReportDTO dto = new ReportDTO
            {
                HitTotal        = 0,
                PayoffAmount    = 0,
                PaylineHitTotal = 0
            };

            for (int i = 0; i < iterationsTotal; i++)
            {
                ReportDTO dtoM = slotMachineInstance.Spin();
                dto.PayoffAmount    += dtoM.PayoffAmount;
                dto.HitTotal        += dtoM.HitTotal;
                dto.PaylineHitTotal += dtoM.PaylineHitTotal;
                dto.SpinTotal       += dtoM.SpinTotal;
            }

            return(dto);
        }
示例#5
0
        public ReportDTO SpinAllCombinations()
        {
            ReportDTO dto = new ReportDTO
            {
                HitTotal        = 0,
                PayoffAmount    = 0,
                PaylineHitTotal = 0,
                SpinTotal       = 0
            };
            ReportDTO dtoI;

            List <List <ESlotSymbol> > stripList = reelStripList
                                                   .Select(r => r.Strip)
                                                   .ToList <List <ESlotSymbol> >();

            if (stripList.Count != 3)
            {
                throw new Exception("SpinAllCombinations need to be updated if you need to test a slotmachine with the total number of reels different than 3");
            }


            var offsets = Enum.GetValues(typeof(ESlotOffset)).Cast <ESlotOffset>();

            /*Note: Each strip has already the added fornt end elements to make it look circular as per requirement.
             *      This is garanteed in the constructor of the Reel*/
            var stripList0     = stripList[0].ToArray <ESlotSymbol>();
            var stripList1     = stripList[1].ToArray <ESlotSymbol>();
            var stripList2     = stripList[2].ToArray <ESlotSymbol>();
            var stripList0Wind = new List <SlotSymbolOffset>();
            var stripList1Wind = new List <SlotSymbolOffset>();
            var stripList2Wind = new List <SlotSymbolOffset>();
            var Count0         = stripList0.Count <ESlotSymbol>() - (visibleAreaHeight - 1);
            var Count1         = stripList1.Count <ESlotSymbol>() - (visibleAreaHeight - 1);
            var Count2         = stripList2.Count <ESlotSymbol>() - (visibleAreaHeight - 1);

            var reelsOutput = new List <List <SlotSymbolOffset> >();
            var slice       = new List <ESlotSymbol>();

            for (int i0 = 0; i0 < Count0; i0++)
            {
                slice          = stripList0.Skip(i0).Take(visibleAreaHeight).ToList <ESlotSymbol>();
                stripList0Wind = slice.Zip(offsets, (s, o) => new SlotSymbolOffset(o, s)).ToList <SlotSymbolOffset>();
                for (int i1 = 0; i1 < Count1; i1++)
                {
                    slice          = stripList1.Skip(i1).Take(visibleAreaHeight).ToList <ESlotSymbol>();
                    stripList1Wind = slice.Zip(offsets, (s, o) => new SlotSymbolOffset(o, s)).ToList <SlotSymbolOffset>();
                    for (int i2 = 0; i2 < Count2; i2++)
                    {
                        slice          = stripList2.Skip(i2).Take(visibleAreaHeight).ToList <ESlotSymbol>();
                        stripList2Wind = slice.Zip(offsets, (s, o) => new SlotSymbolOffset(o, s)).ToList <SlotSymbolOffset>();
                        reelsOutput.Add(stripList0Wind);
                        reelsOutput.Add(stripList1Wind);
                        reelsOutput.Add(stripList2Wind);
                        dtoI                 = slotMachineEngine.Calculate(reelsOutput);
                        dto.PayoffAmount    += dtoI.PayoffAmount;
                        dto.HitTotal        += dtoI.HitTotal;
                        dto.PaylineHitTotal += dtoI.PaylineHitTotal;
                        dto.SpinTotal       += dtoI.SpinTotal;
                        reelsOutput.RemoveAll(e => true);
                    }
                }
            }

            return(dto);
        }