Exemplo n.º 1
0
        public PowerBallGame(PowerBall item)
        {
            m_PowerBall = item;

            m_NoWins = 0;
            m_Profit = 0;
        }
Exemplo n.º 2
0
        public PowerBallGame(PowerBall item, int noWins, int profit)
        {
            m_PowerBall = item;

            m_NoWins = noWins;
            m_Profit = profit;
        }
Exemplo n.º 3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_PowerBall = reader.ReadItem() as PowerBall;

            if (m_PowerBall != null)
            {
                m_PowerBall.AddToSatList(this);
            }
        }
Exemplo n.º 4
0
        public PowerBallSatellite() : base(0xED4)
        {
            Hue = 592;

            Name    = "Let's Play Powerball!";
            Movable = false;

            if (PowerBall.PowerBallInstance != null)
            {
                m_PowerBall = PowerBall.PowerBallInstance;
                m_PowerBall.AddToSatList(this);
            }
            else
            {
                Delete();
            }
        }
Exemplo n.º 5
0
        public PowerBall()
            : base(0xED4)
        {
            if (PowerBallInstance != null)
            {
                Console.WriteLine("You can only have one shard PowerBall Item.");
                Delete();
                return;
            }

            Hue        = 592;
            Name       = "Let's Play Powerball!";
            m_Game     = this;
            m_Instance = new PowerBallGame(this);
            m_Timer    = new PowerBallTimer(this);
            m_Timer.Start();
            m_Active       = true;
            Movable        = false;
            m_HasProcessed = false;

            /*Modify below for custom values.  See readme file for info*/

            m_TicketCost        = 100;
            m_TicketEntryPrice  = 1000;
            m_PowerBallPrice    = 500;
            m_MaxWhiteBalls     = 20;
            m_MaxRedBalls       = 8;
            m_GuaranteedJackpot = true;
            m_Announcement      = true;
            m_GameNumber        = 1;

            m_GameDelay = TimeSpan.FromHours(24);
            m_DeadLine  = TimeSpan.FromMinutes(30);

            m_TimeOfDay = 18;
            m_NextGame  = GetNextGameTime();

            PowerBallInstance = this;
        }
Exemplo n.º 6
0
 public PowerBallTimer(PowerBall pb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(5))
 {
     m_PowerBall = pb;
     Priority    = TimerPriority.FiveSeconds;
 }
Exemplo n.º 7
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            m_Game = this;

            int version = reader.ReadInt();

            m_TimeOfDay         = reader.ReadInt();
            m_TicketCost        = reader.ReadInt();
            m_TicketEntryPrice  = reader.ReadInt();
            m_PowerBallPrice    = reader.ReadInt();
            m_MaxWhiteBalls     = reader.ReadInt();
            m_MaxRedBalls       = reader.ReadInt();
            m_GuaranteedJackpot = reader.ReadBool();
            m_GoldSink          = reader.ReadInt();
            m_NextGame          = reader.ReadDateTime();
            m_Active            = reader.ReadBool();
            m_GameNumber        = reader.ReadInt();
            m_GameDelay         = reader.ReadTimeSpan();
            m_DeadLine          = reader.ReadTimeSpan();
            m_Announcement      = reader.ReadBool();

            if (version == 0)
            {
                m_HasProcessed = reader.ReadBool();
            }
            else
            {
                m_HasProcessed = false;
            }

            if (m_Active)
            {
                m_Timer = new PowerBallTimer(this);
                m_Timer.Start();
            }

            if (m_Instance == null)
            {
                m_Instance = new PowerBallGame(this);
            }

            m_Instance.Profit = reader.ReadInt();
            m_Instance.NoWins = reader.ReadInt();

            int jackpotCount = reader.ReadInt();

            for (int i = 0; i < jackpotCount; i++)
            {
                new PowerBallStats(reader);
            }
            int picksCount = reader.ReadInt();

            for (int i = 0; i < picksCount; i++)
            {
                new PowerBallStats(reader);
            }

            PowerBallInstance = this;
        }
Exemplo n.º 8
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.º 9
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;
                }
            }
        }