Example #1
0
        public static Asda2BattleGroundTimeEntry GetNextStartTime(Asda2BattlegroundTown town)
        {
            var now = DateTime.Now;

            var entry = TimeEntries.FirstOrDefault(x => x.Time > now && x.Town == town);

            return(entry);
        }
 public BattlegroundResultRecord(Asda2BattlegroundTown town, string mvpCharacterName, uint mvpCharacterGuid,
                                 int lightScores, int darkScores)
 {
     this.Town             = town;
     this.MvpCharacterName = mvpCharacterName;
     this.MvpCharacterGuid = mvpCharacterGuid;
     this.LightScores      = lightScores;
     this.DarkScores       = darkScores;
     this.Guid             = BattlegroundResultRecord._idGenerator.Next();
 }
Example #3
0
 public BattlegroundResultRecord(Asda2BattlegroundTown town, string mvpCharacterName, uint mvpCharacterGuid,
                                 int lightScores, int darkScores)
 {
     Town             = town;
     MvpCharacterName = mvpCharacterName;
     MvpCharacterGuid = mvpCharacterGuid;
     LightScores      = lightScores;
     DarkScores       = darkScores;
     Guid             = _idGenerator.Next();
 }
 public static void SendWiningFactionInfoResponse(Asda2BattlegroundTown townId, int factionId, string mvpName)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.WiningFactionInfo))
     {
         packet.WriteInt32((int)townId);
         packet.WriteInt32(factionId);
         packet.WriteFixedAsciiString(mvpName, 20, Locale.Start);
         WCell.RealmServer.Global.World.Broadcast(packet, true, Locale.Any);
     }
 }
Example #5
0
 public static void SendWiningFactionInfoResponse(Asda2BattlegroundTown townId,
                                                  int factionId, string mvpName)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.WiningFactionInfo)) //6257
     {
         packet.WriteInt32((int)townId);                                          //{townId}default value : 0 Len : 4
         packet.WriteInt32(factionId);                                            //{factionId}default value : 0 Len : 4
         packet.WriteFixedAsciiString(mvpName, 20);                               //{MVPName}default value :  Len : 20
         World.Broadcast(packet, true, Locale.Any);
     }
 }
        public static void AddBattleGround(Asda2BattlegroundTown town)
        {
            Asda2Battleground asda2Battleground = new Asda2Battleground()
            {
                Town = town
            };

            switch (town)
            {
            case Asda2BattlegroundTown.Alpia:
                asda2Battleground.MinEntryLevel = (byte)10;
                asda2Battleground.MaxEntryLevel = (byte)29;
                break;

            case Asda2BattlegroundTown.Silaris:
                asda2Battleground.MinEntryLevel = (byte)30;
                asda2Battleground.MaxEntryLevel = (byte)49;
                break;

            case Asda2BattlegroundTown.Flamio:
                asda2Battleground.MinEntryLevel = (byte)50;
                asda2Battleground.MaxEntryLevel = (byte)69;
                break;

            case Asda2BattlegroundTown.Aquaton:
                asda2Battleground.MinEntryLevel = (byte)70;
                asda2Battleground.MaxEntryLevel = (byte)90;
                break;
            }

            Asda2BattlegroundType type;

            asda2Battleground.StartTime = Asda2BattlegroundMgr.GetNextWarTime(town, out type, DateTime.Now);
            asda2Battleground.WarType   = type;
            asda2Battleground.EndTime   = asda2Battleground.StartTime.AddMinutes(type == Asda2BattlegroundType.Occupation
        ? (double)Asda2BattlegroundMgr.OccupationDurationMins
        : (double)Asda2BattlegroundMgr.DeathMatchDurationMins);
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)0,
                X            = (short)258,
                Y            = (short)165,
                BattleGround = asda2Battleground
            });
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)1,
                X            = (short)211,
                Y            = (short)218,
                BattleGround = asda2Battleground
            });
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)2,
                X            = (short)308,
                Y            = (short)221,
                BattleGround = asda2Battleground
            });
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)3,
                X            = (short)260,
                Y            = (short)250,
                BattleGround = asda2Battleground
            });
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)4,
                X            = (short)209,
                Y            = (short)284,
                BattleGround = asda2Battleground
            });
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)5,
                X            = (short)307,
                Y            = (short)285,
                BattleGround = asda2Battleground
            });
            asda2Battleground.Points.Add(new Asda2WarPoint()
            {
                Id           = (short)6,
                X            = (short)258,
                Y            = (short)340,
                BattleGround = asda2Battleground
            });
            foreach (Asda2WarPoint point in asda2Battleground.Points)
            {
                point.OwnedFaction = (short)-1;
                World.TaskQueue.RegisterUpdatableLater((IUpdatable)point);
            }

            Asda2BattlegroundMgr.AllBattleGrounds[town].Add(asda2Battleground);
            World.TaskQueue.RegisterUpdatableLater((IUpdatable)asda2Battleground);
        }
        public static DateTime GetNextWarTime(Asda2BattlegroundTown town, out Asda2BattlegroundType type, DateTime now)
        {
            type = Asda2BattlegroundType.Deathmatch;
            switch (now.DayOfWeek)
            {
            case DayOfWeek.Sunday:
                DateTime dateTime1 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.WeekendDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime1)
                {
                    return(dateTime1);
                }
                DateTime dateTime2 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime2)
                {
                    return(dateTime2);
                }
                DateTime dateTime3 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.WeekendOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime3)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(dateTime3);
                }

                DateTime now1 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now1)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now1);
                }

                now1 = now1.AddDays(1.0).Subtract(new TimeSpan(now1.Hour, now1.Minute, now1.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now1));

            case DayOfWeek.Monday:
                DateTime dateTime4 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime4)
                {
                    return(dateTime4);
                }
                DateTime now2 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now2)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now2);
                }

                now2 = now2.AddDays(1.0).Subtract(new TimeSpan(now2.Hour, now2.Minute, now2.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now2));

            case DayOfWeek.Tuesday:
                DateTime dateTime5 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime5)
                {
                    return(dateTime5);
                }
                DateTime now3 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now3)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now3);
                }

                now3 = now3.AddDays(1.0).Subtract(new TimeSpan(now3.Hour, now3.Minute, now3.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now3));

            case DayOfWeek.Wednesday:
                DateTime dateTime6 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime6)
                {
                    return(dateTime6);
                }
                DateTime now4 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now4)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now4);
                }

                now4 = now4.AddDays(1.0).Subtract(new TimeSpan(now4.Hour, now4.Minute, now4.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now4));

            case DayOfWeek.Thursday:
                DateTime dateTime7 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime7)
                {
                    return(dateTime7);
                }
                DateTime now5 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now5)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now5);
                }

                now5 = now5.AddDays(1.0).Subtract(new TimeSpan(now5.Hour, now5.Minute, now5.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now5));

            case DayOfWeek.Friday:
                DateTime dateTime8 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime8)
                {
                    return(dateTime8);
                }
                DateTime now6 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now6)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now6);
                }

                now6 = now6.AddDays(1.0).Subtract(new TimeSpan(now6.Hour, now6.Minute, now6.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now6));

            case DayOfWeek.Saturday:
                DateTime dateTime9 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayDeathMatchHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < dateTime9)
                {
                    return(dateTime9);
                }
                DateTime now7 =
                    new DateTime(now.Year, now.Month, now.Day, (int)Asda2BattlegroundMgr.EveryDayOcupationHour, 0,
                                 0).AddMinutes(
                        (double)((int)(byte)town * (int)Asda2BattlegroundMgr.BeetweenWarsMinutes));
                if (now < now7)
                {
                    type = Asda2BattlegroundType.Occupation;
                    return(now7);
                }

                now7 = now7.AddDays(1.0).Subtract(new TimeSpan(now7.Hour, now7.Minute, now7.Millisecond))
                       .AddMinutes(1.0);
                return(Asda2BattlegroundMgr.GetNextWarTime(town, out type, now7));

            default:
                return(DateTime.MaxValue);
            }
        }
