Ejemplo n.º 1
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.º 2
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.º 3
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);
        }