Example #1
0
            public static void DoMessage(object state)
            {
                if (state is PowerBallGame)
                {
                    PowerBallGame powerball = (PowerBallGame)state;
                    List <Mobile> mobList   = new List <Mobile>();

                    if (powerball == null)
                    {
                        return;
                    }

                    foreach (PowerBallTicket ticket in powerball.Tickets)
                    {
                        if (ticket.Owner != null && !mobList.Contains(ticket.Owner))
                        {
                            mobList.Add(ticket.Owner);
                        }
                    }

                    if (mobList.Count > 0)
                    {
                        for (int i = 0; i < mobList.Count; ++i)
                        {
                            mobList[i].SendMessage("New Powerball numbers have been chosen so check your tickets!");
                        }
                    }
                }
            }
Example #2
0
 public InternalTimer(PowerBallGame game) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0))
 {
     m_Game  = game;
     m_Ticks = 0;
     m_Start = DateTime.Now;
     Start();
 }
Example #3
0
            public static void DoWinnersMessage(object state)
            {
                if (state is PowerBallGame)
                {
                    PowerBallGame powerball = (PowerBallGame)state;
                    List <Mobile> winList   = new List <Mobile>();

                    if (powerball == null)
                    {
                        return;
                    }

                    foreach (PowerBallTicket ticket in powerball.Tickets)
                    {
                        if (ticket.Owner != null && ticket.Owner is PlayerMobile && ticket.Owner.NetState != null)
                        {
                            foreach (TicketEntry entry in ticket.Entries)
                            {
                                if (entry.Winner && !winList.Contains(ticket.Owner))
                                {
                                    winList.Add(ticket.Owner);
                                }
                            }
                        }
                    }

                    foreach (Mobile mob in winList)
                    {
                        int sound;
                        if (mob.Female)
                        {
                            sound = Utility.RandomList(0x30C, 0x30F, 0x313, 0x31A, 0x31D, 0x32B, 0x330, 0x337);
                            mob.PlaySound(sound);
                        }
                        else
                        {
                            sound = Utility.RandomList(0x41A, 0x41B, 0x41E, 0x422, 0x42A, 0x42D, 0x431, 0x429);
                            mob.PlaySound(sound);
                        }

                        mob.SendMessage("It looks like you have a winning ticket!");
                    }
                }
            }
Example #4
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)1); //Version

            writer.Write(m_TimeOfDay);
            writer.Write(m_TicketCost);
            writer.Write(m_TicketEntryPrice);
            writer.Write(m_PowerBallPrice);
            writer.Write(m_MaxWhiteBalls);
            writer.Write(m_MaxRedBalls);
            writer.Write(m_GuaranteedJackpot);
            writer.Write(m_GoldSink);
            writer.Write(m_NextGame);
            writer.Write(m_Active);
            writer.Write(m_GameNumber);
            writer.Write(m_GameDelay);
            writer.Write(m_DeadLine);
            writer.Write(m_Announcement);
            //writer.Write(m_HasProcessed);

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

            writer.Write(m_Instance.Profit);
            writer.Write(m_Instance.NoWins);

            writer.Write(PowerBallStats.JackpotStats.Count);
            for (int i = 0; i < PowerBallStats.JackpotStats.Count; ++i)
            {
                PowerBallStats.JackpotStats[i].Serialize(writer);
            }
            writer.Write(PowerBallStats.PicksStats.Count);
            for (int i = 0; i < PowerBallStats.PicksStats.Count; ++i)
            {
                PowerBallStats.PicksStats[i].Serialize(writer);
            }

            InvalidateProperties();
        }
Example #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;
        }
Example #6
0
        public void NewGame(bool hasjackpot)
        {
            if (hasjackpot || m_Instance == null)
            {
                m_Instance = new PowerBallGame(this);
            }
            else
            {
                int noWins = m_Instance.NoWins;
                int profit = m_Instance.Profit;

                m_Instance = new PowerBallGame(this, noWins, profit); //No jackpot? Sure! carry over how many non-wins and total profit
            }

            if (m_DoJackpot)
            {
                m_DoJackpot = false;
            }

            m_GameNumber++;
            m_NextGame     = GetNextGameTime();
            m_HasProcessed = false;
        }
Example #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;
        }