Пример #1
0
 public static void DoGiveUp(Client.GameState client)
 {
     client.InArenaMatch = false;
     client.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.WaitingInactive;
     client.Send(client.ArenaStatistic);
     RequestGroupList(client, 1);
     ArenaSignup sign = new ArenaSignup();
     sign.DialogID = ArenaSignup.MainIDs.OpponentGaveUp;
     if (PlayerList.ContainsKey(client.ArenaStatistic.PlayWith))
     {
         PlayerList[client.ArenaStatistic.PlayWith].Send(sign.BuildPacket());
         PlayerList[client.ArenaStatistic.PlayWith].ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
         client.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
         PlayerList[client.ArenaStatistic.PlayWith].Send(PlayerList[client.ArenaStatistic.PlayWith].ArenaStatistic);
         client.Send(client.ArenaStatistic);
         if (client.QualifierGroup != null)
         {
             if (client.QualifierGroup.Inside)
             {
                 client.QualifierGroup.End(client);
             }
             else
             {
                 if (client.ArenaStatistic.PlayWith != 0)
                     Win(PlayerList[client.ArenaStatistic.PlayWith], client);
             }
         }
         else
         {
             if (client.ArenaStatistic.PlayWith != 0)
                 Win(PlayerList[client.ArenaStatistic.PlayWith], client);
         }
     }
 }
Пример #2
0
                public void Import()
                {
                    Player1.InArenaMatch = Player2.InArenaMatch = true;
                    Inside = true;
                    Player1.QualifierGroup = this;
                    Player2.QualifierGroup = this;
                    if (!ServerBase.Kernel.Maps.ContainsKey(700))
                        new Map(700, Database.DMaps.MapPaths[700]);
                    Map origMap = ServerBase.Kernel.Maps[700];
                    dynamicMap = origMap.MakeDynamicMap();
                    Player1.Entity.Teleport(origMap.ID, dynamicMap.ID, (ushort)ServerBase.Kernel.Random.Next(35, 70), (ushort)ServerBase.Kernel.Random.Next(35, 70));
                    Player2.Entity.Teleport(origMap.ID, dynamicMap.ID, (ushort)ServerBase.Kernel.Random.Next(35, 70), (ushort)ServerBase.Kernel.Random.Next(35, 70));
                    if (Player1.Map.ID == Player2.Map.ID)
                    {
                        ArenaSignup sign = new ArenaSignup();
                        sign.DialogID = ArenaSignup.MainIDs.StartTheFight;
                        sign.Stats = Player1.ArenaStatistic;
                        Player2.Send(sign.BuildPacket());
                        sign.Stats = Player2.ArenaStatistic;
                        Player1.Send(sign.BuildPacket());
                        sign.DialogID = ArenaSignup.MainIDs.Match;
                        sign.OptionID = ArenaSignup.DialogButton.MatchOn;
                        Player1.Send(sign.BuildPacket());
                        Player2.Send(sign.BuildPacket());
                        Player1.Send(match.BuildPacket());
                        Player2.Send(match.BuildPacket());
                        Player1.Entity.Ressurect();
                        Player2.Entity.Ressurect();
                        Player1.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Ride);
                        Player2.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Ride);
                        P1Mode = Player1.Entity.PKMode;
                        Player1.Entity.PKMode = Conquer_Online_Server.Game.Enums.PKMode.PK;
                        Player1.Send(new Data(true) { UID = Player1.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)Player1.Entity.PKMode });
                        P2Mode = Player2.Entity.PKMode;
                        Player2.Entity.PKMode = Conquer_Online_Server.Game.Enums.PKMode.PK;
                        Player2.Send(new Data(true) { UID = Player2.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)Player2.Entity.PKMode });

                        Player1.ArenaStatistic.TodayBattles++;
                        Player2.ArenaStatistic.TodayBattles++;
                    }
                    else
                        End();
                }
