Ejemplo n.º 1
0
 public void update()
 {
     if (speed > 0)
     {
         bgPosition = bgPosition + speed;
         if (speed > 5)
         {
             slotSound.Play();
             spriteXPosition = slotSize.Width;
         }
         else
         {
             spriteXPosition = 0;
         }
         if (stoped)
         {
             speed--;
         }
         if (bgPosition % slotSize.Height != 0 && speed == 0)
         {
             speed++;
         }
     }
     if (speed == 0 && stoped)
     {
         this.spinning   = false;
         this.slotResult = setSlotResult();
     }
 }
Ejemplo n.º 2
0
 public void startSpinning(int speed)
 {
     this.slotResult = SlotResult.NONE;
     this.speed      = speed;
     this.spinning   = true;
     this.stoped     = false;
 }
Ejemplo n.º 3
0
        public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng)
        {
            if (paytable.ScatterComboGroup == null)
            {
                throw new Exception("ScatterEvaluator cannot evalate a paytable without a ScatterComboGroup");
            }

            SlotResult        result    = new SlotResult();
            ScattersComponent component = new ScattersComponent();

            List <PayCombo> payCombos = paytable.ScatterComboGroup.Combos;

            for (int combo = 0; combo < payCombos.Count; ++combo)
            {
                PayCombo payCombo      = payCombos[combo];
                int      bestPayAmount = 0;
                PayCombo bestPayCombo  = null;

                // TODO: This assumes the scatter combo contains one type of symbol only.
                // In almost all cases, this will be true so leaving it for now.
                bool   match  = false;
                Symbol symbol = payCombo.SymbolsInPayCombo[0];
                if (reelWindow.SymbolPositions.ContainsKey(symbol) &&
                    reelWindow.SymbolPositions[symbol].Count >= payCombo.SymbolsInPayCombo.Count)
                {
                    match = true;
                }

                if (match && (payCombo.PayAmount >= bestPayAmount))
                {
                    bestPayCombo  = payCombo;
                    bestPayAmount = payCombo.PayAmount;
                }

                if (bestPayCombo != null)
                {
                    // TODO: Might be able to optimize this but making PaylineCoord and SymbolPosition the same thing...
                    Payline payline = new Payline();
                    foreach (var position in reelWindow.SymbolPositions[symbol])
                    {
                        payline.AddPaylineCoord(new PaylineCoord {
                            ReelIndex = position.ReelIndex, Offset = position.ReelOffset
                        });
                    }
                    component.PayResults.Add(new PayResult {
                        PayCombo = bestPayCombo, Payline = payline
                    });
                    result.TotalWin += bestPayCombo.PayAmount;
                }
            }

            if (component.PayResults.Count > 0)
            {
                result.AddComponent <ScattersComponent>(component);
            }

            return(result);
        }
Ejemplo n.º 4
0
    public void Evaluation_Initialization()
    {
        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 0, 0, 0, 0
        });
        SlotResult results = paylineEvaluator.Evaluate(paytable, reelWindow, rng);

        Assert.IsNotNull(results);
    }
