Exemplo n.º 1
0
            protected override void OnTick()
            {
                if (m_Game == null || m_Game.PowerBall == null || m_Game.Picks == null || m_Game.Picks.Count < 6)
                {
                    Stop();
                    return;
                }

                if (m_Start > DateTime.Now)
                {
                    return;
                }

                if (m_Ticks <= 5)
                {
                    string text;
                    int    num = 0;
                    try
                    {
                        num = m_Game.Picks[m_Ticks];
                    }
                    catch
                    {
                        this.Stop();
                        Console.WriteLine("Error with PowerBallGame Timer");
                        return;
                    }

                    if (m_Ticks == 0)
                    {
                        text = "The first pick is... ";
                    }
                    else if (m_Ticks < 5)
                    {
                        text = "The next pick is... ";
                    }
                    else
                    {
                        text = "And the powerball is... ";
                    }

                    if (m_Game != null && m_Game.PowerBall != null)
                    {
                        m_Game.PowerBall.PublicOverheadMessage(0, m_Ticks < 5 ? 2041 : 0x21, false, text);
                        Timer.DelayCall(TimeSpan.FromSeconds(2), new TimerStateCallback(DoDelayMessage), new object[] { m_Game.PowerBall, num, m_Ticks });
                    }

                    foreach (PowerBallSatellite sat in PowerBall.SatList)
                    {
                        sat.PublicOverheadMessage(0, m_Ticks < 5 ? 2041 : 0x21, false, text);
                        Timer.DelayCall(TimeSpan.FromSeconds(2), new TimerStateCallback(DoDelayMessage), new object[] { sat, num, m_Ticks });
                    }

                    m_Ticks++;
                    m_Start = DateTime.Now + TimeSpan.FromSeconds(8 + Utility.Random(10));
                }
                else  //Time to tally picks and start up a new game!
                {
                    m_Game.CheckForWinners();
                    PowerBall.AddToArchive(m_Game.Picks, m_Game.Payout);  //Adds pickslist to Archive for stats gump

                    if (!m_Game.HasJackpot)                               //Still no jackpot eh?
                    {
                        m_Game.NoWins++;
                        Timer.DelayCall(TimeSpan.FromSeconds(2), new TimerStateCallback(DoMessage), m_Game);
                    }
                    else
                    {
                        if (PowerBall.Announcement)
                        {
                            Timer.DelayCall(TimeSpan.FromSeconds(2), new TimerStateCallback(DoJackpotMessage), m_Game.JackpotWinners);
                        }

                        PowerBall.GoldSink += PowerBall.Instance.Profit;
                    }

                    Timer.DelayCall(TimeSpan.FromSeconds(10), new TimerStateCallback(DoWinnersMessage), m_Game);
                    m_Game.PowerBall.NewGame(m_Game.HasJackpot);

                    Stop();
                }
            }
Exemplo n.º 2
0
        private void DistributeAwards(List <TicketEntry> jackpot, Dictionary <TicketEntry, int> prize)
        {
            int pot = m_Profit;

            if (jackpot != null && jackpot.Count > 0)
            {
                foreach (TicketEntry entry in jackpot)
                {
                    if (entry.Ticket != null && entry.Ticket.Owner != null)
                    {
                        int amount = JackPot / jackpot.Count;

                        m_Jackpot            = true;
                        entry.Ticket.Payout += amount;
                        m_Payout            += amount;
                        m_Profit            -= amount;
                        PowerBall.AddToArchive(entry.Ticket.Owner, amount);
                        m_JackpotWinners++;
                        m_PowerBall.InvalidateProperties();

                        if (RewardChance > Utility.RandomDouble())
                        {
                            GiveReward(entry.Ticket.Owner);
                        }
                    }
                }
            }

            if (prize != null && prize.Count > 0)
            {
                int award  = 0;
                int match3 = 0;
                int match4 = 0;
                int match5 = 0;


                foreach (KeyValuePair <TicketEntry, int> kvp in prize)
                {
                    if (kvp.Value == 3)
                    {
                        match3++;
                    }
                    else if (kvp.Value == 4)
                    {
                        match4++;
                    }
                    else
                    {
                        match5++;
                    }
                }

                foreach (KeyValuePair <TicketEntry, int> kvp in prize)
                {
                    TicketEntry entry   = kvp.Key;
                    int         matches = kvp.Value;

                    if (matches == 3)
                    {
                        award = (pot / 50) / match3; //2% of Pot
                    }
                    else if (matches == 4)
                    {
                        award = (pot / 20) / match4; //5% of Pot
                    }
                    else
                    {
                        award = (pot / 10) / match5; //10% of Pot
                    }
                    entry.Ticket.Payout += award;
                    m_Payout            += award;
                    m_Profit            -= award;
                }
            }
        }