コード例 #1
0
 private static void NumberNotHappenedDecrement(RouletteSessionView rouletteSession)
 {
     foreach (Number number in rouletteSession.AllRouletteNumbers)
     {
         number.NotHappened--;
     }
 }
コード例 #2
0
        public static Round EnterNumber(int digit, Round round, RouletteSessionView rouletteSession)
        {
            round.WinningNumber = digit;
            round.CalibrateBetUnit(round.Spin, rouletteSession, digit);
            round.CalibrateMoney(digit, rouletteSession);
            round.ExpectedNumbers = NumberLogic.GetExpectedNumbers(rouletteSession, round);

            return(round);
        }
コード例 #3
0
        private static float CalculateGlobalAverageGap(RouletteSessionView rouletteSession)
        {
            List <float> allNumberGaps = new List <float>();

            foreach (var number in rouletteSession.AllRouletteNumbers)
            {
                allNumberGaps.Add(number.AverageGap);
            }

            return(allNumberGaps.Average());
        }
コード例 #4
0
 public static void CheckIfUserHasWon(Round round, RouletteSessionView rouletteSession)
 {
     if (round.Spin > rouletteSession.SessionStart)
     {
         if (round.Money >= rouletteSession.Goal)
         {
             YouWonView youWon = new YouWonView(rouletteSession.UserName);
             rouletteSession.UserWonView.Content = youWon;
         }
     }
 }
コード例 #5
0
        public static void ResetProgress(RouletteSessionView rouletteSession)
        {
            rouletteSession.AllRounds.Clear();

            foreach (Number number in rouletteSession.AllRouletteNumbers)
            {
                number.Happened    = 0;
                number.NotHappened = 0;
                number.AverageGap  = 0;
                number.NotHappenedList.Clear();
            }
        }
コード例 #6
0
        private static int CalculateHappenedAverage(RouletteSessionView rouletteSession)
        {
            int        happenedAVG;
            List <int> happenedList = new List <int>();

            foreach (var number in rouletteSession.AllRouletteNumbers)
            {
                happenedList.Add(number.Happened);
            }

            happenedAVG = Convert.ToInt32(Math.Round(happenedList.Average(), MidpointRounding.AwayFromZero));

            return(happenedAVG);
        }
コード例 #7
0
        public static List <int> GetExpectedNumbers(RouletteSessionView rouletteSession, Round round)
        {
            int notHappenedDistance = 7;    // CHANGEABLE PARAMETER. Represents how far is Number's NotHappened value from the Number's AverageGap value.

            List <int> expectedNumbers  = new List <int>();
            float      globalAverageGap = CalculateGlobalAverageGap(rouletteSession);

            foreach (var number in rouletteSession.AllRouletteNumbers)
            {
                if (number.NotHappened >= (globalAverageGap - notHappenedDistance) && number.NotHappened <= (globalAverageGap + notHappenedDistance))
                {
                    if (!expectedNumbers.Contains(number.Digit))
                    {
                        expectedNumbers.Add(number.Digit);
                    }
                }
            }

            return(expectedNumbers);
        }
コード例 #8
0
        public static void UpdateNumberProperties(int digit, RouletteSessionView rouletteSession)
        {
            Number number = rouletteSession.AllRouletteNumbers[digit];

            if (number.NotHappened > 0)
            {
                if (number.NotHappenedList != null)
                {
                    number.NotHappenedList.Add(number.NotHappened);
                    number.AverageGap = (float)number.NotHappenedList.Average();
                }
                else
                {
                    number.AverageGap = number.NotHappened;
                }
            }

            NumberNotHappenedIncrement(rouletteSession);
            number.NotHappened = 0;
            number.Happened++;
        }
コード例 #9
0
        public static Round CalibrateMoney(this Round round, int digit, RouletteSessionView rouletteSession)
        {
            if (round.Spin > rouletteSession.SessionStart)
            {
                if (rouletteSession.AllRounds.Last().Money > 0)
                {
                    round.Money = rouletteSession.AllRounds.Last().Money;
                }
                else
                {
                    round.Money = rouletteSession.StartingMoney;
                }

                if (rouletteSession.AllRounds.Last().ExpectedNumbers.Contains(digit))
                {
                    round.Money += (36 * rouletteSession.AllRounds.Last().BetUnit);
                }

                round.Money -= (rouletteSession.AllRounds.Last().ExpectedNumbers.Count *rouletteSession.AllRounds.Last().BetUnit);
            }

            return(round);
        }
コード例 #10
0
        public static void UndoNumberProperties(int?latestNumber, RouletteSessionView rouletteSession)
        {
            foreach (Number number in rouletteSession.AllRouletteNumbers)
            {
                if (number.Digit == latestNumber)
                {
                    NumberNotHappenedDecrement(rouletteSession);

                    if (number.NotHappenedList.Count > 0)
                    {
                        number.NotHappened = number.NotHappenedList.Last();
                        number.NotHappenedList.RemoveAt(number.NotHappenedList.Count - 1);

                        if (number.NotHappenedList.Count > 0)
                        {
                            number.AverageGap = (float)number.NotHappenedList.Average();
                        }
                        else
                        {
                            number.AverageGap = 0;
                        }
                    }
                    else
                    {
                        number.NotHappened = 0;
                    }



                    if (number.Happened > 0)
                    {
                        number.Happened--;
                    }
                }
            }
        }
コード例 #11
0
        public static Round CalibrateBetUnit(this Round round, int spin, RouletteSessionView rouletteSession, int winningNumber)
        {
            if (round.Spin <= rouletteSession.SessionStart)
            {
                round.Money   = rouletteSession.StartingMoney;
                round.BetUnit = rouletteSession.StartingBetUnit;
            }

            if (round.Spin >= rouletteSession.SessionStart)
            {
                if (rouletteSession.AllRounds.Last().Money > 0)
                {
                    round.Money = rouletteSession.AllRounds.Last().Money;
                }
                else
                {
                    round.Money = rouletteSession.StartingMoney;
                }



                if (rouletteSession.AllRounds.Last().BetUnit > 0)
                {
                    round.BetUnit = rouletteSession.AllRounds.Last().BetUnit;
                }
                else
                {
                    round.BetUnit = rouletteSession.StartingBetUnit;
                }


                CalibrateMoney(round, winningNumber, rouletteSession);
                float playingCost = NumberLogic.GetExpectedNumbers(rouletteSession, round).Count *round.BetUnit;



                if (round.Money - playingCost >= rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 50))
                {
                    round.BetUnit = rouletteSession.StartingBetUnit;
                }

                if (round.Money - playingCost <= rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 50))
                {
                    round.BetUnit = rouletteSession.StartingBetUnit * 2;
                }

                if (round.Money - playingCost <= rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 150) && round.Money > rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 350))
                {
                    round.BetUnit = rouletteSession.StartingBetUnit * 4;
                }

                if (round.Money - playingCost <= rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 350) && round.Money > rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 750))
                {
                    round.BetUnit = rouletteSession.StartingBetUnit * 8;
                }

                if (round.Money - playingCost <= rouletteSession.StartingMoney - (rouletteSession.StartingBetUnit * 750))
                {
                    round.BetUnit = rouletteSession.StartingBetUnit * 16;
                }
            }

            return(round);
        }