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); }
public void Init() { symbolsInPayline = new List <Symbol> { new Symbol(0, "AA"), new Symbol(0, "AA"), new Symbol(0, "AA"), }; combo = new PayCombo(symbolsInPayline, 1000); }
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); }