Ejemplo n.º 5
0
        public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng)
        {
            if (paytable.PayComboGroup == null)
            {
                throw new Exception("PaylineEvaluator cannot evalate a paytable without a PayComboGroup");
            }

            SlotResult        result    = new SlotResult();
            PaylinesComponent component = new PaylinesComponent();

            // Iterate through each payline defined in the paytable.
            List <Payline> paylines = paytable.PaylineGroup.Paylines;

            foreach (Payline payline in paylines)
            {
                // Get the list of symbols on the payline.
                List <Symbol> symbolsInPayline =
                    reelWindow.GetSymbolsInPayline(payline);

                // Look for the highest pay amount on a given payline.
                int      bestPayAmount = 0;
                PayCombo bestPayCombo  = null;

                List <PayCombo> payCombos = paytable.PayComboGroup.Combos;

                foreach (PayCombo payCombo in payCombos)
                {
                    bool match = payCombo.IsMatch(paytable.PayComboGroup.SymbolComparer, symbolsInPayline);
                    if (match && (payCombo.PayAmount > bestPayAmount))
                    {
                        // Update the best pay combo so far.
                        bestPayCombo  = payCombo;
                        bestPayAmount = payCombo.PayAmount;
                    }
                }

                // Add the best pay combo.
                if (bestPayCombo != null)
                {
                    component.PayResults.Add(new PayResult {
                        PayCombo = bestPayCombo, Payline = payline
                    });
                    result.TotalWin += bestPayCombo.PayAmount;
                }
            }

            if (component.PayResults.Count > 0)
            {
                result.AddComponent <PaylinesComponent>(component);
            }

            return(result);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> GetSlots(int locationId, DateTime startTime, int slotSizeInMinutes)
        {
            using (var context = new ReservationContext()) {
                if (await context.Location.AnyAsync(x => x.Id == locationId) == false)
                {
                    return(BadRequest("Location id not existing."));
                }

                if (slotSizeInMinutes < 1)
                {
                    return(BadRequest("Slot size must be a positive number."));
                }

                var result    = new SlotResult();
                var dayOfWeek = startTime.DayOfWeek.ToString();
                var opening   = await context.LocationOpening.FirstOrDefaultAsync(x => x.LocationId == locationId &&
                                                                                  x.OpeningDays == dayOfWeek);

                DateTime endTime;

                if (opening == null)
                {
                    endTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, 23, 59, 59);
                }
                else
                {
                    endTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, opening.ClosingTime.Hour, opening.ClosingTime.Minute, opening.ClosingTime.Second);
                }


                var current = startTime;
                do
                {
                    var currentEnd = current.AddMinutes(slotSizeInMinutes);

                    var count = await context.Reservation.CountAsync(x => x.LocationId == locationId &&
                                                                     x.StartTime >= current &&
                                                                     x.StartTime < currentEnd);

                    result.Items.Add(new SlotItem()
                    {
                        Start             = current,
                        End               = currentEnd,
                        RegistrationCount = count
                    });

                    current = current.AddMinutes(slotSizeInMinutes);
                } while (current < endTime);

                return(Ok(result));
            }
        }
Ejemplo n.º 7
0
    public void Evaluation_SlotResult4()
    {
        paytable.ScatterComboGroup.Combos.Clear();
        paytable.ScatterComboGroup.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 4, 1000));

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 0, 0
        });
        SlotResult results   = scatterEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <ScattersComponent>();

        Assert.IsNull(component);
    }
Ejemplo n.º 8
0
    public void Evaluation_SlotResult1()
    {
        rng = new DummyRng(new List <int> {
            7
        });

        SlotResult results = pickEvaluator.Evaluate(paytable, null, rng);

        var component = results.GetComponent <PickComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PickResults.Count);
        Assert.AreEqual("Free Spins", component.PickResults[0].Trigger);
    }
Ejemplo n.º 9
0
    public void Evaluation_SlotResult1()
    {
        paytable.ScatterComboGroup.Combos.Clear();
        paytable.ScatterComboGroup.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 3, 1000));

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 0, 0
        });
        SlotResult results   = scatterEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <ScattersComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PayResults.Count);
        Assert.AreEqual(1000, component.PayResults[0].PayCombo.PayAmount);
    }
Ejemplo n.º 10
0
    public void Evaluation_Payline8()
    {
        // Reel Window
        // WW AA BB AA AA
        // AA AA CC BB BB
        // BB CC WW CC CC

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            3, 0, 1, 0, 0
        });
        SlotResult results   = paylineEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <PaylinesComponent>();

        Assert.IsNull(component);
    }
Ejemplo n.º 11
0
    public void Evaluation_Payline7()
    {
        // Reel Window
        // WW WW WW AA AA
        // AA AA AA BB BB
        // BB BB BB CC CC

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            3, 3, 3, 0, 0
        });
        SlotResult results   = paylineEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PayResults.Count);

        Assert.AreEqual(100, component.PayResults[0].PayCombo.PayAmount);  // 3 x WW
    }
Ejemplo n.º 12
0
    public void Evaluation_Payline4()
    {
        // Reel Window
        // AA AA WW BB BB
        // BB BB AA CC CC
        // CC CC BB WW WW

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 0, 3, 1, 1
        });
        SlotResult results   = paylineEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PayResults.Count);

        Assert.AreEqual(10, component.PayResults[0].PayCombo.PayAmount);  // 3 x AA
    }