Пример #3
0
                public void Export()
                {
                    Player1.InArenaMatch = Player2.InArenaMatch = false;
                    var arr = Watchers.ToArray();
                    foreach (Client.GameState client in arr)
                        QualifyEngine.DoLeave(client);
                    arr = null;
                    Win(Winner, Loser);

                    Inside = false;
                    Player1.Entity.Teleport(Player1.Entity.PreviousMapID, Player1.Entity.PrevX, Player1.Entity.PrevY);
                    Player2.Entity.Teleport(Player2.Entity.PreviousMapID, Player2.Entity.PrevX, Player2.Entity.PrevY);
                    Loser.Entity.Ressurect();
                    Winner.Entity.Ressurect();
                    Player1.ArenaStatistic.AcceptBox = Player2.ArenaStatistic.AcceptBox = false;
                    Player1.ArenaStatistic.AcceptBoxShow = Player2.ArenaStatistic.AcceptBoxShow = Player2.ArenaStatistic.AcceptBoxShow.AddHours(2);
                    Player1.ArenaStatistic.PlayWith = Player2.ArenaStatistic.PlayWith = 0;

                    ArenaSignup sign = new ArenaSignup();
                    sign.DialogID = ArenaSignup.MainIDs.Dialog2;
                    Loser.Send(sign.BuildPacket());
                    sign.OptionID = ArenaSignup.DialogButton.Win;
                    Winner.Send(sign.BuildPacket());
                    Groups.Remove(ID);

                    Player1.Entity.PKMode = P1Mode;
                    Player1.Send(new Data(true) { UID = Player1.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)Player1.Entity.PKMode });
                    Player2.Entity.PKMode = P2Mode;
                    Player2.Send(new Data(true) { UID = Player2.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)Player2.Entity.PKMode });

                    Player1.QualifierGroup = null;
                    Player2.QualifierGroup = null;
                    if (dynamicMap != null)
                        dynamicMap.Dispose();
                }
