コード例 #1
0
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            using (var nobility = new NobilityPacket(packet))
            {
                switch (nobility.Action)
                {
                    case Enums.NobilityAction.Donate:
                        {
                            if (client.Level < 70)
                            {
                                return;
                            }
                            if (nobility.Data3 == 2)
                                Data.NobilityBoard.DonateCPs(client, nobility.Data1HighA);
                            else if (nobility.Data3 == 0)
                                Data.NobilityBoard.Donate(client, nobility.Data1HighA);
                            break;
                        }

                    case Enums.NobilityAction.QueryRemainingSilver:
                        {
                            /*if (client.Nobility == null)
                            {
                                using (var query = new NobilityPacket())
                                {
                                    query.Data4 = 60;
                                    query.Data1High = Data.NobilityBoard.RemainingDonation((Enums.NobilityRank)query.Data1Low, client.Nobility.Donation);
                                    // ...
                                }
                                return;
                            }*/
                            break;
                        }
                    case Enums.NobilityAction.List:
                        {
                            int PageMax;
                            Data.NobilityDonation[] Page = Data.NobilityBoard.GetPage((int)nobility.Data1LowA, out PageMax);
                            PageMax = (PageMax > 0 ? (PageMax + 1) : 0);
                            if (Page != null)
                            {
                                if (Page.Length > 0)
                                {
                                    using (var list = new NobilityPacket((ushort)(NobilityPacket.GetSize(Page.Length) + 32)))
                                    {
                                        list.Action = Enums.NobilityAction.List;
                                        list.Data1LowLow = nobility.Data1LowA;
                                        list.Data1LowHigh = (ushort)PageMax;
                                        list.Data1HighLow = (ushort)Page.Length;
                                        list.WriteData();
                                        foreach (Data.NobilityDonation donation in Page)
                                        {
                                            if (donation != null)
                                            {
                                                list.WriteNobilityData(donation);
                                            }
                                        }
                                        client.Send(list);
                                    }
                                }
                            }
                            break;
                        }

                    default:
                        Console.WriteLine("Unkown Nobility: {0} from {1}", nobility.Action, client.Name);
                        break;
                }
            }
        }
コード例 #2
0
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            using (var nobility = new NobilityPacket(packet))
            {
                switch (nobility.Action)
                {
                case Enums.NobilityAction.Donate:
                {
                    if (client.Level < 70)
                    {
                        return;
                    }
                    if (nobility.Data3 == 2)
                    {
                        Data.NobilityBoard.DonateCPs(client, nobility.Data1HighA);
                    }
                    else if (nobility.Data3 == 0)
                    {
                        Data.NobilityBoard.Donate(client, nobility.Data1HighA);
                    }
                    break;
                }

                case Enums.NobilityAction.QueryRemainingSilver:
                {
                    /*if (client.Nobility == null)
                     * {
                     *      using (var query = new NobilityPacket())
                     *      {
                     *              query.Data4 = 60;
                     *              query.Data1High = Data.NobilityBoard.RemainingDonation((Enums.NobilityRank)query.Data1Low, client.Nobility.Donation);
                     *              // ...
                     *      }
                     *      return;
                     * }*/
                    break;
                }

                case Enums.NobilityAction.List:
                {
                    int PageMax;
                    Data.NobilityDonation[] Page = Data.NobilityBoard.GetPage((int)nobility.Data1LowA, out PageMax);
                    PageMax = (PageMax > 0 ? (PageMax + 1) : 0);
                    if (Page != null)
                    {
                        if (Page.Length > 0)
                        {
                            using (var list = new NobilityPacket((ushort)(NobilityPacket.GetSize(Page.Length) + 32)))
                            {
                                list.Action       = Enums.NobilityAction.List;
                                list.Data1LowLow  = nobility.Data1LowA;
                                list.Data1LowHigh = (ushort)PageMax;
                                list.Data1HighLow = (ushort)Page.Length;
                                list.WriteData();
                                foreach (Data.NobilityDonation donation in Page)
                                {
                                    if (donation != null)
                                    {
                                        list.WriteNobilityData(donation);
                                    }
                                }
                                client.Send(list);
                            }
                        }
                    }
                    break;
                }

                default:
                    Console.WriteLine("Unkown Nobility: {0} from {1}", nobility.Action, client.Name);
                    break;
                }
            }
        }