Ejemplo n.º 1
0
        /**
         * @method Determine if we will have a lottery given a specific outcome.
         * @param outcome - The outcome that we wish to test
         * @returns An object that will tell us whether we will have a lottery, won't have one, or will have one given limited population growth
         */
        public LotteryStatus GetLotteryStatus(Outcome outcome)
        {
            LotteryStatus status = new LotteryStatus();

            // Will we have a lottery?
            if (outcome.TotalAdultTicketsSold > _configuration.projector.lotteryTicketCount)
            {
                status.StatusCode = LotteryStatusCode.WillHaveLottery;
                return(status);
            }

            // We won't have an automatic lottery.  Will we potentially have a lottery?
            float neededPopulationIncreaseForLottery = (float)(_configuration.projector.lotteryTicketCount - outcome.TotalAdultTicketsSold) / (float)(outcome.TotalAdultTicketsSold);

            neededPopulationIncreaseForLottery *= 100f;

            // Is the needed growth outside of our maximum threshold?
            if (neededPopulationIncreaseForLottery > _configuration.projector.maximumExpectedPopulationGrowthPercentage)
            {
                // No lottery.
                status.StatusCode = LotteryStatusCode.NoLottery;
            }
            else
            {
                // Otherwise, we will have a lottery given a particular population growth.
                status.StatusCode = LotteryStatusCode.WillHaveLotteryWithPopulationIncrease;
                status.PopulationUnitIncreaseForLottery = neededPopulationIncreaseForLottery / 100f;
            }

            return(status);
        }
Ejemplo n.º 2
0
        /**
         * @method Obtain a string that describes the lottery status for a particular outcome.
         * @param outcome - The outcome to obtain this description from.
         * @returns A string that describes whether this particular outcome will involve having a ticket lottery.
         */
        public string GetLotteryStatusSummary(Outcome outcome)
        {
            string result = "";

            // Figure out what the status of our lottery is.
            LotteryStatus status = GetLotteryStatus(outcome);

            // Write the string that indicates the result of this operation.
            switch (status.StatusCode)
            {
            case LotteryStatusCode.NoLottery:
                result = "No lottery";
                break;

            case LotteryStatusCode.WillHaveLottery:
                result = "LOTTERY WILL OCCUR";
                break;

            case LotteryStatusCode.WillHaveLotteryWithPopulationIncrease:
                result = "Lottery WILL occur if the population increases by " + (status.PopulationUnitIncreaseForLottery * 100f).ToString("n2") + "%";
                break;

            default:
                Console.WriteLine("Unsupported lottery status code: " + status.StatusCode.ToString());
                break;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public void RollTheDice()
        {
            Result = new int[NumberSize];

            /*var luckManipulation = _collector.OrderBy(x => x.Value).Select(x => x.Key).ToArray();
             * for (int i = 0; i < NumberSize; i++)
             * {
             *  int num;
             *  do
             *  {
             *      num = luckManipulation[Rand.Next(0, PoolSize / 2)];
             *  } while (Result.Contains(num));
             *
             *  Result[i] = num;
             * }*/
            Result = CasinoTestInstance.RandomSequence();
            Status = LotteryStatus.Over;
        }
Ejemplo n.º 4
0
        protected LotteryStatus GetCurrentLotteryStatus()
        {
            LotteryStatus status = new LotteryStatus();

            // Check if there is a performance today

            DataSet result = WebClient.RawClient.ExecuteLocalProcedure(
                        SessionKey: Session[WebClient.TessSessionKeySessionKey].ToString(),
                        LocalProcedureId: 8011, // GetNextPerf
                        LocalProcedureValues: "@skipTodaysPerf=0");
            if (result.Tables[0].Rows.Count > 0)
            {
                DateTime nextPerfDateTime = Convert.ToDateTime(result.Tables[0].Rows[0][1]);
                DateTime compareDate = debugDate;
                if (compareDate == DateTime.Parse("1/1/1900"))//If the debug date was not defined.
                    compareDate = DateTime.Now.Date;
                if (nextPerfDateTime.Date == compareDate.Date)
                {
                    DateTime nextOpenTime = GetNextMatchingDateTime(openHour, openMin);
                    DateTime nextCloseTime = GetNextMatchingDateTime(closeHour, closeMin);
                    DateTime pickupDueTime = GetNextMatchingDateTime(pickupDueHour, pickupDueMin);
                    if (nextOpenTime < nextCloseTime && nextOpenTime < pickupDueTime)
                    {

                        if (nextOpenTime.Date == DateTime.Now.Date)
                            status = LotteryStatus.NotYetOpened;
                        else
                            status = LotteryStatus.PickupPassed;
                    }
                    else if (nextCloseTime < pickupDueTime)
                        status = LotteryStatus.Opened;
                    else
                        status = LotteryStatus.Closed;
                }
                else
                {
                    status = LotteryStatus.NoShow;
                }
            }
            else
                status = LotteryStatus.YearEnd;

            return status;
        }