Пример #4
0
        public static void ArenaSystem_Execute()
        {
            #region in-game players

            var Players = new GameState[PlayerList.Count + 2];
            PlayerList.Values.CopyTo(Players, 0);
            if (Players.Length >= 2)
            {
                for (int count = 0; count < Players.Length; count++)
                {
                    Client.GameState Client = Players[count];
                    if (Client != null && Client.Entity != null && (!ServerBase.Constants.PKFreeMaps.Contains(Client.Map.ID) || Client.Map.ID == 1005))
                    {
                        if (Client.InArenaMatch)
                            continue;
                        #region Select players
                        if (Client.ArenaStatistic.Status == Network.GamePackets.ArenaStatistic.WaitingForOpponent)
                        {
                            for (int count2 = count + 1; count2 < Players.Length; count2++)
                            {
                                Client.GameState Client2 = Players[count2];
                                if (Client2 != null && Client2.Entity != null && (!ServerBase.Constants.PKFreeMaps.Contains(Client2.Map.ID) || Client2.Map.ID == 1005))
                                {
                                    if (Client2.InArenaMatch)
                                        continue;
                                    if (Client2.ArenaStatistic.Status == Network.GamePackets.ArenaStatistic.WaitingForOpponent)
                                    {
                                        byte type = 1;
                                        int diff = 0;
                                        if (Client2.ArenaStatistic.Rank == 0)
                                        {
                                            diff = (int)Client.ArenaStatistic.ArenaPoints - (int)Client2.ArenaStatistic.ArenaPoints;
                                            diff = diff < 0 ? -diff : diff;
                                        }
                                        else
                                        {
                                            if (Client.ArenaStatistic.Rank == 0)
                                            {
                                                diff = (int)Client.ArenaStatistic.ArenaPoints - (int)Client2.ArenaStatistic.ArenaPoints;
                                                diff = diff < 0 ? -diff : diff;
                                            }
                                            else
                                            {
                                                diff = (int)Client.ArenaStatistic.Rank - (int)Client2.ArenaStatistic.Rank;
                                                diff = diff < 0 ? -diff : diff;
                                                type = 2;
                                            }
                                        }
                                        if ((type == 1 && diff <= 100) || (type == 2 && diff <= 10))
                                        {
                                            Client.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.WaitingInactive;
                                            Client2.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.WaitingInactive;
                                            Client.Send(Client.ArenaStatistic);
                                            Client2.Send(Client2.ArenaStatistic);
                                            Client.ArenaStatistic.AcceptBoxShow = Client2.ArenaStatistic.AcceptBoxShow = Time32.Now;
                                            Client.ArenaStatistic.PlayWith = Client2.ArenaStatistic.EntityID;
                                            Client2.ArenaStatistic.PlayWith = Client.ArenaStatistic.EntityID;
                                            Client.InArenaMatch = true;
                                            Client2.InArenaMatch = true;
                                            ArenaSignup sign = new ArenaSignup();
                                            sign.DialogID = ArenaSignup.MainIDs.StartCountDown;
                                            sign.Stats = Client.ArenaStatistic;
                                            Client.Send(sign.BuildPacket());
                                            sign.Stats = Client2.ArenaStatistic;
                                            Client2.Send(sign.BuildPacket());
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                        #region Check for timer
                        else
                        {
                            if (Client != null && Client.ArenaStatistic != null && Time32.Now >= Client.ArenaStatistic.AcceptBoxShow.AddSeconds(60))
                            {
                                if (Client.ArenaStatistic.PlayWith != 0 && Client.QualifierGroup == null)
                                {
                                    Conquer_Online_Server.Client.GameState Client2 = PlayerList[Client.ArenaStatistic.PlayWith];
                                    if (Client2 != null && Client.ArenaStatistic != null)
                                    {
                                        if (Client2.ArenaStatistic.PlayWith != 0 && Client2.QualifierGroup == null)
                                        {
                                            if (Client.ArenaStatistic.AcceptBox && Client2.ArenaStatistic.AcceptBox)
                                            {
                                                Client.ArenaStatistic.AcceptBoxShow = Client2.ArenaStatistic.AcceptBoxShow = Time32.Now;
                                                Client.ArenaStatistic.PlayWith = Client2.ArenaStatistic.EntityID;
                                                Client2.ArenaStatistic.PlayWith = Client.ArenaStatistic.EntityID;
                                                QualifierList.QualifierGroup group = new QualifierList.QualifierGroup(Client, Client2);
                                                QualifierList.Groups.Add(group.ID, group);
                                                group.Import();
                                            }
                                            else
                                            {
                                                if (Client.QualifierGroup != null && Client2.QualifierGroup != null)
                                                    return;
                                                if (Client.ArenaStatistic.AcceptBox == true)
                                                {
                                                    Win(Client, Client2);
                                                }
                                                else
                                                {
                                                    if (Client2.ArenaStatistic.AcceptBox)
                                                    {
                                                        Win(Client2, Client);
                                                    }
                                                    else
                                                    {
                                                        if (Client.ArenaStatistic.ArenaPoints > Client2.ArenaStatistic.ArenaPoints)
                                                        {
                                                            Win(Client, Client2);
                                                        }
                                                        else
                                                        {
                                                            Win(Client2, Client);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Client.ArenaStatistic.PlayWith = 0;
                                        Client.ArenaStatistic.AcceptBox = false;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
            }

            if (QualifierList.Groups.Count > 0)
            {
                QualifierList.QualifierGroup[] GroupsList = QualifierList.Groups.Values.ToArray();
                for (int count = 0; count < QualifierList.Groups.Count; count++)
                {
                    QualifierList.QualifierGroup group = GroupsList[count];
                    if (Time32.Now > group.CreateTime.AddSeconds(5))
                    {
                        if (group.Inside)
                        {
                            if (!group.Done)
                            {
                                if (Time32.Now > group.CreateTime.AddMinutes(5) && !group.CanEnd)
                                {
                                    group.End();
                                }
                            }
                            else
                            {
                                if (Time32.Now > group.DoneStamp.AddSeconds(1))
                                {
                                    group.Export();
                                    group.Done = false;
                                }
                            }
                        }
                    }
                }
                GroupsList = null;
            }
            #endregion
            #region resseting
            DateTime Noww = DateTime.Now;
            TimeSpan Now = Noww.TimeOfDay;
            if (!DayPassed)
                if (Now.Hours == 23 && Now.Minutes == 59)
                    DayPassed = true;
            if (DayPassed)
            {
                if (Now.Hours == 0 && Now.Minutes <= 2)
                {
                    DayPassed = false;
                    foreach (ArenaStatistic stat in ArenaStatistics.Values)
                    {
                        stat.LastSeasonArenaPoints = stat.ArenaPoints;
                        stat.LastSeasonWin = stat.TodayWin;
                        stat.LastSeasonLose = stat.TodayBattles - stat.TodayWin;
                        stat.TodayWin = 0;
                        stat.TodayBattles = 0;
                        stat.CurrentHonor += stat.Rank * 15000;
                        stat.HistoryHonor += stat.Rank * 15000;
                        stat.ArenaPoints = Database.ArenaTable.ArenaPointFill(stat.Level);
                        stat.LastArenaPointFill = DateTime.Now;
                        if (ServerBase.Kernel.GamePool.ContainsKey(stat.EntityID))
                        {
                            Client.GameState client = ServerBase.Kernel.GamePool[stat.EntityID];
                            client.Send(stat);
                        }
                    }
                    SaveArenaStats();
                    YesterdaySort();
                }
            }
            #endregion
        }
Пример #5
0
        public static void Win(Client.GameState winner, Client.GameState loser)
        {
            if (winner == null && loser != null)
            {
                loser.ArenaStatistic.PlayWith = 0;
                loser.ArenaStatistic.AcceptBox = false;
                if (loser.ArenaStatistic.ArenaPoints > 80000)
                    loser.ArenaStatistic.ArenaPoints = 0;
                ArenaSignup sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                loser.Send(sign.BuildPacket());

                sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                sign.OptionID = ArenaSignup.DialogButton.MatchOff;
                loser.Send(sign.BuildPacket());
                if (loser.ArenaStatistic.ArenaPoints == 0)
                {
                    QualifyEngine.DoQuit(loser);
                }
                loser.ArenaStatistic.TotalLose++;

                Sort();
                loser.Send(loser.ArenaStatistic);
                QualifyEngine.DoQuit(loser);

            }
            else if (loser == null && winner != null)
            {
                winner.ArenaStatistic.PlayWith = 0;
                winner.ArenaStatistic.AcceptBox = false;
                winner.ArenaStatistic.TodayWin++;
                winner.ArenaStatistic.TotalWin++;
                ArenaSignup sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                sign.OptionID = ArenaSignup.DialogButton.Win;
                winner.Send(sign.BuildPacket());

                sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                sign.OptionID = ArenaSignup.DialogButton.MatchOff;
                winner.Send(sign.BuildPacket());
                Sort();
                QualifyEngine.DoQuit(winner);
                winner.Send(winner.ArenaStatistic);
            }
            else if (loser == null && winner == null)
            {
                return;
            }
            else
            {
                if (winner.ArenaStatistic.PlayWith != 0 && loser.ArenaStatistic.PlayWith != 0)
                {
                    int diff = (int)winner.ArenaStatistic.ArenaPoints - (int)loser.ArenaStatistic.ArenaPoints;
                    diff = diff < 0 ? -diff : diff;
                    if (diff == 0 || diff > 50)
                        diff = ServerBase.Kernel.Random.Next(30, 50);

                    ArenaSignup sign = new ArenaSignup();
                    sign.DialogID = ArenaSignup.MainIDs.Match;
                    loser.Send(sign.BuildPacket());
                    sign.OptionID = ArenaSignup.DialogButton.Win;
                    winner.Send(sign.BuildPacket());

                    sign = new ArenaSignup();
                    sign.DialogID = ArenaSignup.MainIDs.Match;
                    sign.OptionID = ArenaSignup.DialogButton.MatchOff;
                    loser.Send(sign.BuildPacket());
                    winner.Send(sign.BuildPacket());

                    winner.ArenaStatistic.PlayWith = 0;
                    loser.ArenaStatistic.PlayWith = 0;
                    winner.ArenaStatistic.AcceptBox = false;
                    loser.ArenaStatistic.AcceptBox = false;
                    winner.ArenaStatistic.ArenaPoints += (uint)diff;
                    Message message = null;
                    message = new Message("[Qualifier]" + winner.ArenaStatistic.Name + " has Defeated " + loser.ArenaStatistic.Name + " in the Qualifier, and is currently ranked No. " + winner.ArenaStatistic.Rank + "!", System.Drawing.Color.Red, Message.TopLeft);
                    foreach (Client.GameState client in ServerBase.Kernel.GamePool.Values)
                    {
                        client.Send(message);
                    }
                    loser.ArenaStatistic.ArenaPoints -= (uint)diff;
                    if (loser.ArenaStatistic.ArenaPoints > 80000)
                        loser.ArenaStatistic.ArenaPoints = 0;
                    if (loser.ArenaStatistic.ArenaPoints == 0)
                        QualifyEngine.DoQuit(loser);

                    winner.ArenaStatistic.TodayWin++;
                    winner.ArenaStatistic.TotalWin++;
                    if (winner.ArenaStatistic.TodayWin == 9 || winner.ArenaStatistic.TodayBattles == 20)
                    {
                        winner.Inventory.Add(723912, 0, 1);//EXP Pack
                    }
                    if (winner.ArenaStatistic.TodayWin == 27 || winner.ArenaStatistic.TodayBattles == 40)
                    {
                        winner.Inventory.Add(723912, 0, 1);
                    }
                    if (loser.ArenaStatistic.TodayBattles == 20)
                        loser.IncreaseExperience(loser.ExpBall, false);
                    loser.ArenaStatistic.TotalLose++;

                    Sort();
                    winner.Send(winner.ArenaStatistic);
                    loser.Send(loser.ArenaStatistic);
                    QualifyEngine.DoQuit(winner);
                    QualifyEngine.DoQuit(loser);

                    winner.QualifierGroup = null;
                    loser.QualifierGroup = null;
                }
            }
        }
        public static void Win(Client.GameState winner, Client.GameState loser)
        {
            if (winner == null && loser != null)
            {
                loser.ArenaStatistic.PlayWith = 0;
                loser.ArenaStatistic.AcceptBox = false;
                if (loser.ArenaStatistic.ArenaPoints > 80000)
                    loser.ArenaStatistic.ArenaPoints = 0;
                ArenaSignup sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                loser.Send(sign.BuildPacket());

                sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                sign.OptionID = ArenaSignup.DialogButton.MatchOff;
                loser.Send(sign.BuildPacket());
                if (loser.ArenaStatistic.ArenaPoints == 0)
                {
                    QualifyEngine.DoQuit(loser);
                }
                loser.ArenaStatistic.TotalLose++;

                Sort();
                loser.Send(loser.ArenaStatistic);
                QualifyEngine.DoQuit(loser);

            }
            else if (loser == null && winner != null)
            {
                winner.ArenaStatistic.PlayWith = 0;
                winner.ArenaStatistic.AcceptBox = false;
                winner.ArenaStatistic.TodayWin++;
                winner.ArenaStatistic.TotalWin++;
                ArenaSignup sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                sign.OptionID = ArenaSignup.DialogButton.Win;
                winner.Send(sign.BuildPacket());

                sign = new ArenaSignup();
                sign.DialogID = ArenaSignup.MainIDs.Match;
                sign.OptionID = ArenaSignup.DialogButton.MatchOff;
                winner.Send(sign.BuildPacket());
                Sort();
                QualifyEngine.DoQuit(winner);
                winner.Send(winner.ArenaStatistic);
            }
            else if (loser == null && winner == null)
            {
                return;
            }
            else
            {
                if (winner.ArenaStatistic.PlayWith != 0 && loser.ArenaStatistic.PlayWith != 0)
                {
                    int diff = (int)winner.ArenaStatistic.ArenaPoints - (int)loser.ArenaStatistic.ArenaPoints;
                    diff = diff < 0 ? -diff : diff;
                    if (diff == 0 || diff > 50)
                        diff = ServerBase.Kernel.Random.Next(30, 50);

                    ArenaSignup sign = new ArenaSignup();
                    sign.DialogID = ArenaSignup.MainIDs.Match;
                    loser.Send(sign.BuildPacket());
                    sign.OptionID = ArenaSignup.DialogButton.Win;
                    winner.Send(sign.BuildPacket());

                    sign = new ArenaSignup();
                    sign.DialogID = ArenaSignup.MainIDs.Match;
                    sign.OptionID = ArenaSignup.DialogButton.MatchOff;
                    loser.Send(sign.BuildPacket());
                    winner.Send(sign.BuildPacket());

                    winner.ArenaStatistic.PlayWith = 0;
                    loser.ArenaStatistic.PlayWith = 0;
                    winner.ArenaStatistic.AcceptBox = false;
                    loser.ArenaStatistic.AcceptBox = false;
                    winner.ArenaStatistic.ArenaPoints += (uint)diff;
                    Message message = null;
                    message = new Message("" + winner.ArenaStatistic.Name + " has Defeated " + loser.ArenaStatistic.Name + " in the Qualifier, and is currently ranked No. " + winner.ArenaStatistic.Rank + "!", System.Drawing.Color.Red, Message.Qualifier);
                    foreach (Client.GameState client in ServerBase.Kernel.GamePool.Values)
                    {
                        client.Send(message);
                    }
                    loser.ArenaStatistic.ArenaPoints -= (uint)diff;
                    if (loser.ArenaStatistic.ArenaPoints > 80000)
                        loser.ArenaStatistic.ArenaPoints = 0;
                    if (loser.ArenaStatistic.ArenaPoints == 0)
                        QualifyEngine.DoQuit(loser);

                    winner.ArenaStatistic.TodayWin++;
                    winner.ArenaStatistic.TotalWin++;
                    if (winner.ArenaStatistic.TodayWin == 9)
                        winner.IncreaseExperience(winner.ExpBall, false);
                    if (winner.ArenaStatistic.TodayBattles == 20)
                        winner.IncreaseExperience(winner.ExpBall, false);
                    if (loser.ArenaStatistic.TodayBattles == 20)
                        loser.IncreaseExperience(loser.ExpBall, false);
                    loser.ArenaStatistic.TotalLose++;

                    Sort();
                    winner.Send(winner.ArenaStatistic);
                    loser.Send(loser.ArenaStatistic);
                    QualifyEngine.DoQuit(winner);
                    QualifyEngine.DoQuit(loser);

                    winner.QualifierGroup = null;
                    loser.QualifierGroup = null;

                    _String str = new _String(true);
                    str.UID = winner.Entity.UID;
                    str.TextsCount = 1;
                    str.Type = _String.Effect;
                    str.Texts.Add("sports_victory");
                    winner.SendScreen(str, true);

                    _String strs = new _String(true);
                    strs.UID = loser.Entity.UID;
                    strs.TextsCount = 1;
                    strs.Type = _String.Effect;
                    strs.Texts.Add("sports_failure");
                    loser.SendScreen(strs, true);
                }
            }
        }