Ejemplo n.º 13
0
    public void Evaluation_SlotResult5()
    {
        // Reel Window
        // FF FF FF
        // GG GG GG
        // AA AA AA

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            5, 5, 5
        });
        SlotResult results = paylineEvaluator.Evaluate(paytable, reelWindow, rng);

        var component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PayResults.Count);
        Assert.AreEqual(100, component.PayResults[0].PayCombo.PayAmount); // 3 x AA
    }
Ejemplo n.º 14
0
    public void Evaluation_SlotResult3()
    {
        // Reel Window
        // CC CC CC
        // DD DD DD
        // EE EE EE

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            2, 2, 2
        });
        SlotResult results = paylineEvaluator.Evaluate(paytable, reelWindow, rng);

        var component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PayResults.Count);
        Assert.AreEqual(20, component.PayResults[0].PayCombo.PayAmount);  // 3 x CC
    }
Ejemplo n.º 15
0
    public void Evaluation_Payline_4_4_of_a_kind()
    {
        // Reel Window
        // AA CC BB CC BB
        // CC AA CC AA CC
        // AA BB AA BB AA

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 2, 1, 2, 1
        });
        SlotResult results   = paylineEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(1, component.PayResults.Count);

        Assert.AreEqual(25, component.PayResults[0].PayCombo.PayAmount);  // 4 x AA
    }
Ejemplo n.º 16
0
    public void Evaluation_Payline_1_2_3()
    {
        // Reel Window
        // AA AA AA AA AA
        // BB BB BB BB BB
        // CC CC CC CC CC

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 0, 0, 0, 0
        });
        SlotResult results   = paylineEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(3, component.PayResults.Count);

        Assert.AreEqual(50, component.PayResults[0].PayCombo.PayAmount);  // 5 x AA
        Assert.AreEqual(15, component.PayResults[1].PayCombo.PayAmount);  // 5 x BB
        Assert.AreEqual(10, component.PayResults[2].PayCombo.PayAmount);  // 5 x CC
    }
Ejemplo n.º 17
0
    public void Evaluation_SlotResult3()
    {
        rng = new DummyRng(new List <int> {
            0, 0, 0, 0, 0, 0, 0, 0
        });
        SlotResult results = pickEvaluator.Evaluate(paytable, null, rng);

        var component = results.GetComponent <PickComponent>();

        Assert.IsNotNull(component);
        Assert.AreEqual(8, component.PickResults.Count);
        Assert.AreEqual("Prize_10", component.PickResults[0].Name);
        Assert.AreEqual("Prize_10", component.PickResults[1].Name);
        Assert.AreEqual("Prize_10", component.PickResults[2].Name);
        Assert.AreEqual("Prize_10", component.PickResults[3].Name);
        Assert.AreEqual("Prize_20", component.PickResults[4].Name);
        Assert.AreEqual("Prize_20", component.PickResults[5].Name);
        Assert.AreEqual("Prize_30", component.PickResults[6].Name);
        Assert.AreEqual("PickComplete", component.PickResults[7].Name);
    }
Ejemplo n.º 18
0
    public void Evaluation_PaylineMix3()
    {
        // Reel Window
        // BB AA AA BB CC
        // CC BB BB CC AA
        // AA CC CC AA BB

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            1, 0, 0, 1, 2
        });
        SlotResult results   = paylineEvaluator.Evaluate(paytable, reelWindow, rng);
        var        component = results.GetComponent <PaylinesComponent>();

        Assert.IsNotNull(component);

        Assert.AreEqual(2, component.PayResults.Count);

        Assert.AreEqual(33, component.PayResults[0].PayCombo.PayAmount);  // 4 x MX (Payline 0)
        Assert.AreEqual(22, component.PayResults[1].PayCombo.PayAmount);  // 3 x MX (Payline 4)
    }
Ejemplo n.º 19
0
    public void Evaluation_SlotResult8()
    {
        paytable.ScatterComboGroup.Combos.Clear();
        paytable.ScatterComboGroup.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 3, 100, "Free Spins"));

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, new List <int> {
            0, 0, 0
        });
        SlotResult results = scatterEvaluator.Evaluate(paytable, reelWindow, rng);

        var     component = results.GetComponent <ScattersComponent>();
        Payline payline   = component.PayResults[0].Payline;

        Assert.AreEqual(0, payline.PaylineCoords[0].ReelIndex);
        Assert.AreEqual(0, payline.PaylineCoords[0].Offset);
        Assert.AreEqual(1, payline.PaylineCoords[1].ReelIndex);
        Assert.AreEqual(0, payline.PaylineCoords[1].Offset);
        Assert.AreEqual(2, payline.PaylineCoords[2].ReelIndex);
        Assert.AreEqual(0, payline.PaylineCoords[2].Offset);
    }