Example #8
0
        public static void AddBattleGround(Asda2BattlegroundTown town)
        {
            var newBtgrnd = new Asda2Battleground {
                Town = town
            };

            switch (town)
            {
            case Asda2BattlegroundTown.Alpia:
                newBtgrnd.MinEntryLevel = 10;
                newBtgrnd.MaxEntryLevel = 29;
                break;

            case Asda2BattlegroundTown.Silaris:
                newBtgrnd.MinEntryLevel = 30;
                newBtgrnd.MaxEntryLevel = 49;
                break;

            case Asda2BattlegroundTown.Flamio:
                newBtgrnd.MinEntryLevel = 10;
                newBtgrnd.MaxEntryLevel = 250;
                break;

            case Asda2BattlegroundTown.Aquaton:
                newBtgrnd.MinEntryLevel = 10;
                newBtgrnd.MaxEntryLevel = 250;
                break;
            }
            var nextStartTimeEntry = GetNextStartTime(town);

            if (nextStartTimeEntry == null)
            {
                World.BroadcastMsg("WarManager", "War system broken, restart server!", Color.Red);
                return;
            }

            newBtgrnd.StartTime = nextStartTimeEntry.Time;
            newBtgrnd.WarType   = nextStartTimeEntry.Type;
            newBtgrnd.EndTime   = newBtgrnd.StartTime.AddMinutes(WarLengthMinutes);

            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 0, X = 258, Y = 165, BattleGround = newBtgrnd
            });
            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 1, X = 211, Y = 218, BattleGround = newBtgrnd
            });
            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 2, X = 308, Y = 221, BattleGround = newBtgrnd
            });
            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 3, X = 260, Y = 250, BattleGround = newBtgrnd
            });
            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 4, X = 209, Y = 284, BattleGround = newBtgrnd
            });
            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 5, X = 307, Y = 285, BattleGround = newBtgrnd
            });
            newBtgrnd.Points.Add(new Asda2WarPoint()
            {
                Id = 6, X = 258, Y = 340, BattleGround = newBtgrnd
            });

            foreach (var asda2WarPoint in newBtgrnd.Points)
            {
                asda2WarPoint.OwnedFaction = -1;
                World.TaskQueue.RegisterUpdatableLater(asda2WarPoint);
            }
            AllBattleGrounds[town].Add(newBtgrnd);
            World.TaskQueue.RegisterUpdatableLater(newBtgrnd);
        }