Ejemplo n.º 20
0
        public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng)
        {
            if (paytable.PickTableGroup.PickTable.ContainsKey(PickFeatureId) == false)
            {
                // Can't evaluate if it doesn't exist in paytable.
                return(null);
            }

            PickTable pickTable = paytable.PickTableGroup.PickTable [PickFeatureId];

            // Make a copy of the list since we will be removing elements from it.
            List <PickItem> pickItems = new List <PickItem> (pickTable.PickItemList);

            PickItem      item;
            PickComponent component = new PickComponent();

            do
            {
                // Continue picking items until a trigger is found.
                int randomNumber = rng.GetRandomNumber(pickItems.Count);
                item = pickItems [randomNumber];
                pickItems.RemoveAt(randomNumber);

                component.PickResults.Add(new PickResult {
                    Name    = item.Name,
                    Value   = item.Value,
                    Trigger = item.Trigger.Name
                });
            } while (string.IsNullOrEmpty(item.Trigger.Name));

            // Add the pick component to the slot result.
            SlotResult slotResult = new SlotResult();

            if (component.PickResults.Count > 0)
            {
                slotResult.AddComponent <PickComponent>(component);
            }

            return(slotResult);
        }
Ejemplo n.º 21
0
    /// <summary>
    /// The theme specific game evaluation logic.
    /// </summary>
    public SlotResults RunOneGame(int bet)
    {
        // Create the slot results.
        SlotResults slotResults = new SlotResults();

        // Create the evaluators for the base game.
        PaylineEvaluator bgPaylineEval = new PaylineEvaluator();
        ScatterEvaluator bgScatterEval = new ScatterEvaluator();

        // Create the evaluators for the free games.
        PaylineEvaluator fgPaylineEval = new PaylineEvaluator();
        ScatterEvaluator fgScatterEval = new ScatterEvaluator();

        // Generate the random numbers.
        List <int> randomNumbers = new List <int>();

        for (int reel = 0; reel < paytable.BaseGameReelGroup.Reels.Count; ++reel)
        {
            ReelStrip reelStrip = paytable.BaseGameReelGroup.Reels[reel].ReelStrip;
            randomNumbers.Add(rng.GetRandomNumber(reelStrip.Symbols.Count));
        }

        ReelWindow reelWindow = new ReelWindow(paytable.BaseGameReelGroup, randomNumbers);

        // Evaluate the base game (payline and scatter evaluation).
        SlotResult paylineResults = bgPaylineEval.Evaluate(paytable, reelWindow, rng);
        SlotResult scatterResults = bgScatterEval.Evaluate(paytable, reelWindow, rng);

        slotResults.Results.Add(paylineResults);
        slotResults.Results.Add(scatterResults);

        slotResults.TotalWin += paylineResults.TotalWin;
        slotResults.TotalWin += scatterResults.TotalWin;

        // Evaluate the free games (if any).
        if (scatterResults.GetComponent <ScattersComponent>() != null)
        {
            // Add total number of free games.
            int freeGamesAwarded = 5;

            for (int i = 0; i < freeGamesAwarded; ++i)
            {
                // Generate the random numbers.
                randomNumbers = new List <int>();
                for (int reel = 0; reel < paytable.FreeGamesReelGroup.Reels.Count; ++reel)
                {
                    ReelStrip reelStrip = paytable.FreeGamesReelGroup.Reels[reel].ReelStrip;
                    randomNumbers.Add(rng.GetRandomNumber(reelStrip.Symbols.Count));
                }

                reelWindow = new ReelWindow(paytable.FreeGamesReelGroup, randomNumbers);

                // Evaluate the free game (payline and scatter evaluation).
                SlotResult fgPaylineResults = fgPaylineEval.Evaluate(paytable, reelWindow, rng);
                SlotResult fgScatterResults = fgScatterEval.Evaluate(paytable, reelWindow, rng);
                slotResults.Results.Add(fgPaylineResults);
                slotResults.Results.Add(fgScatterResults);

                slotResults.TotalWin += paylineResults.TotalWin;
                slotResults.TotalWin += scatterResults.TotalWin;
            }
        }

        return(slotResults);
    }